fix(hjf): 保单商品多份购买分润计算全链路修复

- 公排入队:按件数拆分为 N 条独立记录,每条单份金额,逐条触发退款检测
- 周期佣金:位次统计改为按报单商品总件数(cart_num 之和),而非订单数
- 分销等级任务:type 6/7 订单数统计改为按 cart_num 累计保单商品份数
- 推荐返佣与积分奖励:验证 cart_num 倍乘逻辑正确

Made-with: Cursor
This commit is contained in:
panchengyong
2026-04-06 02:40:01 +08:00
parent fb89fbbacb
commit 364d5333d7
4 changed files with 93 additions and 42 deletions

View File

@@ -1028,13 +1028,25 @@ class StoreOrderCreateServices extends BaseServices
return '0';
}
// fsgx B6统计推荐人已完成的报单订单数作为起始位次基准
$completedCount = (int)\think\facade\Db::name('store_order')
// fsgx B6统计推荐人已完成的报单商品总件数(非订单数,作为起始位次基准
$completedOrderIds = \think\facade\Db::name('store_order')
->where('spread_uid', $spread_uid)
->where('is_queue_goods', 1)
->where('paid', 1)
->where('is_del', 0)
->count();
->column('id');
$completedCount = 0;
if ($completedOrderIds) {
$completedCartRows = \think\facade\Db::name('store_order_cart_info')
->whereIn('oid', $completedOrderIds)
->column('cart_info');
foreach ($completedCartRows as $ccRow) {
$ccItem = is_string($ccRow) ? json_decode($ccRow, true) : $ccRow;
if (!empty($ccItem['productInfo']['is_queue_goods'])) {
$completedCount += (int)($ccItem['cart_num'] ?? 1);
}
}
}
// fsgx B-2B逐件轮巡每件商品取下一个位次的佣金比例后累加
$total = '0';