Files
huangjingfen/pro_v3.5.1_副本/app/services/agent/PromoterApplyServices.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

134 lines
4.5 KiB
PHP

<?php
namespace app\services\agent;
use app\dao\agent\PromoterApplyDao;
use app\services\BaseServices;
use app\services\other\AgreementServices;
use app\services\user\UserServices;
use crmeb\exceptions\ApiException;
use crmeb\services\FormBuilder as Form;
use think\annotation\Inject;
class PromoterApplyServices extends BaseServices
{
/**
* @var PromoterApplyDao
*/
#[Inject]
protected PromoterApplyDao $dao;
/**
* 获取推广员申请信息
* @param int $uid 用户ID
* @param array $user 用户信息
* @return array
*/
public function applyInfo($uid, $user)
{
$applyInfo = $this->dao->get(['uid' => $uid, 'is_del' => 0]);
$user = [
'id' => $applyInfo['id'] ?? 0,
'uid' => $uid,
'nickname' => $user['nickname'] ?? '',
'real_name' => $user['real_name'] ?? '',
'phone' => $user['phone'] ?? '',
'status' => $applyInfo ? $applyInfo['status'] : -1,
'refusal_reason' => $applyInfo ? $applyInfo['refusal_reason'] : '',
'add_time' => $applyInfo ? date('Y/m/d H:i', $applyInfo['add_time']) : '',
'status_time' => $applyInfo && $applyInfo['status_time'] ? date('Y/m/d H:i', $applyInfo['status_time']) : '',
];
$agreement = app()->make(AgreementServices::class)->getAgreementBytype(2);
return compact('user', 'agreement');
}
/**
* 申请成为推广员
* @param array $data 申请数据
* @param int $id 申请记录ID
* @param array $userInfo 用户信息
* @return int
* @throws ApiException
*/
public function applyPromoter($data, $id, $userInfo)
{
if (!sys_config('brokerage_func_status')) throw new ApiException('未开启推广功能');
if (sys_config('store_brokerage_statu') != 1) throw new ApiException('非指定分销模式无需申请推广员');
if ($userInfo['is_promoter']) throw new ApiException('您已经是推广员');
if ($data['phone'] != $userInfo['phone']) {
$phoneUsed = app()->make(UserServices::class)->count(['phone' => $data['phone']]);
if ($phoneUsed) throw new ApiException('该手机号已被使用');
}
if ($id) {
$data['status'] = 0;
$res = $this->dao->update(['id' => $id], $data);
} else {
$data['add_time'] = time();
$this->dao->update(['uid' => $data['uid']], ['is_del' => 1]);
$res = $this->dao->save($data);
$id = $res->id;
}
if (!$res) throw new ApiException('申请失败');
return $id;
}
/**
* 获取推广员申请列表
* @param array $where 查询条件
* @return array
*/
public function applyList($where)
{
[$page, $limit] = $this->getPageValue();
$list = $this->dao->applyList($where, $page, $limit);
foreach ($list as &$item) {
$item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
$item['status_time'] = date('Y-m-d H:i:s', $item['status_time']);
}
$count = $this->dao->applyCount($where);
return compact('list', 'count');
}
/**
* 删除推广员申请记录
* @param int $id 申请记录ID
* @return bool
*/
public function applyDelete($id)
{
$this->dao->update(['id' => $id], ['is_del' => 1]);
return true;
}
/**
* 获取推广员审核表单
* @param int $id 申请记录ID
* @return array
*/
public function applyExamine($id)
{
$field = [];
$field[] = Form::radio('status', '状态:', 1)->options([['label' => '通过', 'value' => 1], ['label' => '拒绝', 'value' => 2]]);
$field[] = Form::textarea('refusal_reason', '备注:', '')->rows(5);
return create_form('分销员审核', $field, $this->url('/agent/promoter/apply/examine/' . $id), 'POST');
}
/**
* 保存推广员审核结果
* @param int $id 申请记录ID
* @param array $data 审核数据
* @return bool
* @throws ApiException
*/
public function applyExamineSave($id, $data)
{
$info = $this->dao->get($id);
if (!$info) throw new ApiException('申请不存在');
$this->dao->update(['id' => $id], ['status' => $data['status'], 'refusal_reason' => $data['refusal_reason'], 'status_time' => time()]);
if ($data['status'] == 1) {
app()->make(UserServices::class)->update(['uid' => $info['uid']], ['is_promoter' => 1]);
}
return true;
}
}