Преглед на файлове

Merge branch 'zhongqi-cancelPresell' of git.huaml.com:zhh/huahuibao into zhongqi-cancelPresell

shizhongqi преди 4 месеца
родител
ревизия
460fddf68f

+ 1 - 1
app-ghs/controllers/AuthController.php

@@ -45,7 +45,7 @@ class AuthController extends PublicController
         $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
         if (empty($sessionKey)) {
             Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
-            noticeUtil::push($cacheKey . " 登录失败!!sessionKey空的", '15280215347');
+            //noticeUtil::push($cacheKey . " 登录失败!!sessionKey空的", '15280215347');
             util::success(['hasNoOpenId' => 1], '登录失败。');
         }
         $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");

+ 3 - 3
app-ghs/controllers/ConsoleController.php

@@ -162,8 +162,8 @@ class ConsoleController extends BaseController
             $remainingSeconds = $deadTime - $currentTime;
             $remainingDays = ceil($remainingSeconds / 86400);
             
-            // 25天 = 2160000秒
-            if ($remainingSeconds <= 2160000) {
+            // 到期前7天提醒
+            if ($remainingSeconds <= 604800) {
                 if ($remainingSeconds <= 0) {
                     $notice[] = ['title' => '系统已到期', 'action' => '续费', 'page' => '/admin/shop/renew'];
                 } else {
@@ -172,7 +172,7 @@ class ConsoleController extends BaseController
             }
         }
 
-        //$notice[] = ['title' => '请勿咨询共享股东功能,有没有用,太多人问', 'action' => '', 'page' => ''];
+        //$notice[] = ['title' => '因批发店越来越多,有问题优先在自己的群、官方群反馈。除非涉及隐私,直接发消息给小石将减少回应,直到没有回应,请谅解。', 'action' => '', 'page' => ''];
         //$notice[] = ['title' => '新功能:客户端和后台使用跑腿的流程', 'action' => '', 'page' => '/admin/book/detail?id=use_pt'];
 
         $mainId = $this->mainId;

+ 26 - 8
app-ghs/controllers/ProductController.php

@@ -16,6 +16,7 @@ use bizGhs\item\classes\ItemClassClass;
 use bizGhs\item\classes\UnitChangeClass;
 use bizGhs\merchant\classes\ShopClass;
 use bizGhs\notify\classes\NotifyClass;
+use bizGhs\order\classes\CheckOrderClass;
 use bizGhs\order\classes\PurchaseOrderClass;
 use bizGhs\product\classes\ProductClass;
 use bizGhs\product\models\Product;
@@ -90,14 +91,31 @@ class ProductController extends BaseController
     {
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
+        $clearStock = $get['clearStock'] ?? -1;
+        if($clearStock == -1){
+            util::fail('请选择是否清库存');
+        }
         $info = ProductClass::getById($id, true);
         ProductClass::check($info, $this->mainId);
-        if ($info->stock > 0) {
-            util::fail('没有库存才能停止预售');
-        }
         $info->presell = 0;
         $info->presellDate = '';
         $info->save();
+
+        if ($clearStock == 1) {
+            // 清库存,参考项目里的盘点功能,盘点成0
+            $staff = $this->shopAdmin;
+            $modifyData = [
+                'remark' => '停止预售清库存',
+                'sjId' => $this->sjId,
+                'shopId' => $this->shopId,
+                'adminId' => $this->adminId,
+                'mainId' => $this->mainId,
+                'staffName' => $staff->name ?? '',
+                'itemInfo' => [['productId' => $id, 'bigNum' => 0, 'smallNum' => 0]],
+            ];
+            CheckOrderClass::opOrder($modifyData, false, false);
+        }
+
         util::complete();
     }
 
@@ -219,7 +237,7 @@ class ProductController extends BaseController
         }
         $p->times = $num;
 
