shish 4 anni fa
parent
commit
dbd56c7f81

+ 2 - 0
biz/recharge/classes/RechargeClass.php

@@ -110,6 +110,8 @@ class RechargeClass extends BaseClass
         $ghsId = isset($ghsId) ? $ghsId : 0;
         //处理充值成功的流程
         self::complete($recharge, $payWay, $rechargeRenew, $ghsId);
+
+        return $recharge;
     }
 
 }

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

@@ -4,6 +4,7 @@ namespace biz\wx\classes;
 
 use biz\base\classes\BaseClass;
 use biz\shop\classes\ShopAdminClass;
+use biz\shop\classes\ShopClass;
 use common\components\dict;
 use common\components\noticeUtil;
 use common\components\util;
@@ -653,4 +654,48 @@ class WxMessageClass extends BaseClass
         }
     }
 
+    //客户充值通知供应商 shish 20211005
+    public static function customRechargeInformGhs($recharge, $hbInfo)
+    {
+        $amount = $recharge->amount ?? 0;
+        $shopId = $hbInfo->ghsShopId ?? 0;
+        $customName = $hbInfo->customName ?? '';
+        $customId = $hbInfo->customId ?? 0;
+        $shopInfo = ShopClass::getById($shopId, true);
+        $ptStyle = $shopInfo->ptStyle ?? 0;
+        $wxBase = WxOpenClass::getWxBase();
+        $wx = $wxBase[$ptStyle] ?? [];
+        $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
+        $shortTempId = 'OPENTM411530050';
+        $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
+        if (empty($tempId)) {
+            return false;
+        }
+        $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
+        foreach ($adminList as $admin) {
+            $openId = isset($admin['openId']) ? $admin['openId'] : '';
+            if (empty($openId)) {
+                continue;
+            }
+            $data = [
+                "touser" => $openId,
+                "template_id" => $tempId,
+                "url" => Yii::$app->params['ghsDomain'],
+                "data" => [
+                    "first" => ["value" => "有新客户充值", "color" => "#173177"],
+                    "keyword1" => ["value" => $customName, "color" => "#173177"],
+                    "keyword2" => ["value" => $customId, "color" => "#D52B4D"],
+                    "keyword3" => ["value" => $amount, "color" => "#173177"],
+                    "remark" => ["value" => '点击查看详情', "color" => "#173177"]
+                ]
+            ];
+            $data['miniprogram']['appid'] = $wx['miniAppId'];
+            $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
+            wxUtil::sendTaskInform($data, $wx, $ptStyle);
+        }
+    }
+
 }

+ 32 - 27
common/components/payUtil.php

@@ -2,9 +2,11 @@
 
 namespace common\components;
 
+use biz\hb\classes\HbClass;
 use biz\recharge\classes\RechargeClass;
 use biz\renew\classes\RenewClass;
 use biz\shop\classes\ShopExtClass;
+use biz\wx\classes\WxMessageClass;
 use bizHd\order\classes\OrderClass;
 use bizHd\purchase\classes\PurchaseClearClass;
 use bizHd\purchase\services\PurchaseService;
@@ -17,71 +19,74 @@ class payUtil
 
     public static function thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId = '')
     {
-
         //3秒内不允许第三方重复通知
         $cacheKey = 'third_pay_' . $orderSn;
         $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
         if (!empty($has)) {
-            Yii::info("第三方3秒内重复通知:{$capitalType} {$orderSn}");
-            noticeUtil::push("第三方支付回调,3秒内重复通知:{$capitalType} {$orderSn}", '15280215347');
+            Yii::info("支付回调短时间内出现重复通知,流水类型:{$capitalType} orderSn:{$orderSn}");
+            noticeUtil::push("支付回调短时间内出现重复通知:流水类型:{$capitalType} orderSn:{$orderSn}", '15280215347');
             return false;
         }
         Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 3, 'has']);
 
-
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-
             //流水类型列表
             switch ($capitalType) {
                 case dict::getDict('capitalType', 'xhRecharge', 'id'):
                     //商家充值
-                    RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                    $currentRecharge = RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                    $transaction->commit();
+                    //有发红包的通知供货商
+                    $hbId = $currentRecharge->hbId ?? 0;
+                    if (empty($hbId)) {
+                        return false;
+                    }
+                    $hbInfo = HbClass::getById($hbId, true);
+                    WxMessageClass::customRechargeInformGhs($currentRecharge, $hbInfo);
                     break;
                 case dict::getDict('capitalType', 'xhPurchase', 'id'):
                     //零售采购
                     PurchaseService::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
+                    $transaction->commit();
                     break;
                 case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
                     //零售结帐
                     PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                    $transaction->commit();
                     break;
                 case dict::getDict('capitalType', 'xhOrder', 'id'):
                     //花粉下单
                     OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                    $transaction->commit();
+                    //收款声音播放 shish 202010726
+                    $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
+                    if (isset($order->fromType) && $order->fromType == dict::getDict("fromType", "shop")) {
+                        $shopId = $order->shopId ?? 0;
+                        $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+                        if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
+                            $actPrice = floatval($order->actPrice) ?? 0;
+                            $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
+                            $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元" : "支付宝收款{$actPrice}元";
+                            $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version=3&message=" . $sound;
+                            $curl = new curl\Curl();
+                            $curl->get($url);
+                        }
+                    }
                     break;
                 case dict::getDict('capitalType', 'xhRenew', 'id'):
                     //商家续期
                     RenewClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                    $transaction->commit();
                     break;
                 case dict::getDict('capitalType', 'pxApply', 'id'):
                     //培训报名
                     PxApplyService::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                    $transaction->commit();
                     break;
                 default:
             }
-
-            $transaction->commit();
-
-            //收款声音播放 shish 202010726
-            if ($capitalType == dict::getDict('capitalType', 'xhOrder', 'id')) {
-                $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
-                if (isset($order->fromType) && $order->fromType == dict::getDict("fromType", "shop")) {
-                    $shopId = $order->shopId ?? 0;
-                    $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
-                    if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
-                        $actPrice = floatval($order->actPrice) ?? 0;
-                        $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
-                        $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元" : "支付宝收款{$actPrice}元";
-                        $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version=3&message=" . $sound;
-                        $curl = new curl\Curl();
-                        $curl->get($url);
-                    }
-                }
-            }
-
-
         } catch
         (Exception $exception) {
             $transaction->rollBack();