Explorar el Código

批量价格修改

shish hace 4 años
padre
commit
99031e3d18
Se han modificado 1 ficheros con 4 adiciones y 5 borrados
  1. 4 5
      app-ghs/controllers/ProductController.php

+ 4 - 5
app-ghs/controllers/ProductController.php

@@ -323,16 +323,15 @@ class ProductController extends BaseController
             util::fail('请在首店修改');
         }
 
-        $data = Yii::$app->request->post('data', ''); //data = [{id:1,inTurn:10,addPrice:2,cost:10}]
+        $data = Yii::$app->request->post('data', '');
         $type = Yii::$app->request->post('type', '');
         if (empty($data) || empty($type)) {
             util::fail("参数错误");
         }
-        if (in_array($type, ['inTurn', 'addPrice', 'cost', 'weight', 'ratio', 'ratio', 'price', 'stockWarning', 'shelfLife'])) {
-            $data = json_decode($data, true);
-        } else {
-            util::fail('非法操作');
+        if (in_array($type, ['inTurn', 'addPrice', 'qtAddPrice', 'byAddPrice', 'hjAddPrice', 'zsAddPrice', 'cost', 'weight', 'ratio', 'ratio', 'price', 'stockWarning', 'shelfLife']) == false) {
+            util::fail('非法数据修改');
         }
+        $data = json_decode($data, true);
         foreach ($data as $v) {
             if ($type == 'status') {
                 $val = $v[$type] ?? '';