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;