-        if($priceOption == 2){
+        if ($priceOption == 2) {
             // 每7个汉字截取一次(支持汉字、字母、数字混合),多处需要同步修改,关键词 label_print_substr
             $content = '';
             $len = mb_strlen($name, 'UTF-8');
@@ -227,11 +245,11 @@ class ProductController extends BaseController
             $u = 0;
             for ($i = 0; $i < $len; $i += 6) {
                 $currentName = mb_substr($name, $i, 6, 'UTF-8');
-                $number = $baseNum + 90*$u;
+                $number = $baseNum + 90 * $u;
                 $u++;
                 $content .= '<TEXT x="10" y="' . $number . '" font="12" w="3" h="3" r="0">' . $currentName . '</TEXT>';
             }
-        }else{
+        } else {
             if (stringUtil::getWordNum($name) > 8) {
                 $content = '<TEXT x="30" y="30" font="12" w="1" h="1" r="0">' . $name . '</TEXT>';
             } else {
@@ -240,7 +258,7 @@ class ProductController extends BaseController
         }
 
         if ($type == 0) {
-            if($priceOption != 2) {
+            if ($priceOption != 2) {
                 //打标签
                 $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">' . $ptItemId . '</BC128>';
                 if (in_array($mainId, [52, 1459])) {
@@ -357,7 +375,7 @@ class ProductController extends BaseController
                 $where['name'] = ['like', $name];
             }
         }
-        if($requestType == 'hideItem'){
+        if ($requestType == 'hideItem') {
             $where['frontHide'] = 1;
         }
         //客户等级

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

@@ -59,7 +59,7 @@ class TestController extends BaseController
         $ghsShopId = 7855;
         $ghsShop = ShopClass::getById($ghsShopId, true);
         if (empty($ghsShop)) {
-            util::fail('没有找到供货商门店');
+            util::fail('没有找到供货商门店');
         }
         $refundFee = bcmul(64, 100);
         $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';

+ 2 - 2
app-hd/controllers/PurchaseController.php

@@ -647,7 +647,7 @@ class PurchaseController extends BaseController
                         // 按当天计时,把 sendTimeWant 要限制在两天的时间范围之内
                         $future = date("Y-m-d", strtotime('+2 day'));
                         if (strtotime($respond->sendTimeWant) > strtotime($future)) {
-                            util::fail('配货日期要在两天之内');
+                            util::fail('配送日期只能选最近二天');
                         }
                     }
 
@@ -684,7 +684,7 @@ class PurchaseController extends BaseController
                         // 按当天计时,把 sendTimeWant 要限制在两天的时间范围之内
                         $future = date("Y-m-d", strtotime('+2 day'));
                         if (strtotime($respond->sendTimeWant) > strtotime($future)) {
-                            util::fail('配送日期要在两天之内');
+                            util::fail('配送日期只能选最近二天');
                         }
                     }
                 }

+ 2 - 2
app-mall/controllers/ItemController.php

@@ -153,8 +153,8 @@ class ItemController extends BaseController
             $where['status'] = $status;
         }
         $where['delStatus'] = $delStatus;
-        //商城端没有隐藏
-        $where['frontHide'] = 0;
+        //批发端没有隐藏
+        //$where['frontHide'] = 0;
         //零售端没有隐藏
         $where['frontUse'] = 0;
         $level = 0;

+ 1 - 1
app-pt/controllers/WxController.php

@@ -185,7 +185,7 @@ class WxController extends PublicController
                     //关注
                     case 'subscribe':
 
-                        noticeUtil::push('批发端新关注者openId:' . $this->fromUsername, '15280215347');
+                        //noticeUtil::push('批发端新关注者openId:' . $this->fromUsername, '15280215347');
 
                         $text = $this->replyTextContent("{$this->fromUsername}");
                         $pc = new \WXBizMsgCrypt($openToken, $encodingAesKey, $openAppId);

+ 33 - 18
biz-ghs/order/classes/OrderClass.php

@@ -1510,8 +1510,8 @@ class OrderClass extends BaseClass
         if ($showPrice == 1) {
             if (floatval($unitPrice) == 0.01) {
                 $content .= $productNum . ' = ' . $productPrice . '元 赠送价<BR>';
-            }else{
-                $content .= $productNum . ' = ' . $productPrice . '元  ' . ($ratioType==0 ? $ratio.'支装' : ($ratioType==1 ? '若干支装' : '')) . '<BR>';
+            } else {
+                $content .= $productNum . ' = ' . $productPrice . '元  ' . ($ratioType == 0 ? $ratio . '支装' : ($ratioType == 1 ? '若干支装' : '')) . '<BR>';
             }
         }
         $content .= '--------------------------------<BR>';
@@ -1891,7 +1891,7 @@ class OrderClass extends BaseClass
         /**************************如果是好多花的云仓还要再打一下标签纸,多处要同步修改,关键词 hdh_yc *****************************/
         $orderMainId = $orderInfo['mainId'] ?? 0;
         if (getenv('YII_ENV') == 'production') {
-            $map = [65726, 58];
+            $map = [65726, 58, 25119];
         } else {
             $map = [828];
         }
@@ -2127,7 +2127,7 @@ class OrderClass extends BaseClass
                         'num' => floatval($bigNum) . $xhUnitName . ' * ' . floatval($bigUnitPrice) . '元',
                         'count' => floatval($bigNum) . $xhUnitName,
                         'price' => floatval($bigTotalPrice),
-                        'unitPrice'=>floatval($bigUnitPrice),
+                        'unitPrice' => floatval($bigUnitPrice),
                         'refundNum' => $refundNum,
                         'unitName' => $xhUnitName,
                         'itemNum' => $bigNum,
@@ -2143,7 +2143,7 @@ class OrderClass extends BaseClass
                         'num' => floatval($smallNum) . '支 * ' . floatval($smallUnitPrice) . '元',
                         'count' => floatval($smallNum) . '支',
                         'price' => floatval($smallTotalPrice),
-                        'unitPrice'=>floatval($smallUnitPrice),
+                        'unitPrice' => floatval($smallUnitPrice),
                         'refundNum' => $refundNum,
                         'unitName' => '支',
                         'itemNum' => $smallNum,
@@ -2156,7 +2156,7 @@ class OrderClass extends BaseClass
                         'num' => floatval($giveNum) . $xhUnitName . ' * 0元',
                         'count' => floatval($giveNum) . $xhUnitName,
                         'price' => 0,
-                        'unitPrice'=>0,
+                        'unitPrice' => 0,
                         'unitName' => $xhUnitName,
                         'itemNum' => $giveNum,
                         'remark' => $remark,
@@ -2944,7 +2944,7 @@ XL;
         /**************************如果是好多花的云仓还要再打一下标签纸,多处要同步修改,关键词 hdh_yc *****************************/
         $orderMainId = $order->mainId;
         if (getenv('YII_ENV') == 'production') {
-            $map = [65726, 58];
+            $map = [65726, 58, 25119];
         } else {
             $map = [828];
         }
@@ -3003,13 +3003,24 @@ XL;
                 util::fail('客户短名没有设置');
             }
             $p->times = 1;
