shish 2 лет назад
Родитель
Сommit
83576b0133

+ 4 - 1
app-ghs/controllers/TestController.php

@@ -106,7 +106,10 @@ class TestController extends BaseController
             //['name' => '昆明新宏源', 'merchantNo' => '82239305992007H', 'wx' => [606098318, 606100317], 'zfb' => '2088920878302843'],
             //['name' => '昆明纯彩', 'merchantNo' => '82239905992003L', 'wx' => [604923629, 604922175], 'zfb' => '2088920533160795'],
             //['name' => '花优田(军兴旺)', 'merchantNo' => '8227310599200GX', 'wx' => [605191281, 605190492], 'zfb' => '2088920588715249'],
-            ['name' => '惠州惠雅鲜花批发', 'merchantNo' => '82259505992003S', 'wx' => [611676975, 611677314], 'zfb' => '2088330136601427'],
+            ['name' => '广州国恋', 'merchantNo' => '8225810599200Q7', 'wx' => [612321716, 612320978], 'zfb' => '2088330479975012'],
+            //['name' => '欣研鲜花', 'merchantNo' => '82260305992001Y', 'wx' => [612181234, 612181615], 'zfb' => '2088330365608286'],
+            //['name' => '村长冷链', 'merchantNo' => '82260205992008G', 'wx' => [612168406, 612168000], 'zfb' => '2088330360870932'],
+            //['name' => '惠州惠雅鲜花批发', 'merchantNo' => '82259505992003S', 'wx' => [611676975, 611677314], 'zfb' => '2088330136601427'],
             //['name' => '杭州斗南鲜花', 'merchantNo' => '8223310599200AR', 'wx' => [608955814, 608955082], 'zfb' => '2088130449323603'],
             //['name' => '营口简约花卉', 'merchantNo' => '8227310599200HJ', 'wx' => [608439898, 608440994], 'zfb' => '2088130112725929'],
             //['name' => '惠雅鲜花惠州店', 'merchantNo' => '82260205992007Z', 'wx' => [608406948, 608403207], 'zfb' => '2088130098167302'],

+ 3 - 16
app-hd/controllers/GhsProductController.php

@@ -7,12 +7,9 @@
 namespace hd\controllers;
 
 use biz\shop\services\ShopService;
-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\util;
 use Yii;
 
@@ -24,25 +21,15 @@ class GhsProductController extends BaseController
     {
         $get = Yii::$app->request->get();
         $shopId = $get['shopId']??0;
-        $sjId = $get['sjId']??0;
-
-        //获取所有当前供货商的分类 (全部、常用)
-        //根据分类组装分类下的花材信息
-        //中央ID
         $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
-//        $where['sjId'] = $sjId;
-//        $where['shopId'] = $shopId;
-
         $where['mainId'] = $this->mainId;
         $where['delStatus'] = 0;
-
         $itemInfoData = ProductClass::getAllByCondition($where,['actualSold'=>SORT_DESC,'inTurn'=>SORT_DESC],"*");
         $itemInfoData = ProductClass::groupProductInfo($itemInfoData);
-
-        $data = ProductService::assembleData($classIds, $itemInfoData, true);
+        $respond = ProductService::assembleData($classIds, $itemInfoData, true);
+        $classItem = $respond['classItem'] ?? [];
         ShopService::totalViewPlus($shopId);
-        util::success($data);
-
+        util::success($classItem);
     }
 
 }

+ 96 - 7
app-hd/controllers/ProductController.php

@@ -152,10 +152,9 @@ class ProductController extends BaseController
         $field = 'id,cover,name,cost,itemId,classId,property,skPrice,skMore,addPrice,variety,price,discountPrice,skDiscountPrice,stock,stockWarning,presell,ratioType,smallRatio,smallUnit,bigUnit,ratio,actualSold';
         $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
         $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
-
-        $data = ProductService::assembleData($classIds, $itemInfoData, true);
-
-        util::success($data);
+        $respond = ProductService::assembleData($classIds, $itemInfoData, true);
+        $classItem = $respond['classItem'] ?? [];
+        util::success($classItem);
     }
 
     //当前门店所有花材分类
@@ -359,8 +358,68 @@ class ProductController extends BaseController
         $connection = Yii::$app->db;//事务处理
         $transaction = $connection->beginTransaction();
         try {
+            //获取所有当前供货商的分类 (全部、常用)
+            //根据分类组装分类下的花材信息
+            $shop = ShopClass::getById($shopId, true);
+            $mainId = $shop->mainId ?? 0;
+            $classIds = ItemClassClass::getGhsItemClassAll($mainId);
+            $where['mainId'] = $mainId;
+            $where['delStatus'] = 0;
+            //是否显示全部花材,包括下架的
+            $showAll = $get['showAll'] ?? 0;
+            if ($showAll == 0) {
+                $where['status'] = 1;
+            }
+            $where['frontHide'] = 0;
 
+            $level = $ghs['giveLevel'] ?? 1;
+            $field = 'id,py,cover,name,ratio,classId,itemId,weight,smallUnit,bigUnit,smallUnit,smallRatio,ratioType,variety,price,skPrice,skDiscountPrice,hjPrice,hjDiscountPrice,actualSold,stock,stockWarning,discountPrice,presell,presellDate,reachNum,reachNumDiscount';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::hdCgGroup($itemInfoData, $level);
+            $myProduct = ProductClass::getAllByCondition(['mainId' => $this->mainId, 'delStatus' => 0], null, 'id,stock,onStock,stockWarning,itemId', 'itemId');
+            if (!empty($itemInfoData)) {
+                $myShop = $this->shop;
+                $myDisplay = isset($myShop->pfShopId) && $myShop->pfShopId > 0 ? 1 : 0;
+                foreach ($itemInfoData as $key => $val) {
+                    $ptItemId = $val['itemId'] ?? 0;
+                    $myStock = $myProduct[$ptItemId]['stock'] ?? 0;
+                    $myStock = floatval($myStock);
+                    $myOnStock = $myProduct[$ptItemId]['onStock'] ?? 0;
+                    $myStockWarning = $myProduct[$ptItemId]['stockWarning'] ?? 5;
+                    $myLack = bcadd($myStock, $myOnStock, 2) > $myStockWarning ? 0 : 1;
+                    $itemInfoData[$key]['myStock'] = $myStock;
+                    $itemInfoData[$key]['myOnStock'] = $myOnStock;
+                    $itemInfoData[$key]['myStockWarning'] = $myStockWarning;
+                    $itemInfoData[$key]['myLack'] = $myLack;
+                    $itemInfoData[$key]['myDisplay'] = $myDisplay;
+                }
+            }
+            $respond = ProductService::assembleData($classIds, $itemInfoData, true);
+            $classItem = $respond['classItem'] ?? [];
+            util::success($classItem);
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::info("报错内容:" . $e->getMessage());
+            util::fail();
+        }
+    }
 
