Kaynağa Gözat

Merge branch 'master' of http://git.huaml.com/zhh/huahuibao

shish 5 yıl önce
ebeveyn
işleme
b4caa5ab6f

+ 4 - 0
app-ghs/controllers/OrderController.php

@@ -252,10 +252,14 @@ class OrderController extends BaseController
         //2021.3.28 接入达达
         $get = Yii::$app->request->get();
         $orderId = $get['id'] ?? 0; //订单ID
+
         $customId = $get['customId'] ?? 0;
         if (!empty($customId)) {
             util::success(['sedCost' => 27]);
         }
+        if(empty($orderId)){
+            util::success(['sedCost' => 10]);
+        }
         $province = $get['province'] ?? '';
         $city = $get['city'] ?? '';
         $address = $get['address'] ?? '';

+ 12 - 15
app-hd/controllers/GhsProductController.php

@@ -17,33 +17,30 @@ use Yii;
 class GhsProductController extends BaseController
 {
     //从零售端采购入库,查看供货商的某个门店的product
-    public function actionList()
+    public function actionIndex()
     {
         $get = Yii::$app->request->get();
         $shopId = $get['shopId']??0;
         $sjId = $get['sjId']??0;
         $py = $get['py']??'';
-
+        AdminClass::addRecentShop($shopId,$this->admin);
         //获取所有当前供应商的分类 (全部、常用)
         //根据分类组装分类下的花材信息
         $classIds = ItemClassClass::getGhsItemClassAll($sjId);
+        $where['merchantId'] = $sjId;
+        $where['shopId'] = $shopId;
 
-        //获取供应商下所有花材ID (itemIds)
-        $itemIdsInfo = ItemService::getGhsItemIds($sjId);
-
-        $itemIds = array_column($itemIdsInfo,'itemId');
-
-        if($py){
-            $pyNameItemIds = ItemClass::getItemIdsByPyName($py);
-            $itemIds = array_intersect($itemIds,$pyNameItemIds);
-        }
-
-        $itemInfoData = ProductClass::getProductInfoByItemIds($itemIds,$shopId);
+        $itemInfoData = ProductClass::getAllByCondition($where,null,"*");
+        $itemInfoData = ProductClass::groupProductInfo($itemInfoData);
         //常用的itemIds
         $oftenItemIds = ProductClass::getOftenItemIds($shopId);
+        //获取供应商下所有花材ID (itemIds)
+        $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
+
+        //dd($itemInfoData);
         //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
-        $data = ProductService::assembleData($classIds,$itemIdsInfo,$itemInfoData,$oftenItemIds);
-        AdminClass::addRecentShop($shopId,$this->admin);
+        $data = ProductService::assembleData($classIds, $itemIdsInfo,$itemInfoData, $oftenItemIds, '');
+
         util::success($data);
 
     }

+ 19 - 1
app-hd/controllers/GoodsController.php

@@ -174,4 +174,22 @@ class GoodsController extends BaseController
         util::success($info);
     }
 
-}
+    public function actionIndex()
+    {
+        $classIds = CategoryService::getCategoryClassAll($this->sjId);
+        $where['merchantId'] = $this->sjId;
+        $where['delStatus'] = 0;
+        $goodsData = GoodsCategoryService::getGoodsAll($where);
+
+        //常用的GoodsId
+        $oftenIds = GoodsCategoryService::getOftenIds($this->sjId);
+
+        $goodsCateData = GoodsCategoryService::getGoodsCategory($this->sjId);
+
+
+        //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
+        $data = GoodsCategoryService::assembleData($classIds,$goodsCateData,$goodsData, $oftenIds);
+
+        util::success($data);
+    }
+}

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

@@ -6,8 +6,59 @@
 
 namespace hd\controllers;
 
