Phase1 后端核心:
- 新增 fsgx_v1.sql 迁移脚本(is_queue_goods/frozen_points/available_points/no_assess)
- SystemConfigServices 返佣设置扩展(周期人数/分档比例/范围/时机)
- StoreOrderCreateServices 周期循环佣金计算
- StoreOrderTakeServices 佣金发放后同步冻结积分
- StoreProductServices/StoreProduct 保存 is_queue_goods
Phase2 后端接口:
- GET /api/hjf/brokerage/progress 佣金周期进度
- GET /api/hjf/assets/overview 资产总览
- HjfPointsServices 每日 frozen_points 0.4‰ 释放定时任务
- PUT /adminapi/hjf/member/{uid}/no_assess 不考核接口
- GET /adminapi/hjf/points/release_log 积分日志接口
Phase3 前端清理:
- hjfCustom.js 路由精简(仅保留 points/log)
- hjfQueue.js/hjfMember.js API 清理/重定向至 CRMEB 原生接口
- pages.json 公排→推荐佣金/佣金记录/佣金规则
Phase4-5 前端改造:
- queue/status.vue 推荐佣金进度页整体重写
- 商品详情/订单确认/支付结果页文案与逻辑改造
- 个人中心/资产页/引导页/规则页文案改造
- HjfQueueProgress/HjfRefundNotice/HjfAssetCard 组件改造
- 推广中心嵌入佣金进度摘要
- hjfMockData.js 全量更新(公排字段→佣金字段)
Phase6 Admin 增强:
- 用户列表新增 frozen_points/available_points 列及不考核操作按钮
- hjfPoints.js USE_MOCK=false 对接真实积分日志接口
Phase7 配置文档:
- docs/fsgx-phase7-config-checklist.md 后台配置与全链路验收清单
Made-with: Cursor
242 lines
8.0 KiB
PHP
242 lines
8.0 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
// +----------------------------------------------------------------------
|
|
// | Author: liu21st <liu21st@gmail.com>
|
|
// +----------------------------------------------------------------------
|
|
declare (strict_types = 1);
|
|
|
|
namespace think\view\driver;
|
|
|
|
use think\App;
|
|
use think\helper\Str;
|
|
use think\Template;
|
|
use think\template\exception\TemplateNotFoundException;
|
|
|
|
class Think
|
|
{
|
|
// 模板引擎实例
|
|
private $template;
|
|
|
|
// 模板引擎参数
|
|
protected $config = [
|
|
// 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法
|
|
'auto_rule' => 1,
|
|
// 视图目录名
|
|
'view_dir_name' => 'view',
|
|
// 模板起始路径
|
|
'view_path' => '',
|
|
// 模板文件后缀
|
|
'view_suffix' => 'html',
|
|
// 模板文件名分隔符
|
|
'view_depr' => DIRECTORY_SEPARATOR,
|
|
// 是否开启模板编译缓存,设为false则每次都会重新编译
|
|
'tpl_cache' => true,
|
|
];
|
|
|
|
public function __construct(private App $app, array $config = [])
|
|
{
|
|
$this->config = array_merge($this->config, (array) $config);
|
|
|
|
if (empty($this->config['cache_path'])) {
|
|
$this->config['cache_path'] = $app->getRuntimePath() . 'temp' . DIRECTORY_SEPARATOR;
|
|
}
|
|
|
|
$this->template = new Template($this->config);
|
|
$this->template->setCache($app->cache);
|
|
$this->template->extend('$Think', function (array $vars) {
|
|
$type = strtoupper(trim(array_shift($vars)));
|
|
$param = implode('.', $vars);
|
|
|
|
return match ($type) {
|
|
'CONST' => strtoupper($param),
|
|
'CONFIG' => 'config(\'' . $param . '\')',
|
|
'LANG' => 'lang(\'' . $param . '\')',
|
|
'NOW' => "date('Y-m-d g:i a',time())",
|
|
'LDELIM' => '\'' . ltrim($this->getConfig('tpl_begin'), '\\') . '\'',
|
|
'RDELIM' => '\'' . ltrim($this->getConfig('tpl_end'), '\\') . '\'',
|
|
default => defined($type) ? $type : '\'\'',
|
|
};
|
|
});
|
|
|
|
$this->template->extend('$Request', function (array $vars) {
|
|
// 获取Request请求对象参数
|
|
$method = array_shift($vars);
|
|
if (!empty($vars)) {
|
|
$params = implode('.', $vars);
|
|
if ('true' != $params) {
|
|
$params = '\'' . $params . '\'';
|
|
}
|
|
} else {
|
|
$params = '';
|
|
}
|
|
|
|
return 'app(\'request\')->' . $method . '(' . $params . ')';
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 检测是否存在模板文件
|
|
* @access public
|
|
* @param string $template 模板文件或者模板规则
|
|
* @return bool
|
|
*/
|
|
public function exists(string $template): bool
|
|
{
|
|
if ('' == pathinfo($template, PATHINFO_EXTENSION)) {
|
|
// 获取模板文件名
|
|
$template = $this->parseTemplate($template);
|
|
}
|
|
|
|
return is_file($template);
|
|
}
|
|
|
|
/**
|
|
* 渲染模板文件
|
|
* @access public
|
|
* @param string $template 模板文件
|
|
* @param array $data 模板变量
|
|
* @return void
|
|
*/
|
|
public function fetch(string $template, array $data = []): void
|
|
{
|
|
if (empty($this->config['view_path'])) {
|
|
$view = $this->config['view_dir_name'];
|
|
|
|
if (is_dir($this->app->getAppPath() . $view)) {
|
|
$path = $this->app->getAppPath() . $view . DIRECTORY_SEPARATOR;
|
|
} else {
|
|
$appName = $this->app->http->getName();
|
|
$path = $this->app->getRootPath() . $view . DIRECTORY_SEPARATOR . ($appName ? $appName . DIRECTORY_SEPARATOR : '');
|
|
}
|
|
|
|
$this->config['view_path'] = $path;
|
|
$this->template->view_path = $path;
|
|
}
|
|
|
|
if ('' == pathinfo($template, PATHINFO_EXTENSION)) {
|
|
// 获取模板文件名
|
|
$template = $this->parseTemplate($template);
|
|
}
|
|
|
|
// 模板不存在 抛出异常
|
|
if (!is_file($template)) {
|
|
throw new TemplateNotFoundException('template not exists:' . $template, $template);
|
|
}
|
|
|
|
$this->template->fetch($template, $data);
|
|
}
|
|
|
|
/**
|
|
* 渲染模板内容
|
|
* @access public
|
|
* @param string $template 模板内容
|
|
* @param array $data 模板变量
|
|
* @return void
|
|
*/
|
|
public function display(string $template, array $data = []): void
|
|
{
|
|
$this->template->display($template, $data);
|
|
}
|
|
|
|
/**
|
|
* 自动定位模板文件
|
|
* @access private
|
|
* @param string $template 模板文件规则
|
|
* @return string
|
|
*/
|
|
private function parseTemplate(string $template): string
|
|
{
|
|
// 分析模板文件规则
|
|
$request = $this->app['request'];
|
|
|
|
// 获取视图根目录
|
|
if (strpos($template, '@')) {
|
|
// 跨模块调用
|
|
list($app, $template) = explode('@', $template);
|
|
}
|
|
|
|
if (isset($app)) {
|
|
$view = $this->config['view_dir_name'];
|
|
$viewPath = $this->app->getBasePath() . $app . DIRECTORY_SEPARATOR . $view . DIRECTORY_SEPARATOR;
|
|
|
|
if (is_dir($viewPath)) {
|
|
$path = $viewPath;
|
|
} else {
|
|
$path = $this->app->getRootPath() . $view . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR;
|
|
}
|
|
|
|
$this->template->view_path = $path;
|
|
} else {
|
|
$path = $this->config['view_path'];
|
|
}
|
|
|
|
$depr = $this->config['view_depr'];
|
|
|
|
if (0 !== strpos($template, '/')) {
|
|
$template = str_replace(['/', ':'], $depr, $template);
|
|
$controller = $request->controller();
|
|
|
|
if (strpos($controller, '.')) {
|
|
$pos = strrpos($controller, '.');
|
|
$controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1));
|
|
} else {
|
|
$controller = Str::snake($controller);
|
|
}
|
|
|
|
if ($controller) {
|
|
if ('' == $template) {
|
|
// 如果模板文件名为空 按照默认模板渲染规则定位
|
|
if (2 == $this->config['auto_rule']) {
|
|
$template = $request->action(true);
|
|
} elseif (3 == $this->config['auto_rule']) {
|
|
$template = $request->action();
|
|
} else {
|
|
$template = Str::snake($request->action());
|
|
}
|
|
|
|
$template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template;
|
|
} elseif (false === strpos($template, $depr)) {
|
|
$template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template;
|
|
}
|
|
}
|
|
} else {
|
|
$template = str_replace(['/', ':'], $depr, substr($template, 1));
|
|
}
|
|
|
|
return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.');
|
|
}
|
|
|
|
/**
|
|
* 配置模板引擎
|
|
* @access private
|
|
* @param array $config 参数
|
|
* @return void
|
|
*/
|
|
public function config(array $config): void
|
|
{
|
|
$this->template->config($config);
|
|
$this->config = array_merge($this->config, $config);
|
|
}
|
|
|
|
/**
|
|
* 获取模板引擎配置
|
|
* @access public
|
|
* @param string $name 参数名
|
|
* @return void
|
|
*/
|
|
public function getConfig(string $name)
|
|
{
|
|
return $this->template->getConfig($name);
|
|
}
|
|
|
|
public function __call($method, $params)
|
|
{
|
|
return call_user_func_array([$this->template, $method], $params);
|
|
}
|
|
}
|