Files
huangjingfen/pro_v3.5.1_副本/app/controller/api/v1/diy/Diy.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

198 lines
6.6 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>
// +----------------------------------------------------------------------
namespace app\controller\api\v1\diy;
use app\Request;
use app\services\activity\coupon\StoreCouponUserServices;
use app\services\activity\newcomer\StoreNewcomerServices;
use app\services\activity\video\VideoServices;
use app\services\diy\DiyServices;
use app\services\product\product\StoreProductLogServices;
use app\services\product\product\StoreProductRankServices;use app\services\user\level\SystemUserLevelServices;
use app\services\user\UserRelationServices;
use app\services\user\UserServices;
use app\services\user\UserSignServices;
use think\annotation\Inject;
/**
* Class Diy
* @package app\controller\api\v1\diy
*/
class Diy
{
/**
* @var DiyServices
*/
#[Inject]
protected DiyServices $services;
/**
* 获取页面数据
* @param $id
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getDiy($id = 0)
{
return app('json')->successful($this->services->getDiyInfo((int)$id));
}
/**
* 获取diy缓存版本
* @param $id
* @return \think\Response
* @throws \Throwable
*/
public function getDiyVersion($id = 0)
{
return app('json')->successful(['version' => $this->services->getDiyVersion((int)$id)]);
}
/**
* 获取底部导航
* @param $template_name
* @return \think\Response
*/
public function getNavigation($template_name = '')
{
return app('json')->success($this->services->getNavigation((string)$template_name));
}
/**
* 获取diy用户数据
* @param Request $request
* @param UserServices $userServices
* @return mixed
*/
public function userInfo(Request $request, UserServices $userServices)
{
$uid = (int)$request->uid();
$userInfo = [];
if ($uid) {
$userInfo = $userServices->getUserInfo($uid, 'uid,nickname,phone,avatar,level,integral,now_money,exp,is_money_level,bar_code');
if ($userInfo) {
$userInfo = $userInfo->toArray();
/** @var StoreCouponUserServices $storeCoupon */
$storeCoupon = app()->make(StoreCouponUserServices::class);
$userInfo['coupon_num'] = $storeCoupon->getUserValidCouponCount((int)$uid);
$userInfo['vip_name'] = '';
if ($userInfo['level']) {
/** @var SystemUserLevelServices $systemUserLevel */
$systemUserLevel = app()->make(SystemUserLevelServices::class);
$levelList = $systemUserLevel->getList(['is_del' => 0, 'is_show' => 1], 'id,name,exp_num');
$i = 0;
foreach ($levelList as &$level) {
if ($level['id'] == $userInfo['level']) {
$userInfo['vip_name'] = $level['name'];
}
$level['next_exp_num'] = $levelList[$i + 1]['exp_num'] ?? $level['exp_num'];
$i++;
}
$levelList = array_combine(array_column($levelList,'id'), $levelList);
$userInfo['next_exp'] = $levelList[$userInfo['level']]['next_exp_num'] ?? 0;
} else {
/** @var SystemUserLevelServices $systemUserLevel */
$systemUserLevel = app()->make(SystemUserLevelServices::class);
$levelList = $systemUserLevel->getList(['is_del' => 0, 'is_show' => 1], 'id,name,exp_num');
$userInfo['next_exp'] = $levelList[0]['exp_num'] ?? 0;
}
/** @var UserRelationServices $productRelation */
$productRelation = app()->make(UserRelationServices::class);
$collectCategory = sys_config('video_func_status', 1) ? '' : 'product';
$userInfo['collectCount'] = $productRelation->getUserCount($uid, 0, 'collect', $collectCategory);
/** @var StoreProductLogServices $storeProductLogServices */
$storeProductLogServices = app()->make(StoreProductLogServices::class);
$userInfo['visit_num'] = $storeProductLogServices->getDistinctCount(['uid' => $uid, 'type' => 'visit'], 'product_id');
}
}
return app('json')->success($userInfo);
}
/**
* 获取diy短视频
* @param Request $request
* @param VideoServices $videoServices
* @return mixed
*/
public function videoList(Request $request, VideoServices $videoServices)
{
$uid = (int)$request->uid();
return app('json')->success($videoServices->getDiyVideoList($uid));
}
/**
* 获取新人礼商品
* @param Request $request
* @param StoreNewcomerServices $newcomerServices
* @return mixed
*/
public function newcomerList(Request $request, StoreNewcomerServices $newcomerServices)
{
$where = $request->getMore([
['priceOrder', ''],
['salesOrder', ''],
]);
$uid = (int)$request->uid();
return app('json')->success($newcomerServices->getDiyNewcomerList($uid, $where));
}
/**
* 首页diy签到数据
* @param Request $request
* @return \think\Response
*/
public function diySign(Request $request, UserSignServices $services)
{
$uid = (int)$request->uid();
return app('json')->successful($services->homeDiysignData($uid));
}
/**
* 商品排行榜
* @param Request $request
* @param StoreProductRankServices $productRankServices
* @return \think\Response
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \throwable
*/
public function productRank(Request $request, StoreProductRankServices $productRankServices)
{
[$limit] = $request->getMore([
['limit', 3]
], true);
$uid = 0;
if ($request->hasMacro('uid')) $uid = (int)$request->uid();
$data = [];
$data['sales'] = $productRankServices->getProductRankList($uid, 1, [], $limit);
$data['star'] = $productRankServices->getProductRankList($uid, 2, [], $limit);
$data['collect'] = $productRankServices->getProductRankList($uid, 3, [], $limit);
return app('json')->success($data);
}
/**
* 悬浮框
* @return \think\Response
* User: liusl
* DateTime: 2024/9/6 10:17
*/
public function getSuspendedDiy()
{
$data = $this->services->getSuspendedDiy();
return app('json')->success($data);
}
}