diff --git a/app/Console/Commands/Dealer/OrderProcessCommand.php b/app/Console/Commands/Dealer/OrderProcessCommand.php index 59411146..94c606e2 100644 --- a/app/Console/Commands/Dealer/OrderProcessCommand.php +++ b/app/Console/Commands/Dealer/OrderProcessCommand.php @@ -393,6 +393,10 @@ class OrderProcessCommand extends Command $ranking = 0; foreach ($dealers as $dealer) { + if (! in_array($dealer->lvl, [DealerLvl::Secondary, DealerLvl::Top])) { + continue; + } + // 如果当前经销商等级没有对应的管理津贴分配规则,则忽略 if (is_null($rule = $rules->get($dealer->lvl->value))) { continue; @@ -400,6 +404,27 @@ class OrderProcessCommand extends Command // 同等级管理津贴最多给三次 if ($last === null || $dealer->lvl->value > $last->lvl->value) { + if ($ranking < 3 && $dealer->lvl === DealerLvl::Top) { + if ($secondarySubsidyRule = $rules->get(DealerLvl::Secondary)) { + $key = 'price_'.(1 + $ranking).'st'; + + $secondarySubsidy = $secondarySubsidyRule->{$key}; + + if (bccomp($secondarySubsidy, '0') === 1) { + $logs[] = [ + 'user_id' => $dealer->user_id, + 'order_id' => $product->order_id, + 'product_id' => $product->product_id, + 'lvl' => $dealer->lvl, + 'sales_volume' => $product->qty, + 'total_amount' => bcmul($product->qty, $secondarySubsidy, 2), + 'created_at' => $tz, + 'updated_at' => $tz, + ]; + } + } + } + $ranking = 1; } elseif ($ranking < 3 && $dealer->lvl->value === $last->lvl->value) { $ranking++;