Selaa lähdekoodia

自取采购单 直接完成

shish 5 vuotta sitten
vanhempi
commit
9a022b1baf

+ 13 - 21
biz-ghs/order/services/OrderService.php

@@ -78,19 +78,11 @@ class OrderService extends BaseService
         self::payAfter($return, $payWay);
         PurchaseService::payAfter($purchase, $payWay);
 
-        if (isset($return->sendType) == false) {
-            util::fail('没有找到配送方式');
-        }
-        //自取订单直接完成
-        if ($return->sendType == OrderClass::SEND_TYPE_NO) {
-            self::withoutSend($return, $purchase);
-        }
-
         return $return->attributes;
     }
 
     //自取免配送流程处理 ssh 2021.1.24
-    public static function withoutSend($order, $purchase)
+    public static function withoutSend($order)
     {
         if (isset($order->status) == false) {
             util::fail('没有订单状态');
@@ -100,7 +92,7 @@ class OrderService extends BaseService
         }
         //自取订单,订单直接完成。【现在有三个地方有订单完成操作】
         $shopId = $order->shopId ?? 0;
-        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        $shop = ShopClass::getLockById($shopId);
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
@@ -114,15 +106,6 @@ class OrderService extends BaseService
         //订单完成
         self::finish($order, $shop);
 
-        $purchaseShopId = $purchase->shopId;
-        $purchaseShop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $purchaseShopId])->one();
-        if (empty($purchaseShop)) {
-            util::fail('没有找到门店');
-        }
-        $purchaseShop->cgUnSend -= 1;
-        $purchaseShop->cgSending += 1;
-        $purchaseShop->save();
-
         OrderSendClass::withoutSend($order);
 
         return OrderClass::TOTAL_FLOW;
@@ -469,7 +452,6 @@ class OrderService extends BaseService
             }
         }
 
-
         //更新订单基础状态和支付状态
         $order->payWay = $payWay;
         $order->status = OrderClass::ORDER_STATUS_UN_SEND;
@@ -489,7 +471,7 @@ class OrderService extends BaseService
 
         /**客户资产变化**/
         $customId = $order->customId;
-        $custom = Custom::findBySql('select * from ' . Custom::tableName() . ' where id = :id for update', ['id' => $customId])->one();
+        $custom = CustomClass::getLockById($customId);
         if (empty($custom)) {
             util::fail('没有找到客户信息');
         }
@@ -512,6 +494,16 @@ class OrderService extends BaseService
         $time = date("Y-m-d H:i:s");
         $placeData = ['payTime' => $time, 'orderSn' => $orderSn, 'orderId' => $orderId];
         OrderSendClass::placeOrder($placeData);
+
+        if (isset($order->sendType) == false) {
+            util::fail('没有找到配送方式');
+        }
+
+        //自取订单直接完成
+        if ($order->sendType == OrderClass::SEND_TYPE_NO) {
+            self::withoutSend($order);
+        }
+
     }
 
 }

+ 13 - 10
biz-hd/purchase/services/PurchaseService.php

@@ -276,20 +276,23 @@ class PurchaseService extends BaseService
         $ghs->expendNum += 1;
         $ghs->save();
 
+        //自取采购单直接完成
+        if($info->getType == PurchaseClass::GET_TYPE_SELF_GET){
+            $shop->cgUnSend -= 1;
+            $shop->cgSending += 1;
+            $shop->save();
+        }
+
         //通知供货商语音播放  ghsId =>shopId =>shopAdminIds
-        $ghsInfo = GhsClass::getById($ghsId);
-        if ($ghsInfo) {
-            $ghsShopId = $ghsInfo['shopId'];
-            if ($ghsShopId) {
-                $ghsShopAdminIds = \bizGhs\shop\classes\ShopAdminClass::getRemindAdminIdsByShopId($ghsShopId);
-                if ($ghsShopAdminIds) {
-                    foreach ($ghsShopAdminIds as $v) {
-                        WsService::newOrderNotice($v);
-                    }
+        $ghsShopId = $ghs->shopId;
+        if (!empty($ghsShopId)) {
+            $ghsShopAdminIds = \bizGhs\shop\classes\ShopAdminClass::getRemindAdminIdsByShopId($ghsShopId);
+            if ($ghsShopAdminIds) {
+                foreach ($ghsShopAdminIds as $v) {
+                    WsService::newOrderNotice($v);
                 }
             }
         }
-
     }
 
 }

+ 1 - 1
biz/shop/classes/ShopCouponClass.php

@@ -34,7 +34,7 @@ class ShopCouponClass extends BaseClass
         ],
         [
             'name' => '优惠券',
-            'amount' => '20',
+            'amount' => '15',
             'miniCost' => '100',
             'beginTime' => "+0 days",
             'endTime' => "+7 days",