Browse Source

重复问题

shish 11 months ago
parent
commit
c6be0590ed
2 changed files with 65 additions and 16 deletions
  1. 44 16
      app-mall/controllers/NoticeController.php
  2. 21 0
      biz/shop/classes/ShopExtClass.php

+ 44 - 16
app-mall/controllers/NoticeController.php

@@ -5,6 +5,7 @@ namespace mall\controllers;
 use biz\shop\classes\ShopClass;
 use biz\wx\classes\WxMessageClass;
 use bizHd\order\classes\OrderClass;
+use bizHd\order\classes\ScanPayClass;
 use bizHd\refund\classes\HdRefundClass;
 use bizHd\wx\classes\WxOpenClass;
 use common\components\noticeUtil;
@@ -180,6 +181,15 @@ class NoticeController extends PublicController
                     ShopExtClass::newWorkRemind($shopExt, $order);
                 }
             }
+            if ($capitalType == dict::getDict('capitalType', 'scanPay', 'id')) {
+                $myKey = 'mall_order_scan_pay_' . $orderSn;
+                $has = Yii::$app->redis->executeCommand('GET', [$myKey]);
+                if (empty($has)) {
+                    Yii::$app->redis->executeCommand('SETEX', [$myKey, 864000, 'has']);
+                    $scan = ScanPayClass::getByCondition(['orderSn' => $orderSn], true);
+                    ShopExtClass::hdScanPayReport($scan);
+                }
+            }
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::error("失败原因:" . $e->getMessage());
@@ -455,23 +465,41 @@ class NoticeController extends PublicController
                 payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
                 $transaction->commit();
 
-                //打印小票和语音播报
-                $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
-                if (!empty($order)) {
-                    $order->thirdLogNo = $thirdLogNo;
-                    $order->save();
-                    ShopExtClass::hdGatheringReport($order);
-                    OrderClass::onlinePrint($order);
-
-                    $shopId = $order->shopId ?? 0;
-                    $shop = ShopClass::getById($shopId, true);
-                    if (in_array($order->fromType, [dict::getDict("fromType", "shop"), dict::getDict("fromType", "friend")])) {
-                        //您有新的收入提醒
-                        WxMessageClass::gatheringIncomeInform($shop, $order);
+                if ($capitalType == dict::getDict('capitalType', 'xhOrder', 'id')) {
+                    //避免重复
+                    $cacheKey = 'mall_order_pay_' . $orderSn;
+                    $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+                    if (empty($has)) {
+                        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 864000, 'has']);
+                        //打印小票和语音播报
+                        $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
+                        if (!empty($order)) {
+                            $order->thirdLogNo = $thirdLogNo;
+                            $order->save();
+                            ShopExtClass::hdGatheringReport($order);
+                            OrderClass::onlinePrint($order);
+
+                            $shopId = $order->shopId ?? 0;
+                            $shop = ShopClass::getById($shopId, true);
+                            if (in_array($order->fromType, [dict::getDict("fromType", "shop"), dict::getDict("fromType", "friend")])) {
+                                //您有新的收入提醒
+                                WxMessageClass::gatheringIncomeInform($shop, $order);
+                            }
+                            if ($order->fromType == dict::getDict("fromType", "mall")) {
+                                //来自商城的新订单微信通知
+                                WxMessageClass::hdNewOrderInform($shop, $order);
+                            }
+                        }
                     }
-                    if ($order->fromType == dict::getDict("fromType", "mall")) {
-                        //来自商城的新订单微信通知
-                        WxMessageClass::hdNewOrderInform($shop, $order);
+                }
+                if ($capitalType == dict::getDict('capitalType', 'scanPay', 'id')) {
+                    //避免重复
+                    $myKey = 'mall_order_scan_pay_' . $orderSn;
+                    $has = Yii::$app->redis->executeCommand('GET', [$myKey]);
+                    if (empty($has)) {
+                        Yii::$app->redis->executeCommand('SETEX', [$myKey, 864000, 'has']);
+                        $scan = ScanPayClass::getByCondition(['orderSn' => $orderSn], true);
+                        ShopExtClass::hdScanPayReport($scan);
                     }
                 }
             }

+ 21 - 0
biz/shop/classes/ShopExtClass.php

@@ -307,6 +307,27 @@ class ShopExtClass extends BaseClass
         }
     }
 
+    public static function hdScanPayReport($order)
+    {
+        if (empty($ordor)) {
+            return false;
+        }
+        if ($order->payStatus != 1) {
+            //还没有付款订单不播报
+            return false;
+        }
+        $shopId = $order->shopId ?? 0;
+        $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        if (!empty($shopExt->lbSn)) {
+            $actPrice = $order->actPrice ?? 0;
+            $payWay = $order->payWay ?? 0;
+            $sound = $payWay == 0 ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临";
+            $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
+            $curl = new curl\Curl();
+            $curl->get($url);
+        }
+    }
+
     //供货商收款声音播放 ssh 20230421
     public static function ghsGatheringReport($order)
     {