Просмотр исходного кода

Merge branch 'master' into stabble

zz 5 лет назад
Родитель
Сommit
c71a22e970

+ 29 - 0
app/Http/Controllers/Wap/Order/OrdersController.php

@@ -31,6 +31,7 @@ use App\Modules\Product\Services\ProductService;
 use App\Modules\Subscribe\Services\SubstituteOrderService;
 use Hashids;
 use DB;
+use Cookie;
 
 class OrdersController extends BaseController
 {
@@ -858,4 +859,32 @@ class OrdersController extends BaseController
             }
         }
     }
+
+    /*public function monthPay(Request $request,$channel_id,$domain){
+        \Log::info('monthPay url--------------');
+        \Log::info($request->all());
+        $from = $request->get('from_wxpay');
+        if($from && $from == 1){
+            //if()
+            $source = Cookie::get('month_pay_redirect');
+            if($source){
+                $source = urldecode($source);
+            }else{
+                $source = '/person';
+            }
+            return redirect()->to($source);
+        }
+        $source = $request->get('redirect_url');
+        if($source){
+            Cookie::queue('month_pay_redirect',$source,600);
+        }
+        $url = generateMonthOrderUrl($this->uid);
+        $h5_scheme = env('PROTOCOL', 'https');
+
+        $refer = str_replace('http://', $h5_scheme . '://', url()->current());
+        \Log::info('$refer is :'.$refer);
+        return redirect()->to($url)->withHeaders([
+            'Referer'=>$refer
+        ]);
+    }*/
 }

+ 26 - 1
app/Http/Controllers/Wap/Pay/MonthOrderController.php

@@ -71,8 +71,9 @@ class MonthOrderController extends Controller
         }
         $sign = _sign(compact('app_id','plan_id','user_id','change_type'),$key.$key);
         $sign = strtoupper($sign);
+        $user_info = UserService::getById($user_id);
         if($sign == $request->post('sign')){
-            UserMonthService::createSign($user_id,$plan_id,$change_type);
+            UserMonthService::createSign($user_id,$plan_id,$change_type,$user_info->openid);
         }
         Log::info('signCallBack-------------------end-----------------------signCallBack');
         return response('success');
@@ -150,4 +151,28 @@ 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');
+        $r = urldecode($r);
+        return view('pay.order.monthpaywait',['url'=>$r]);
+    }
+
+    public function issuccess(Request $request){
+        $uid = \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');
+    }
 }

+ 10 - 7
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -16,6 +16,7 @@ use App\Modules\User\Services\ForceSubscribeUserIService;
 use App\Modules\User\Services\UserBindHkWelfareService;
 use App\Modules\User\Services\UserDivisionCpcPropertyService;
 use App\Modules\User\Services\UserDivisionPropertyService;
+use App\Modules\User\Services\UserMonthService;
 use App\Modules\User\Services\UserService;
 use Illuminate\Http\Request;
 use App\Http\Controllers\Wap\BaseController;
@@ -189,7 +190,7 @@ class WelcomeController extends BaseController
 
         //用户分割
         $this->userPproperty($user->openid);
-        $month_order_info = $this->monthOrderInfo();
+        $month_order_info = $this->monthOrderInfo($user->openid);
         $options = json_encode([
             'distribution_channel_id' => (int)$this->distribution_channel_id,
             'send_order_id' => $send_order_id,
@@ -2187,17 +2188,19 @@ class WelcomeController extends BaseController
             }
         }
     }
-    private function monthOrderInfo(){
+    private function monthOrderInfo($openid){
         $property = $this->property;
         if (!$property) $property = 'low';
         if (in_array($this->distribution_channel_id, explode(',', redisEnv('OPEN_ORDER_INNER_SITES')))
             && in_array($property, ['low', 'medium'])
         ) {
-            return [
-                'price'=>'30元',
-                'text' => '30元包月 全站万本精彩小说免费看',
-                'link'=>generateMonthOrderUrl($this->uid)
-            ];
+            if(!UserMonthService::isSignMonth($openid)){
+                return [
+                    'price'=>'30元',
+                    'text' => '30元包月 全站万本精彩小说免费看',
+                    'link'=> generateMonthOrderUrl($this->uid).'&redirect_url='
+                ];
+            }
         }
         return '';
     }

+ 2 - 1
app/Http/Middleware/EncryptCookies.php

@@ -28,6 +28,7 @@ class EncryptCookies extends BaseEncrypter
         'is_paid',
         'crm_person_img',
         'crm_person_name',
-        'sign_recomand_bids'
+        'sign_recomand_bids',
+        'month_pay_redirect'
     ];
 }

