shish 4 роки тому
батько
коміт
c9c4b78120

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

@@ -152,7 +152,7 @@ class RechargeController extends BaseController
             util::fail('充值金额有问题');
         }
         if ($this->sj->parentShopId != $ghsShopId) {
-            util::fail('无法充值,请找第一个邀请您的供应商');
+            util::fail('不能充值,请找第一个邀请您的供应商');
         }
 
         $wxPay = dict::getDict('payWay', 'wxPay');
@@ -174,7 +174,7 @@ class RechargeController extends BaseController
             'totalHb' => $hbInfo->totalHb,
             'valid' => $hbInfo->valid,
             'miniExpend' => $hbInfo->miniExpend,
-            'ffHbGhsId' => $ghsId,
+            'ghsId' => $ghsId,
         ];
         $order = RechargeClass::addOrder($data, true);
         $orderSn = $order->orderSn;

+ 15 - 15
biz/recharge/classes/RechargeClass.php

@@ -60,23 +60,23 @@ class RechargeClass extends BaseClass
         $fix = false;
 
         //免费续期功能暂时关闭
-        /**
-        if ($rechargeRenew == 1) {
-            $sjId = $recharge->sjId;
-            SjClass::renewOneYear($sjId, 2, ['amount' => $recharge->amount, 'orderSn' => $orderSn]);
-            $fix = true;
-
-            if (!empty($ghsId)) {
-                $ghs = GhsClass::getById($ghsId);
-                $ghsName = $ghs['name'] ?? '';
-                $customName = $shop->shopName ?? '';
-                noticeUtil::push("客户[{$customName}]在供应商[{$ghsName}]充值花款{$recharge->amount}元,免费续期一年", '15280215347');
-            }
-        }
-        **/
+
+//        if ($rechargeRenew == 1) {
+//            $sjId = $recharge->sjId;
+//            SjClass::renewOneYear($sjId, 2, ['amount' => $recharge->amount, 'orderSn' => $orderSn]);
+//            $fix = true;
+//
+//            if (!empty($ghsId)) {
+//                $ghs = GhsClass::getById($ghsId);
+//                $ghsName = $ghs['name'] ?? '';
+//                $customName = $shop->shopName ?? '';
+//                noticeUtil::push("客户[{$customName}]在供应商[{$ghsName}]充值花款{$recharge->amount}元,免费续期一年", '15280215347');
+//            }
+//        }
+
 
         //充值送红包
-        if($recharge->sjStyle == SjClass::STYLE_RETAIL && !empty($recharge->ffHbGhsId)) {
+        if ($recharge->sjStyle == SjClass::STYLE_RETAIL && !empty($recharge->ghsId)) {
             ShopCouponClass::giveCoupon($recharge);
         }
 

+ 35 - 1
biz/shop/classes/ShopCouponClass.php

@@ -4,6 +4,7 @@ namespace biz\shop\classes;
 
 use biz\base\classes\BaseClass;
 use biz\ghs\classes\GhsClass;
+use bizGhs\custom\classes\CustomClass;
 use common\components\noticeUtil;
 use common\components\util;
 
@@ -43,6 +44,7 @@ class ShopCouponClass extends BaseClass
         ]
     ];
 
+    //发放红包 shish 20211002
     public static function giveCoupon($recharge)
     {
         $sjId = $recharge->sjId ?? 0;
@@ -58,6 +60,28 @@ class ShopCouponClass extends BaseClass
             noticeUtil::push("充值成功但红包没有发放成功,数量:{$hbNum} 金额:{$amount} id:{$rechargeId}", '15280215347');
             return false;
         }
+
+        $ghs = GhsClass::getById($ghsId, true);
+        if (empty($ghs)) {
+            noticeUtil::push("充值成功但红包没有发放成功,没有找到供货商,数量:{$hbNum} 金额:{$amount} id:{$rechargeId}", '15280215347');
+            return false;
+        }
+        $ghsName = $ghs->name ?? '';
+        $ghsAvatar = $ghs->avatar ?? '';
+        $ghsSjId = $ghs->sjId ?? 0;
+        $ghsShopId = $ghs->shopId ?? 0;
+        $customId = $ghs->customId ?? 0;
+        $custom = CustomClass::getById($customId, true);
+        if (empty($custom)) {
+            noticeUtil::push("充值成功但红包没有发放成功,没有找到客户,数量:{$hbNum} 金额:{$amount} id:{$rechargeId}", '15280215347');
+            return false;
+        }
+        $customName = $custom->name ?? '';
+        $customPy = $custom->py ?? '';
+        $customAvatar = $custom->avatar ?? '';
+        $customSjId = $custom->sjId ?? 0;
+        $customShopId = $custom->shopId ?? 0;
+
         for ($i = 0; $i < $hbNum; $i++) {
             $start = date("Y-m-d H:i:s");
             $end = date("Y-m-d H:i:s", time() + $valid * 86400);
@@ -66,11 +90,21 @@ class ShopCouponClass extends BaseClass
                 'shopId' => $shopId,
                 'beginTime' => $start,
                 'endTime' => $end,
-                'name' => '红包',
+                'name' => '红包',
                 'amount' => $hbAmount,
                 'miniCost' => $miniExpend,
                 'status' => self::STATUS_UN_USE,
                 'ghsId' => $ghsId,
+                'ghsName' => $ghsName,
+                'ghsAvatar' => $ghsAvatar,
+                'ghsSjId' => $ghsSjId,
+                'ghsShopId' => $ghsShopId,
+                'customId' => $customId,
+                'customName' => $customName,
+                'customPy' => $customPy,
+                'customAvatar' => $customAvatar,
+                'customSjId' => $customSjId,
+                'customShopId' => $customShopId,
             ];
             self::add($coupon);
         }