From 2a17dde78dbcf6c464dd6bdca3113f5576ca17ab Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Sep 2024 14:58:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E5=BC=95=E5=85=A5=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E9=87=91=E9=80=BB=E8=BE=91=EF=BC=8C=E8=B0=83=E6=95=B4=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E5=88=A9=E6=B6=A6=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 4 ++-- app/common/logic/CommissionnLogic.php | 11 ++++++++++- app/common/logic/StoreFinanceFlowLogic.php | 15 +++++++++++---- .../StoreFinanceFlowProduct.php | 9 --------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 856c5b75a..ecd3643f6 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -8,6 +8,7 @@ use app\common\enum\UserShipEnum; use app\common\enum\YesNoEnum; use app\common\logic\BaseLogic; use app\common\logic\CapitalFlowLogic; +use app\common\logic\CommissionnLogic; use app\common\logic\PayNotifyLogic; use app\common\logic\StoreFinanceFlowLogic; use app\common\logic\UserSignLogic; @@ -566,8 +567,7 @@ class OrderLogic extends BaseLogic 'store_id' => $params['store_id'], 'staff_id' => $params['staff_id'] ?? 0, ], ['id' => $order['id']]); - //修改商品统计记录标识 - (new StoreProductLog())->where('oid', $order['id'])->update(['store_id' => $params['store_id']]); + (new StoreOrderCartInfo())->update([ 'verify_code' => $params['verify_code'] . '-1', 'writeoff_time' => time(), diff --git a/app/common/logic/CommissionnLogic.php b/app/common/logic/CommissionnLogic.php index 44b9ae9b1..d070ea47a 100644 --- a/app/common/logic/CommissionnLogic.php +++ b/app/common/logic/CommissionnLogic.php @@ -77,26 +77,35 @@ class CommissionnLogic extends BaseLogic $financeLogic->in($transaction_id, bcsub($order['pay_price'],$order['refund_price'],2), OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 //缴纳齐全了就加商户没有就加到平台 + //查询保证金额度 和已交保证金 $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); //保证金剩余额度 + //保证金剩余额度 + $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); + //门店利润 $store_profit = StoreFinanceFlowProduct::where('oid', $order['id'])->where('type', $type)->sum('number'); if ($deposit > 0) { + //如果保证金大于利润就全部扣除利润到保证金中 if ($deposit > $store_profit) { if ($store_profit > 0) { + //添加到门店保证中 $financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + //添加到门店余额中 $financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 } } else { + //利润减去保证金 $money = bcsub($store_profit, $deposit, 2); 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'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 } } } else { if ($store_profit > 0) { + //添加到门店余额中 $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 } } diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index 98b3131be..1a2e06f8a 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -146,13 +146,20 @@ class StoreFinanceFlowLogic extends BaseLogic */ public function updateStatusStore($order_id, $store_id, $money, $deposit) { - StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 11])->update(['status' => 1]); - StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 2])->update(['status' => 1]); $store = SystemStore::where('id', $store_id)->find(); $capitalFlowDao = new CapitalFlowLogic($store, 'store'); if ($money > 0) { - $capitalFlowDao->storeIncome('store_money_add', 'order', $order_id, $money,'','store_money'); - SystemStore::where('id', $store_id)->inc('store_money', $money)->update(); + //判断是否是押金 + if($store['paid_deposit']<$store['security_deposit']){ + StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 11])->update(['status' => 1,'number'=>$money]); + StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 2])->update(['status' => 1,'number'=>0]); + + $capitalFlowDao->storeIncome('store_paid_deposit_add', 'order', $order_id, $money,'','paid_deposit'); + SystemStore::where('id', $store_id)->inc('paid_deposit', $money)->update(); + }else{ + $capitalFlowDao->storeIncome('store_money_add', 'order', $order_id, $money,'','store_money'); + SystemStore::where('id', $store_id)->inc('store_money', $money)->update(); + } } if ($deposit > 0) { $capitalFlowDao->storeIncome('store_paid_deposit_add', 'order', $order_id, $deposit,'','paid_deposit'); diff --git a/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php b/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php index bea36cb01..daa72cf84 100644 --- a/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php +++ b/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php @@ -18,13 +18,4 @@ class StoreFinanceFlowProduct extends BaseModel use SoftDelete; protected $name = 'store_finance_flow_product'; protected $deleteTime = 'delete_time'; - - public static function onAfterWrite($data){ - try{ - channelLog($data->getOrigin(),'store_finance_flow_product','更新前'); - channelLog($data->toArray(),'store_finance_flow_product','更新后'); - }catch(Throwable $e){ - Log::error('store_finance_flow_product:'.$e->getMessage()); - } - } } \ No newline at end of file