-            $content = '<TEXT x="420" y="130" font="12" w="4" h="4" r="90">' . $shortName . '</TEXT>';
-            $content .= '<TEXT x="395" y="10" font="12" w="2" h="2" r="90">地址</TEXT>';
-            $content .= '<TEXT x="290" y="130" font="12" w="3" h="3" r="90">' . $customMobile . '</TEXT>';
-            $content .= '<TEXT x="265" y="10" font="12" w="2" h="2" r="90">号码</TEXT>';
-            $content .= '<TEXT x="170" y="130" font="12" w="4" h="4" r="90">' . $wlName . '</TEXT>';
-            $content .= '<TEXT x="150" y="10" font="12" w="2" h="2" r="90">物流</TEXT>';
-            $content .= '<TEXT x="45" y="70" font="12" w="2" h="2" r="90">' . $currentName . ' ' . $telephone . '</TEXT>';
+            //安庆三叶鲜花批发,比较特殊
+            if ($orderMainId == 2071) {
+                $content = '<TEXT x="386" y="120" font="12" w="4" h="4" r="90">' . $shortName . '</TEXT>';
+                $content .= '<TEXT x="363" y="10" font="12" w="2" h="2" r="90">地址</TEXT>';
+                $content .= '<TEXT x="270" y="120" font="12" w="3" h="3" r="90">' . $customMobile . '</TEXT>';
+                $content .= '<TEXT x="256" y="10" font="12" w="2" h="2" r="90">号码</TEXT>';
+                $content .= '<TEXT x="182" y="120" font="12" w="4" h="4" r="90">' . $wlName . '</TEXT>';
+                $content .= '<TEXT x="158" y="10" font="12" w="2" h="2" r="90">物流</TEXT>';
+                $content .= '<TEXT x="65" y="35" font="12" w="2" h="2" r="90">' . $currentName . ' ' . $telephone . '</TEXT>';
+            }else{
+                $content = '<TEXT x="420" y="130" font="12" w="4" h="4" r="90">' . $shortName . '</TEXT>';
+                $content .= '<TEXT x="395" y="10" font="12" w="2" h="2" r="90">地址</TEXT>';
+                $content .= '<TEXT x="290" y="130" font="12" w="3" h="3" r="90">' . $customMobile . '</TEXT>';
+                $content .= '<TEXT x="265" y="10" font="12" w="2" h="2" r="90">号码</TEXT>';
+                $content .= '<TEXT x="170" y="130" font="12" w="4" h="4" r="90">' . $wlName . '</TEXT>';
+                $content .= '<TEXT x="150" y="10" font="12" w="2" h="2" r="90">物流</TEXT>';
+                $content .= '<TEXT x="45" y="70" font="12" w="2" h="2" r="90">' . $currentName . ' ' . $telephone . '</TEXT>';
+            }
         } else {
             /**************************如果是好多花的云仓还要再打一下标签纸,多处要同步修改,关键词 hdh_yc *****************************/
             $sameTimeIds = $order->sameTimeIds;
@@ -3023,10 +3034,14 @@ XL;
             if ($num > 1) {
                 $customName = $customName . ' ' . $num . '单';
             }
-            $content = '<TEXT x="405" y="30" font="12" w="4" h="4" r="90">' . $shortName . '</TEXT>';
-            $content .= '<TEXT x="285" y="30" font="12" w="2" h="3" r="90">' . $customName . '</TEXT>';
-            $content .= '<TEXT x="190" y="30" font="12" w="1" h="2" r="90">' . $fullAddress . '</TEXT>';
-            $content .= '<TEXT x="120" y="30" font="12" w="2" h="2" r="90">' . $customMobile . '</TEXT>';
+            $content = '<TEXT x="400" y="30" font="12" w="4" h="4" r="90">' . $shortName . '</TEXT>';
+            $content .= '<TEXT x="290" y="30" font="12" w="2" h="3" r="90">' . $customName . '</TEXT>';
+            $content .= '<TEXT x="195" y="30" font="12" w="1" h="2" r="90">' . $fullAddress . '</TEXT>';
+            $content .= '<TEXT x="128" y="30" font="12" w="2" h="2" r="90">' . $customMobile . '</TEXT>';
+            //福州易批花,不仅要自动打印,还要打印出物流名称
+            if ($orderMainId == 25119) {
+                $content .= '<TEXT x="70" y="30" font="12" w="2" h="2" r="90">物流 ' . $wlName . '</TEXT>';
+            }
             /**************************如果是好多花的云仓还要再打一下标签纸,多处要同步修改,关键词 hdh_yc *****************************/
         }
         $p->printLabelMsg($content);

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

