fix(hjf): 保单商品多份购买分润计算全链路修复
- 公排入队:按件数拆分为 N 条独立记录,每条单份金额,逐条触发退款检测 - 周期佣金:位次统计改为按报单商品总件数(cart_num 之和),而非订单数 - 分销等级任务:type 6/7 订单数统计改为按 cart_num 累计保单商品份数 - 推荐返佣与积分奖励:验证 cart_num 倍乘逻辑正确 Made-with: Cursor
This commit is contained in:
@@ -423,7 +423,31 @@ class AgentLevelTaskServices extends BaseServices
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计直推下级的报单订单数(type=6 任务)
|
||||
* 根据订单 ID 列表,统计其中报单商品的总件数(cart_num 之和)
|
||||
*
|
||||
* 一笔订单购买 N 份报单商品时 cart_num=N,本方法返回所有订单的 N 之和,
|
||||
* 而非订单行数。与 HjfOrderPayJob / StoreOrderCreateServices 中的 B3/B6 逻辑一致。
|
||||
*/
|
||||
private function sumQueueGoodsQty(array $orderIds): int
|
||||
{
|
||||
if (empty($orderIds)) {
|
||||
return 0;
|
||||
}
|
||||
$cartRows = Db::name('store_order_cart_info')
|
||||
->whereIn('oid', $orderIds)
|
||||
->column('cart_info');
|
||||
$total = 0;
|
||||
foreach ($cartRows as $row) {
|
||||
$item = is_string($row) ? json_decode($row, true) : $row;
|
||||
if (!empty($item['productInfo']['is_queue_goods'])) {
|
||||
$total += (int)($item['cart_num'] ?? 1);
|
||||
}
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计直推下级的报单商品总份数(type=6 任务)
|
||||
*
|
||||
* @param int $uid 用户 ID
|
||||
* @return int
|
||||
@@ -437,14 +461,14 @@ class AgentLevelTaskServices extends BaseServices
|
||||
if (empty($directUids)) {
|
||||
return 0;
|
||||
}
|
||||
// fsgx B5:补充 refund_status 检查,与其他任务类型保持一致,排除已全额退款订单
|
||||
return (int)Db::name('store_order')
|
||||
$orderIds = Db::name('store_order')
|
||||
->whereIn('uid', $directUids)
|
||||
->where('is_queue_goods', 1)
|
||||
->where('paid', 1)
|
||||
->where('is_del', 0)
|
||||
->whereIn('refund_status', [0, 3])
|
||||
->count();
|
||||
->column('id');
|
||||
return $this->sumQueueGoodsQty($orderIds);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,14 +516,14 @@ class AgentLevelTaskServices extends BaseServices
|
||||
if ($childGrade >= 2) {
|
||||
continue;
|
||||
}
|
||||
// fsgx B5:补充 refund_status 检查,排除已全额退款订单
|
||||
$total += (int)Db::name('store_order')
|
||||
$childOrderIds = Db::name('store_order')
|
||||
->where('uid', $child['uid'])
|
||||
->where('is_queue_goods', 1)
|
||||
->where('paid', 1)
|
||||
->where('is_del', 0)
|
||||
->whereIn('refund_status', [0, 3])
|
||||
->count();
|
||||
->column('id');
|
||||
$total += $this->sumQueueGoodsQty($childOrderIds);
|
||||
$total += $this->recursiveUmbrellaCount((int)$child['uid'], $remainDepth - 1);
|
||||
}
|
||||
return $total;
|
||||
|
||||
Reference in New Issue
Block a user