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
141 lines
5.6 KiB
PHP
141 lines
5.6 KiB
PHP
<?php
|
|
|
|
|
|
namespace app\jobs\order;
|
|
|
|
|
|
use app\jobs\supplier\SupplierFinanceJob;use app\services\order\StoreOrderCartInfoServices;
|
|
use app\services\order\StoreOrderServices;
|
|
use app\services\order\StoreOrderSplitServices;
|
|
use app\services\supplier\SystemSupplierServices;
|
|
use crmeb\basic\BaseJobs;
|
|
use crmeb\traits\QueueTrait;
|
|
|
|
/**
|
|
* 分配订单
|
|
* Class ShareOrderJob
|
|
* @package app\jobs
|
|
*/
|
|
class ShareOrderJob extends BaseJobs
|
|
{
|
|
use QueueTrait;
|
|
|
|
/**
|
|
* 门店分配订单
|
|
* @param $orderInfo
|
|
* @return bool
|
|
*/
|
|
public function doJob($orderInfo)
|
|
{
|
|
if (!$orderInfo) {
|
|
return true;
|
|
}
|
|
//整单分给门店
|
|
/** @var StoreOrderServices $storeOrderServices */
|
|
$storeOrderServices = app()->make(StoreOrderServices::class);
|
|
$order = $storeOrderServices->get($orderInfo['id']);
|
|
if (!$order) {
|
|
return true;
|
|
}
|
|
$orderInfo = $order->toArray();
|
|
|
|
|
|
try {
|
|
$id = (int)$orderInfo['id'];
|
|
/** @var StoreOrderCartInfoServices $storeOrderCartInfoServices */
|
|
$storeOrderCartInfoServices = app()->make(StoreOrderCartInfoServices::class);
|
|
//订单下原商品信息
|
|
$cartInfo = $storeOrderCartInfoServices->getCartColunm(['oid' => $id, 'split_status' => [0, 1]], 'cart_id,type,relation_id,is_gift,cart_num,split_surplus_num', 'cart_id');
|
|
if (!$cartInfo) {
|
|
return true;
|
|
}
|
|
$suppplierIds = $storeIds = [];
|
|
foreach ($cartInfo as $cart) {
|
|
$type = $cart['type'] ?? 0;
|
|
switch ($type) {
|
|
case 0://兼容之前供应商商品
|
|
if ($cart['relation_id']) {
|
|
$suppplierIds[] = $cart['relation_id'];
|
|
}
|
|
break;
|
|
case 1:
|
|
$storeIds[] = $cart['relation_id'];
|
|
break;
|
|
case 2:
|
|
$suppplierIds[] = $cart['relation_id'];
|
|
break;
|
|
}
|
|
}
|
|
if ($suppplierIds) {//验证供应商状态(关闭|删除不分配)
|
|
/** @var SystemSupplierServices $supplierServices */
|
|
$supplierServices = app()->make(SystemSupplierServices::class);
|
|
$suppplierIds = $supplierServices->getColumn([['id', 'in', $suppplierIds], ['is_show', '=', 1], ['is_del', '=', 0]], 'id');
|
|
}
|
|
$cart_ids = [];
|
|
$other_cart_ids = [];
|
|
//分配给供应商、门店
|
|
if ($suppplierIds) {
|
|
$suppplier_id = $suppplierIds[0] ?? 0;
|
|
$updateData = [];
|
|
//先拆分供应商
|
|
if ($suppplier_id) {
|
|
foreach ($cartInfo as $cart_id => $cart) {
|
|
if ($cart['type'] == 2 && $cart['relation_id'] == $suppplier_id) {//拆分
|
|
$cart_ids[] = ['cart_id' => $cart_id, 'cart_num' => $cart['cart_num']];
|
|
} else {
|
|
$other_cart_ids[] = ['cart_id' => $cart_id, 'cart_num' => $cart['cart_num']];
|
|
}
|
|
}
|
|
$updateData['supplier_id'] = $suppplier_id;
|
|
}
|
|
//下单商品都是某一个供应商|| 门店商品,不用拆分
|
|
if (!$other_cart_ids && count($suppplierIds) == 1) {
|
|
$storeOrderServices->update(['id' => $id], ['supplier_id' => $suppplier_id]);
|
|
if (isset($updateData['supplier_id'])) {
|
|
//供应商账单流水
|
|
SupplierFinanceJob::dispatch([$id, 1]);
|
|
SpliteStoreOrderJob::dispatchDo('splitAfter', [$orderInfo]);
|
|
}
|
|
} else {
|
|
//分配订单
|
|
/** @var StoreOrderSplitServices $storeOrderSplitServices */
|
|
$storeOrderSplitServices = app()->make(StoreOrderSplitServices::class);
|
|
$splitResult = $storeOrderSplitServices->equalSplit($id, $cart_ids);
|
|
$otherOrder = [];
|
|
if ($splitResult) {//拆分供应商订单
|
|
[$orderInfo, $otherOrder] = $splitResult;
|
|
}
|
|
$storeOrderServices->update(['id' => $orderInfo['id']], $updateData);
|
|
if (isset($updateData['store_id'])) {//拆分门店订单
|
|
SpliteStoreOrderJob::dispatchDo('splitAfter', [$orderInfo]);
|
|
} elseif (isset($updateData['supplier_id'])) {
|
|
//供应商账单流水
|
|
SupplierFinanceJob::dispatch([$orderInfo['id'], 1]);
|
|
SpliteStoreOrderJob::dispatchDo('splitAfter', [$orderInfo]);
|
|
}
|
|
//还有商品
|
|
if ($other_cart_ids && $otherOrder) {
|
|
//还有其他供应商 || 门店 继续分配
|
|
if (count($suppplierIds) >= 1) {
|
|
ShareOrderJob::dispatch([$otherOrder]);
|
|
}
|
|
}
|
|
}
|
|
|
|
} else {//平台配送
|
|
SpliteStoreOrderJob::dispatchDo('splitAfter', [$orderInfo]);
|
|
}
|
|
|
|
} catch (\Throwable $e) {
|
|
response_log_write([
|
|
'message' => '自动拆分供应商订单失败,原因:' . $e->getMessage(),
|
|
'file' => $e->getFile(),
|
|
'line' => $e->getLine()
|
|
]);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
}
|