@@ -1072,7 +1072,7 @@ class ProductClass extends BaseClass
             self::updateStockById($productId, 6850);
         }
 
-        //库存=0 下架商品,特价去掉,限购去掉 lqh 2021.7.9 ssh 20251106
+        //库存=0 下架商品,特价去掉,限购去掉 lqh 2021.7.9 ssh 20251106 花材满减去掉 20260318
         if ($newStock <= 0) {
             self::changeStatus($productId, 2);
         }
@@ -2642,6 +2642,9 @@ class ProductClass extends BaseClass
             $data['skDiscountPrice'] = 0;
             //限购记录也取消
             self::cancelLimitBuy($productId);
+            //花材满减去掉 ssh 20260318
+            $data['reachNum'] = 0;
+            $data['reachNumDiscount'] = 0;
         }
         return self::updateById($productId, $data);
     }

+ 2 - 2
biz-hd/custom/observers/BuyAmountObserver.php

@@ -96,7 +96,7 @@ class BuyAmountObserver extends Behavior
 		    'shopId' => $shopId,
 			'userId' => $userId,
 			'userName' => $userName,
-			'event' => $eventRemark !== '' ? $eventRemark . ',成长值同步变更' : '累计消费变更同步成长值',
+			'event' => $eventRemark !== '' ? $eventRemark : '累计消费变更同步成长值',
 			'relateId' => $relateId,
 			'relateType' => $relateType,
 			'num' => $buyAmountDelta,
