Browse Source

取消制作单

shish 3 years ago
parent
commit
aa597feb12

+ 1 - 1
app-hd/controllers/RefundController.php

@@ -96,7 +96,7 @@ class RefundController extends BaseController
             if (bccomp($post['price'], $order->orderPrice, 2) == 1) {
                 util::fail("退款金额超过订单金额");
             }
-
+            $post['orderId'] = $id;
             $post['shopId'] = $this->shopId;
             $post['sjId'] = $this->sjId;
             $post['shopAdminId'] = $this->shopAdminId;

+ 6 - 1
biz-hd/order/classes/OrderGoodsClass.php

@@ -7,6 +7,7 @@ use bizGhs\product\classes\ProductClass;
 use bizGhs\stock\classes\StockRecordClass;
 use bizGhs\stock\services\StockRecordService;
 use bizHd\goods\classes\GoodsClass;
+use bizHd\work\classes\WorkClass;
 use common\components\business;
 use common\components\dict;
 use common\components\imgUtil;
@@ -72,8 +73,12 @@ class OrderGoodsClass extends BaseClass
     }
 
     //退货增加库存 ssh 20220427
-    public static function refundAddStock($orderSn, $sjId, $shopId, $mainId, $goodsId, $goodsNum, $shopAdminName)
+    public static function refundAddStock($orderSn, $sjId, $shopId, $mainId, $goodsId, $goodsNum, $shopAdminName, $orderId)
     {
+        //取消制作单
+        $work = WorkClass::getByCondition(['orderId' => $orderId, 'goodsId' => $goodsId], true);
+        WorkClass::removeWork($work);
+
         //加商品库存
         $respond = GoodsClass::addStock($goodsId, $mainId, $goodsNum);
         //商品流水记录

+ 2 - 1
biz-hd/refund/classes/HdRefundGoodsClass.php

@@ -26,8 +26,9 @@ class HdRefundGoodsClass extends BaseClass
         $goodsId = $data['goodsId'] ?? 0;
         $num = $data['num'] ?? 0;
         $shopAdminName = $post['shopAdminName'] ?? '';
+        $orderId = $post['orderId'] ?? 0;
 
-        OrderGoodsClass::refundAddStock($refundSn, $sjId, $shopId, $mainId, $goodsId, $num, $shopAdminName);
+        OrderGoodsClass::refundAddStock($refundSn, $sjId, $shopId, $mainId, $goodsId, $num, $shopAdminName, $orderId);
 
         return self::add($data);
     }

+ 29 - 0
biz-hd/work/classes/WorkClass.php

@@ -20,6 +20,7 @@ use common\components\printUtil;
 use common\components\util;
 use bizHd\base\classes\BaseClass;
 use Shishaoqi\MeituanFlashPurchase\Application;
+use linslin\yii2\curl;
 
 class WorkClass extends BaseClass
 {
@@ -233,6 +234,34 @@ class WorkClass extends BaseClass
         return $work;
     }
 
+    //美团取消订单同时取消制作单 ssh 20220925
+    public static function removeWork($work)
+    {
+        if (empty($work)) {
+            return false;
+        }
+        if ($work->status != 0) {
+            return false;
+        }
+        $work->status = 2;
+        $work->save();
+        $fromType = $work->fromType ?? 1;
+        $shopId = $work->shopId ?? 0;
+        $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        $makeLbSn = $ext->makeLbSn ?? '';
+        $makeLbVersion = $ext->makeLbVersion ?? '';
+        $mtLbSn = $ext->mtLbSn ?? '';
+        $mtLbVersion = $ext->mtLbVersion ?? '';
+        $lbSn = $fromType == 4 ? $mtLbSn : $makeLbSn;
+        $lbVersion = $fromType == 4 ? $mtLbVersion : $makeLbVersion;
+        if (!empty($lbSn)) {
+            $sound = "您有制作单已经取消";
+            $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
+            $curl = new curl\Curl();
+            $curl->get($url);
+        }
+    }
+
     //取消制作单
     public static function cancel($work)
     {