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(); // } }