From 176aef31f0afa7bc03a3970c838ef6e1ad20bdb0 Mon Sep 17 00:00:00 2001 From: monanxiao Date: Fri, 24 Mar 2023 14:15:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=99=AE=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=8B=E5=8D=95=EF=BC=8C=E4=BE=9B=E5=BA=94=E9=93=BE?= =?UTF-8?q?=E5=9B=A2=E9=98=9F=E8=8E=B7=E5=BE=97=E6=94=B6=E7=9B=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/StoreOrderCreateRepository.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index faa06d08..09d29bd2 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -972,6 +972,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository $cartIds = []; $orderList = []; $user_address = isset($address) ? ($address['province'] . $address['city'] . $address['district'] . $address['street'] . $address['detail']) : ''; + // 验证下单来源,如果是普通来源,则执行分销推广佣金分配 if($source == 2) // 普通商品 { @@ -1063,6 +1064,28 @@ class StoreOrderCreateRepository extends StoreOrderRepository } unset($cart); + // 开始计算------------------------------------------------------------ + + // 供应链关联 + $supplyChainLink = SupplyChainLinkMerchant::with('supplyChain') + ->where('eb_merchant_id', $merchantCart['mer_id']) + ->find(); + + $shareRate = 0; + $supplyPrice = 0; + if($supplyChainLink) + { + // 分润比例 + $shareRate = $supplyChainLink['supplyChain']['shareRate']; + // 大约分润比例金额 + $makePrice = $merchantCart['order']['pay_price'] * $shareRate / 100; + // 获取实际分润金额 + $supplyPrice = sprintf("%.2f", $makePrice); + } + + + // 计算结束------------------------------------------------------------ + $rate = 0; if ($merchantCart['commission_rate'] > 0) { $rate = $merchantCart['commission_rate']; @@ -1106,6 +1129,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository 'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'], 'pay_type' => $pay_type, 'source' => $source, // 增加订单来源 1 小组采购 2 普同商品 + 'supply_chain_rate' => $shareRate, // 供应链分润比例 + 'supply_chain_price' => $supplyPrice, // 供应链分润金额 ]; $allUseCoupon = array_merge($allUseCoupon, $merchantCart['order']['useCouponIds']); $orderList[] = $_order;