From a5d93516b254b91a14d65010bd668d40a33ad230 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 2 Sep 2024 16:52:49 +0800 Subject: [PATCH] =?UTF-8?q?feat(StoreOrderLogic):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=92=88=E5=AF=B9=E7=89=B9=E5=AE=9A=E5=95=86=E5=BA=97ID?= =?UTF-8?q?=E7=9A=84=E4=BB=B7=E6=A0=BC=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/store_order/StoreOrderLogic.php | 4 ++ app/common/logic/StoreFinanceFlowLogic.php | 55 ++++++++++--------- process/Task.php | 2 +- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/app/admin/logic/store_order/StoreOrderLogic.php b/app/admin/logic/store_order/StoreOrderLogic.php index ec66af92..6b54d1d9 100644 --- a/app/admin/logic/store_order/StoreOrderLogic.php +++ b/app/admin/logic/store_order/StoreOrderLogic.php @@ -46,6 +46,9 @@ class StoreOrderLogic extends BaseLogic $v['uid'] = $params['user_id']; $v['store_id'] = $params['store_id']; $v['cart_num'] = $v['stock']; + if(in_array($params['store_id'],[17,18])){ + StoreBranchProduct::where('id', $v['id'])->update(['price' => $v['price'], 'vip_price' => $v['price'], 'cost' => $v['price'], 'purchase' => $v['price']]); + } unset($v['id']); $res = CartLogic::add($v); $cartId[] = $res['id']; @@ -53,6 +56,7 @@ class StoreOrderLogic extends BaseLogic $user = User::where('id', $params['user_id'])->find(); $params['shipping_type'] = 2; $params['pay_type'] = 7; + $params['source'] =2; $order = OrderLogic::createOrder($cartId, null, $user, $params); return true; } diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index 70c21d8d..98b3131b 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -183,39 +183,40 @@ class StoreFinanceFlowLogic extends BaseLogic ->select(); foreach ($list as $k => $value) { //用户 - switch ($value['type']) { - case 0: - if ($value['financial_type'] == 12 && $value['other_uid'] > 0) { - $user = User::where('id', $value['other_uid'])->findOrEmpty(); - $capitalFlowDao = new CapitalFlowLogic($user); - $user->now_money = bcsub($user['now_money'], $value['number'], 2); - $user->save(); - // Log::error('aa'.$a); - // Log::error('aa'.$user['now_money']); - // Log::error('aa'.$value['number']); - $capitalFlowDao->userExpense('user_order_promotion_refund', 'system_back', $value['order_id'], $value['number'], '', $value['pay_type']); - } - break; - //商户 - case 1: - $store = SystemStore::where('id', $store_id)->find(); - $capitalFlowDao = new CapitalFlowLogic($store, 'store'); - if ($value['number'] > 0 && $value['financial_type'] == 2) { - SystemStore::where('id', $value['store_id'])->dec('store_money', $value['number'])->update(); - $capitalFlowDao->storeExpense('store_paid_deposit_dec', 'order', $value['order_id'],$value['number']); + if($value['type']==0){ + if ($value['financial_type'] == 12 && $value['other_uid'] > 0) { + $user = User::where('id', $value['other_uid'])->findOrEmpty(); + $capitalFlowDao = new CapitalFlowLogic($user); + $user->now_money = bcsub($user['now_money'], $value['number'], 2); + $user->save(); + $capitalFlowDao->userExpense('user_order_promotion_refund', 'system_back', $value['order_id'], $value['number'], '', $value['pay_type']); + } + }elseif($value['type']==1){ + $store = SystemStore::where('id', $store_id)->find(); + $capitalFlowDao = new CapitalFlowLogic($store, 'store'); + if ($value['number'] > 0 && $value['financial_type'] == 2) { + $find=SystemStore::where('id', $value['store_id'])->find(); + $find->store_money=bcsub($find['store_money'], $value['number'],2); + $find->save(); + $capitalFlowDao->storeExpense('store_money_refund', 'order', $value['order_id'],$value['number'],'','store_money'); - } - if ($value['number'] > 0 && $value['financial_type'] == 16) { - SystemStore::where('id', $value['store_id'])->dec('attrition', $value['number'])->update(); - $capitalFlowDao->storeExpense('store_attrition_dec', 'order', $value['order_id'], $value['number']); + } + if ($value['number'] > 0 && $value['financial_type'] == 16) { + $find=SystemStore::where('id', $value['store_id'])->find(); + $find->attrition=bcsub($find['attrition'], $value['number'],2); + $find->save(); + $capitalFlowDao->storeExpense('store_attrition_refund', 'order', $value['order_id'], $value['number'],'','attrition'); - } - break; + } } } $find = StoreFinanceFlow::where('order_sn', $orderSn)->where('financial_type', 11)->where('status', 1)->find(); if ($find && $find['number'] > 0) { - SystemStore::where('id', $find['store_id'])->dec('paid_deposit', $find['number'])->update(); + $find=SystemStore::where('id', $value['store_id'])->find(); + $capitalFlowDao = new CapitalFlowLogic($find, 'store'); + $find->paid_deposit=bcsub($find['paid_deposit'], $value['number'],2); + $find->save(); + $capitalFlowDao->storeExpense('store_paid_deposit_refund', 'order', $value['order_id'],$value['number'],'','paid_deposit'); } // $data = StoreFinanceFlow::where('order_sn', $orderSn)->select(); // foreach ($data as $k => &$value) { diff --git a/process/Task.php b/process/Task.php index 2fedfff8..a25bda15 100644 --- a/process/Task.php +++ b/process/Task.php @@ -23,7 +23,7 @@ class Task new Crontab('0 */10 * * * *', function () { $where = ['paid' => 0]; $where[] = ['create_time', '<', time() - 600]; // 10分钟前创建的订单 - $where[] = ['shipping_type', '<>',4]; + $where[] = ['source', '<',2]; // 删除10分钟未支付的订单 $oid = StoreOrder::where($where)->column('id'); // 删除时间设置为当前时间,即删除 if ($oid) {