fix(fsgx): 伞下人数与待释放积分发放链路
- spread/people 增加 umbrellaCount、umbrellaOrderCount;MemberLevelServices 递归统计伞下人数 - 佣金记录页使用新字段展示团队业绩 - 报单积分改由 HjfOrderPayJob 在等级升级后发放,避免 grade=0 时序问题 - PointsRewardServices::reward 按 points_release_log 幂等防重复 - 移除 backOrderBrokerage 内同步 grantFrozenPointsByBrokerage Made-with: Cursor
This commit is contained in:
@@ -111,6 +111,32 @@ class MemberLevelServices extends BaseServices
|
||||
return $this->agentLevelTaskServices->getUmbrellaQueueOrderCount($uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归统计伞下总人数(DFS,最大深度 8 层,不含本人)
|
||||
*/
|
||||
public function getUmbrellaMemberCount(int $uid, int $maxDepth = 8): int
|
||||
{
|
||||
return $this->recursiveUmbrellaMemberCount($uid, $maxDepth);
|
||||
}
|
||||
|
||||
private function recursiveUmbrellaMemberCount(int $uid, int $remainDepth): int
|
||||
{
|
||||
if ($remainDepth <= 0) {
|
||||
return 0;
|
||||
}
|
||||
$children = Db::name('user')
|
||||
->where('spread_uid', $uid)
|
||||
->column('uid');
|
||||
if (empty($children)) {
|
||||
return 0;
|
||||
}
|
||||
$count = count($children);
|
||||
foreach ($children as $childUid) {
|
||||
$count += $this->recursiveUmbrellaMemberCount((int)$childUid, $remainDepth - 1);
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动设置会员等级(管理后台使用)
|
||||
*
|
||||
|
||||
@@ -45,6 +45,16 @@ class PointsRewardServices extends BaseServices
|
||||
public function reward(int $orderUid, string $orderId, int $orderDbId = 0): void
|
||||
{
|
||||
try {
|
||||
// 幂等检查:若该订单已有积分奖励记录则跳过,防止重复发放
|
||||
$exists = Db::name('points_release_log')
|
||||
->where('order_id', $orderId)
|
||||
->whereIn('type', ['reward_direct', 'reward_umbrella'])
|
||||
->count();
|
||||
if ($exists > 0) {
|
||||
Log::info("[PointsReward] 订单 {$orderId} 已有积分奖励记录,跳过重复发放");
|
||||
return;
|
||||
}
|
||||
|
||||
$buyer = $this->userDao->get($orderUid);
|
||||
if (!$buyer || !$buyer['spread_uid']) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user