From 88e6f861ab5ada887334e500230f17389c6b5d98 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 14 Jun 2024 13:46:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BA=86=E8=B5=84=E9=87=91=E6=B5=81=E5=90=91=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E5=AF=B9VIP=E8=AE=A2=E5=8D=95=E5=92=8C=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=9A=84=E5=8C=BA=E5=88=86=E5=A4=84=E7=90=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 90 ++++++++++++++++------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index f7cfcf2c2..57381099b 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -259,49 +259,57 @@ class PayNotifyLogic extends BaseLogic $financeLogic->order = $order; $financeLogic->user = ['uid' => $order['uid']]; // if ($order->pay_type != 9 || $order->pay_type != 10) { - $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY); //用户订单支付 - //商户应该获得的钱 每个商品的price-ot_price 利润 - // if (isset($order->profit) && $order->profit > 0) { - //平台手续费 - $fees = bcdiv(bcmul($order['pay_price'], '0.02', 2), 1, 2); + $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY); //用户订单支付 + $count_frees=0; + //商户应该获得的钱 每个商品的price-ot_price 利润 + // if (isset($order->profit) && $order->profit > 0) { - $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'],0,$order['pay_type']); //平台手续费 + //平台手续费 + $fees = bcdiv(bcmul($order['pay_price'], '0.02', 2), 1, 2); + $count_frees=bcadd($count_frees,$fees,2); + $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], 0, $order['pay_type']); //平台手续费 - $financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'],0,$order['pay_type']); //商户平台手续费支出 - //冻结金额的 - // $frozen = bcsub($order->profit, $fees, 2); - //缴纳齐全了就加商户没有就加到平台 - $money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find(); - $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度 - $store_profit= bcdiv(bcmul($order['pay_price'], '0.05', 2), 1, 2); - if ($deposit > 0 ) { - if($deposit>$store_profit){ - $financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'],0,$order['pay_type']); - }else{ - $money=bcsub($store_profit,$deposit,2); - $financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'],0,$order['pay_type']); - $financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'],0,$order['pay_type']); //平台手续费 - } - }else{ - $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'],0,$order['pay_type']); //平台手续费 - } - if($order['is_vip']==1 ){ - if($order['spread_uid']>0){ - $financeLogic->other_arr['vip_uid'] = $order['spread_uid']; - $fees = bcdiv(bcmul($order['pay_price'], '0.08', 2), 1, 2); - $financeLogic->in($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'],0,$order['pay_type']); //vip订单获得 - $financeLogic->out($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], $order['staff_id'],0,$order['pay_type']); - } - $fees = bcdiv(bcmul($order['pay_price'], '0.01', 2), 1, 2); - $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'],0,$order['pay_type']); //vip订单获得 - $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'],0,$order['pay_type']); - $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'],0,$order['pay_type']); //vip订单获得 - $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'],0,$order['pay_type']); - $financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'],0,$order['pay_type']); //vip订单获得 - $financeLogic->out($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'],0,$order['pay_type']); - } - // } - $financeLogic->save(); + $financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出 + //冻结金额的 + // $frozen = bcsub($order->profit, $fees, 2); + //缴纳齐全了就加商户没有就加到平台 + $money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find(); + $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度 + $store_profit = bcdiv(bcmul($order['pay_price'], '0.05', 2), 1, 2); + $count_frees=bcadd($count_frees,$store_profit,2); + if ($deposit > 0) { + if ($deposit > $store_profit) { + $financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } else { + $money = bcsub($store_profit, $deposit, 2); + $financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + $financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //平台手续费 + } + } else { + $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //平台手续费 + } + if ($order['is_vip'] == 1) { + if ($order['spread_uid'] > 0) { + $financeLogic->other_arr['vip_uid'] = $order['spread_uid']; + $fees = bcdiv(bcmul($order['pay_price'], '0.08', 2), 1, 2); + $count_frees=bcadd($count_frees,$fees,2); + $financeLogic->in($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //vip订单获得 + $financeLogic->out($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + $fees = bcdiv(bcmul($order['pay_price'], '0.01', 2), 1, 2); + $count_frees=bcadd($count_frees,bcmul($fees,3,2),2); + + $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //vip订单获得 + $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //vip订单获得 + $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + $financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //vip订单获得 + $financeLogic->out($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + $financeLogic->in($transaction_id, $count_frees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //vip订单获得 + $financeLogic->out($transaction_id, $count_frees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + // } + $financeLogic->save(); // } }