Files
huangjingfen/pro_v3.5.1_副本/app/services/user/label/UserLabelExtendServices.php
apple 434aa8c69d feat(fsgx): 完成全部24项开发任务 Phase1-7
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
2026-03-23 22:32:19 +08:00

243 lines
9.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\services\user\label;
use app\services\BaseServices;
use app\dao\user\label\UserLabelExtendDao;
use app\services\product\category\StoreProductCategoryServices;
use app\services\product\label\StoreProductLabelServices;
use app\services\product\product\StoreProductServices;
use crmeb\exceptions\AdminException;
use crmeb\services\FormBuilder as Form;
use FormBuilder\Factory\Iview;
use think\annotation\Inject;
use think\exception\ValidateException;
/**
* 标签规则关联表
* Class UserLabelExtendServices
* @package app\services\user\label
* @mixin UserLabelExtendDao
*/
class UserLabelExtendServices extends BaseServices
{
/**
* @var UserLabelExtendDao
*/
#[Inject]
protected UserLabelExtendDao $dao;
/**
* 获取某一条标签扩展规则
* @param $id
* @return array|\think\Model|null
*/
public function getLabelExtend($id)
{
return $this->dao->get($id);
}
/**
* 获取所有标签扩展规则
* @param array $where
* @param array|string[] $field
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getLabelExtendList(array $where = [], array $field = ['*'])
{
return $this->dao->getList(0, 0, $where, $field);
}
/**
* 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getList(array $where)
{
[$page, $limit] = $this->getPageValue();
$list = $this->dao->getList($page, $limit, $where);
$count = $this->dao->count($where);
return compact('list', 'count');
}
/**
* 根据标签ID获取扩展规则
* @param int $labelId
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getByLabelId(int $labelId): array
{
return $this->dao->getByLabelId($labelId);
}
/**
* 根据规则类型获取扩展规则
* @param int $ruleType
* @param array $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getByRuleType(int $ruleType, array $where = []): array
{
return $this->dao->getByRuleType($ruleType, $where);
}
/**
* 添加修改标签扩展规则表单
* @param int $id
* @param int $labelId
* @return mixed
*/
public function add(int $id, int $labelId = 0)
{
$labelExtend = $this->getLabelExtend($id);
$field = array();
/** @var UserLabelServices $labelService */
$labelService = app()->make(UserLabelServices::class);
$labelOptions = [];
foreach ($labelService->getLabelList() as $item) {
$labelOptions[] = ['value' => $item['id'], 'label' => $item['label_name']];
}
// 规则类型选项
$ruleTypeOptions = [
['value' => 1, 'label' => '商品'],
['value' => 2, 'label' => '资产'],
['value' => 3, 'label' => '交易'],
['value' => 4, 'label' => '客户(所有)']
];
// 规则子类型选项
$subTypeOptions = [
['value' => 1, 'label' => '积分'],
['value' => 2, 'label' => '余额']
];
// 余额类型选项
$balanceTypeOptions = [
['value' => 1, 'label' => '充值'],
['value' => 2, 'label' => '消耗']
];
// 次数/金额选项
$operationTypeOptions = [
['value' => 1, 'label' => '次数'],
['value' => 2, 'label' => '金额']
];
// 时间维度选项
$timeDimensionOptions = [
['value' => 1, 'label' => '历史'],
['value' => 2, 'label' => '最近'],
['value' => 3, 'label' => '累计']
];
// 商品维度选项
$specifyDimensionOptions = [
['value' => 1, 'label' => '商品'],
['value' => 2, 'label' => '分类'],
['value' => 3, 'label' => '标签']
];
// 客户身份选项
$customerIdentityOptions = [
['value' => 1, 'label' => '注册时间'],
['value' => 2, 'label' => '访问时间'],
['value' => 3, 'label' => '用户等级'],
['value' => 4, 'label' => '客户身份']
];
if (!$labelExtend) {
$title = '添加标签扩展规则';
$field[] = Form::select('label_id', '关联标签', $labelId)->setOptions($labelOptions)->filterable(true)->appendValidate(Iview::validateInt()->message('请选择关联标签')->required());
} else {
$title = '编辑标签扩展规则';
$field[] = Form::select('label_id', '关联标签', $labelExtend['label_id'])->setOptions($labelOptions)->filterable(true)->appendValidate(Iview::validateInt()->message('请选择关联标签')->required());
}
$field[] = Form::select('rule_type', '规则类型', $labelExtend['rule_type'] ?? 0)->setOptions($ruleTypeOptions)->appendValidate(Iview::validateInt()->message('请选择规则类型')->required());
$field[] = Form::select('sub_type', '规则子类型', $labelExtend['sub_type'] ?? 0)->setOptions($subTypeOptions);
$field[] = Form::select('balance_type', '余额类型', $labelExtend['balance_type'] ?? 0)->setOptions($balanceTypeOptions);
$field[] = Form::select('operation_type', '次数/金额', $labelExtend['operation_type'] ?? 0)->setOptions($operationTypeOptions);
$field[] = Form::select('time_dimension', '时间维度', $labelExtend['time_dimension'] ?? 0)->setOptions($timeDimensionOptions);
$field[] = Form::number('time_value', '时间值(天)', $labelExtend['time_value'] ?? 0);
$field[] = Form::select('specify_dimension', '商品维度', $labelExtend['specify_dimension'] ?? 0)->setOptions($specifyDimensionOptions);
$field[] = Form::number('amount_value_min', '金额/数值最小', $labelExtend['amount_value_min'] ?? 0)->precision(2);
$field[] = Form::number('amount_value_max', '金额/数值最大', $labelExtend['amount_value_max'] ?? 0)->precision(2);
$field[] = Form::number('operation_times_min', '操作次数最小', $labelExtend['operation_times_min'] ?? 0);
$field[] = Form::number('operation_times_max', '操作次数最大', $labelExtend['operation_times_max'] ?? 0);
$field[] = Form::select('customer_identity', '客户身份', $labelExtend['customer_identity'] ?? 0)->setOptions($customerIdentityOptions);
$field[] = Form::number('customer_num', '客户身份数据', $labelExtend['customer_num'] ?? 0);
return create_form($title, $field, '/admin/user/label_extend/save/' . $id, 'POST');
}
/**
* 删除标签扩展规则
* @param int $id
* @return bool
*/
public function del(int $id)
{
$labelExtend = $this->getLabelExtend($id);
if (!$labelExtend) {
throw new AdminException('标签扩展规则不存在');
}
return $this->dao->delete($id);
}
/**
* 根据商品维度获取商品/分类/标签信息
* @param int $id 标签扩展ID
* @return array
*/
public function getLabelSpecify(int $id)
{
$labelExtend = $this->getLabelExtend($id);
if (!$labelExtend) {
return [];
}
$product_ids = $labelExtend['product_ids'] ? explode(',', $labelExtend['product_ids']) : [];
$data = [];
switch ($labelExtend['specify_dimension']) {
case 1:
//商品
$data = app()->make(StoreProductServices::class)->search([])->whereIn('id', $product_ids)->column('id,store_name,image');
break;
case 2:
//分类
$data = app()->make(StoreProductCategoryServices::class)->search([])->whereIn('id', $product_ids)->column('id,cate_name');
break;
case 3:
//标签
$data = app()->make(StoreProductLabelServices::class)->search([])->whereIn('id', $product_ids)->column('id,label_name');
break;
}
return $data;
}
}