shish 3 éve
szülő
commit
f623f28c93

+ 5 - 3
app-ghs/controllers/OrderController.php

@@ -985,14 +985,16 @@ class OrderController extends BaseController
         //开单提交订单时,别人修改价格,暂成提交价格不是真实卖价问题解决!!
         if ($dealPrice == 0) {
             $diff = [];
+            $priceMap = CustomClass::$levelPriceKeyMap;
+            $addPriceMap = CustomClass::$levelAddPriceKeyMap;
+            $level = $custom['level'] ?? 1;
             foreach ($productList as $currentProduct) {
                 $currentPrice = $currentProduct['price'] ?? 0;
                 $currentId = $currentProduct['productId'] ?? 0;
                 $systemInfo = $itemInfo[$currentId] ?? [];
-                $systemPrice = $systemInfo['price'] ?? 0;
-                $systemDiscountPrice = $systemInfo['discountPrice'] ?? 0;
                 $name = $systemInfo['name'] ?? '';
-                if (floatval($currentPrice) != floatval($systemPrice) && floatval($currentPrice) != floatval($systemDiscountPrice)) {
+                $systemPrice = ProductClass::getFinalPrice($systemInfo, $level, $priceMap, $addPriceMap);
+                if (floatval($currentPrice) != floatval($systemPrice)) {
                     $diff[] = [
                         'name' => $name,
                         'price' => $systemPrice,

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

@@ -217,7 +217,7 @@ class ProductController extends BaseController
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
         } elseif ($requestType == 'changePrice') {
             //修改价格列表
-            $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,discountPrice,skMore,variety,price,stock,presell,frontHide';
+            $field = 'id,py,cover,name,cost,itemId,classId,addPrice,hjAddPrice,skPrice,discountPrice,skMore,variety,price,hjPrice,stock,presell,frontHide';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
             $itemInfoData = ProductClass::changePriceGroup($itemInfoData, $level);
         } elseif ($requestType == 'changeStock') {
@@ -227,14 +227,14 @@ class ProductController extends BaseController
             $itemInfoData = ProductClass::changeStockGroup($itemInfoData, $level);
         } elseif ($requestType == 'kd') {
             //开单的花材列表
-            $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio';
+            $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
             $itemInfoData = ProductClass::kdItemGroup($itemInfoData, $level);
         } elseif ($requestType == 'itemList') {
             //花材列表
             if (getenv('YII_ENV', 'local') == 'production') {
                 $showFrontHide = [7615, 7756];
-            }else{
+            } else {
                 $showFrontHide = [644];
             }
             if (in_array($this->mainId, $showFrontHide)) {
@@ -556,7 +556,8 @@ class ProductController extends BaseController
         $targetId = Yii::$app->request->post('targetId', 0);
         $changeParams = ['staffId' => $shopAdmin->id, 'staffName' => $shopAdmin->name, 'changeType' => $changeType, 'targetId' => $targetId];
 
-        $data = Yii::$app->request->post('data', '');
+        $post = Yii::$app->request->post();
+        $data = $post['data'] ?? '';
         if (empty($data)) {
             util::fail('没有修改');
         }
@@ -565,6 +566,11 @@ class ProductController extends BaseController
             util::fail('没有修改哦');
         }
 
+        $appVersion = $post['appVersion'] ?? 0;
+        if ($appVersion != 1) {
+            util::fail('请先升级应用');
+        }
+
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
@@ -617,7 +623,7 @@ class ProductController extends BaseController
                     util::fail('请填写' . $productName . '的零售价');
                 }
                 $skPrice = $product['skPrice'];
-
+                $hjPrice = $product['hjPrice'] ?? 0;
                 if (isset($productInfo->mainId) == false || $productInfo->mainId != $this->mainId) {
                     util::fail('没有权限访问');
                 }
@@ -625,7 +631,7 @@ class ProductController extends BaseController
                     continue;
                 }
                 $ptItemId = $productInfo->itemId;
-                ProductClass::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $changeParams);
+                ProductClass::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $hjPrice, $changeParams);
                 //在首店修改需要同步到所有直营店
                 if ($default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
                     foreach ($chainShopList as $chain) {
@@ -635,7 +641,7 @@ class ProductController extends BaseController
                         $chainMainId = $chain->mainId ?? 0;
                         $staff = ShopAdminClass::getByCondition(['mainId' => $chainMainId, 'adminId' => $adminId], true);
                         $changeParams2 = ['staffId' => $staff->id, 'staffName' => $staff->name, 'changeType' => $changeType, 'targetId' => $targetId];
-                        ProductClass::changeSinglePrice($chain, $ptItemId, $price, $skPrice, $changeParams2);
+                        ProductClass::changeSinglePrice($chain, $ptItemId, $price, $skPrice, $hjPrice, $changeParams2);
                     }
                 }
             }
