Bladeren bron

month pay debug

zz 5 jaren geleden
bovenliggende
commit
576b6406ca

+ 14 - 4
app/Http/Controllers/Wap/Pay/MonthOrderController.php

@@ -326,24 +326,30 @@ class MonthOrderController extends Controller
         $plan_id = $xml['plan_id'];
         $type = 'MONTH';
         $fee = 0;
+        $day = 0;
         if($plan_id == env('MONTH_ORDER_PLAN_ID')){
             $fee = 3000;
             $type = 'MONTH';
+            $day = 30;
         }
 
         if($plan_id == env('MONTH_WEEK_ORDER_PLAN_ID')){
             $fee = 700;
             $type = 'WEEK';
+            $day = 7;
         }
 
         if($plan_id == env('MONTH_QUARTER_ORDER_PLAN_ID')){
-            $fee = 10000;
+            $fee = 9800;
             $type = 'QUARTER';
+            $day = 92;
         }
-        //$fee = 1;
 
         $user_id = $xml['contract_code'];
         $change_type = $xml['change_type'];
+        if (in_array($user_id, explode(',', env('TEST_UID')))) {
+            $fee = 1;
+        }
 
         $user_info = UserService::getById($user_id);
         if (!$user_info) {
@@ -359,14 +365,18 @@ class MonthOrderController extends Controller
             'change_type'=>$change_type,
             'operate_time'=>$xml['operate_time'],
             'contract_id'=>$xml['contract_id'],
-            'contract_expired_time'=>$xml['contract_expired_time'],
+            'contract_expired_time'=>isset($xml['contract_expired_time'])?$xml['contract_expired_time']:'',
             'contract_termination_mode'=>isset($xml['contract_termination_mode'])?$xml['contract_termination_mode']:0,
             'request_serial'=>$xml['request_serial']
 
         ]);
         UserMonthService::createSign($user_id, $plan_id, $change_type, $user_info->openid,$type);
         if($change_type == 'ADD'){
-            UserMonthService::monthPayApplypap($user_id,$xml['contract_id'],$fee,'追书云包季扣款','47.97.95.151','sign_back',\GuzzleHttp\json_encode(['uid'=>$user_id,'plan_id'=>$plan_id]));
+            //获取上次扣费时间
+            $info = UserMonthService::getLastMonthOrderInfo($user_id,$type);
+            if($info->isEmpty() || time() >= (strtotime($info->created_at)+$day*86400) ){
+                UserMonthService::monthPayApplypap($user_id,$xml['contract_id'],$fee,'追书云包季扣款','47.97.95.151','sign_back',\GuzzleHttp\json_encode(['uid'=>$user_id,'plan_id'=>$plan_id]));
+            }
         }
         Log::info('signCallBack-------------------end-----------------------signCallBack');
         $result = ['return_code'=>'SUCCESS','return_msg'=>'OK'];

+ 8 - 0
app/Modules/User/Services/UserMonthService.php

@@ -183,4 +183,12 @@ class UserMonthService
             \Log::error($e);
         }
     }
+
+    public static function getLastMonthOrderInfo($uid,$type){
+        return UserMonthOrder::where('uid',$uid)
+            ->where('type',$type)
+            ->orderBy('id','desc')
+            ->select('id','plan_id','created_at')
+            ->first();
+    }
 }