-
+use bizGhs\admin\classes\AdminClass;
+use bizGhs\item\classes\ItemClass;
+use bizGhs\item\classes\ItemClassClass;
+use bizGhs\product\classes\ProductClass;
+use bizGhs\product\services\ProductService;
+use bizGhs\item\services\ItemService;
+use common\components\noticeUtil;
+use common\components\util;
+use Yii;
 class ProductController extends BaseController
 {
 
+    public function actionIndex()
+    {
+        $py = Yii::$app->request->get('py', '');
+        $type = Yii::$app->request->get('type', '');
+
+        //访问店铺时用户增加最近访问的店铺 ssh 2021.3.1
+        AdminClass::addRecentShop($this->shopId, $this->admin);
+
+        //获取所有当前供应商的分类 (全部、常用)
+        //根据分类组装分类下的花材信息
+        $classIds = ItemClassClass::getGhsItemClassAll($this->sjId);
+
+        $where['merchantId'] = $this->sjId;
+        if ($py) {
+            $pyName = strtolower($py);
+            $where['py'] = $pyName;
+        }
+        $shopId = $this->shopId;
+
+        //库存预警
+        if ($type == 'waring') {
+            //shopId 改为可以前端传,默认是当前shopId linqh  2021.1.26
+            $shopId = Yii::$app->request->get('shopId', 0);
+            if (!$shopId) {
+                $shopId = $this->shopId;
+            }
+        }
+        $where['shopId'] = $shopId;
+
+        $itemInfoData = ProductClass::getAllByCondition($where,null,"*");
+        $itemInfoData = ProductClass::groupProductInfo($itemInfoData);
+        //常用的itemIds
+        $oftenItemIds = ProductClass::getOftenItemIds($shopId);
+        //获取供应商下所有花材ID (itemIds)
+        $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
+
+        //dd($itemInfoData);
+        //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
+        $data = ProductService::assembleData($classIds, $itemIdsInfo,$itemInfoData, $oftenItemIds, $type);
+
+        util::success($data);
+    }
+
 }

+ 2 - 1
biz-ghs/express/services/DadaExpressServices.php

@@ -123,7 +123,8 @@ class DadaExpressServices
             'receiver_lat' =>(float)$orderInfo['lat'], // 存的是百度经纬度,需要转高德经纬度
             'receiver_lng' =>(float)$orderInfo['long'], // 存的是百度经纬度,需要转高德经纬度
             'callback'=> Yii::$app->params['ghsHost'].'/notice/express-call-back',
-            'cargo_weight'=>0.01,//订单重量(单位:Kg)
+
+            'cargo_weight'=>(float)$orderInfo['weight'],//订单重量(单位:Kg)
             'receiver_phone'=>$orderInfo['customMobile'],//否	收货人手机号(手机号和座机号必填一项)
             'info'=>'',//备注
             'cargo_type'=>3, //类型:鲜花

+ 9 - 0
biz-ghs/order/classes/OrderClass.php

@@ -95,6 +95,15 @@ class OrderClass extends BaseClass
         $data['deadline'] = date("Y-m-d H:i:s", (time() + 1800));
         $data['sendCost'] = isset($data['sendCost']) && is_numeric($data['sendCost']) ? $data['sendCost'] : 0;
         $data['status'] = self::ORDER_STATUS_UN_PAY;
+
+        //计算总重量(kg)
+        $weight = 0;
+        foreach ($product as $key => $val) {
+            $w = ProductClass::getWeight($val['productId'], $val['bigNum'], $val['smallNum']);
+            $weight = bcadd($w,$weight,2);
+        }
+
+        $data['weight'] = $weight;
         $return = self::add($data);
 
         //总订单和待付款订单增加

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

@@ -10,6 +10,7 @@ use common\components\imgUtil;
 use common\components\util;
 use common\services\xhItemService;
 use Yii;
+use yii\di\ServiceLocator;
 
 class ProductClass extends BaseClass
 {
@@ -210,7 +211,7 @@ class ProductClass extends BaseClass
 		if (!$productData) {
 			util::fail("花材不存在");
 		}
-		$newStock = bcadd($productData->stock, $itemNum, 2);
+		$newStock = bcadd($productData->stock, $productData['ratio'], 2);
 		self::updateStockById($productId, $newStock);
 		return true;
 	}
@@ -229,10 +230,9 @@ class ProductClass extends BaseClass
 		if (!$productData) {
 			util::fail("花材不存在");
 		}
-		$itemId = $productData['itemId'];
-		$unitNum = xhItemService::getItemUnitNum($itemId);
+		$ratio = $productData['ratio'];
 		//转成小数,更新库存
-		$itemNum = self::mergeItemNum($itemNumBundle, $itemNumPiece, $unitNum);
+		$itemNum = self::mergeItemNum($itemNumBundle, $itemNumPiece, $ratio);
 		$newStock = bcsub($productData->stock, $itemNum, 2);
 		self::updateStockById($productId, $newStock);
 		return true;
@@ -500,4 +500,16 @@ class ProductClass extends BaseClass
         return self::updateById($productId, ['addPrice' => $addPrice]);
     }
 
+    //根据productId 计算花材的重量
+    public static function getWeight($productId,$bigNum,$smallNum)
+    {
+        $productInfo = self::getById($productId);
+        if(empty($productInfo)){
+            return 0;
+        }
+        $ratio = $productInfo['ratio'];
+        $weight = $productInfo['weight'];
+        $mergeNum = self::mergeItemNum($bigNum,$smallNum,$ratio);
+        return bcmul($mergeNum,$weight,2);
+    }
 }