@@ -865,6 +871,12 @@ class ProductController extends BaseController
         }
 
         $post = Yii::$app->request->post();
+
+        $appVersion = $post['appVersion'] ?? 0;
+        if ($appVersion != 1) {
+            util::fail('请先升级应用');
+        }
+
         $post['adminId'] = $this->adminId;
         $post['staffId'] = $this->shopAdmin->id;
         $post['staffName'] = $this->shopAdmin->name;
@@ -968,6 +980,12 @@ class ProductController extends BaseController
     public function actionAdd()
     {
         $post = Yii::$app->request->post();
+
+        $appVersion = $post['appVersion'] ?? 0;
+        if ($appVersion != 1) {
+            util::fail('请先升级应用');
+        }
+
         $shop = $this->shop;
         $join = $shop->join ?? 0;
         $default = $shop->default ?? 0;
@@ -1009,6 +1027,11 @@ class ProductController extends BaseController
     {
         $post = Yii::$app->request->post();
 
+        $appVersion = $post['appVersion'] ?? 0;
+        if ($appVersion != 1) {
+            util::fail('请先升级应用');
+        }
+
         $shop = $this->shop;
         $join = $shop->join ?? 0;
         $default = $shop->default ?? 0;
@@ -1027,9 +1050,20 @@ class ProductController extends BaseController
         $post['staffName'] = $shopAdmin->name ?? '';
 
         $price = $post['price'] ?? 0;
+        if (empty($price) || $price <= 0) {
+            util::fail('请填写批发价');
+        }
+        $skPrice = $post['skPrice'] ?? 0;
+        if (empty($skPrice) || $skPrice <= 0) {
+            util::fail('请填写零售价');
+        }
+        $hjPrice = $post['hjPrice'] ?? 0;
+        if (empty($hjPrice) || $hjPrice <= 0) {
+            util::fail('请填写会员价');
+        }
         $addPrice = $post['addPrice'] ?? 0;
         if ($addPrice > $price) {
-            util::fail('加价不能大于售价');
+            util::fail('批发价的加价不能大于售价');
         }
         //复制标识
         $post['copy'] = 1;

+ 6 - 1
app-ghs/controllers/PurchaseOrderItemController.php

@@ -31,15 +31,20 @@ class PurchaseOrderItemController extends BaseController
                 $cost = round($cost);
                 $current = $itemList[$productId] ?? [];
                 $addPrice = $current['addPrice'] ?? 0;
+                $hjAddPrice = $current['hjAddPrice'] ?? 0;
                 $skMore = $current['skMore'] ?? 0;
                 $suggestPrice = bcadd($cost, $addPrice, 2);
                 $suggestPrice = floatval($suggestPrice);
-                $suggestSkPrice = bcadd($suggestPrice, $skMore, 2);
+                $suggestSkPrice = bcadd($cost, $skMore, 2);
                 $suggestSkPrice = floatval($suggestSkPrice);
+                $suggestHjPrice = bcadd($cost, $hjAddPrice, 2);
+                $suggestHjPrice = floatval($suggestHjPrice);
                 $list[$key]['suggestPrice'] = $suggestPrice;
                 $list[$key]['suggestSkPrice'] = $suggestSkPrice;
+                $list[$key]['suggestHjPrice'] = $suggestHjPrice;
                 $list[$key]['skMore'] = $skMore;
                 $list[$key]['addPrice'] = $addPrice;
+                $list[$key]['hjAddPrice'] = $hjAddPrice;
             }
         }
         util::success(['list' => $list]);

