shish 3 лет назад
Родитель
Сommit
856ea48311
2 измененных файлов с 3 добавлено и 25 удалено
  1. 3 20
      app-ghs/controllers/ItemController.php
  2. 0 5
      app-ghs/controllers/ProductController.php

+ 3 - 20
app-ghs/controllers/ItemController.php

@@ -294,20 +294,7 @@ class ItemController extends BaseController
 
     public function actionAdd()
     {
-        $post = Yii::$app->request->post();
-        $post['adminId'] = $this->adminId;
-        $post['sjId'] = $this->sjId;
-
-        $connection = Yii::$app->db;//事务处理
-        $transaction = $connection->beginTransaction();
-        try {
-            ItemService::addGhsItem($post);
-            $transaction->commit();
-            util::complete('添加成功');
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            util::fail('添加失败');
-        }
+        util::fail('开发中');
     }
 
     //批量添加花材
@@ -336,11 +323,6 @@ class ItemController extends BaseController
         if (!empty($has)) {
             util::fail("有花材已经添加过了");
         }
-
-        $shopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*');
-        if (count($shopList) > 1) {
-            util::fail('您已有多家门店,暂不支持批量添加花材');
-        }
         $shopId = $this->shopId;
         $mainId = $this->mainId;
         $connection = Yii::$app->db;
@@ -351,7 +333,8 @@ class ItemController extends BaseController
                 $v['sjId'] = $sjId;
                 $v['shopId'] = $shopId;
                 $v['mainId'] = $mainId;
-                ItemService::addGhsItem($v);
+                $v['staffName'] = $shopAdmin->name ?? '';
+                ProductClass::addProduct($v, $this->shop);
             }
             $transaction->commit();
             util::complete('添加成功');

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

@@ -889,18 +889,15 @@ class ProductController extends BaseController
     public function actionAdd()
     {
         $post = Yii::$app->request->post();
-
         $shop = $this->shop;
         $default = $shop->default ?? 0;
         if ($default == 0) {
             util::fail('请在默认门店添加花材,分店只能修改花材');
         }
-
         $shopAdmin = $this->shopAdmin;
         if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
             util::fail('管理员才能添加花材');
         }
-
         $post['sjId'] = $this->sjId;
         $post['adminId'] = $this->adminId;
         $post['mainId'] = $this->mainId;
@@ -909,8 +906,6 @@ class ProductController extends BaseController
         if ($addPrice > $price) {
             util::fail('加价不能大于售价');
         }
-        $cost = bcsub($price, $addPrice, 2);
-        $post['cost'] = $cost;
         $post['staffName'] = $shopAdmin->name ?? '';
         ProductClass::addProduct($post, $this->shop);
         util::complete('添加成功');