Ver Fonte

Merge branch 'master' into zhongqi-chat

shizhongqi há 11 meses atrás
pai
commit
0bfc30a44d

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

@@ -6,6 +6,7 @@ use biz\ghs\classes\GhsClass;
 use bizGhs\clear\classes\ClearClass;
 use bizGhs\clear\classes\ClearClass;
 use bizGhs\clear\services\ClearService;
 use bizGhs\clear\services\ClearService;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\custom\classes\CustomClass;
+use bizGhs\order\classes\OrderClearClass;
 use bizHd\shop\classes\ShopClass;
 use bizHd\shop\classes\ShopClass;
 use common\components\dict;
 use common\components\dict;
 use common\components\imgUtil;
 use common\components\imgUtil;
@@ -42,7 +43,7 @@ class ClearController extends BaseController
             util::fail('账单已取消');
             util::fail('账单已取消');
         }
         }
         $clear->status = ClearClass::STATUS_EXPIRE;
         $clear->status = ClearClass::STATUS_EXPIRE;
-        $clear->remark = "客户手动取消 ".date('Y-m-d H:i:s');
+        $clear->remark = "客户手动取消 " . date('Y-m-d H:i:s');
         $clear->save();
         $clear->save();
         $orderSn = $clear->orderSn ?? '';
         $orderSn = $clear->orderSn ?? '';
 
 
@@ -148,7 +149,57 @@ class ClearController extends BaseController
         $remainSecond = $remainSecond > 0 ? $remainSecond : 0;
         $remainSecond = $remainSecond > 0 ? $remainSecond : 0;
         $clear['remainSecond'] = $remainSecond;
         $clear['remainSecond'] = $remainSecond;
         $clear['hasRenew'] = 1;
         $clear['hasRenew'] = 1;
+
+        //如果是虚拟关系,暂时允许花店一键结账
+        $ghsId = $clear['ghsId'] ?? 0;
+        $ghs = GhsClass::getById($ghsId, true);
+        $live = $ghs->live ?? 1;
+        $clear['live'] = $live;
+
         util::success($clear);
         util::success($clear);
     }
     }
 
 
+    public function actionHasWxPay()
+    {
+        $id = Yii::$app->request->get('id');
+        $clear = ClearClass::getById($id, true);
+        if (empty($clear)) {
+            util::fail('没有结账信息哦');
+        }
+        if ($clear->customShopId != $this->shopId) {
+            util::fail('不是你的结账单');
+        }
+
+        util::checkRepeatCommit($this->adminId, 4);
+
+        //暂时用批发端的写法来顶替一下
+
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $payWay = 0;
+            $amount = $clear->actPrice ?? 0;
+            $customId = $clear->customId ?? 0;
+            $custom = CustomClass::getLockById($customId);
+            $shop = $this->shop;
+            $staff = $this->shopAdmin;
+            //充值
+            $return = CustomClass::rechargeBalance($custom, $amount, $shop, $staff, $payWay);
+            $custom = $return['custom'];
+            $ghs = $return['ghs'];
+            //结账
+            OrderClearClass::confirmClear($clear, $payWay);
+            $clearInfo = OrderClearClass::getLockById($id);
+            //结账消余额
+            CustomClass::clearConsumeBalance($amount, $custom, $ghs, $shop, $staff, $clearInfo);
+            $transaction->commit();
+            util::complete();
+        } catch (\Exception $exception) {
+            $transaction->rollBack();
+            Yii::info("失败:" . $exception->getMessage());
+            util::fail('操作失败');
+        }
+
+    }
+
 }
 }

+ 2 - 0
app-hd/controllers/ItemController.php

