shish hace 3 años
padre
commit
9f185dbbaa
Se han modificado 1 ficheros con 42 adiciones y 1 borrados
  1. 42 1
      app-hd/controllers/MtController.php

+ 42 - 1
app-hd/controllers/MtController.php

@@ -144,10 +144,51 @@ class MtController extends PublicController
 
     }
 
+    //删除商品 ssh 20220914
     public function actionGoodsDel()
     {
         $post = Yii::$app->request->post();
-        Yii::info('confirmOrderData: ' . json_encode($post));
+        if (isset($post['retail_data']) == false) {
+            noticeUtil::push("美团删除商品,通知我们时出错了,没有获取到相应信息", '15280215347');
+            return Json::encode(['data' => 'ok']);
+        }
+        $retailData = $post['retail_data'];
+        $retail = urldecode(urldecode($retailData));
+        $info = json_decode($retail);
+        $obj = $info[0] ?? null;
+        $shopId = $obj->app_poi_code ?? 0;
+        $shop = ShopClass::getById($shopId, true);
+        if (empty($shop)) {
+            noticeUtil::push("美团删除商品,通知我们时出错了,没有找到门店", '15280215347');
+            return Json::encode(['data' => 'ok']);
+        }
+        $sjId = $shop->sjId ?? 0;
+        $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        if (empty($ext)) {
+            noticeUtil::push("美团删除商品,通知我们时出错了,没有找到门店拓展信息", '15280215347');
+            return Json::encode(['data' => 'ok']);
+        }
+        $mainId = $shop->mainId ?? 0;
+        if (empty($mainId)) {
+            noticeUtil::push("美团删除商品,通知我们时出错了,没有main信息", '15280215347');
+            return Json::encode(['data' => 'ok']);
+        }
+        $mtCategory = CategoryClass::getByCondition(['mainId' => $mainId, 'style' => 1], true);
+        if (empty($mtCategory)) {
+            $mtCategory = CategoryClass::add(['style' => 1, 'categoryName' => '美团', 'mainId' => $mainId, 'sjId' => $sjId], true);
+        }
+        $catId = $mtCategory->id ?? 0;
+        if (empty($catId)) {
+            noticeUtil::push("美团删除商品,通知我们时出错了,没有美团的分类id", '15280215347');
+            return Json::encode(['data' => 'ok']);
+        }
+        $appSpuCode = $obj->app_spu_code ?? '';
+        $hasGoods = GoodsClass::getByCondition(['mainId' => $mainId, 'spu' => $appSpuCode], true);
+        if (empty($hasGoods)) {
+            return Json::encode(['data' => 'ok']);
+        }
+        $hasGoods->delStatus = 1;
+        $hasGoods->save();
         return Json::encode(['data' => 'ok']);
     }