+ 32 - 16
biz-hd/goods/services/CategoryService.php

@@ -11,9 +11,10 @@ use linslin\yii2\curl;
 
 class CategoryService extends BaseService
 {
-	
+
+
 	public static $baseFile = '\bizHd\goods\classes\CategoryClass';
-	
+
 	//取所有的分类 ssh 2019.12.7
 	public static function getCategoryList($merchantId)
 	{
@@ -28,7 +29,7 @@ class CategoryService extends BaseService
 		}
 		return $cat;
 	}
-	
+
 	//取出可用的分类 ssh 2019.12.2
 	public static function getEnableList($merchantId)
 	{
@@ -43,21 +44,21 @@ class CategoryService extends BaseService
 		}
 		return $cat;
 	}
-	
+
 	//获取商家所有的分类名称
 	public static function getNameList($merchantId)
 	{
 		$cat = CategoryClass::getAllByCondition(['merchantId' => $merchantId, 'delStatus' => 0], 'inTurn DESC', '*');
 		return empty($cat) ? [] : array_column($cat, 'categoryName');
 	}
-	
+
 	//取出商家所有的分类ID ssh 2019.12.7
 	public static function getCategoryIdList($merchantId)
 	{
 		return CategoryClass::getCategoryIdList($merchantId);
 	}
-	
-	
+
+
 	//获取商家最靠前的分类id ssh 2019.12.2
 	public static function getTopCategoryId($merchantId)
 	{
@@ -65,7 +66,7 @@ class CategoryService extends BaseService
 		$id = isset($cat['id']) ? $cat['id'] : 0;
 		return $id;
 	}
-	
+
 	//获取前三个分类信息 ssh 2019.12.2
 	public static function getTopThreeCategory($merchantId)
 	{
@@ -75,7 +76,7 @@ class CategoryService extends BaseService
 		}
 		return $cat;
 	}
-	
+
 	//验证操作权限 ssh 2019.12.8
 	public static function valid($category, $merchantId)
 	{
@@ -83,24 +84,24 @@ class CategoryService extends BaseService
 			util::fail('您没有权限操作');
 		}
 	}
-	
+
 	//获取详情 ssh 2019.12.8
 	public static function getInfo($id)
 	{
 		return CategoryClass::getInfo($id);
 	}
-	
+
 	//添加分类 ssh 2019.12.8
 	public static function addCategory($data)
 	{
 		return CategoryClass::addCategory($data);
 	}
-	
+
 	public static function changeStatus($categoryId, $status)
 	{
 		return CategoryClass::changeStatus($categoryId, $status);
 	}
-	
+
 	//更新分类 ssh 2019.12.8
 	public static function updateCategory($category, $post)
 	{
@@ -115,10 +116,25 @@ class CategoryService extends BaseService
 		}
 		CategoryClass::updateById($categoryId, $post);
 	}
-	
+
 	public static function deleteCategory($id)
 	{
 		return CategoryClass::deleteCategory($id);
 	}
-	
-}
+
+    //获取开单页所有的分类:包括、常用
+    public static function getCategoryClassAll($merchantId)
+    {
+        $where = [
+            'merchantId'=>$merchantId
+        ];
+        $data = self::getAllList('id,categoryName as name',$where,'inTurn desc');
+        $use = [
+            'id'=>-2,
+            'name'=>'常用'
+        ];
+        array_unshift($data,$use);
+        return $data;
+    }
+
+}

+ 107 - 7
biz-hd/goods/services/GoodsCategoryService.php