@@ -128,6 +128,8 @@ class ItemController extends BaseController
             $list = ProductClass::partItemGroup($list, $level);
             $list = ProductClass::partItemGroup($list, $level);
         } elseif ($requestType == 'check') {
         } elseif ($requestType == 'check') {
             $list = ProductClass::checkItemGroup($list, $level);
             $list = ProductClass::checkItemGroup($list, $level);
+        } elseif ($requestType == 'cg') {
+            $list = ProductClass::cgItemGroup($list, $level);
         } elseif ($requestType == 'changeStock') {
         } elseif ($requestType == 'changeStock') {
             $list = ProductClass::changeStockGroup($list, $level);
             $list = ProductClass::changeStockGroup($list, $level);
         } elseif ($requestType == 'stockOut') {
         } elseif ($requestType == 'stockOut') {

+ 4 - 0
app-hd/controllers/MainController.php

@@ -34,6 +34,10 @@ class MainController extends BaseController
         $merchant = WxOpenClass::getMallWxInfo();
         $merchant = WxOpenClass::getMallWxInfo();
         $ptStyle = dict::getDict('ptStyle', 'mall');
         $ptStyle = dict::getDict('ptStyle', 'mall');
 
 
+        if (getenv('YII_ENV') != 'production') {
+            util::success(['goodsUrl' => 'www.google.com', 'imgUrl' => 'www.google.com', 'itemUrl' => 'www.google.com']);
+        }
+
         $goodsShortUrl = 'wx_mini_goods_short_url';
         $goodsShortUrl = 'wx_mini_goods_short_url';
         $itemShortUrl = 'wx_mini_item_short_url';
         $itemShortUrl = 'wx_mini_item_short_url';
         $imageShortUrl = 'wx_mini_image_short_url';
         $imageShortUrl = 'wx_mini_image_short_url';

+ 8 - 6
app-hd/controllers/OrderController.php

@@ -645,12 +645,14 @@ class OrderController extends BaseController
                                 $name = $systemInfo['name'] ?? '';
                                 $name = $systemInfo['name'] ?? '';
                                 $hsData = GoodsClass::getFinalPrice($systemInfo, $shop, $custom, $params);
                                 $hsData = GoodsClass::getFinalPrice($systemInfo, $shop, $custom, $params);
                                 $systemPrice = $hsData['price'] ?? 0;
                                 $systemPrice = $hsData['price'] ?? 0;
-                                if (floatval($currentPrice) != floatval($systemPrice)) {
-                                    $diff[] = [
-                                        'name' => $name,
-                                        'price' => $systemPrice,
-                                        'kdPrice' => $currentPrice,
-                                    ];
+                                if ($systemInfo['priceType'] == 1) {
+                                    if (floatval($currentPrice) != floatval($systemPrice)) {
+                                        $diff[] = [
+                                            'name' => $name,
+                                            'price' => $systemPrice,
+                                            'kdPrice' => $currentPrice,
+                                        ];
+                                    }
                                 }
                                 }
                             }
                             }
                         }
                         }

+ 5 - 0
app-hd/controllers/PurchaseClearController.php

@@ -89,6 +89,11 @@ class PurchaseClearController extends BaseController
         $respond['remainSecond'] = $remainSecond;
         $respond['remainSecond'] = $remainSecond;
         $getPayType = dict::getDict('getPayType');
         $getPayType = dict::getDict('getPayType');
         $respond['getPayType'] = $getPayType;
         $respond['getPayType'] = $getPayType;
+
+        //如果是虚拟关系,暂时允许花店一键结账
+        $live = $ghs->live ?? 1;
+        $respond['live'] = $live;
+
         util::success($respond);
         util::success($respond);
     }
     }
 
 

+ 5 - 2
biz-ghs/custom/classes/CustomClass.php

@@ -453,11 +453,14 @@ class CustomClass extends BaseClass
         $amount = $order->remainDebtPrice ?? 0;
         $amount = $order->remainDebtPrice ?? 0;
         $custom->isDebt = CustomClass::IS_DEBT_YES;
         $custom->isDebt = CustomClass::IS_DEBT_YES;
         $debtLimit = $custom->debtLimit ?? 0;
         $debtLimit = $custom->debtLimit ?? 0;
-        if ($bookOrder == false) {
+        if (!$bookOrder) {
             if (isset($order->shopAdminId) && $order->shopAdminId == 0) {
             if (isset($order->shopAdminId) && $order->shopAdminId == 0) {
                 //客户自己下单要受额度限制
                 //客户自己下单要受额度限制
                 if ($custom->debtAmount > $debtLimit) {
                 if ($custom->debtAmount > $debtLimit) {
-                    util::fail("已欠款{$custom->debtAmount},请先结账哦");
+                    //虚拟供货商和客户关系不受影响
+                    if($custom->live == 1){
+                        util::fail("已欠款{$custom->debtAmount},请先结账哦");
+                    }
                 }
                 }
             }
             }
         }
         }

+ 5 - 5
biz-hd/goods/classes/GoodsCategoryClass.php

@@ -38,7 +38,7 @@ class GoodsCategoryClass extends BaseClass
             $query->andWhere(['like', 'xhGoodsCategory.name', $askInfo['searchText']]);
             $query->andWhere(['like', 'xhGoodsCategory.name', $askInfo['searchText']]);
         }
         }
 
 
