diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index f40bd4027..cd804d806 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -304,10 +304,10 @@ class PayNotifyLogic extends BaseLogic //平台手续费 $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,0, $order['pay_type']); //平台手续费 - - $financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出 - //冻结金额的 + if ($fees > 0) { + $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], 0, 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(); @@ -316,22 +316,32 @@ class PayNotifyLogic extends BaseLogic $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']); + if ($store_profit > 0) { + $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, 0,$order['pay_type']); //平台手续费 + if ($deposit > 0) { + $financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + if ($money) { + $financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 + } } } else { - $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0,0, $order['pay_type']); //平台手续费 + if ($store_profit > 0) { + $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 + } } - if ($order['is_vip'] >=1) { + 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, 0,$order['pay_type']); //vip订单获得 - $financeLogic->out($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + if ($fees > 0) { + $financeLogic->in($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], 0, 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); @@ -351,27 +361,34 @@ class PayNotifyLogic extends BaseLogic } } } - //村长获得 - if ($village_uid > 0) { - $financeLogic->other_arr['vip_uid'] = $village_uid; + if ($fees > 0) { + //村长获得 + if ($village_uid > 0) { + $financeLogic->other_arr['vip_uid'] = $village_uid; + } + + $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + //队长获得 + if ($brigade_uid > 0) { + $financeLogic->other_arr['vip_uid'] = $brigade_uid; + } + $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + //其他获得 + $financeLogic->other_arr['vip_uid'] = 0; + $financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); } - $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0,$order['pay_type']); - $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - //队长获得 - if ($brigade_uid > 0) { - $financeLogic->other_arr['vip_uid'] = $brigade_uid; - } - $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0,$order['pay_type']); - $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - //其他获得 - $financeLogic->other_arr['vip_uid'] = 0; - $financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0,0, $order['pay_type']); - $financeLogic->out($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); } + $fees=bcsub($order['pay_price'], $count_frees, 2); //供应链订单获得 - $financeLogic->in($transaction_id, bcsub($order['pay_price'], $count_frees, 2), OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0,0, $order['pay_type']); - $financeLogic->out($transaction_id, $count_frees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - // } + if ($fees > 0) { + $financeLogic->in($transaction_id,$fees , OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + + } +// } $financeLogic->save(); // } }