+    public function actionGhsItemV2()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $ghs = GhsClass::getGhsInfo($id);
+        if (empty($ghs)) {
+            util::fail('没有找到供货商');
+        }
+        $shopId = $ghs['shopId'] ?? 0;
+        $black = $ghs['black'] ?? 2;
+        if ($black == 2) {
+            util::fail('暂无花材');
+        }
+        $connection = Yii::$app->db;//事务处理
+        $transaction = $connection->beginTransaction();
+        try {
             //获取所有当前供货商的分类 (全部、常用)
             //根据分类组装分类下的花材信息
             $shop = ShopClass::getById($shopId, true);
@@ -397,14 +456,44 @@ class ProductController extends BaseController
                     $itemInfoData[$key]['myDisplay'] = $myDisplay;
                 }
             }
-            $data = ProductService::assembleData($classIds, $itemInfoData, true);
-            util::success($data);
+            $respond = ProductService::assembleData($classIds, $itemInfoData, true);
+            if ($showAll == 1) {
+                if (isset($respond['classItem']) && !empty($respond['classItem'])) {
+                    foreach ($respond['classItem'] as $bigKey => $bigVal) {
+                        if (isset($bigVal['child']) && !empty($bigVal['child'])) {
+                            foreach ($bigVal['child'] as $key => $val) {
+                                unset($bigVal['child'][$key]['cover']);
+                                unset($bigVal['child'][$key]['actualSold']);
+                                unset($bigVal['child'][$key]['defaultGradePrice']);
+                                unset($bigVal['child'][$key]['discountPrice']);
+                                unset($bigVal['child'][$key]['hjDiscountPrice']);
+                                unset($bigVal['child'][$key]['hjPrice']);
+                                unset($bigVal['child'][$key]['presellDateShow']);
+                                unset($bigVal['child'][$key]['prePrice']);
+                                unset($bigVal['child'][$key]['print']);
+                                unset($bigVal['child'][$key]['reachNum']);
+                                unset($bigVal['child'][$key]['reachNumDiscount']);
+                                unset($bigVal['child'][$key]['reachPrice']);
+                                unset($bigVal['child'][$key]['skDiscountPrice']);
+                                unset($bigVal['child'][$key]['skPrice']);
+                                unset($bigVal['child'][$key]['bigUnit']);
+                                unset($bigVal['child'][$key]['weight']);
+                                unset($bigVal['child'][$key]['stockWarning']);
+                                //unset($bigVal['child'][$key]['smallPrice']);
+                                //unset($bigVal['child'][$key]['smallRatio']);
+                            }
+                            $respond['classItem'][$bigKey]['child'] = $bigVal['child'];
+                        }
+                    }
+                }
+            }
+
+            util::success($respond);
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::info("报错内容:" . $e->getMessage());
             util::fail();
         }
-
     }
 
     public function actionDetail()

+ 5 - 1
biz-ghs/product/services/ProductService.php

@@ -128,6 +128,7 @@ class ProductService extends BaseService
     {
         //今日特价
         $tjItem = [];
+        $itemGroup = [];
         $preSellItem = [];
         if ($itemInfoData) {
             foreach ($itemInfoData as $v) {
@@ -137,11 +138,13 @@ class ProductService extends BaseService
                     $v['classId'] = self::TJ_CLASS_ID;
                     $v['className'] = '今日特价';
                     $tjItem[] = $v;
+                    $itemGroup[] = $v;
                 }
                 if (isset($v['presell']) && $v['presell'] == 1) {
                     $v['classId'] = self::PRESELL_CLASS_ID;
                     $v['className'] = '预售专区';
                     $preSellItem[] = $v;
+                    $itemGroup[] = $v;
                 }
             }
         }
@@ -176,6 +179,7 @@ class ProductService extends BaseService
                                 $v['className'] = $className;
                                 $v['print'] = $print;
                                 $tmp['child'][] = $v;
+                                $itemGroup[] = $v;
                             }
                         }
                     } else {
@@ -207,7 +211,7 @@ class ProductService extends BaseService
             ]];
             $classData = array_merge($preSellClass, $classData);
         }
-        return $classData;
+        return ['classItem' => $classData, 'itemList' => $itemGroup];
     }
 
 

+ 1 - 0
biz/wx/classes/WxMessageClass.php

@@ -202,6 +202,7 @@ class WxMessageClass extends BaseClass
             if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
                 $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
             }
+
             $orderSn = $shopName == '首店' ? $order->orderSn : $shopName;
             if (isset($order->presell) && $order->presell == 1) {
                 $title = '【预售】';