Browse Source

花材列表:
1.去除全部分类
2.各个花材增加分类ID
3.增加价格标识

林琦海 5 năm trước cách đây
mục cha
commit
5cff378e1f

+ 3 - 4
app/ghs/controllers/ProductController.php

@@ -87,12 +87,11 @@ class ProductController extends BaseController
         }
 
         //判断是否有效
-        $productData = ProductClass::getProductData($productId,$this->shopId,true);
+        $productData = ProductClass::getProductData($productId,$this->shopId);
         if(!$productData){
             util::fail("花材不存在");
         }
-        $productData->price = $price;
-        $productData->save();
+        ProductClass::changePrice($productId,$this->shopId,$price, ProductClass::PRICE_LABEL_CHANGE);
         util::complete("改价成功");
     }
 
@@ -112,7 +111,7 @@ class ProductController extends BaseController
             util::fail("出错拉");
         }
         $price = bcadd($itemData['unitCost'],$itemData['unitAddPrice'],2);
-        ProductClass::changePrice($productId,$this->shopId,$price);
+        ProductClass::changePrice($productId,$this->shopId,$price, ProductClass::PRICE_LABEL_AUTO);
         util::complete("操作成功");
     }
 

+ 4 - 2
biz-ghs/product/classes/ProductClass.php

@@ -13,6 +13,8 @@ class ProductClass extends BaseClass
 {
 
     public static $baseFile = '\bizGhs\product\models\Product';
+    const PRICE_LABEL_AUTO = 1; //自动调价
+    const PRICE_LABEL_CHANGE = 2; //改价
 
     //根据itemIds获取相应的花材信息
     public static function getProductInfoByItemIds(array $itemIds)
@@ -383,9 +385,9 @@ class ProductClass extends BaseClass
     }
 
     //修改价格 linqh 2021.1.28
-    public static function changePrice($id,$shopId,$price)
+    public static function changePrice($id,$shopId,$price,$priceLabel)
     {
-        return ProductClass::updateByCondition(['id'=>$id,'shopId'=>$shopId],['price'=>$price]);
+        return ProductClass::updateByCondition(['id'=>$id,'shopId'=>$shopId],['price'=>$price,'priceLabel'=>$priceLabel]);
     }
 
     //下单时计算商品的价格  linqh 2021.1.28

+ 15 - 4
biz-ghs/product/services/ProductService.php

@@ -9,15 +9,22 @@ class ProductService extends BaseService
 
     public static $baseFile = '\bizGhs\product\classes\ProductClass';
 
+    const ALL_CLASS_ID = '-1';
+    const OFTEN_CLASS_ID = '-2';
+
     //组装分类花材数据
     public static function assembleData($classIds,$itemIdsInfo,$itemInfoData,$oftenItemIds)
     {
         $oftenItemInfoData = [];
+        $allData = [];
         if($itemInfoData){
             foreach ($itemInfoData as $v){
                 if(in_array($v['itemId'],$oftenItemIds)){
+                    $v['classId'] = self::OFTEN_CLASS_ID;
                     $oftenItemInfoData[] = $v;
                 }
+                $v['classId'] = self::ALL_CLASS_ID;
+                $allData[] = $v;
             }
         }
         //classId=>itemId
@@ -30,15 +37,15 @@ class ProductService extends BaseService
         //全部, 常用, 各个分类
         $allData = [
             [
-                'classId'=> -1,
+                'classId'=> self::ALL_CLASS_ID,
                 'className'=>'全部',
-                'child'=>$itemInfoData,
+                'child'=>$allData,
             ]
         ];
         //常用
         $oftenData = [
             [
-                'classId'=> -2,
+                'classId'=> self::OFTEN_CLASS_ID,
                 'className'=>'常用',
                 'child'=>$oftenItemInfoData,
             ]
@@ -54,7 +61,9 @@ class ProductService extends BaseService
                 if($items){
                     foreach ($itemInfoData as $v){
                         if(in_array($v['itemId'],$items)){
+                            $v['classId'] = $classId; //前端要求增加classId 2021.1.31 linqh
                             $tmp['child'][] = $v;
+
                         }
                     }
                 }else{
@@ -64,7 +73,9 @@ class ProductService extends BaseService
             }
 
         }
-        $data = array_merge($oftenData,$allData,$classData);
+        //$data = array_merge($oftenData,$allData,$classData);
+        //去除全部
+        $data = array_merge($oftenData,$classData);
 
         return $data;
     }

+ 8 - 1
sql.sql

@@ -1062,4 +1062,11 @@ CREATE TABLE `xhCustom` (
   PRIMARY KEY (`id`)
 ) COMMENT='客户表';
 ALTER TABLE `xhCustom` ADD `mobile` VARCHAR(15) NOT NULL DEFAULT '0' COMMENT '手机号' AFTER `name`;
-ALTER TABLE xhCustom ADD `visitTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '最后一次访问时间' AFTER `member`;
+ALTER TABLE xhCustom ADD `visitTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '最后一次访问时间' AFTER `member`;
+
+======
+==linqh 2021.1.31
+
+ALTER TABLE `xhGhsProduct`
+ADD COLUMN `priceLabel`  tinyint(2) UNSIGNED NOT NULL DEFAULT 1 COMMENT '价格标识(price): 1 自动调价,2改价' AFTER `price`;
+