-        $query->joinWith(['goods' => function ($query) use ($askInfo,$requestType) {
+        $query->joinWith(['goods' => function ($query) use ($askInfo, $requestType) {
 
 
             if ($requestType == 'kd') {
             if ($requestType == 'kd') {
                 //花束开单
                 //花束开单
@@ -46,9 +46,10 @@ class GoodsCategoryClass extends BaseClass
                 $query->andWhere(['>', 'xhGoods.stock', 0]);
                 $query->andWhere(['>', 'xhGoods.stock', 0]);
             } elseif ($requestType == 'goodsList') {
             } elseif ($requestType == 'goodsList') {
                 //花束管理列表
                 //花束管理列表
+
                 $query->andWhere(['xhGoods.delStatus' => 0]);
                 $query->andWhere(['xhGoods.delStatus' => 0]);
 
 
-                $priceStatus = $askInfo['priceStatus'] ?? -1;
+                $priceStatus = is_numeric($askInfo['priceStatus']) ? $askInfo['priceStatus'] : -1;
                 if ($priceStatus > -1) {
                 if ($priceStatus > -1) {
                     //1 有价格,2 无价格
                     //1 有价格,2 无价格
                     if ($priceStatus == 1) {
                     if ($priceStatus == 1) {
@@ -59,7 +60,7 @@ class GoodsCategoryClass extends BaseClass
                     }
                     }
                 }
                 }
 
 
-                $stockStatus = $askInfo['stockStatus'] ?? -1;
+                $stockStatus = is_numeric($askInfo['stockStatus']) ? $askInfo['stockStatus'] : -1;
                 if ($stockStatus > -1) {
                 if ($stockStatus > -1) {
                     //1 有库存,2 无库存
                     //1 有库存,2 无库存
                     if ($stockStatus == 1) {
                     if ($stockStatus == 1) {
@@ -70,7 +71,7 @@ class GoodsCategoryClass extends BaseClass
                     }
                     }
                 }
                 }
 
 
-                $flowerNum = $askInfo['flowerNum'] ?? 0;
+                $flowerNum = is_numeric($askInfo['flowerNum']) ? $askInfo['flowerNum'] : 0;
                 if ($flowerNum > 0) {
                 if ($flowerNum > 0) {
                     $query->andWhere(['xhGoods.flowerNum' => $flowerNum]);
                     $query->andWhere(['xhGoods.flowerNum' => $flowerNum]);
                 }
                 }
@@ -89,7 +90,6 @@ class GoodsCategoryClass extends BaseClass
         }]);
         }]);
 
 
 
 
-
         $query->orderBy(['inTurn' => SORT_DESC]);
         $query->orderBy(['inTurn' => SORT_DESC]);
         // 获取总数
         // 获取总数
         $total = $query->count();
         $total = $query->count();

+ 18 - 2
biz-hd/goods/classes/GoodsClass.php

@@ -400,6 +400,7 @@ class GoodsClass extends BaseClass
         $goodsIds = array_column($list, 'id');
         $goodsIds = array_column($list, 'id');
         // 一次性获取所有商品的分类关系
         // 一次性获取所有商品的分类关系
         $allGoodsCategories = GoodsCategoryClass::getGoodsHasCategoryIdsBatch($goodsIds);
         $allGoodsCategories = GoodsCategoryClass::getGoodsHasCategoryIdsBatch($goodsIds);
+        // &$val 这里的指向符号不能去掉
         foreach ($list as $key => &$val) {
         foreach ($list as $key => &$val) {
             $id = $val['id'];
             $id = $val['id'];
             //大中小图片转化
             //大中小图片转化
@@ -415,11 +416,26 @@ class GoodsClass extends BaseClass
             $val['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
             $val['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
             $val['smallCover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
             $val['smallCover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
             $val['bigCover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
             $val['bigCover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
-            //前端使用字段
+
+            $actualSold = $val['actualSold'] ?? 0;
+            $sold = $val['sold'] ?? 0;
+            $totalSold = bcadd($actualSold, $sold);
+            $val['totalSold'] = $totalSold;
+
+            $val = self::getFinalPrice($val, $shop, $custom, $params);
+            $price = $val['price'] ?? 0;
+
+            //冗余给前端使用的字段,这样花束开单前端很多东西就不再需要修改,重要,不要删除 ssh
             $val['bigCount'] = 0;
             $val['bigCount'] = 0;
+            $stock = $val['stock'] ?? 0;
+            $val['bigNum'] = $stock;
+            $val['smallNum'] = 0;
+            $val['classId'] = 0;
+            $val['bigPrice'] = $price;
+            $val['smallPrice'] = $price;
         }
         }
         //获取最终需要的价格
         //获取最终需要的价格
-        return self::getFinalPrice($list, $shop, $custom, $params);
+        return $list;
     }
     }
 
 
     //新建商品 ssh 20220404
     //新建商品 ssh 20220404

+ 23 - 0
biz-hd/product/classes/ProductClass.php

@@ -319,6 +319,29 @@ class ProductClass extends BaseClass
         return $list;
         return $list;
     }
     }
 
 
+    public static function cgItemGroup($list, $level = 0)
+    {
+        $priceMap = \bizGhs\custom\classes\CustomClass::$levelPriceKeyMap;
+        $addPriceMap = \bizGhs\custom\classes\CustomClass::$levelAddPriceKeyMap;
+        foreach ($list as $k => $v) {
+            $shortCover = $v['cover'] ?? '';
+            $list[$k]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_100,w_100";
+            $ratio = isset($v['ratio']) && $v['ratio'] > 0 ? $v['ratio'] : 1;
+            $stockInfo = self::formatStock($v['stock'], $ratio);
+            $list[$k]['bigNum'] = $stockInfo['bigNum'];
+            $list[$k]['smallNum'] = $stockInfo['smallNum'];
+
+            $price = \bizGhs\product\classes\ProductClass::getFinalPrice($v, $level, $priceMap, $addPriceMap);
+            $list[$k]['price'] = $price;
+            $list[$k]['bigPrice'] = $price;
+            $smallRatio = $v['smallRatio'] ?? 0;
+            $smallPrice = bcdiv($price, $ratio, 2);
+            $smallPrice = bcmul($smallPrice, $smallRatio, 2);
+            $list[$k]['smallPrice'] = $smallPrice;
+        }
+        return $list;
+    }
+
     //通用花材列表数组组合
     //通用花材列表数组组合
     public static function changeStockGroup($list, $level = 0)
     public static function changeStockGroup($list, $level = 0)
     {
     {

+ 3 - 4
common/components/business.php

@@ -37,7 +37,7 @@ class business
     //对商品图片转化 ssh 2019.12.2
     //对商品图片转化 ssh 2019.12.2
     public static function formatGoodsImg($info)
     public static function formatGoodsImg($info)
     {
     {
-        $shopImg = isset($info['shopImg']) ? $info['shopImg'] : [];
+        $shopImg = $info['shopImg'] ?? [];
         unset($info['shopImg']);
         unset($info['shopImg']);
         if (empty($shopImg)) {
         if (empty($shopImg)) {
             $info['shortImgList'] = ['/hhb_small.png'];
             $info['shortImgList'] = ['/hhb_small.png'];
@@ -46,7 +46,7 @@ class business
             return $info;
             return $info;
         }
         }
         $arr = json_decode($shopImg, true);
         $arr = json_decode($shopImg, true);
-        if (is_array($arr) == false) {
+        if (!is_array($arr)) {
             $info['shortImgList'] = ['/hhb_small.png'];
             $info['shortImgList'] = ['/hhb_small.png'];
             $info['imgList'] = [imgUtil::groupImg('')];
             $info['imgList'] = [imgUtil::groupImg('')];
             $info['smallImgList'] = [imgUtil::groupImg('')];
             $info['smallImgList'] = [imgUtil::groupImg('')];
@@ -54,10 +54,9 @@ class business
         }
         }
         $imgList = [];
         $imgList = [];
         $smallImgList = [];
         $smallImgList = [];
-        $prefixImgUrl = imgUtil::getPrefix();
         foreach ($arr as $imgUrl) {
         foreach ($arr as $imgUrl) {
             $small = imgUtil::groupImg($imgUrl) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
             $small = imgUtil::groupImg($imgUrl) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
-            $normal = $prefixImgUrl . $imgUrl;
+            $normal = imgUtil::groupImg($imgUrl) . "?x-oss-process=image/resize,m_fill,h_900,w_900";
             $imgList[] = $normal;
             $imgList[] = $normal;
             $smallImgList[] = $small;
             $smallImgList[] = $small;
         }
         }