From 26b26768c6650e9b967f8a644f5bc00653989883 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 10 Jan 2025 15:49:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=80=E6=AC=BE=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/store_order/StoreOrderController.php | 4 ++-- app/common/service/RefundOrderService.php | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/admin/controller/store_order/StoreOrderController.php b/app/admin/controller/store_order/StoreOrderController.php index e900c08a2..28b6ab613 100644 --- a/app/admin/controller/store_order/StoreOrderController.php +++ b/app/admin/controller/store_order/StoreOrderController.php @@ -133,8 +133,8 @@ class StoreOrderController extends BaseAdminController return $this->fail('无该订单请检查'); } $params['id'] = $detail['id']; - if (empty($params['product_arr'])) { - $params['old_cart_id'] = StoreOrderCartInfo::where('oid', $detail['id'])->where('status', '<>', 2)->column('id'); + if (!isset($params['product_arr'])) { + $params['product_arr'] = StoreOrderCartInfo::where('oid', $detail['id'])->where('status', '<>', 2)->field('product_id,cart_num')->select()->toArray(); } $refundOrderService->refund($detail['uid'], $params); return $this->success('退款成功',[],1,1); diff --git a/app/common/service/RefundOrderService.php b/app/common/service/RefundOrderService.php index 67a57b27b..59b57184e 100644 --- a/app/common/service/RefundOrderService.php +++ b/app/common/service/RefundOrderService.php @@ -37,14 +37,15 @@ class RefundOrderService } $orderCartInfoWhere = ['oid' => $order['id']]; $refundNum = 0; - if (!empty($params['old_cart_id'])) { - $orderCartInfoWhere['id'] = $params['old_cart_id']; - $refundNum = count($params['old_cart_id']); - } if (!empty($params['product_arr'])) { $orderCartInfoWhere['product_id'] = array_column($params['product_arr'], 'product_id'); $refundNum = count($params['product_arr']); } + if (!empty($params['old_cart_id'])) { + $orderCartInfoWhere['id'] = $params['old_cart_id']; + $refundNum = count($params['old_cart_id']); + $params['product_arr'] = StoreOrderCartInfo::field('product_id,cart_num')->where($orderCartInfoWhere)->select()->toArray(); + } $orderCartProducts = StoreOrderCartInfo::where($orderCartInfoWhere)->select(); if (isset($params['refund_price'])) { $refundAmount = $params['refund_price']; @@ -223,7 +224,7 @@ class RefundOrderService } } $productIds = array_unique(array_column($storeOrderProducts->toArray(), 'product_id')); - StoreFinanceFlowProduct::where('oid', $order['id'])->whereIn('product_id', $productIds)->update(['number' => 0, 'update_time' => strtotime(time())]); + StoreFinanceFlowProduct::where('oid', $order['id'])->whereIn('product_id', $productIds)->update(['number' => 0, 'update_time' => time()]); $village_uid = StoreFinanceFlow::where('order_id', $order['id'])->where('financial_type', 14)->value('other_uid'); $brigade_uid = StoreFinanceFlow::where('order_id', $order['id'])->where('financial_type', 15)->value('other_uid'); $transaction_id = StoreFinanceFlow::where('order_id', $order['id'])->value('transaction_id');