@@ -10,9 +10,9 @@ use linslin\yii2\curl;
 
 class GoodsCategoryService extends BaseService
 {
-	
+    const OFTEN_CLASS_ID = '-2'; //常用分类
 	public static $baseFile = '\bizHd\goods\classes\GoodsCategoryClass';
-	
+
 	//查询一个分类下的商品,有分页 ssh 2019.12.2
 	public static function getGoodsList($where)
 	{
@@ -26,7 +26,7 @@ class GoodsCategoryService extends BaseService
 		$data['list'] = GoodsClass::groupGoodsBaseInfo($list);
 		return $data;
 	}
-	
+
 	//查询指定分类下的商品,没有分页,首页使用 ssh 2019.12.2
 	public static function getAppointCategoryList($category)
 	{
@@ -49,11 +49,11 @@ class GoodsCategoryService extends BaseService
 		//查出商品信息
 		$goodsInfoList = GoodsService::getAllByCondition(['id' => ['in', $goodsList]], 'inTurn DESC', '*', 'id');
 		$goodsInfoList = GoodsClass::groupGoodsBaseInfo($goodsInfoList);
-		
+
 		//每个分类取的商品数
 		$getNum = [6, 2, 4];
 		$showRowNum = [2, 1, 2];
-		
+
 		foreach ($category as $key => $val) {
 			$id = $val['id'];
 			//当前分类下有哪些商品id,并组合商品信息
@@ -73,7 +73,7 @@ class GoodsCategoryService extends BaseService
 		}
 		return $category;
 	}
-	
+
 	//获取商品所属的分类id  ssh 201917
 	public static function getGoodsHasCategoryIdList($goodsId)
 	{
@@ -85,4 +85,104 @@ class GoodsCategoryService extends BaseService
 		return $ids;
 	}
 
-}
+	//所有商品
+    public static function getGoodsAll($where)
+    {
+        $list = GoodsCategoryClass::getAllList('*', $where, 'inTurn DESC');
+
+        $ids = array_column($list, 'gId');
+        $list = GoodsService::getAllByCondition(['id' => ['in', $ids]], 'inTurn DESC', '*');
+        $data = GoodsClass::groupGoodsBaseInfo($list);
+        return $data;
+    }
+
+    //获取商家下 所有商品的分类
+    public static function getGoodsCategory($sjId)
+    {
+        $where = [
+            'merchantId' => $sjId
+        ];
+        $data = self::getAllList('cId as classId,gId', $where);
+        return $data;
+    }
+
+	//获取常用分类的 goods id  linqh 2021.04.09
+    public static function getOftenIds($sjId)
+    {
+        $data = GoodsClass::getLimitList("id", ['merchantId' => $sjId], 10,'actualSold desc');
+        if ($data) {
+            $data = array_column($data, 'id');
+        }
+        return $data;
+    }
+
+    //
+    public static function assembleData($classIds,$goodsCateData,$goodsData, $oftenIds)
+    {
+        $oftenItemInfoData = [];
+        if($goodsData){
+            foreach ($goodsData as $v){
+                if(in_array($v['id'],$oftenIds)){
+                    $v['classId'] = self::OFTEN_CLASS_ID;
+                    $oftenItemInfoData[] = $v;
+                }
+            }
+        }
+
+        //classId=>itemId
+        $classMapItem = [];
+        if($goodsData){
+            foreach ($goodsCateData as $v){
+                $classMapItem[$v['classId']][] = $v['gId'];
+            }
+        }
+
+        //常用
+        $oftenData = [
+            [
+                'classId'=> self::OFTEN_CLASS_ID,
+                'className'=>'常用',
+                'child'=>$oftenItemInfoData,
+            ]
+        ];
+
+        $classData = [];
+
+
+        foreach ($classIds as $v){
+            $classId = $v['id'];
+            if($classId > 0 ){
+                $tmp =[];
+                $tmp['classId'] = $classId;
+                $tmp['className'] = $v['name'];
+                $items = $classMapItem[$classId]??[];
+                if($items){
+                    if($goodsData){
+                        foreach ($goodsData as $v){
+                            if(in_array($v['id'],$items)){
+                                $v['classId'] = $classId; //前端要求增加classId 2021.1.31 linqh
+                                $tmp['child'][] = $v;
+                            }
+                        }
+                    }else{
+                        $tmp['child'] = [];
+                    }
+                }else{
+                    $tmp['child'] = [];
+                }
+                //去除空分类
+                if(empty($tmp['child'])){
+                    continue;
+                }
+                $classData[] = $tmp;
+            }
+
+        }
+
+        //$data = array_merge($oftenData,$allData,$classData);
+        //去除全部
+        $data = array_merge($oftenData,$classData);
+
+        return $data;
+    }
+}

+ 9 - 1
sql.sql

@@ -2014,4 +2014,12 @@ ADD COLUMN `smallUnit`  smallint(6) NOT NULL DEFAULT 0 COMMENT '小单位' AFTER
 
 
 ====== shish 2021-4-9
-ALTER TABLE xhCustom DROP COLUMN `totalBuyNum`;
+ALTER TABLE xhCustom DROP COLUMN `totalBuyNum`;
+
+========
+==linqh 2021.4.9
+ALTER TABLE `xhGoods`
+ADD COLUMN `py`  varchar(20) NOT NULL DEFAULT '' COMMENT '拼音' AFTER `shortUrl`;
+
+ALTER TABLE `xhGhsOrder`
+ADD COLUMN `weight`  decimal(9,2) NOT NULL DEFAULT 0 COMMENT '花材总重量(公斤)' AFTER `status`;