Browse Source

修改价格提醒

shish 1 year ago
parent
commit
4dedc19e40

+ 2 - 2
app-ghs/controllers/ProductController.php

@@ -732,7 +732,7 @@ class ProductController extends BaseController
 
 
             $mainId = $shop->mainId ?? 0;
             $mainId = $shop->mainId ?? 0;
             if (!empty($mainId)) {
             if (!empty($mainId)) {
-                //提醒零售收银台界面要刷新
+                //提醒零售收银台界面要刷新,多处要修改,关键词 modify_price_remind_cashier
                 $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
                 $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
                 if (!empty($staffList)) {
                 if (!empty($staffList)) {
                     foreach ($staffList as $staff) {
                     foreach ($staffList as $staff) {
@@ -851,7 +851,7 @@ class ProductController extends BaseController
             }
             }
 
 
             if (!empty($mainId)) {
             if (!empty($mainId)) {
-                //提醒零售收银台界面要刷新
+                //提醒零售收银台界面要刷新,多处要修改,关键词 modify_price_remind_cashier
                 $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
                 $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
                 if (!empty($staffList)) {
                 if (!empty($staffList)) {
                     foreach ($staffList as $staff) {
                     foreach ($staffList as $staff) {

+ 1 - 1
app-hd/controllers/ProductController.php

@@ -339,7 +339,7 @@ class ProductController extends BaseController
 
 
             $mainId = $shop->mainId ?? 0;
             $mainId = $shop->mainId ?? 0;
             if (!empty($mainId)) {
             if (!empty($mainId)) {
-                //提醒零售收银台界面要刷新
+                //提醒零售收银台界面要刷新,多处要修改,关键词 modify_price_remind_cashier
                 $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
                 $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
                 if (!empty($staffList)) {
                 if (!empty($staffList)) {
                     foreach ($staffList as $staff) {
                     foreach ($staffList as $staff) {

+ 21 - 5
biz-ghs/product/classes/ProductClass.php

@@ -1522,9 +1522,12 @@ class ProductClass extends BaseClass
         }
         }
         $cost = $data['cost'] ?? 0;
         $cost = $data['cost'] ?? 0;
         $price = $data['price'] ?? 0;
         $price = $data['price'] ?? 0;
+        $price = floatval($price);
         $skPrice = $data['skPrice'] ?? 0;
         $skPrice = $data['skPrice'] ?? 0;
+        $skPrice = floatval($skPrice);
         $hjPrice = $data['hjPrice'] ?? 0;
         $hjPrice = $data['hjPrice'] ?? 0;
-        if (is_numeric($price) == false || $price <= 0) {
+        $hjPrice = floatval($hjPrice);
+        if (!is_numeric($price) || $price <= 0) {
             util::fail('请填写价格');
             util::fail('请填写价格');
         }
         }
         if ($hjPrice > $price) {
         if ($hjPrice > $price) {
@@ -1546,7 +1549,7 @@ class ProductClass extends BaseClass
             if ($shop->default == 0 && $shop->join == 0) {
             if ($shop->default == 0 && $shop->join == 0) {
 
 
                 //除了小蔡鲜花的蔡总、郑总,其他人直营分店不能改价格,多处要同步修改,关键词d_price_change
                 //除了小蔡鲜花的蔡总、郑总,其他人直营分店不能改价格,多处要同步修改,关键词d_price_change
-                if(!in_array($adminId,[35725,23659])){
+                if (!in_array($adminId, [35725, 23659])) {
                     util::fail('直营店不能改价哦');
                     util::fail('直营店不能改价哦');
                 }
                 }
 
 
@@ -1650,12 +1653,25 @@ class ProductClass extends BaseClass
         $staffName = $data['staffName'] ?? '';
         $staffName = $data['staffName'] ?? '';
         $changeParams = ['staffId' => $staffId, 'staffName' => $staffName];
         $changeParams = ['staffId' => $staffId, 'staffName' => $staffName];
 
 
-        if ($price != $product->price || $skPrice != $product->skPrice || $hjPrice != $product->hjPrice) {
-            //批发价有变化
+        if ($price != floatval($product->price) || $skPrice != floatval($product->skPrice) || $hjPrice != floatval($product->hjPrice)) {
+
             self::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $hjPrice, $changeParams);
             self::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $hjPrice, $changeParams);
             unset($upData['price']);
             unset($upData['price']);
             unset($upData['skPrice']);
             unset($upData['skPrice']);
             unset($upData['hjPrice']);
             unset($upData['hjPrice']);
+
+            if (!empty($mainId)) {
+                //提醒零售收银台界面要刷新,多处要修改,关键词 modify_price_remind_cashier
+                $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
+                if (!empty($staffList)) {
+                    foreach ($staffList as $staff) {
+                        $staffId = $staff->id ?? 0;
+                        Yii::$app->redis->executeCommand('SET', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh', 'yes']);
+                        Yii::$app->redis->executeCommand('SET', ['ghs_cashier_' . $mainId . '_' . $staffId . '_may_refresh', 'yes']);
+                    }
+                }
+            }
+
         }
         }
 
 
         if ($cost != $product->cost) {
         if ($cost != $product->cost) {
@@ -1979,7 +1995,7 @@ class ProductClass extends BaseClass
     //补className
     //补className
     public static function groupClassName($mainId, $data)
     public static function groupClassName($mainId, $data)
     {
     {
-        $classNameMap = ItemClassClass::getAllByCondition(['mainId'=>$mainId],null,'id,name','id');
+        $classNameMap = ItemClassClass::getAllByCondition(['mainId' => $mainId], null, 'id,name', 'id');
         foreach ($data as $k => $v) {
         foreach ($data as $k => $v) {
             $classId = $v['classId'];
             $classId = $v['classId'];
             $className = isset($classNameMap[$classId]) && isset($classNameMap[$classId]['name']) ? $classNameMap[$classId]['name'] : '';
             $className = isset($classNameMap[$classId]) && isset($classNameMap[$classId]['name']) ? $classNameMap[$classId]['name'] : '';