From 050927ffbc3eb0a7b6be8d7885d57099086923db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Mon, 14 Feb 2022 15:57:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AE=A1=E7=90=86=E6=B4=A5?= =?UTF-8?q?=E8=B4=B4=E5=88=86=E9=85=8D=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/Dealer/OrderProcessCommand.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) 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++;