@@ -112,7 +112,7 @@ class BuyAmountObserver extends Behavior
             'shopId' => $shopId,
 			'userId' => $userId,
 			'userName' => $userName,
-			'event' => $eventRemark !== '' ? $eventRemark . ',积分同步变更' : '累计消费变更同步积分',
+			'event' => $eventRemark !== '' ? $eventRemark : '累计消费变更同步积分',
 			'relateId' => $relateId,
 			'relateType' => $relateType,
 			'num' => $buyAmountDelta,

+ 30 - 13
console/controllers/CustomController.php

@@ -109,7 +109,7 @@ class CustomController extends Controller
     //每天凌晨3点35分执行,取出所有 lunar==1 的 且 birthdayTime 小于当前时间的客户,然后把他们的阴历转阳历,然后更新他们的 birthdayTime
     public function actionUpdateBirthday()
     {
-        try{
+        try {
             $calendar = new Calendar();
             $customList = CustomClass::getAllByCondition(['lunar' => 1, 'birthdayTime<' => time()], null, 'id, userId, birthday, birthdayTime, birthdayMonth, birthdayDate', null, true);
             foreach ($customList as $custom) {
@@ -140,8 +140,8 @@ class CustomController extends Controller
                 ]);
             }
             Yii::info('阴历转阳历脚本成功执行');
-        }catch(\Exception $e){
-            Yii::error('阴历转阳历脚本执行失败,原因:'.$e->getMessage());
+        } catch (\Exception $e) {
+            Yii::error('阴历转阳历脚本执行失败,原因:' . $e->getMessage());
         }
     }
 
@@ -152,14 +152,28 @@ class CustomController extends Controller
         ini_set('memory_limit', '2045M');
         set_time_limit(0);
 
