shish 4 месяцев назад
Родитель
Сommit
a3b0aee16c
1 измененных файлов с 14 добавлено и 8 удалено
  1. 14 8
      app-ghs/controllers/ProductController.php

+ 14 - 8
app-ghs/controllers/ProductController.php

@@ -90,14 +90,20 @@ class ProductController extends BaseController
     {
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
+        $clearStock = $get['clearStock'] ?? -1;
+        if($clearStock == -1){
+            util::fail('请选择是否清库存');
+        }
         $info = ProductClass::getById($id, true);
         ProductClass::check($info, $this->mainId);
-        if ($info->stock > 0) {
-            util::fail('没有库存才能停止预售');
-        }
         $info->presell = 0;
         $info->presellDate = '';
         $info->save();
+
+        if($clearStock == 1){
+            //清库存
+        }
+
         util::complete();
     }
 
@@ -199,7 +205,7 @@ class ProductController extends BaseController
         }
         $p->times = $num;
 
-        if($priceOption == 2){
+        if ($priceOption == 2) {
             // 每7个汉字截取一次(支持汉字、字母、数字混合),多处需要同步修改,关键词 label_print_substr
             $content = '';
             $len = mb_strlen($name, 'UTF-8');
@@ -207,11 +213,11 @@ class ProductController extends BaseController
             $u = 0;
             for ($i = 0; $i < $len; $i += 6) {
                 $currentName = mb_substr($name, $i, 6, 'UTF-8');
-                $number = $baseNum + 90*$u;
+                $number = $baseNum + 90 * $u;
                 $u++;
                 $content .= '<TEXT x="10" y="' . $number . '" font="12" w="3" h="3" r="0">' . $currentName . '</TEXT>';
             }
-        }else{
+        } else {
             if (stringUtil::getWordNum($name) > 8) {
                 $content = '<TEXT x="30" y="30" font="12" w="1" h="1" r="0">' . $name . '</TEXT>';
             } else {
@@ -220,7 +226,7 @@ class ProductController extends BaseController
         }
 
         if ($type == 0) {
-            if($priceOption != 2) {
+            if ($priceOption != 2) {
                 //打标签
                 $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">' . $ptItemId . '</BC128>';
                 if (in_array($mainId, [52, 1459])) {
@@ -337,7 +343,7 @@ class ProductController extends BaseController
                 $where['name'] = ['like', $name];
             }
         }
-        if($requestType == 'hideItem'){
+        if ($requestType == 'hideItem') {
             $where['frontHide'] = 1;
         }
         //客户等级