林琦海 4 лет назад
Родитель
Сommit
f027ca07e1

+ 24 - 3
app-ghs/controllers/XjController.php

@@ -3,8 +3,9 @@
 namespace ghs\controllers;
 
 use biz\product\classes\XjClass;
+use biz\shop\classes\ShopExtClass;
 use common\components\util;
-
+use Yii;
 class XjController extends BaseController
 {
 
@@ -14,7 +15,7 @@ class XjController extends BaseController
         $where = [];
         $where['shopId'] = $this->shopId;
         $where['status'] = 1;
-        $list = XjClass::getAllXj();
+        $list = XjClass::getShopXj($this->shopId);
         util::success(['list' => $list]);
     }
 
@@ -31,7 +32,7 @@ class XjController extends BaseController
         $where = [];
         $where['shopId'] = $this->shopId;
         $where['status'] = 1;
-        $list = XjClass::getAllXj();
+        $list = XjClass::getShopXj($this->shopId);
         $ext = $this->shopExt;
         $xj = $ext->xj ?? '';
         $hasIds = [];
@@ -50,4 +51,24 @@ class XjController extends BaseController
         util::success(['list' => $list]);
     }
 
+
+    //清除全部小菊  lqh 2021.12.8
+    public function actionClearAll()
+    {
+        XjClass::clearAll($this->shopId);
+        ShopExtClass::clearXjALl($this->shopId);
+        util::complete();
+    }
+
+    //新增小菊 lqh 2021.12.8
+    public function actionAdd()
+    {
+        $post = Yii::$app->request->post();
+        $cover = $post['cover']??'';
+        if(empty($cover)){
+            util::fail("请上传图片");
+        }
+        XjClass::addXj($this->shopId,$cover,$this->shopExt);
+        util::complete();
+    }
 }

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

@@ -1117,7 +1117,10 @@ class ProductClass extends BaseClass
             $ptItemId = $data['itemId'] ?? 0;
             $ptItemInfo = PtItemClass::getById($ptItemId, true);
             $data['variety'] = $ptItemInfo->variety ?? 0;
-            $data['addPrice'] = $ptItemInfo->addPrice ?? 0;
+            //2021-12-07 lqh 如果前端有传取前端的,没有则取pt
+            if(!$addPrice){
+                $data['addPrice'] = $ptItemInfo->addPrice ?? 0;
+            }
             $data['skAddPrice'] = $ptItemInfo->skAddPrice ?? 0;
             $data['hjAddPrice'] = $ptItemInfo->hjAddPrice ?? 0;
             $data['zsAddPrice'] = $ptItemInfo->zsAddPrice ?? 0;

+ 60 - 1
biz/product/classes/XjClass.php

@@ -44,4 +44,63 @@ class XjClass extends BaseClass
         return $list;
     }
 
-}
+    //清除门店下所有的小菊
+    public static function clearAll($shopId)
+    {
+        $where = [];
+        $where['shopId'] = $shopId;
+        $data = [];
+        $data['status'] =2;
+        $data['delStatus'] = 1;
+        return self::updateByCondition($where,$data);
+    }
+
+    // 获取当前门店小菊的总数
+    public static function getXjCount($shopId)
+    {
+        $where =[];
+        $where['shopId'] = $shopId;
+        $where['delStatus'] = 0;
+        return self::getCount($where);
+    }
+
+    //新增小菊
+    public static function addXj($shopId,$cover,$shopExt)
+    {
+        $count = self::getXjCount($shopId);
+        if($count < 10) {
+            $count ++ ;
+            $count = "0".$count;
+        }
+        $name = "小菊".$count;
+        $data = [];
+        $data['cover'] = $cover;
+        $data['name'] = $name;
+        $data['shopId'] = $shopId;
+        $data['status'] = 1;
+        $res = self::add($data);
+        $id = $res['id'];
+        //启用
+        $xj = $shopExt->xj;
+        $hasIds = [];
+        if (!empty($xj)) {
+            $hasIds = json_decode($xj, true);
+        }
+        if(in_array($id,$hasIds) == false){
+            $hasIds[] = $id;
+            $shopExt->xj = json_encode($hasIds);
+            $shopExt->save();
+        }
+    }
+
+    //获取当前门店下所有的xj
+    public static function getShopXj($shopId)
+    {
+        $where = [];
+        $where['shopId'] = $shopId;
+        $where['status'] = 1;
+        $where['delStatus'] = 0;
+        $list = self::getAllByCondition($where, null, '*', null);
+        return self::groupInfo($list);
+    }
+}

+ 7 - 0
biz/shop/classes/ShopExtClass.php

@@ -9,4 +9,11 @@ class ShopExtClass extends BaseClass
 
     public static $baseFile = '\biz\shop\models\ShopExt';
 
+    //清除所有小菊
+    public static function clearXjALl($shopId)
+    {
+        $where = [];
+        $where['shopId'] = $shopId;
+        return self::updateByCondition($where,['xj'=>'']);
+    }
 }

+ 5 - 0
sql.txt

@@ -0,0 +1,5 @@
+# sql 变更记录  2021.12.8
+=========lqh 2021.12.8
+ALTER TABLE `xhXj`
+ADD COLUMN `shopId`  int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '门店ID' AFTER `status`,
+ADD INDEX `idx_shopId` (`shopId`) USING BTREE ;