+ 8 - 2
app-hd/controllers/ProductController.php

@@ -204,6 +204,12 @@ class ProductController extends BaseController
         if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
             util::fail('超管才能修改');
         }
+
+        $pfShopId = $shop->pfShopId ?? 0;
+        if (!empty($pfShopId)) {
+            util::fail('请在批发端操作');
+        }
+
         $data = Yii::$app->request->post('data', '');
         if (empty($data)) {
             util::fail('没有修改');
@@ -302,8 +308,8 @@ class ProductController extends BaseController
                 $where['frontHide'] = 0;
             }
 
-            $level = 1;
-            $field = 'id,py,cover,name,ratio,classId,itemId,weight,smallUnit,bigUnit,smallUnit,smallRatio,ratioType,variety,price,stock,stockWarning,discountPrice,presell,presellDate';
+            $level = $ghs['giveLevel'] ?? 1;
+            $field = 'id,py,cover,name,ratio,classId,itemId,weight,smallUnit,bigUnit,smallUnit,smallRatio,ratioType,variety,price,hjPrice,stock,stockWarning,discountPrice,presell,presellDate';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
             $itemInfoData = ProductClass::hdCgGroup($itemInfoData, $level);
 

+ 31 - 36
biz-ghs/product/classes/ProductClass.php

@@ -572,6 +572,10 @@ class ProductClass extends BaseClass
             $list[$k]['bigNum'] = $stockInfo['bigNum'];
             $list[$k]['smallNum'] = $stockInfo['smallNum'];
             $list[$k]['itemName'] = $v['name'] ?? '';
+            //默认等级价格
+            $defaultGradePrice = self::getFinalPrice($v, 1, $priceMap, $addPriceMap);
+            $list[$k]['defaultGradePrice'] = $defaultGradePrice;
+            $list[$k]['myLevel'] = $level;
             //今日特价、会员价
             $price = self::getFinalPrice($v, $level, $priceMap, $addPriceMap);
             $list[$k]['price'] = $price;
@@ -1021,21 +1025,25 @@ class ProductClass extends BaseClass
     }
 
     //单个修改价格 lqh 2021.1.28
-    public static function changeSinglePrice($shop, $ptItemId, $price, $skPrice = null, $params = [])
+    public static function changeSinglePrice($shop, $ptItemId, $price, $skPrice = null, $hjPrice = null, $params = [])
     {
         $mainId = $shop->mainId ?? 0;
         $productInfo = ProductClass::getByCondition(['itemId' => $ptItemId, 'mainId' => $mainId], true);
         if (empty($productInfo)) {
             return false;
         }
+        if(empty($price)){
+            util::fail('没有批发价');
+        }
         $productInfo->price = $price;
         if (empty($skPrice)) {
-            $skMore = $productInfo->skMore ?? 0;
-            $skPrice = bcadd($price, $skMore, 2);
-            $productInfo->skPrice = $skPrice;
-        } else {
-            $productInfo->skPrice = $skPrice;
+            util::fail('没有零售价');
+        }
+        if (empty($hjPrice)) {
+            util::fail('没有会员价');
         }
+        $productInfo->skPrice = $skPrice;
+        $productInfo->hjPrice = $hjPrice;
         $productInfo->save();
 
         $sjId = $shop->sjId ?? 0;
@@ -1061,6 +1069,7 @@ class ProductClass extends BaseClass
             'ptItemId' => $ptItemId,
             'price' => $price,
             'skPrice' => $skPrice,
+            'hjPrice' => $hjPrice,
             'staffId' => $staffId,
             'staffName' => $staffName,
             'name' => $name,
@@ -1292,18 +1301,22 @@ class ProductClass extends BaseClass
                 }
             }
         }
-        //加价
-        $addPrice = $data['addPrice'] ?? 0;
-        $upData['addPrice'] = $addPrice;
         $cost = $data['cost'] ?? 0;
