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
227 lines
7.9 KiB
PHP
227 lines
7.9 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||
// +----------------------------------------------------------------------
|
||
// | Author: CRMEB Team <admin@crmeb.com>
|
||
// +----------------------------------------------------------------------
|
||
namespace app\controller\admin\v1\wechat;
|
||
|
||
use app\controller\admin\AuthController;
|
||
use app\jobs\notice\template\WechatTemplateJob;
|
||
use app\services\message\SystemNotificationServices;
|
||
use app\services\message\TemplateMessageServices;
|
||
use crmeb\services\{FormBuilder as Form, template\Template};
|
||
use crmeb\services\CacheService;
|
||
use think\annotation\Inject;
|
||
use think\facade\Route as Url;
|
||
use think\Request;
|
||
|
||
/**
|
||
* 微信模板消息
|
||
* Class WechatTemplate
|
||
* @package app\controller\admin\v1\application\wechat
|
||
*/
|
||
class WechatTemplate extends AuthController
|
||
{
|
||
/**
|
||
* @var string
|
||
*/
|
||
protected string $cacheTag = 'system_wechat';
|
||
|
||
/**
|
||
* @var TemplateMessageServices
|
||
*/
|
||
#[Inject]
|
||
protected TemplateMessageServices $services;
|
||
|
||
/**
|
||
* 显示资源列表
|
||
*
|
||
* @return \think\Response
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function index()
|
||
{
|
||
$where = $this->request->getMore([
|
||
['name', ''],
|
||
['status', '']
|
||
]);
|
||
$where['type'] = 1;
|
||
$data = $this->services->getTemplateList($where);
|
||
$industry = CacheService::get($this->cacheTag . '_wechat_industry', function () {
|
||
try {
|
||
$cache = (new Template('wechat'))->getIndustry();
|
||
if (!$cache) return [];
|
||
return $cache->toArray();
|
||
} catch (\Exception $e) {
|
||
return $e->getMessage();
|
||
}
|
||
}, 0) ?: [];
|
||
!is_array($industry) && $industry = [];
|
||
$industry['primary_industry'] = isset($industry['primary_industry']) ? $industry['primary_industry']['first_class'] . ' | ' . $industry['primary_industry']['second_class'] : '未选择';
|
||
$industry['secondary_industry'] = isset($industry['secondary_industry']) ? $industry['secondary_industry']['first_class'] . ' | ' . $industry['secondary_industry']['second_class'] : '未选择';
|
||
$lst = array(
|
||
'industry' => $industry,
|
||
'count' => $data['count'],
|
||
'list' => $data['list']
|
||
);
|
||
return $this->success($lst);
|
||
}
|
||
|
||
/**
|
||
* 显示创建资源表单页.
|
||
*
|
||
* @return \think\Response
|
||
*/
|
||
public function create()
|
||
{
|
||
$f = array();
|
||
$f[] = Form::input('tempkey', '模板编号');
|
||
$f[] = Form::input('tempid', '模板ID');
|
||
$f[] = Form::input('name', '模板名');
|
||
$f[] = Form::input('content', '回复内容')->type('textarea');
|
||
$f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
|
||
return $this->makePostForm('添加模板消息', $f, Url::buildUrl('/app/wechat/template'), 'POST');
|
||
}
|
||
|
||
/**
|
||
* 保存新建的资源
|
||
*
|
||
* @param \think\Request $request
|
||
* @return \think\Response
|
||
*/
|
||
public function save(Request $request)
|
||
{
|
||
$data = $this->request->postMore([
|
||
'tempkey',
|
||
'tempid',
|
||
'name',
|
||
'content',
|
||
['status', 0],
|
||
['type', 1]
|
||
]);
|
||
if ($data['tempkey'] == '') return $this->fail('请输入模板编号');
|
||
if ($data['tempkey'] != '' && $this->services->getOne(['tempkey' => $data['tempkey']]))
|
||
return $this->fail('请输入模板编号已存在,请重新输入');
|
||
if ($data['tempid'] == '') return $this->fail('请输入模板ID');
|
||
if ($data['name'] == '') return $this->fail('请输入模板名');
|
||
if ($data['content'] == '') return $this->fail('请输入回复内容');
|
||
$data['add_time'] = time();
|
||
$this->services->save($data);
|
||
return $this->success('添加模板消息成功!');
|
||
}
|
||
|
||
/**
|
||
* 显示指定的资源
|
||
*
|
||
* @param int $id
|
||
* @return \think\Response
|
||
*/
|
||
public function read($id)
|
||
{
|
||
//
|
||
}
|
||
|
||
/**
|
||
* 显示编辑资源表单页.
|
||
*
|
||
* @param int $id
|
||
* @return \think\Response
|
||
*/
|
||
public function edit($id)
|
||
{
|
||
if (!$id) return $this->fail('数据不存在');
|
||
$product = $this->services->get($id);
|
||
if (!$product) return $this->fail('数据不存在!');
|
||
$f = array();
|
||
$f[] = Form::input('tempkey', '模板编号', $product->getData('tempkey'))->disabled(1);
|
||
$f[] = Form::input('name', '模板名', $product->getData('name'))->disabled(1);
|
||
$f[] = Form::input('tempid', '模板ID', $product->getData('tempid'));
|
||
$f[] = Form::radio('status', '状态', $product->getData('status'))->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
|
||
return $this->makePostForm('编辑模板消息', $f, Url::buildUrl('/app/wechat/template/' . $id), 'PUT');
|
||
}
|
||
|
||
/**
|
||
* 保存更新的资源
|
||
*
|
||
* @param \think\Request $request
|
||
* @param int $id
|
||
* @return \think\Response
|
||
*/
|
||
public function update(Request $request, $id)
|
||
{
|
||
$data = $this->request->postMore([
|
||
'tempid',
|
||
['status', 0],
|
||
['type', 1]
|
||
]);
|
||
if ($data['tempid'] == '') return $this->fail('请输入模板ID');
|
||
if (!$id) return $this->fail('数据不存在');
|
||
$product = $this->services->get($id);
|
||
if (!$product) return $this->fail('数据不存在!');
|
||
$this->services->update($id, $data, 'id');
|
||
return $this->success('修改成功!');
|
||
}
|
||
|
||
/**
|
||
* 删除指定资源
|
||
*
|
||
* @param int $id
|
||
* @return \think\Response
|
||
*/
|
||
public function delete($id)
|
||
{
|
||
if (!$id) return $this->fail('数据不存在!');
|
||
if (!$this->services->delete($id))
|
||
return $this->fail('删除失败,请稍候再试!');
|
||
else
|
||
return $this->success('删除成功!');
|
||
}
|
||
|
||
/**
|
||
* 修改状态
|
||
* @param $id
|
||
* @param $status
|
||
* @return mixed
|
||
*/
|
||
public function set_status($id, $status)
|
||
{
|
||
if ($status == '' || $id == 0) return $this->fail('参数错误');
|
||
$this->services->update($id, ['status' => $status], 'id');
|
||
return $this->success($status == 0 ? '关闭成功' : '开启成功');
|
||
}
|
||
|
||
/**
|
||
* 同步订阅消息
|
||
* @return mixed
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function syncSubscribe()
|
||
{
|
||
if (!sys_config('wechat_appid') || !sys_config('wechat_appsecret')) {
|
||
return $this->fail('请先配置微信公众号appid、appSecret等参数');
|
||
}
|
||
$tempall = $this->services->getTemplateList(['status' => 1, 'type' => 1]);
|
||
$temp = $tempall['list'] ?? [];
|
||
if (!$temp) {
|
||
return $this->fail('请先检查`eb_template_message`数据完整性,完整sql路径/public/install/crmeb.sql');
|
||
}
|
||
WechatTemplateJob::dispatch([$temp]);
|
||
|
||
/** @var SystemNotificationServices $systemNotificationServices */
|
||
$systemNotificationServices = app()->make(SystemNotificationServices::class);
|
||
//清空模版缓存
|
||
$systemNotificationServices->clearTemplateCache();
|
||
|
||
return $this->success('队列执行中,请稍后查看');
|
||
}
|
||
}
|