Selaa lähdekoodia

Merge branch 'master' into debt

shish 1 vuosi sitten
vanhempi
commit
96e3b8e3a4

+ 43 - 2
app-ghs/controllers/ItemController.php

@@ -22,7 +22,48 @@ use Yii;
 class ItemController extends BaseController
 {
 
-    //取消花材的限购,重新开始计算
+    //花材已购客户列表 ssh 20250710
+    public function actionHasLimitBuyCustomList()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $item = ItemClass::getById($id, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        $customList = ProductClass::getHasLimitBuyList($item);
+        util::success(['customList' => $customList]);
+    }
+
+    //清空单个客户的已购 ssh 20250710
+    public function actionClearOneLimitBuy()
+    {
+        $get = Yii::$app->request->get();
+        $productId = $get['productId'] ?? '';
+        $customId = $get['customId'] ?? 0;
+        $item = ItemClass::getById($productId, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        $custom = CustomClass::getById($customId, true);
+        if (empty($custom)) {
+            util::fail('没有客户');
+        }
+        if ($custom->ownMainId != $this->mainId) {
+            util::fail('不是你的客户');
+        }
+        ProductClass::baseClearLimitBuy($productId, $customId);
+        util::complete('清除成功');
+    }
+
+
+    //取消花材全部客户的已限数,重新开始计算
     public function actionClearLimitBuy()
     {
         $get = Yii::$app->request->get();
@@ -980,7 +1021,7 @@ class ItemController extends BaseController
         $productList = [];
         if (!empty($list)) {
             foreach ($list as $key => $item) {
-                if(!empty($item)){
+                if (!empty($item)) {
                     $productList = array_merge($productList, $item);
                 }
             }

+ 31 - 9
app-hd/controllers/PurchaseController.php

@@ -36,6 +36,28 @@ class PurchaseController extends BaseController
 
     public $guestAccess = ['detail', 'ali-pay', 'get-ali-pay-code', 'wx-pay'];
 
+    //取消采购单 ssh 20250710
+    public function actionCancel()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $info = PurchaseClass::getById($id, true);
+        if (empty($info)) {
+            util::fail('没有找到采购单');
+        }
+        if (!isset($info->mainId) || $info->mainId != $this->mainId) {
+            util::fail('访问错误');
+        }
+        if ($info->status == 5) {
+            util::fail('已取消');
+        }
+        if ($info->status != 1) {
+            util::fail('不能取消');
+        }
+        PurchaseService::expire($info);
+        util::complete('已取消');
+    }
+
     //获取支付宝付款码 ssh 20240713
     public function actionGetAliPayCode()
     {
@@ -593,20 +615,20 @@ class PurchaseController extends BaseController
                     }
                 }
 
-                if(isset($ghsInfo['home'])){
-                    if($ghsInfo['home'] == 0){
+                if (isset($ghsInfo['home'])) {
+                    if ($ghsInfo['home'] == 0) {
                         util::fail('暂不支持送货上门,请选其它配送方式');
                     }
-                    if(!empty($ghsInfo['homeAmount'])){
-                        $homeType = $ghsInfo['homeType']??0;
+                    if (!empty($ghsInfo['homeAmount'])) {
+                        $homeType = $ghsInfo['homeType'] ?? 0;
                         $homeAmount = floatval($ghsInfo['homeAmount']);
-                        if($homeType == 0){
-                            if($homeAmount>$respond->actPrice){
+                        if ($homeType == 0) {
+                            if ($homeAmount > $respond->actPrice) {
                                 util::fail("满{$homeAmount}元 可送货上门");
                             }
                         }
-                        if($homeType == 1){
-                            if ($homeAmount>$respond->bigNum) {
+                        if ($homeType == 1) {
+                            if ($homeAmount > $respond->bigNum) {
                                 util::fail("满{$homeAmount}扎 可送货上门");
                             }
                         }
@@ -720,7 +742,7 @@ class PurchaseController extends BaseController
                 if (isset($cg->book) && $cg->book == 0) {
                     $ghsShopId = $ghs['shopId'] ?? 0;
                     if (getenv('YII_ENV') == 'production') {
-                        $specialList = [10649, 8042, 16454, 21319, 33668,42345];
+                        $specialList = [10649, 8042, 16454, 21319, 33668, 42345];
                     } else {
                         $specialList = [36523];
                     }

+ 5 - 27
app-pt/views/main/app.php

@@ -1,14 +1,3 @@
-<?php
-$host = $_SERVER['HTTP_HOST'];
-$xhbApi = substr($host, strpos($host, '.') + 1);
-if ($xhbApi == 'wixhb.com') {
-    $hhbApi = 'huahb.cn';
-    $title = '中花汇';
-} else {
-    $hhbApi = 'huaml.com';
-    $title = '测试';
-}
-?>
 <!DOCTYPE html>
 <html lang="en">
 <head>
@@ -16,38 +5,27 @@ if ($xhbApi == 'wixhb.com') {
     <meta name="viewport"
           content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
-    <title><?php echo $title; ?></title>
+    <title>app下载</title>
 </head>
 <body>
 <div style="text-align:center;margin-top:100px;">
     <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
-       href="https://api.shop.<?php echo $xhbApi; ?>/1235.apk">销花宝APP</a>
+       href="https://api.shop.hzghd.com/1235.apk">销花宝APP</a>
 </div>
 
 <div style="text-align:center;margin-top:30px;">
     <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
-       href="https://api.shop.<?php echo $hhbApi; ?>/192.apk">花掌柜APP</a>
+       href="https://api.shop.hzghd.com/192.apk">花掌柜APP</a>
 </div>
 <div style="text-align:center;margin-top:30px;">
     <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
 
-       href="https://api.shop.wixhb.com/pad180.apk">花掌柜收银</a>
+       href="https://api.shop.hzghd.com/pad181.apk">花掌柜收银</a>
 </div>
 <div style="text-align:center;margin-top:30px;">
     <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
 
-       href="https://api.shop.wixhb.com/pad141.apk">销花宝收银</a>
-</div>
-<div style="width:100%;text-align:center;margin-top:20px;">-----------------------------------------------------------------</div>
-<div style="text-align:center;margin-top:30px;">
-    <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
-
-       href="https://api.shop.wixhb.com/pad180.apk">花掌柜收银(最新版)</a>
-</div>
-<div style="text-align:center;margin-top:30px;">
-    <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
-
-       href="https://api.shop.wixhb.com/pad144.apk">销花宝收银(最新版)</a>
+       href="https://api.shop.hzghd.com/pad145.apk">销花宝收银</a>
 </div>
 </body>
 </html>

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

@@ -2238,6 +2238,12 @@ class OrderClass extends BaseClass
                 $recordData['relateName'] = $order->customName ?? '';
                 $recordData['ptStyle'] = dict::getDict('ptStyle', 'ghs');
                 StockRecordClass::addSellStockOrderCancelRecord($recordData);
+
+                //如果有限购数量占用,也需要清除
+                $customId = $order->customId ?? 0;
+                $num = floor($v['num']);
+                ProductClass::baseClearLimitBuy($v['productId'], $customId, $num);
+
             }
         }
         return $order;

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

@@ -2598,9 +2598,57 @@ class ProductClass extends BaseClass
         $arr = Yii::$app->redis->executeCommand('HKEYS', [$limitKey]);
         if (!empty($arr)) {
             foreach ($arr as $field) {
-                Yii::$app->redis->executeCommand('HDEL', [$limitKey, $field]);
+                self::baseClearLimitBuy($productId, $field);
             }
         }
     }
 
+    //$num -1 表示减全部,大于-1表示减值
+    public static function baseClearLimitBuy($productId, $customId, $num = -1)
+    {
+        $limitKey = 'limit_buy_' . $productId;
+        if ($num <= -1) {
+            //清掉全部
+            Yii::$app->redis->executeCommand('HDEL', [$limitKey, $customId]);
+        } else {
+            $hasNum = Yii::$app->redis->executeCommand('HGET', [$limitKey, $customId]);
+            $remainNum = $hasNum > $num ? bcsub($num, $hasNum) : 0;
+            $remainNum = floor($remainNum);
+            if ($remainNum > 0) {
+                Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $remainNum]);
+            } else {
+                Yii::$app->redis->executeCommand('HDEL', [$limitKey, $customId]);
+            }
+        }
+    }
+
+    public static function getHasLimitBuyList($product)
+    {
+        $productId = $product->id;
+        $limitBuy = $product->limitBuy ?? 0;
+        $limitKey = 'limit_buy_' . $productId;
+        $arr = Yii::$app->redis->executeCommand('HKEYS', [$limitKey]);
+        $customList = [];
+        if (!empty($arr)) {
+            $numMap = [];
+            $ids = [];
+            foreach ($arr as $customId) {
+                $num = Yii::$app->redis->executeCommand('HGET', [$limitKey, $customId]);
+                $numMap[$customId] = $num;
+                $ids[] = $customId;
+            }
+            $customList = CustomClass::getAllByCondition(['id' => ['in', $ids]], null, '*');
+            foreach ($customList as $key => $val) {
+                $customId = $val['id'];
+                $num = $numMap[$customId] ?? 0;
+                $customList[$key]['hasLimitBuyNum'] = $num;
+                $customList[$key]['hasReachLimitBuyNum'] = $num >= $limitBuy ? 1 : 0;
+                $avatar = $val['avatar'] ?? '';
+                $smallAvatar = imgUtil::groupImg($avatar);
+                $customList[$key]['smallAvatar'] = $smallAvatar . "?x-oss-process=image/resize,m_fill,h_80,w_80";
+            }
+        }
+        return $customList;
+    }
+
 }

+ 1 - 1
biz-hd/purchase/services/PurchaseService.php

@@ -182,7 +182,7 @@ class PurchaseService extends BaseService
     public static function expire($purchase)
     {
         if ($purchase->status != PurchaseClass::STATUS_UN_PAY) {
-            util::fail('不是待付款订单哦');
+            util::fail('不能取消');
         }
         //采购单失效
         $id = $purchase->id;