shish 4 lat temu
rodzic
commit
0a8f535f18
1 zmienionych plików z 31 dodań i 0 usunięć
  1. 31 0
      app-hd/controllers/ProductController.php

+ 31 - 0
app-hd/controllers/ProductController.php

@@ -21,6 +21,37 @@ class ProductController extends BaseController
 
     public $guestAccess = ['ghs-item'];
 
+    //新增花材  2021.6.21
+    public function actionAdd()
+    {
+        $post = Yii::$app->request->post();
+
+        $shopAdmin = $this->shopAdmin;
+        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
+            util::fail('管理员才能添加花材');
+        }
+
+        $shop = $this->shop;
+        $default = $shop->default ?? 0;
+        if ($default != 1) {
+            util::fail('请在总店添加');
+        }
+
+        $post['sjId'] = $this->sjId;
+        $post['adminId'] = $this->adminId;
+        $post['mainId'] = $this->mainId;
+
+        $price = $post['price'] ?? 0;
+        $addPrice = $post['addPrice'] ?? 0;
+        if ($addPrice > $price) {
+            util::fail('加价不能大于售价');
+        }
+        $cost = bcsub($price, $addPrice, 2);
+        $post['cost'] = $cost;
+        ProductClass::addProduct($post);
+        util::complete('添加成功');
+    }
+
     //获取拼音缩写 ssh 20210707
     public function actionPy()
     {