From fcf6efe6ae63478704d0944500feb88477e0393a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 27 Jul 2024 16:45:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=A3=8E=E6=A0=BC=E5=92=8C=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionLogic.php | 80 ++++++++++++++-------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/app/common/logic/CommissionLogic.php b/app/common/logic/CommissionLogic.php index ea880882..4075d299 100644 --- a/app/common/logic/CommissionLogic.php +++ b/app/common/logic/CommissionLogic.php @@ -15,49 +15,47 @@ class CommissionLogic extends BaseLogic */ public static function setVillage($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0) { - self::user($order, 3, $transaction_id, $village_uid, 14); //村长 - self::user($order, 0, $transaction_id, 0, 12); //会员、厨师 - self::user($order, 5, $transaction_id, 0, 20); //个人店铺 - self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长 + self::user($order, 3, $transaction_id, $village_uid, 14); //村长 + self::user($order, 0, $transaction_id, 0, 12); //会员、厨师 + self::user($order, 5, $transaction_id, 0, 20); //个人店铺 + self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长 - self::platform($order, 2, $transaction_id); //平台 - self::store($order, 1, $transaction_id, 0); //门店 + self::platform($order, 2, $transaction_id); //平台 + self::store($order, 1, $transaction_id, 0); //门店 // $attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗 self::suppliter($order, $transaction_id); - } /** * 走队长分润 */ public static function setBrigade($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0) { - self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长 - self::user($order, 0, $transaction_id, 0, 12); ////会员、厨师 - self::user($order, 5, $transaction_id, 0, 20); ////会员、厨师 - self::user($order, 3, $transaction_id, $village_uid, 14); //村长 + self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长 + self::user($order, 0, $transaction_id, 0, 12); ////会员、厨师 + self::user($order, 5, $transaction_id, 0, 20); ////会员、厨师 + self::user($order, 3, $transaction_id, $village_uid, 14); //村长 - self::platform($order, 2, $transaction_id); //平台 - self::store($order, 1, $transaction_id, 0); //门店 + self::platform($order, 2, $transaction_id); //平台 + self::store($order, 1, $transaction_id, 0); //门店 // $attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗 self::suppliter($order, $transaction_id); - } /** * 走厨师分润 */ public static function setCook($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0) { - if($order['spread_uid']<=0){ - $uid=$order['uid']; - }else{ - $uid=$order['spread_uid']; + if ($order['spread_uid'] <= 0) { + $uid = $order['uid']; + } else { + $uid = $order['spread_uid']; } - self::user($order, 0, $transaction_id, $uid, 12); //会员、厨师 - self::user($order, 5, $transaction_id, $uid, 20); //会员、厨师 - self::user($order, 3, $transaction_id, $village_uid, 14); //村长 - self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长 - self::platform($order, 2, $transaction_id); //平台 - self::store($order, 1, $transaction_id, 0); //门店 + self::user($order, 0, $transaction_id, $uid, 12); //会员、厨师 + self::user($order, 5, $transaction_id, $uid, 20); //会员、厨师 + self::user($order, 3, $transaction_id, $village_uid, 14); //村长 + self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长 + self::platform($order, 2, $transaction_id); //平台 + self::store($order, 1, $transaction_id, 0); //门店 // $attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗 // $moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, 0, 2), 2); self::suppliter($order, $transaction_id); @@ -68,17 +66,17 @@ class CommissionLogic extends BaseLogic */ public static function setStore($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0) { - if($order['spread_uid']<=0){ - $uid=$order['uid']; - }else{ - $uid=$order['spread_uid']; + if ($order['spread_uid'] <= 0) { + $uid = $order['uid']; + } else { + $uid = $order['spread_uid']; } - self::user($order, 0, $transaction_id, $uid, 12); //会员、厨师 - self::user($order, 5, $transaction_id, $uid, 20); //会员、厨师 - self::user($order, 3, $transaction_id, $village_uid, 14); //村长 - self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长 - self::platform($order, 2, $transaction_id); //平台 - self::store($order, 1, $transaction_id, 0); //门店 + self::user($order, 0, $transaction_id, $uid, 12); //会员、厨师 + self::user($order, 5, $transaction_id, $uid, 20); //会员、厨师 + self::user($order, 3, $transaction_id, $village_uid, 14); //村长 + self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长 + self::platform($order, 2, $transaction_id); //平台 + self::store($order, 1, $transaction_id, 0); //门店 self::suppliter($order, $transaction_id); } @@ -91,7 +89,7 @@ class CommissionLogic extends BaseLogic $financeLogic = new StoreFinanceFlowLogic(); $financeLogic->order = $order; $financeLogic->user['uid'] = $order['uid']; - $fees=StoreFinanceFlowProduct::where('oid',$order['id'])->where('type',$type)->sum('number'); + $fees = StoreFinanceFlowProduct::where('oid', $order['id'])->where('type', $type)->sum('number'); if ($fees > 0) { $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 $financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出 @@ -108,7 +106,7 @@ class CommissionLogic extends BaseLogic $financeLogic->order = $order; $financeLogic->user['uid'] = $order['uid']; $pay_price = $order['pay_price']; - $number=StoreFinanceFlowProduct::where('oid',$order['id'])->sum('number'); + $number = StoreFinanceFlowProduct::where('oid', $order['id'])->sum('number'); $fees = bcsub($pay_price, $number, 2); if ($fees > 0) { $financeLogic->in($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); @@ -130,7 +128,7 @@ class CommissionLogic extends BaseLogic //缴纳齐全了就加商户没有就加到平台 $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=StoreFinanceFlowProduct::where('oid',$order['id'])->where('type',$type)->sum('number'); + $store_profit = StoreFinanceFlowProduct::where('oid', $order['id'])->where('type', $type)->sum('number'); if ($deposit > 0) { if ($deposit > $store_profit) { if ($store_profit > 0) { @@ -161,17 +159,17 @@ class CommissionLogic extends BaseLogic public static function user($order, $type, $transaction_id, $uid = 0, $enum = 0) { $financeLogic = new StoreFinanceFlowLogic(); - $fees=StoreFinanceFlowProduct::where('oid',$order['id'])->where('type',$type)->field('sum(number) as fees,other_uid')->find(); + $fees = StoreFinanceFlowProduct::where('oid', $order['id'])->where('type', $type)->field('sum(number) as fees,other_uid')->find(); if ($fees && $fees['fees'] > 0) { //记录用户余额收入 $financeLogic->user['uid'] = $order['uid']; $financeLogic->other_arr['vip_uid'] = $fees['other_uid']; $financeLogic->order = $order; - $financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - $financeLogic->out($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + $financeLogic->in($transaction_id, $fees['fees'], $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees['fees'], $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->save(); } - return $fees; + return $fees['fees']; } /**