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

188 lines
7.0 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
namespace app\services\agent;
use app\dao\agent\DivisionApplyDao;
use app\services\BaseServices;
use app\services\user\UserServices;
use crmeb\exceptions\AdminException;
use crmeb\exceptions\ApiException;
use think\annotation\Inject;
use crmeb\services\FormBuilder as Form;
class DivisionApplyServices extends BaseServices
{
/**
* @var DivisionApplyDao
*/
#[Inject]
protected DivisionApplyDao $dao;
/**
* 申请列表
* @param $where
* @return array
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function applyList($where)
{
[$page, $limit] = $this->getPageValue();
$list = $this->dao->applyList($where, $page, $limit);
$divisionIds = array_column($list, 'division_id');
$divisionNames = app()->make(UserServices::class)->getColumn([['uid', 'in', $divisionIds]], 'division_name', 'uid');
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']);
$item['images'] = json_decode($item['images'], true);
$item['spread_name'] = $divisionNames[$item['division_id']] ?? '';
}
$count = $this->dao->applyCount($where);
return compact('list', 'count');
}
/**
* 申请审核
* @param $id
* @param $type
* @return mixed
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function applyExamine($id, $type)
{
$field = [];
$field[] = Form::hidden('type', $type);
$field[] = Form::hidden('id', $id);
if ($type) {
$field[] = Form::number('division_percent', '佣金比例', '')->placeholder('代理商佣金比例1-100')->info('填写1-100如填写50代表返佣50%,但是不能高于上级的比例')->style(['width' => '173px'])->min(0)->max(100)->required();
$field[] = Form::date('division_end_time', '到期时间', '')->placeholder('代理商代理到期时间');
$field[] = Form::radio('division_status', '代理状态', 1)->options([['label' => '开通', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
$title = '同意申请';
} else {
$field[] = Form::textarea('refusal_reason', '拒绝原因', '')->rows(5);
$title = '拒绝申请';
}
return create_form($title, $field, $this->url('/agent/division/apply/examine/save'), 'POST');
}
/**
* 申请审核保存
* @param $data
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function applyExamineSave($data)
{
return $this->transaction(function () use ($data) {
$applyInfo = $this->dao->get($data['id']);
if ($data['type'] == 1) {
$agentData = [
'spread_uid' => $applyInfo['division_id'],
'spread_time' => time(),
'division_name' => $applyInfo['division_name'],
'division_id' => $applyInfo['division_id'],
'division_status' => 1,
'division_percent' => $data['division_percent'],
'division_change_time' => time(),
'division_end_time' => strtotime($data['division_end_time']),
'division_type' => 2,
'agent_id' => $applyInfo['uid'],
'is_promoter' => 1,
];
/** @var UserServices $userServices */
$userServices = app()->make(UserServices::class);
$divisionInfo = $userServices->getUserInfo($applyInfo['division_id'], 'division_end_time,division_percent');
if ($divisionInfo) {
if ($agentData['division_percent'] > $divisionInfo['division_percent']) throw new AdminException('代理商比例不能大于上级区域代理');
if ($agentData['division_end_time'] > $divisionInfo['division_end_time']) throw new AdminException('代理商到期时间不能大于上级区域代理');
}
$applyInfo->status = 1;
$applyInfo->status_time = time();
$res = $applyInfo->save();
$res = $res && $userServices->update($applyInfo['uid'], $agentData);
} else {
$applyInfo->status = 2;
$applyInfo->refusal_reason = $data['refusal_reason'];
$applyInfo->status_time = time();
$res = $applyInfo->save();
}
if (!$res) throw new AdminException($data['type'] == 1 ? '通过失败' : '拒绝失败');
return true;
});
}
/**
* 删除申请
* @param $id
* @return bool
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function applyDelete($id)
{
$res = $this->dao->update(['id' => $id], ['is_del' => 1]);
if (!$res) throw new AdminException('删除失败');
return true;
}
/**
* 申请代理商
* @param $data
* @param $id
* @return bool
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function applyAgent($data, $id)
{
$data['images'] = json_encode($data['images']);
$data['add_time'] = time();
/** @var UserServices $userServices */
$userServices = app()->make(UserServices::class);
$divisionId = $userServices->value(['division_invite' => $data['division_invite']], 'division_id');
if (!$divisionId) throw new ApiException('区域代理不存在');
$data['division_id'] = $divisionId;
if ($id) {
$data['status'] = 0;
$res = $this->dao->update(['id' => $id], $data);
} else {
$this->dao->update(['uid' => $data['uid']], ['is_del' => 1]);
$res = $this->dao->save($data);
}
if (!$res) throw new ApiException('申请失败');
return true;
}
/**
* 申请代理商详情
* @param $uid
* @return array|int[]
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function applyInfo($uid)
{
$data = $this->dao->get(['uid' => $uid, 'is_del' => 0]);
if (!$data) return ['status' => -1];
$data = $data->toArray();
$data['images'] = json_decode($data['images'], true);
$data['add_time'] = date('Y/m/d H:i', $data['add_time']);
$data['status_time'] = $data['status_time'] ? date('Y/m/d H:i', $data['status_time']) : '';
return $data;
}
}