Quellcode durchsuchen

充值免费续期

shish vor 5 Jahren
Ursprung
Commit
d11318208e

+ 4 - 4
app-hd/controllers/ConsoleController.php

@@ -2,6 +2,7 @@
 
 namespace hd\controllers;
 
+use biz\sj\classes\SjClass;
 use biz\sj\services\MerchantAssetService;
 use bizHd\stat\services\StatIncomeMonthService;
 use bizHd\stat\services\StatIncomeService;
@@ -29,10 +30,9 @@ class ConsoleController extends BaseController
         $current = time();
         $remain = strtotime($deadline) - $current;
         if ($remain <= 1296000) {
-            //是否参加过免费续期活动
-            $rechargeRenew = $this->sjExtend['rechargeRenew'] ?? 2;
-            $parentId = $sj['parentId'] ?? 0;
-            if (!empty($parentId) && $rechargeRenew == 1) {
+            //是否有充值免费续期权限
+            $hasRight = SjClass::hasRechargeRenewRight($this->sj, $this->sjExtend);
+            if ($hasRight) {
                 $title = '您的试用期已到,点击免费续期1年';
                 if ($remain > 0) {
                     $num = ceil($remain / 86400);

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

@@ -22,13 +22,13 @@ class RechargeController extends BaseController
         util::success($list);
     }
 
-    //免费续期活动 ssh 2021.2.21 
+    //免费续期活动 ssh 2021.2.21
     public function actionRenew()
     {
         $sj = $this->sj;
         $shopId = $sj['parentShopId'] ?? 0;
         $shopName = '';
-        $rechargeNum = getenv('RECHARGE_NUM') ?? 268;
+        $rechargeNum = getenv('RECHARGE_NUM') == false ? 268 : getenv('RECHARGE_NUM');
         if (!empty($shopId)) {
             $shop = ShopClass::getShopInfo($shopId);
             if (!empty($shop)) {
@@ -38,8 +38,8 @@ class RechargeController extends BaseController
             }
         }
         $data = [
-            'renew' => getenv('RENEW_PRICE') ?? 3980,
-            'recharge' => getenv('RECHARGE_PRICE') ?? 5980,
+            'renew' => getenv('RENEW_PRICE') == false ? 3980 : getenv('RENEW_PRICE'),
+            'recharge' => getenv('RECHARGE_PRICE') == false ? 5980 : getenv('RECHARGE_PRICE'),
             'shopName' => $shopName,
             'userNum' => $rechargeNum
         ];
@@ -51,7 +51,7 @@ class RechargeController extends BaseController
     {
         ini_set('date.timezone', 'Asia/Shanghai');
         $wxPay = dict::getConfig('payWay', 'wxPay');
-        $price = getenv('RECHARGE_PRICE') ?? 5980;
+        $price = getenv('RECHARGE_PRICE') == false ? 5980 : getenv('RECHARGE_PRICE');
         $data = [
             'amount' => $price,
             'payWay' => $wxPay,

+ 18 - 0
biz/sj/classes/SjClass.php

@@ -63,4 +63,22 @@ class SjClass extends BaseClass
         RenewLogClass::addLog($log);
     }
 
+    //是否有充值免费续期权限 shish 2021.4.26
+    public static function hasRechargeRenewRight($sj, $ext)
+    {
+        $rechargeRenew = $ext['rechargeRenew'] ?? 2;
+        if ($rechargeRenew == 2) {
+            return false;
+        }
+        $parentId = $sj['parentId'] ?? 0;
+        if (empty($parentId)) {
+            return false;
+        }
+        $current = self::getById($parentId);
+        if (isset($current['style']) == false || $current['style'] != self::STYLE_SUPPLIER) {
+            return false;
+        }
+        return true;
+    }
+
 }