shish %!s(int64=5) %!d(string=hai) anos
pai
achega
9e8aafe4bd

+ 42 - 7
app-ghs/controllers/ProductController.php

@@ -115,9 +115,9 @@ class ProductController extends BaseController
         $type = Yii::$app->request->get('type', '');
         $showPage = Yii::$app->request->get('showPage', 0);
         if ($showPage) {
-            if($type=='waring'){
+            if ($type == 'waring') {
                 $respond = ProductClass::getList("*", $where, "stock asc");
-            }else{
+            } else {
                 $respond = ProductClass::getList("*", $where, "inTurn desc");
             }
 
@@ -125,10 +125,10 @@ class ProductController extends BaseController
             $respond['list'] = ProductClass::groupClassName($this->sjId, $respond['list']);
             util::success($respond);
         }
-        if($type=='waring'){
+        if ($type == 'waring') {
             //库存预警 按库存从小到大排序
             $data = ProductClass::getAllByCondition($where, ['stock' => SORT_ASC, 'inTurn' => SORT_DESC], "*");
-        }else{
+        } else {
             $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
         }
 
@@ -152,6 +152,21 @@ class ProductController extends BaseController
     //改价
     public function actionChangePrice()
     {
+
+        $shop = $this->shop;
+        $default = $shop->default ?? 0;
+        if ($default != 1) {
+            util::fail('请在首店修改');
+        }
+
+        $shopAdmin = $this->shopAdmin;
+        $roleId = $shopAdmin['roleId'] ?? 0;
+        $role = AdminRoleClass::getById($roleId);
+        $roleName = $role['roleName'] ?? '';
+        if ($roleName == '员工') {
+            util::fail('没有权限操作哦');
+        }
+
         $productId = Yii::$app->request->post('productId', 0);
         $price = Yii::$app->request->post('price', '');
         if (is_numeric($price) && $price > 0) {
@@ -225,12 +240,18 @@ class ProductController extends BaseController
     public function actionBatchUpdate()
     {
 
+        $shop = $this->shop;
+        $default = $shop->default ?? 0;
+        if ($default != 1) {
+            util::fail('请在首店修改');
+        }
+
         $shopAdmin = $this->shopAdmin;
         $roleId = $shopAdmin['roleId'] ?? 0;
         $role = AdminRoleClass::getById($roleId);
         $roleName = $role['roleName'] ?? '';
         if ($roleName == '员工') {
-            util::fail('您没有权限操作哦');
+            util::fail('没有权限操作哦');
         }
 
         $data = Yii::$app->request->post('data', ''); //data = [{id:1,inTurn:10,addPrice:2,cost:10}]
@@ -301,13 +322,20 @@ class ProductController extends BaseController
     {
         $post = Yii::$app->request->post();
 
+        $shop = $this->shop;
+        $default = $shop->default ?? 0;
+        if ($default != 1) {
+            util::fail('请在首店修改');
+        }
+
         $shopAdmin = $this->shopAdmin;
         $roleId = $shopAdmin['roleId'] ?? 0;
         $role = AdminRoleClass::getById($roleId);
         $roleName = $role['roleName'] ?? '';
         if ($roleName == '员工') {
-            util::fail('您没有权限操作哦');
+            util::fail('没有权限操作哦');
         }
+
         ProductClass::updateProduct($post);
         util::complete();
     }
@@ -325,13 +353,20 @@ class ProductController extends BaseController
     {
         $post = Yii::$app->request->post();
 
+        $shop = $this->shop;
+        $default = $shop->default ?? 0;
+        if ($default != 1) {
+            util::fail('请在首店添加');
+        }
+
         $shopAdmin = $this->shopAdmin;
         $roleId = $shopAdmin['roleId'] ?? 0;
         $role = AdminRoleClass::getById($roleId);
         $roleName = $role['roleName'] ?? '';
         if ($roleName == '员工') {
-            util::fail('您没有权限操作哦');
+            util::fail('没有权限操作哦');
         }
+
         $post['sjId'] = $this->sjId;
         ProductClass::addProduct($post);
         util::complete('添加成功');

+ 6 - 0
app-ghs/controllers/PurchaseOrderController.php

@@ -20,6 +20,12 @@ class PurchaseOrderController extends BaseController
         $post['shopId'] = $this->shopId;
         $post['adminId'] = $this->adminId;
 
+        $shop = $this->shop;
+        $default = $shop->default ?? 0;
+        if ($default != 1) {
+            util::fail('首店才能采购');
+        }
+
         $shopAdmin = $this->shopAdmin;
         $roleId = $shopAdmin['roleId'] ?? 0;
         $role = AdminRoleClass::getById($roleId);