瀏覽代碼

添加花材

shish 4 年之前
父節點
當前提交
976402e827
共有 2 個文件被更改,包括 37 次插入0 次删除
  1. 11 0
      app-hd/controllers/GoodsController.php
  2. 26 0
      biz-hd/goods/classes/GoodsClass.php

+ 11 - 0
app-hd/controllers/GoodsController.php

@@ -18,6 +18,17 @@ class GoodsController extends BaseController
 
     public $guestAccess = ['detail'];
 
+    //添加商品 ssh 2019.12.7
+    public function actionAdd()
+    {
+        $data = Yii::$app->request->post();
+        $data['sjId'] = $this->sjId;
+        $data['mainId'] = $this->mainId;
+        unset($data['stock']);
+        $return = GoodsClass::addGoods($data);
+        util::success($return);
+    }
+
     //根据sn获取商品详情 ssh 20220505
     public function actionGetBySn()
     {

+ 26 - 0
biz-hd/goods/classes/GoodsClass.php

@@ -314,6 +314,32 @@ class GoodsClass extends BaseClass
                 ];
                 GoodsItemClass::addData($goodsItemData);
             }
+        } else {
+            $itemList = $data['itemList'] ?? '';
+            $itemArr = json_decode($itemList, true);
+            if (empty($itemArr)) {
+                util::fail('请选择花材');
+            }
+            foreach ($itemArr as $item) {
+                $goodsItemData = [
+                    'name' => $item['name'] ?? '',
+                    'cover' => $item['cover'] ?? '',
+                    'sjId' => $sjId,
+                    'shopId' => $shopId,
+                    'mainId' => $mainId,
+                    'goodsId' => $id,
+                    'itemId' => $item['id'] ?? 0,
+                    'ptItemId' => $item['ptItemId'] ?? 0,
+                    'num' => $item['num'] ?? 0,
+                    'count' => $item['count'] ?? 0,
+                    'ratio' => $item['ratio'] ?? 0,
+                    'bigName' => $item['bigName'] ?? '',
+                    'smallName' => $item['smallName'] ?? '',
+                    'unitType' => $item['unitType'] ?? 0,
+                    'unitName' => $item['unitName'] ?? '',
+                ];
+                GoodsItemClass::addData($goodsItemData);
+            }
         }
         return $info;
     }