From d7b94f90b6037b718b98c28dca8c436ceb691337 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Fri, 19 Nov 2021 17:02:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/service/OrderMainDao.php | 31 ++++++++++++++++++++--- application/admin/service/PaymentOrderService.php | 6 ++++- application/admin/service/ReceiptOrderService.php | 11 +++++--- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/application/admin/service/OrderMainDao.php b/application/admin/service/OrderMainDao.php index e3d8dc4..f572934 100644 --- a/application/admin/service/OrderMainDao.php +++ b/application/admin/service/OrderMainDao.php @@ -101,8 +101,11 @@ class OrderMainDao $statusList['isPayment']++; } } - $orderInfo = $this->getInfoById($orderId); - $orderStatus = $this->getStatus($cnt,$statusList,$orderInfo); + $orderInfoRe = $this->getInfoById($orderId); + if (!$orderInfoRe['flag']) { + return $orderInfoRe; + } + $orderStatus = $this->getStatus($cnt,$statusList,$orderInfoRe['data']); //更新金额 $orderMain = new OrderMain(); $orderMain->save(["total_amount" => $amount, "cost_amount" => $cost,"profit_amount"=>$amount-$cost,"order_status"=>$orderStatus],["id" => $orderId]); @@ -122,7 +125,6 @@ class OrderMainDao public function getStatus($cnt,$statusList,$orderInfo){ //资源单状态 1、未发单/ 2已发单、3已确认、4已取消 //订单状态0待处理 1已确认 2部分取消 3处理中 10已完成 11已取消 - //已完成:订单已完成付款、已完成收款(无视子订单状态) if ($orderInfo['receipt_order_status'] ==2 && $statusList['isPayment'] == $cnt) { return 10; @@ -293,4 +295,27 @@ class OrderMainDao return Util::returnArrEr("将主订单从收款单下移除失败".$e->getMessage()); } } + + /** + * 获取收款单下所有主订单的订单ID + * @param $receipt_order_id + * @return array + */ + public function getOrderMainIdsByReceipt($receipt_order_id){ + $orderModel = new OrderMain(); + try { + $subOrderList = $orderModel->where(["receipt_order_id" => $receipt_order_id, "del_flag" => 0])->select()->toArray(); + if (null == $subOrderList) { + return []; + } + + $id = []; + foreach ($subOrderList as $val){ + $id[] = $val['id']; + } + return array_unique($id); + }catch (Exception $e) { + return []; + } + } } \ No newline at end of file diff --git a/application/admin/service/PaymentOrderService.php b/application/admin/service/PaymentOrderService.php index d03e226..dc68b4d 100644 --- a/application/admin/service/PaymentOrderService.php +++ b/application/admin/service/PaymentOrderService.php @@ -74,7 +74,11 @@ class PaymentOrderService $orderMainIds = array_unique(array_merge($hotelIds,$itemIds)); $orderMainDao = new OrderMainDao(); foreach ($orderMainIds as $orderId) { - $orderMainDao->setOrderAmount($orderId); + $setRe = $orderMainDao->setOrderAmount($orderId); + if (!$setRe['flag']) { + Db::rollback(); + return $setRe; + } } Db::commit(); return Util::returnArrSu(); diff --git a/application/admin/service/ReceiptOrderService.php b/application/admin/service/ReceiptOrderService.php index 5bbe79c..9a84cf7 100644 --- a/application/admin/service/ReceiptOrderService.php +++ b/application/admin/service/ReceiptOrderService.php @@ -64,10 +64,15 @@ class ReceiptOrderService Db::rollback(); return $orderRe; } + //3.设置订单状态 - $setRe = $orderDao->setOrderAmount($id); - if (!$setRe['flag']) { - return $setRe; + $orderIds = $orderDao->getOrderMainIdsByReceipt($id); + foreach ($orderIds as $orderId) { + $setRe = $orderDao->setOrderAmount($orderId); + if (!$setRe['flag']) { + Db::rollback(); + return $setRe; + } } Db::commit(); return Util::returnArrSu();