-        try{
-            // 1. 查询 xhShop 表,获取所有 ptStyle = 1 的门店数据
-            $allShops = \bizHd\shop\classes\ShopClass::getAllByCondition(['ptStyle'=>1, 'status'=>1], 'id ASC', 'id, mainId');
-            // 2. 把每个门店下的所有用户进行遍历,刷新他们的累计消费和成长值、积分
+        $redisKey = 'refresh_custom_data_processed_shops';
+
+        // 1. 查询 xhShop 表,获取所有 ptStyle = 1 的门店数据,每次取出500个进行处理
+        $query = \bizHd\shop\models\Shop::find()
+            ->select('id, mainId')
+            ->where(['ptStyle' => 1])
+            ->orderBy('id DESC')
+            ->asArray();
+
+        // 2. 把每个门店下的所有用户进行遍历,刷新他们的累计消费和成长值、积分
+        foreach ($query->batch(500) as $allShops) {
             if (!empty($allShops)) {
                 foreach ($allShops as $shop) {
                     $shopId = $shop['id'];
                     $mainId = $shop['mainId'];
+
+                    // 判断是否已经执行过,执行过则跳过
+                    $hasProcessed = Yii::$app->redis->executeCommand('SISMEMBER', [$redisKey, $shopId]);
+                    if ($hasProcessed) {
+                        continue;
+                    }
+
                     $customs = CustomClass::getAllByCondition(['shopId' => $shopId], null, 'id, userId, buyAmount, growth, member, memberName', null, true);
                     $levelDatas = MemberLevelClass::getAllByCondition(['mainId' => $mainId], 'amount DESC', 'id, name, level, amount');
                     if (!empty($customs) && !empty($levelDatas)) {
@@ -174,7 +188,7 @@ class CustomController extends Controller
                                     } elseif ($order['forward'] == 1) { //1 售后付款单(红冲)
                                         $buyAmount = bcsub($buyAmount, $order['actPrice'], 2);
                                     } else {
-                                        Yii::info('订单类型不存在,订单ID:'.$order['id']);
+                                        Yii::info('订单类型不存在,订单ID:' . $order['id']);
                                         continue;
                                     }
                                 }
@@ -191,16 +205,19 @@ class CustomController extends Controller
                             $c->save();
 
                             // 更新客户所对应花店的消费金额
-                            HdClass::updateByCondition(['shopId'=>$shopId, 'userId'=>$c->userId], ['expendAmount'=>$buyAmount]);
+                            HdClass::updateByCondition(['shopId' => $shopId, 'userId' => $c->userId], ['expendAmount' => $buyAmount]);
                         }
                     }
+
+                    // 记录该 shopId 已经执行完成
+                    Yii::$app->redis->executeCommand('SADD', [$redisKey, $shopId]);
                 }
             }
-
-            Yii::info('客户的累计消费和成长值、积分刷新脚本成功执行');
-        }catch(\Exception $e){
-            Yii::error('客户的累计消费和成长值、积分刷新脚本执行失败,原因:'.$e->getMessage());
         }
+
+        // 脚本执行完之后,清除缓存
+        Yii::$app->redis->executeCommand('DEL', [$redisKey]);
+
     }
 
     //批量创建客户

+ 33 - 0
console/controllers/TestController.php

@@ -29,6 +29,7 @@ use bizHd\purchase\classes\PurchaseClass;
 use bizHd\purchase\models\Purchase;
 use bizHd\saas\classes\StaffClass;
 use bizHd\user\classes\UserClass;
+use bizHd\user\models\User;
 use bizMall\hd\classes\HdClass;
 use common\components\stringUtil;
 use common\components\util;
@@ -39,6 +40,38 @@ use yii\console\Controller;
 class TestController extends Controller
 {
 
+    public function actionUpdateCustom()
+    {
+
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        $query = User::find()
+            ->select('id, mobile')
+            ->orderBy('id DESC')
+            ->asArray();
+
+        foreach ($query->batch(1000) as $allUser) {
+            if (!empty($allUser)) {
+                foreach ($allUser as $user) {
+                    $userId = $user['id'];
+                    $mobile = $user['mobile'];
+                    $customList = CustomClass::getAllByCondition(['userId' => $userId], null, 'id,mobile,userId');
+                    if (!empty($customList)) {
+                        foreach ($customList as $custom) {
+                            $customId = $custom['id'];
+                            $userMobile = $custom['mobile'];
+                            if (!empty($userMobile) && $userMobile != $mobile) {
+                                echo $userId . ' ' . $customId . ' ' . $mobile . "\n";
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+    }
+
     public function actionStaff()
     {
         ini_set('memory_limit', '2045M');