+ 4 - 1
app/Http/Routes/Wap/WapRoutes.php

@@ -22,7 +22,7 @@ Route::group(['domain'=>env('PAY_WAP_DOMAIN'),'namespace'=>'App\Http\Controllers
     Route::get('monthpay/getH5RedirectUrl','Pay\MonthOrderController@getH5RedirectUrl');
     Route::get('monthpay/getWechatRedirectUrl','Pay\MonthOrderController@getWechatRedirectUrl');
     Route::any('monthpay/signcallback','Pay\MonthOrderController@signCallBack');
-    Route::any('monthpay/ordercallback','Pay\MonthOrderController@orderCallBack');
+    Route::post('monthpay/ordercallback','Pay\MonthOrderController@orderCallBack');
 
 });
 Route::group(['domain'=>env('OFFICIAL_AUTH_FOMAIN'),'namespace'=>'App\Http\Controllers\Wap'],function(){
@@ -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');
     //枪关链接回调地址

+ 2 - 1
app/Libs/Helpers.php

@@ -626,6 +626,7 @@ function generateMonthOrderUrl($user_id){
     $ip = _getIp();
     $sign = _sign(compact('app_id','app_secret','plan_id','user_id','ip'),$key.$key);
     $sign = strtoupper($sign);
-    $url = 'http://pap.manyuedu.org/?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
+    $return_web = 1;
+    $url = 'http://pap.manyuedu.org/?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign','return_web'));
     return $url;
 }

+ 1 - 1
app/Modules/Subscribe/Services/YearOrderService.php

@@ -78,7 +78,7 @@ class YearOrderService
             }
             return $old;
         } else {
-            return YearOrder::save_year_order($insert_data);
+            return YearOrder::create($insert_data);
         }
     }
 

+ 1 - 1
app/Modules/User/Models/UserMonthSign.php

@@ -7,5 +7,5 @@ use Illuminate\Database\Eloquent\Model;
 class UserMonthSign extends Model
 {
     protected $table = 'user_month_sign';
-    protected $fillable = ['uid','plan_id','change_type'];
+    protected $fillable = ['uid','plan_id','change_type','openid'];
 }

+ 12 - 1
app/Modules/User/Services/UserMonthService.php

@@ -13,7 +13,7 @@ use App\Modules\User\Models\UserMonthSign;
 
 class UserMonthService
 {
-    public static function createSign(int $uid, int $plan_id, string $change_type)
+    public static function createSign(int $uid, int $plan_id, string $change_type,string $openid)
     {
         $model = new UserMonthSign();
         $info = $model->where('uid', $uid)->where('plan_id', $plan_id)->first();
@@ -24,11 +24,22 @@ class UserMonthService
             $model->uid = $uid;
             $model->plan_id = $plan_id;
             $model->change_type = $change_type;
+            $model->openid = $openid;
             $model->save();
         }
         return;
     }
 
+    public static function isSignMonth($openid){
+        $model = new UserMonthSign();
+        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>

+ 4 - 4
resources/views/wap/index.blade.php

@@ -9,7 +9,7 @@
     <script>window.VueRouter || document.write('<script src="https://cdn-novel.iycdm.com/static/vue-router.min.js"><\/script>')</script>
     <script>(window.Vue && window.VueLazyload) || document.write('<script src="https://cdn-novel.iycdm.com/static/vue-lazyload.js"><\/script>')</script>
     <title>{{$title}}</title>
-    <link href=https://cdn-novel.iycdm.com/static2019-7-30/css/app.b9e2cf4ae5caf4911372a00d337f8a47.css rel=stylesheet>
+    <link href=https://cdn-novel.iycdm.com/static2019-7-31/css/app.924cd356e44e4ab8a47c25a7485d3f6e.css rel=stylesheet>
 </head>
 <body>
 <div id=app></div>
@@ -32,8 +32,8 @@
     })();</script>
 <script id=options>window.options = {!! $options!!};</script>
 <script type=text/javascript
-        src=https://cdn-novel.iycdm.com/static2019-7-30/js/manifest.7d589a9e4ea59354792d.js></script>
-<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-7-30/js/vendor.67516a6a43f9adc48771.js></script>
-<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-7-30/js/app.66031ffabc3372dab827.js></script>
+        src=https://cdn-novel.iycdm.com/static2019-7-31/js/manifest.50e08a92cf515c0c7cea.js></script>
+<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-7-31/js/vendor.67516a6a43f9adc48771.js></script>
+<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-7-31/js/app.318862f944c8bb5c5f7f.js></script>
 </body>
 </html>