diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 255cdb3b..462f302f 100755 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -313,19 +313,29 @@ class StoreOrderRepository extends BaseRepository $_payPrice = bcsub($order->pay_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2); + // 平台收入手续费 if ($order['commission_rate'] > 0) { $commission_rate = bcdiv((string)$order['commission_rate'],'100',6); $platformCommission = bcmul($_payPrice, (string)$commission_rate, 2); - // 平台收入手续费 - $financeDao->platformIn($platformCommission, 'platform_commission'); - $promoter = $order->merchant->promoter(); - if (!empty($promoter)) { - $promoterCommission = bcmul($_payPrice, 0.003, 2); - // 平台支出推广费 - $financeDao->platformOut($promoterCommission, 'promoter_commission'); - } + $financeDao->platformIn($platformCommission, 'commission_to_platform'); $_payPrice = bcsub($_payPrice, $platformCommission, 2); } + + // 平台支出推广费 + $promoter = $order->merchant->promoter(); + if (!empty($promoter)) { + $promoterCommission = bcmul($_payPrice, 0.003, 2); + $financeDao->platformOut($promoterCommission, 'commission_to_promoter'); + } + + if ($_payPrice > 0) { + /** @var MerchantRepository $merchantRepo */ + $merchantRepo = app()->make(MerchantRepository::class); + $merchantRepo->merId = $order['mer_id']; + $merchantRepo->forceMargin = false; + [$_payPrice, $financeDao] = $merchantRepo->deductDeposit($_payPrice, $order, $financeDao); + } + // 商户收入金额 $financeDao->merchantIn($_payPrice, 'merchant_order', $order['mer_id']); diff --git a/app/common/repositories/system/merchant/FinancialRecordRepository.php b/app/common/repositories/system/merchant/FinancialRecordRepository.php index 01010850..1e73b504 100755 --- a/app/common/repositories/system/merchant/FinancialRecordRepository.php +++ b/app/common/repositories/system/merchant/FinancialRecordRepository.php @@ -31,7 +31,7 @@ class FinancialRecordRepository extends BaseRepository { public $commonFinancialType = [ - 'order', 'order_refund', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon', + 'order', 'order_presell', 'order_refund', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon', 'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund' ,'commission_to_entry_merchant','commission_to_entry_merchant_refund' ,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund', 'commission_to_store', 'commission_to_courier', 'commission_to_promoter', 'commission_to_store_refund', 'commission_to_courier_refund', 'commission_to_promoter_refund', 'auto_margin', 'auto_margin_refund', 'supply_chain', 'supply_chain_refund', 'platform_consumption', 'platform_consumption_refund'