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
152 lines
6.1 KiB
PHP
152 lines
6.1 KiB
PHP
<?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\services\order;
|
||
|
||
|
||
use app\dao\order\StoreOrderDao;
|
||
use app\services\BaseServices;
|
||
use app\services\product\product\StoreProductLogServices;
|
||
use think\annotation\Inject;
|
||
|
||
/**
|
||
* Class StoreOrderWapServices
|
||
* @package app\services\order
|
||
* @mixin StoreOrderDao
|
||
*/
|
||
class StoreOrderWapServices extends BaseServices
|
||
{
|
||
/**
|
||
* @var StoreOrderDao
|
||
*/
|
||
#[Inject]
|
||
protected StoreOrderDao $dao;
|
||
|
||
/**
|
||
* 获取 今日 昨日 本月 订单金额
|
||
* @return mixed
|
||
*/
|
||
public function getOrderTimeData(int $store_id = 0)
|
||
{
|
||
$where = ['pid' => 0, 'timeKey' => 'add_time', 'paid' => 1, 'is_del' => 0, 'is_system_del' => 0, 'refund_status' => [0, 3]];
|
||
//今日成交额
|
||
$data['todayPrice'] = $this->dao->together($where + ['time' => 'today'], 'pay_price');
|
||
//今日订单数
|
||
$data['todayCount'] = $this->dao->count($where + ['time' => 'today']);
|
||
//昨日成交额
|
||
$data['proPrice'] = $this->dao->together($where + ['time' => 'yesterday'], 'pay_price');
|
||
//昨日订单数
|
||
$data['proCount'] = $this->dao->count($where + ['time' => 'yesterday']);
|
||
//本月成交额
|
||
$data['monthPrice'] = $this->dao->together($where + ['time' => 'month'], 'pay_price');
|
||
//本月订单数
|
||
$data['monthCount'] = $this->dao->count($where + ['time' => 'month']);
|
||
return $data;
|
||
}
|
||
|
||
/**
|
||
* 订单每月统计数据
|
||
* @param array $where
|
||
* @param int $store_id
|
||
* @return array
|
||
*/
|
||
public function getOrderDataPriceCount(array $where = [], int $store_id = 0)
|
||
{
|
||
[$page, $limit] = $this->getPageValue();
|
||
$data = $this->dao->getOrderDataPriceCount($where + ['pid' => 0, 'is_del' => 0, 'paid' => 1, 'refund_status' => [0, 3], 'is_system_del' => 0], ['sum(pay_price) as price', 'count(id) as count', 'add_time'], $page, $limit);
|
||
if (count($data) > 0) {
|
||
/** @var StoreProductLogServices $productLogServices */
|
||
$productLogServices = app()->make(StoreProductLogServices::class);
|
||
foreach ($data as $key => &$time) {
|
||
$time['time'] = date('m-d', $time['add_time']);
|
||
$time['visit'] = $productLogServices->count(['time' => [$time['add_time'], $time['add_time'] + 86400], 'type' => 'visit']);
|
||
}
|
||
}
|
||
return $data;
|
||
}
|
||
|
||
/**
|
||
* 前端订单列表
|
||
* @param array $where
|
||
* @param array|string[] $field
|
||
* @param array $with
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function getOrderApiList(array $where, array $field = ['*'], array $with = [])
|
||
{
|
||
[$page, $limit] = $this->getPageValue();
|
||
if (isset($where['status']) && $where['status'] === '') {
|
||
$data = $this->dao->getOrderList($where, $field, $page, $limit, $with, 'id DESC');
|
||
} else {
|
||
$data = $this->dao->getOrderList($where, $field, $page, $limit, $with);
|
||
}
|
||
/** @var StoreOrderServices $orderServices */
|
||
$orderServices = app()->make(StoreOrderServices::class);
|
||
foreach ($data as &$item) {
|
||
$item['type_name'] = '';
|
||
if ($item['type'] > 0) {
|
||
[$type_name, $color] = $orderServices->tidyOrderType($item, true);
|
||
$item['type_name'] = $type_name;
|
||
}
|
||
$item = $orderServices->tidyOrder($item, true);
|
||
$cart_num = 0;
|
||
foreach ($item['cartInfo'] ?: [] as $key => $product) {
|
||
if (isset($item['_status']['_type']) && $item['_status']['_type'] == 3) {
|
||
$item['cartInfo'][$key]['add_time'] = isset($product['add_time']) ? date('Y-m-d H:i', (int)$product['add_time']) : '时间错误';
|
||
}
|
||
$item['cartInfo'][$key]['productInfo']['price'] = $product['truePrice'] ?? 0;
|
||
|
||
if (isset($product['is_gift']) && $product['is_gift']) continue;
|
||
$cart_num += $product['cart_num'];
|
||
}
|
||
if (count($item['refund'])) {
|
||
$refund_num = array_sum(array_column($item['refund'], 'refund_num'));
|
||
$item['is_all_refund'] = $refund_num == $cart_num;
|
||
} else {
|
||
$item['is_all_refund'] = false;
|
||
}
|
||
}
|
||
return $data;
|
||
}
|
||
|
||
/**
|
||
* 获取手机端订单管理
|
||
* @param array $where
|
||
* @param array $with
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function getWapAdminOrderList(array $where, array $with = [])
|
||
{
|
||
[$page, $limit] = $this->getPageValue();
|
||
$list = $this->dao->getOrderList($where, ['*'], $page, $limit, $with);
|
||
/** @var StoreOrderServices $orderServices */
|
||
$orderServices = app()->make(StoreOrderServices::class);
|
||
$list = $orderServices->tidyOrderList($list);
|
||
foreach ($list as &$item) {
|
||
$refund_num = array_sum(array_column($item['refund'], 'refund_num'));
|
||
$cart_num = 0;
|
||
foreach ($item['_info'] as $items) {
|
||
if (isset($items['cart_info']['is_gift']) && $items['cart_info']['is_gift']) continue;
|
||
$cart_num += $items['cart_info']['cart_num'];
|
||
}
|
||
$item['is_all_refund'] = $refund_num == $cart_num;
|
||
}
|
||
return $list;
|
||
}
|
||
|
||
}
|