From 91f39ea2745163d1e224b695e418f4d449f87ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=98=8A=E5=A4=A9?= <442384644@qq.com> Date: Mon, 27 Feb 2023 19:14:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8B=E5=8D=95=E9=AA=8C?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/v1/order/StoreOrderController.php | 15 +++------------ .../services/order/StoreOrderCreateServices.php | 13 ++++++++++++- crmeb/crmeb/utils/Json.php | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/crmeb/app/api/controller/v1/order/StoreOrderController.php b/crmeb/app/api/controller/v1/order/StoreOrderController.php index e6a94e5f4..3116b8d81 100644 --- a/crmeb/app/api/controller/v1/order/StoreOrderController.php +++ b/crmeb/app/api/controller/v1/order/StoreOrderController.php @@ -196,10 +196,7 @@ class StoreOrderController if ($bargainId) { $bargainServices->checkBargainUser((int)$bargainId, $uid); } - //下单前发票验证 - if ($invoice_id) { - $userInvoiceServices->checkInvoice((int)$invoice_id, $uid); - } + if ($pinkId) { $pinkId = (int)$pinkId; /** @var StorePinkServices $pinkServices */ @@ -235,7 +232,7 @@ class StoreOrderController } } $virtual_type = $cartGroup['cartInfo'][0]['productInfo']['virtual_type'] ?? 0; - $order = $createServices->createOrder($uid, $key, $cartGroup, $request->user()->toArray(), $addressId, $payType, !!$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $shipping_type, $real_name, $phone, $storeId, !!$news, $advanceId, $virtual_type, $customForm); + $order = $createServices->createOrder($uid, $key, $cartGroup, $request->user()->toArray(), $addressId, $payType, !!$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $shipping_type, $real_name, $phone, $storeId, !!$news, $advanceId, $virtual_type, $customForm, $invoice_id); if ($order === false) { if ($seckill_id || $combinationId || $advanceId || $bargainId) { foreach ($cartInfo as $item) { @@ -261,14 +258,8 @@ class StoreOrderController if (!$orderInfo || !isset($orderInfo['paid'])) { return app('json')->fail(410194); } - //创建开票数据 - if ($invoice_id) { - $storeOrderInvoiceServices->makeUp($uid, $orderId, (int)$invoice_id); - } - $info = compact('orderId', 'key'); - - return app('json')->status('success', 410203, $info); + return app('json')->status('success', 410203, compact('orderId', 'key')); // if ($orderId) { // switch ($payType) { diff --git a/crmeb/app/services/order/StoreOrderCreateServices.php b/crmeb/app/services/order/StoreOrderCreateServices.php index a00fc1665..a4fa5919b 100644 --- a/crmeb/app/services/order/StoreOrderCreateServices.php +++ b/crmeb/app/services/order/StoreOrderCreateServices.php @@ -21,6 +21,7 @@ use app\services\product\product\StoreCategoryServices; use app\services\shipping\ShippingTemplatesFreeServices; use app\services\shipping\ShippingTemplatesRegionServices; use app\services\shipping\ShippingTemplatesServices; +use app\services\user\UserInvoiceServices; use app\services\wechat\WechatUserServices; use app\services\BaseServices; use crmeb\exceptions\ApiException; @@ -137,8 +138,13 @@ class StoreOrderCreateServices extends BaseServices * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function createOrder($uid, $key, $cartGroup, $userInfo, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckillId = 0, $bargainId = 0, $shippingType = 1, $real_name = '', $phone = '', $storeId = 0, $news = false, $advanceId = 0, $virtual_type = 0, $customForm = []) + public function createOrder($uid, $key, $cartGroup, $userInfo, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckillId = 0, $bargainId = 0, $shippingType = 1, $real_name = '', $phone = '', $storeId = 0, $news = false, $advanceId = 0, $virtual_type = 0, $customForm = [], $invoice_id = 0) { + //下单前发票验证 + if ($invoice_id) { + app()->make(UserInvoiceServices::class)->checkInvoice((int)$invoice_id, $uid); + } + /** @var StoreOrderComputedServices $computedServices */ $computedServices = app()->make(StoreOrderComputedServices::class); $priceData = $computedServices->computedOrder($uid, $userInfo, $cartGroup, $addressId, $payType, $useIntegral, $couponId, true, $shippingType); @@ -271,6 +277,11 @@ class StoreOrderCreateServices extends BaseServices return $order; }); + //创建开票数据 + if ($invoice_id) { + app()->make(StoreOrderInvoiceServices::class)->makeUp($uid, $order['order_id'], (int)$invoice_id); + } + // 订单创建成功后置事件 event('OrderCreateAfterListener', [$order, compact('cartInfo', 'priceData', 'addressId', 'cartIds', 'news'), $uid, $key, $combinationId, $seckillId, $bargainId]); // 推送订单 diff --git a/crmeb/crmeb/utils/Json.php b/crmeb/crmeb/utils/Json.php index 8c1703070..bef491937 100644 --- a/crmeb/crmeb/utils/Json.php +++ b/crmeb/crmeb/utils/Json.php @@ -68,6 +68,6 @@ class Json $result = $msg; $msg = 'success'; } - return app('json')->success($msg, compact('status', 'result')); + return $this->success($msg, compact('status', 'result')); } }