-        //价格
         $price = $data['price'] ?? 0;
+        $skPrice = $data['skPrice'] ?? 0;
+        $hjPrice = $data['hjPrice'] ?? 0;
         if (is_numeric($price) == false || $price < 0) {
             util::fail('请填写价格');
         }
+        if (isset($data['addPrice']) && is_numeric($data['addPrice'])) {
+            $upData['addPrice'] = $data['addPrice'];
+        }
         if (isset($data['skMore']) && is_numeric($data['skMore'])) {
             $upData['skMore'] = $data['skMore'];
         }
+        if (isset($data['hjAddPrice']) && is_numeric($data['hjAddPrice'])) {
+            $upData['hjAddPrice'] = $data['hjAddPrice'];
+        }
         if (isset($data['stockWarning'])) {
             $upData['stockWarning'] = $data['stockWarning'];
         }
@@ -1361,25 +1374,16 @@ class ProductClass extends BaseClass
         $paramsBack = $upData;
         $ptItemId = $product->itemId ?? 0;
 
-        $currentSkPrice = null;
-        if (isset($data['skMore']) && is_numeric($data['skMore'])) {
-            $currentSkPrice = bcadd($price, $data['skMore'], 2);
-        }
-
         $staffId = $data['staffId'] ?? 0;
         $staffName = $data['staffName'] ?? '';
         $changeParams = ['staffId' => $staffId, 'staffName' => $staffName];
 
-        if ($price != $product->price) {
+        if ($price != $product->price || $skPrice != $product->skPrice || $hjPrice != $product->hjPrice) {
             //批发价有变化
-            self::changeSinglePrice($shop, $ptItemId, $price, $currentSkPrice, $changeParams);
+            self::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $hjPrice, $changeParams);
             unset($upData['price']);
-        } else {
-            //批发价没有变化,但零售价比批发价贵多少有修改时,也要改价
-            if (isset($data['skMore']) && is_numeric($data['skMore']) && $data['skMore'] != $product->skMore) {
-                self::changeSinglePrice($shop, $ptItemId, $price, $currentSkPrice, $changeParams);
-                unset($upData['price']);
-            }
+            unset($upData['skPrice']);
+            unset($upData['hjPrice']);
         }
 
         if ($cost != $product->cost) {
@@ -1449,23 +1453,19 @@ class ProductClass extends BaseClass
                 //加盟店仅同步名称等非重要参数
                 if ($chainShop->join == 1) {
                     unset($params['skPrice']);
-                    unset($params['skMore']);
                     unset($params['price']);
+                    unset($params['hjPrice']);
                     unset($params['addPrice']);
+                    unset($params['skMore']);
+                    unset($params['hjAddPrice']);
                     self::updateById($chainProduct->id, $params);
                     continue;
                 }
 
                 if ($price != $chainProduct->price) {
                     //批发价有变化
-                    self::changeSinglePrice($chainShop, $ptItemId, $price, $currentSkPrice, $changeParams2);
+                    self::changeSinglePrice($chainShop, $ptItemId, $price, $skPrice, $hjPrice, $changeParams2);
                     unset($params['price']);
-                } else {
-                    //批发价没有变化,但零售价比批发价贵多少有修改时,也要改价
-                    if (isset($data['skMore']) && is_numeric($data['skMore']) && $data['skMore'] != $chainProduct->skMore) {
-                        self::changeSinglePrice($chainShop, $ptItemId, $price, $currentSkPrice, $changeParams2);
-                        unset($params['price']);
-                    }
                 }
 
                 if ($cost != $chainProduct->cost) {
@@ -1740,11 +1740,6 @@ class ProductClass extends BaseClass
             if (empty($price) || $price <= 0) {
                 util::fail('请填写价格');
             }
-            //零售价
-            $skMore = isset($data['skMore']) && $data['skMore'] > 0 ? $data['skMore'] : 5;
-
-            $data['skPrice'] = bcadd($price, $skMore, 2);
-
             $data['property'] = 1;
             $respond = self::addBaseData($data, true);