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
189 lines
8.5 KiB
PHP
189 lines
8.5 KiB
PHP
<?php
|
|
|
|
namespace app\services\system;
|
|
|
|
use app\dao\system\SystemRecommendDao;
|
|
use app\services\BaseServices;
|
|
use app\services\order\StoreCartServices;
|
|
use app\services\product\product\StoreProductLogServices;
|
|
use app\services\product\product\StoreProductServices;
|
|
use app\services\user\UserRelationServices;
|
|
use crmeb\exceptions\AdminException;
|
|
use think\annotation\Inject;
|
|
|
|
class SystemRecommendServices extends BaseServices
|
|
{
|
|
/**
|
|
* @var SystemRecommendDao
|
|
*/
|
|
#[Inject]
|
|
protected SystemRecommendDao $dao;
|
|
|
|
/**
|
|
* 获取推荐配置列表
|
|
* @param array $where 查询条件
|
|
* @return array
|
|
*/
|
|
public function getRecommendList($where = [])
|
|
{
|
|
[$page, $limit] = $this->getPageValue();
|
|
$list = $this->dao->recommendList($where, $page, $limit, 'id,name,title,pic,type,update_time,status', 'id asc');
|
|
foreach ($list as &$item) {
|
|
$item['update_time'] = date('Y-m-d H:i:s', $item['update_time']);
|
|
}
|
|
$count = $this->dao->recommendCount($where);
|
|
return compact('list', 'count');
|
|
}
|
|
|
|
/**
|
|
* 获取推荐配置详情
|
|
* @param int $id 推荐ID
|
|
* @return array
|
|
*/
|
|
public function getRecommendInfo($id)
|
|
{
|
|
$info = $this->dao->getOne(['id' => $id]);
|
|
if ($info) {
|
|
$info = $info->toArray();
|
|
$info['specify_recommend_content'] = json_decode($info['specify_recommend_content'], true);
|
|
$info['personality_recommend_content'] = json_decode($info['personality_recommend_content'], true);
|
|
$info['sort_recommend_content'] = json_decode($info['sort_recommend_content'], true);
|
|
} else {
|
|
$info = [];
|
|
}
|
|
return $info;
|
|
}
|
|
|
|
/**
|
|
* 编辑推荐标题
|
|
* @param int $id 推荐ID
|
|
* @param string $title 标题
|
|
* @return bool
|
|
*/
|
|
public function editRecommendTitle($id, $title)
|
|
{
|
|
$this->dao->update($id, ['title' => $title]);
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 保存推荐配置
|
|
* @param int $id 推荐ID
|
|
* @param array $data 配置数据
|
|
* @return bool
|
|
* @throws AdminException
|
|
*/
|
|
public function saveRecommend($id, $data)
|
|
{
|
|
$data['specify_recommend_content'] = json_encode($data['specify_recommend_content']);
|
|
$data['personality_recommend_content'] = json_encode($data['personality_recommend_content']);
|
|
$data['sort_recommend_content'] = json_encode($data['sort_recommend_content']);
|
|
$data['update_time'] = time();
|
|
if ($id) {
|
|
$res = $this->dao->update($id, $data);
|
|
} else {
|
|
$res = $this->dao->save($data);
|
|
}
|
|
if (!$res) {
|
|
throw new AdminException('保存失败');
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 设置推荐状态
|
|
* @param int $id 推荐ID
|
|
* @param int $status 状态
|
|
* @return bool
|
|
*/
|
|
public function setRecommendStatus($id, $status)
|
|
{
|
|
$data = [
|
|
'status' => $status,
|
|
'update_time' => time(),
|
|
];
|
|
return $this->dao->update((int)$id, $data);
|
|
}
|
|
|
|
/**
|
|
* 获取推荐商品ID列表
|
|
* @param int $type 推荐类型
|
|
* @param int $uid 用户ID
|
|
* @return array
|
|
*/
|
|
public function getRecommendProductIds($type, $uid = 0)
|
|
{
|
|
$info = $this->dao->getOne(['type' => $type]);
|
|
if (!$info || !$info['status']) return ['为您推荐', []];
|
|
$info = $info->toArray();
|
|
$specifyProductIds = $personalityProductIds = $sortProductIds = [];
|
|
$info['specify_recommend_content'] = json_decode($info['specify_recommend_content'], true);
|
|
$info['personality_recommend_content'] = json_decode($info['personality_recommend_content'], true);
|
|
$info['sort_recommend_content'] = json_decode($info['sort_recommend_content'], true);
|
|
if ($info['specify_recommend_status'] == 1) {
|
|
$specifyProductIds = array_column($info['specify_recommend_content'], 'product_id');
|
|
}
|
|
if ($uid != 0 && $info['personality_recommend_status'] == 1) {
|
|
$productLogServices = app()->make(StoreProductLogServices::class);
|
|
foreach ($info['personality_recommend_content'] as $item) {
|
|
switch ($item['value']) {
|
|
case 1:
|
|
$cartProductIds = $productLogServices->getColumn([['uid', '=', $uid], ['type', '=', 'cart'], ['add_time', '>', strtotime('-30 days')]], 'product_id');
|
|
$personalityProductIds = array_merge($personalityProductIds, array_diff($cartProductIds, $personalityProductIds));
|
|
break;
|
|
case 2:
|
|
$relationProductIds = $productLogServices->getColumn([['uid', '=', $uid], ['type', '=', 'collect'], ['add_time', '>', strtotime('-30 days')]], 'product_id');
|
|
$personalityProductIds = array_merge($personalityProductIds, array_diff($relationProductIds, $personalityProductIds));
|
|
break;
|
|
case 3:
|
|
$visitProductIds = $productLogServices->getColumn([['uid', '=', $uid], ['type', '=', 'visit'], ['add_time', '>', strtotime('-30 days')]], 'product_id');
|
|
$personalityProductIds = array_merge($personalityProductIds, array_diff($visitProductIds, $personalityProductIds));
|
|
break;
|
|
case 4:
|
|
$payProductIds = $productLogServices->getColumn([['uid', '=', $uid], ['type', '=', 'pay'], ['add_time', '>', strtotime('-30 days')]], 'product_id');
|
|
$personalityProductIds = array_merge($personalityProductIds, array_diff($payProductIds, $personalityProductIds));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if ($info['sort_recommend_status'] == 1) {
|
|
$productLogServices = app()->make(StoreProductLogServices::class);
|
|
$productServices = app()->make(StoreProductServices::class);
|
|
foreach ($info['sort_recommend_content'] as $item) {
|
|
switch ($item['value']) {
|
|
case 1:
|
|
$salesProductIds = [];
|
|
$salesProductList = $productLogServices->getProductIds('pay', 'product_id, COUNT(*) as pay_count', 'pay_count desc', 20);
|
|
if (count($salesProductList)) $salesProductIds = array_column($salesProductList, 'product_id');
|
|
$sortProductIds = array_merge($sortProductIds, array_diff($salesProductIds, $sortProductIds));
|
|
break;
|
|
case 2:
|
|
$payPriceProductIds = [];
|
|
$payPriceProductList = $productLogServices->getProductIds('pay', 'product_id, SUM(pay_price) as total_pay_price', 'total_pay_price desc', 20);
|
|
if (count($payPriceProductList)) $payPriceProductIds = array_column($payPriceProductList, 'product_id');
|
|
$sortProductIds = array_merge($sortProductIds, array_diff($payPriceProductIds, $sortProductIds));
|
|
break;
|
|
case 3:
|
|
$addTimeProductIds = $productServices->getProductIds(['is_show' => 1, 'is_del' => 0, 'is_verify' => 1], 'product_id, add_time', 'add_time desc', 20);
|
|
$sortProductIds = array_merge($sortProductIds, array_diff($addTimeProductIds, $sortProductIds));
|
|
break;
|
|
case 4:
|
|
$starProductIds = $productServices->getProductIds(['is_show' => 1, 'is_del' => 0, 'is_verify' => 1], 'product_id, star', 'star desc, add_time desc', 20);
|
|
$sortProductIds = array_merge($sortProductIds, array_diff($starProductIds, $sortProductIds));
|
|
break;
|
|
case 5:
|
|
$visitProductIds = [];
|
|
$visitProductList = $productLogServices->getProductIds('visit', 'product_id, COUNT(*) as visit_count', 'visit_count desc', 20);
|
|
if (count($visitProductList)) $visitProductIds = array_column($visitProductList, 'product_id');
|
|
$sortProductIds = array_merge($sortProductIds, array_diff($visitProductIds, $sortProductIds));
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
$productIds = array_merge($specifyProductIds, array_diff($personalityProductIds, $specifyProductIds));
|
|
$productIds = array_merge($productIds, array_diff($sortProductIds, $productIds));
|
|
return [$info['title'], $productIds];
|
|
}
|
|
}
|