zz 5 éve
szülő
commit
bf045d8011

+ 23 - 0
app/Http/Controllers/Wap/Pay/MonthOrderController.php

@@ -151,4 +151,27 @@ class MonthOrderController extends Controller
         ];
         OrderService::save_order($init_order);
     }
+
+    public function wait(Request $request){
+        //$user_cookie = \Cookie::get(env('COOKIE_AUTH_WEB_WECHAT'));
+        //$uid = $user_cookie ? decrypt($user_cookie) : null;
+        $r = $request->get('r');
+        return view('pay.order.monthpaywait',['url'=>$r]);
+    }
+
+    public function issuccess(Request $request){
+        $user_cookie = \Cookie::get(env('COOKIE_AUTH_WEB_WECHAT'));
+        $uid = $user_cookie ? decrypt($user_cookie) : null;
+        if(!$uid){
+            return response()->success();
+        }
+        $last = UserMonthService::getLastOrder($uid);
+        if(!$last){
+            return response()->error('WAP_SYS_ERROR');
+        }
+        if(time()-strtotime($last->created_at) <20){
+            return response()->success();
+        }
+        return response()->error('WAP_SYS_ERROR');
+    }
 }

+ 3 - 0
app/Http/Routes/Wap/WapRoutes.php

@@ -90,6 +90,9 @@ Route::group(['domain'=>env('WAP_DOMAIN'),'namespace'=>'App\Http\Controllers\Wap
     Route::get('pay/wait','Pay\OrdersController@waitPage');
     Route::get('pay/waitv2','Pay\OrdersController@waitPageV2');
 
+    Route::get('monthpay/wait','Pay\MonthOrderController@wait');
+    Route::get('api/monthorder/issuccess','Pay\MonthOrderController@issuccess');
+
     //链接强关跳转地址
     Route::get('subscribeauth','Subscribe\LinkSubscribeController@index');
     //枪关链接回调地址

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

@@ -35,6 +35,11 @@ class UserMonthService
         return $model->where('openid',$openid)->where('change_type','ADD')->select('id')->first();
     }
 
+    public static function getLastOrder(int $uid){
+        $model = new UserMonthOrder();
+        return $model->where('uid',$uid)->orderBy('id','desc')->first();
+    }
+
     public static function createLOrder(int $uid, int $plan_id, int $total_fee, string $trade_no,string $out_trade_no)
     {
         $model = new UserMonthOrder();

+ 113 - 0
resources/views/pay/order/monthpaywait.blade.php

@@ -0,0 +1,113 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
+    <meta http-equiv="X-UA-Compatible" content="ie=edge">
+    <title>请等待</title>
+    <style>
+        * {
+            padding: 0;
+            margin: 0;
+        }
+
+        html,
+        body {
+            height: 100%;
+            -webkit-background-size: cover;
+            -moz-background-size: cover;
+            -o-background-size: cover;
+            background-size: cover;
+            position: relative;
+        }
+        .page{
+            overflow: auto;
+            margin: auto;
+            text-align: center;
+            position: absolute;
+            top:40%;
+            left: 20%;
+        }
+        .page span{
+            font-size:22px;
+            line-height:40px;
+            display: block;
+
+        }
+        .page .text{
+            background:rgba(51,51,51,0.9);
+            padding: 10px;
+            border-radius: 5px;
+            color:#fff;
+        }
+
+        .page img{
+            position:absolute;
+            display:block;
+            width:60%;
+            top:15%;
+        }
+        #second{
+            font-size:25px;
+        }
+        .page .button{
+            position:absolute;
+            top:55%;
+            height:30px;
+            width:100%;
+        }
+        .page .button p{
+            width:60%;
+            font-size:20px;
+            line-height:40px;
+            text-align:center;
+            background-color:#38B2FF;
+            border-radius:3px;
+            color:#fff;
+        }
+
+    </style>
+</head>
+<body>
+
+<div class="page">
+
+    <span class="text">包月处理中,请勿退出...<span id="second">9</span></span>
+
+</div>
+</body>
+<script src="//apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
+<script>
+    window.onload = function(){
+        interval();
+        var time;
+        var num;
+        function interval(){
+            num = parseInt(document.getElementById('second').innerHTML);
+            time = setInterval(function(){
+                if(num < 0){
+                    clearInterval(time);
+                    location.href = "{!! $url !!}";
+                }else{
+                    ajax();
+                    document.getElementById('second').innerHTML = num--
+                }
+            },1000)
+        }
+
+        function ajax(){
+            $.ajax({
+                url:"/api/monthorder/issuccess",
+                success:function(res){
+                    if(res['code'] == 0){
+                        clearInterval(time);
+                        location.href = "{!! $url !!}";
+
+                    }
+
+                }
+            });
+        }
+    }
+</script>
+</html>