Pārlūkot izejas kodu

Merge branch 'master' of iqiyoo:zhuishuyun_wap

onlinetest 6 gadi atpakaļ
vecāks
revīzija
6c48912341

+ 40 - 0
app/Http/Controllers/Wap/Advertises/AdvertiseController.php

@@ -151,4 +151,44 @@ class AdvertiseController extends BaseController
         DB::table('advertise_access_rec')->insert($params);
         return response()->success();
     }
+
+    
+    public function pddAd(Request $request){
+        $links = [
+            '2019041501'=>'https://mobile.yangkeduo.com/duo_brand_sales.html?pid=8571127_60403841&cpsSign=CM8571127_60403841_29e8aa97a487aa94a63fd31f45da38cf&duoduo_type=2',
+            '2019041502'=>'https://mobile.yangkeduo.com/duo_nine_nine.html?pid=8571127_60403841&cpsSign=CM8571127_60403841_d766485b4f32d85c227b4cefd604a02d&duoduo_type=2',
+            '2019041601'=>'https://mobile.yangkeduo.com/duo_coupon_landing.html?goods_id=7539798822&pid=8585481_60984090&cpsSign=190416_CC8585481_60984090_03b2f7fa0ef1e609c2249cc365b42f3e&duoduo_type=2',
+            '2019041602'=>'https://mobile.yangkeduo.com/duo_coupon_landing.html?goods_id=190857743&pid=8585481_60984090&cpsSign=190416_CC8585481_60984090_f1ef254d6b95420817e9d398b9b0ab63&duoduo_type=2',
+            '2019041603'=>'https://mobile.yangkeduo.com/duo_coupon_landing.html?goods_id=6748389609&pid=8585481_60984090&cpsSign=190416_CC8585481_60984090_3dfafd4426b6ac11cff1bb7e7f274871&duoduo_type=2',
+            '2019041604'=>'https://mobile.yangkeduo.com/duo_coupon_landing.html?goods_id=2200177&pid=8585481_60984090&cpsSign=190416_CC8585481_60984090_bb29ca22aaa8ed3d9927f312ff9f4eb0&duoduo_type=2',
+            '2019041605'=>'https://mobile.yangkeduo.com/duo_coupon_landing.html?goods_id=6878198875&pid=8585481_60984090&cpsSign=190416_CC8585481_60984090_8e4542ff01347e7d0b4e63e5d0cada0d&duoduo_type=2',
+            '2019041606'=>'https://mobile.yangkeduo.com/duo_coupon_landing.html?goods_id=25858329&pid=8585481_60984090&cpsSign=190416_CC8585481_60984090_430a54cf797bfd73fa5baf31a240d600&duoduo_type=2',
+            '2019041607'=>'https://mobile.yangkeduo.com/duo_coupon_landing.html?goods_id=3785330482&pid=8585481_60984090&cpsSign=190416_CC8585481_60984090_904632cdd98a39a26f618dfbe0c4e482&duoduo_type=2',
+            '2019041608'=>'https://mobile.yangkeduo.com/duo_coupon_landing.html?goods_id=4220538441&pid=8585481_60984090&cpsSign=190416_CC8585481_60984090_9ff313f511eaa7df46b9358524421825&duoduo_type=2',
+            '2019041609'=>'https://mobile.yangkeduo.com/duo_coupon_landing.html?goods_id=4330142633&pid=8585481_60984090&cpsSign=190416_CC8585481_60984090_3cd524bbc1d78b76e56c5c0e13020ee9&duoduo_type=2',
+            '2019041610'=>'https://mobile.yangkeduo.com/duo_coupon_landing.html?goods_id=5826309739&pid=8585481_60984090&cpsSign=190416_CC8585481_60984090_cd18616d2a6b5ae15d5cd24b24717785&duoduo_type=2',
+            '2019041611'=>'https://mobile.yangkeduo.com/duo_theme_activity.html?themeId=5595&pid=8585481_60984090&cpsSign=190416_CT8585481_60984090_c5aef71fd6a8b510ccd8a400dc6500a1&duoduo_type=2',
+            '2019041612'=>'https://mobile.yangkeduo.com/duo_theme_activity.html?themeId=5328&pid=8585481_60984090&cpsSign=190416_CT8585481_60984090_7bb6baecf55ccece8887e36499400351&duoduo_type=2',
+            '2019041613'=>'https://mobile.yangkeduo.com/duo_theme_activity.html?themeId=5198&pid=8585481_60984090&cpsSign=190416_CT8585481_60984090_d26f463995bf7df3d5db6d71be5e5924&duoduo_type=2',
+            '2019041614'=>'https://mobile.yangkeduo.com/duo_theme_activity.html?themeId=4274&pid=8585481_60984090&cpsSign=190416_CT8585481_60984090_cd454f3cc9f5eb6e9a26e00bf01a8d03&duoduo_type=2',
+            '2019041615'=>'https://mobile.yangkeduo.com/duo_theme_activity.html?themeId=5505&pid=8585481_60984090&cpsSign=190416_CT8585481_60984090_9cc457adb40cf436e8477f06535bb706&duoduo_type=2'
+        ];
+        $link_key = $request->get('link','2019041501');
+        if($this->uid){
+            try{
+                //$key = sprintf('pddad:uv:%s:%s',$link_key,date('Y-m-d'));
+                //Redis::sadd($key,$this->uid);
+                DB::table('ad_pdd')->insert([
+                    'uid'=>$this->uid,
+                    'img'=>sprintf('https://cdn-novel.iycdm.com/h5/ad/pdd/%s.jpg',$link_key),
+                    'date'=>date('Y-m-d'),
+                    'created_at'=>date('Y-m-d H:i:s'),
+                    'updated_at'=>date('Y-m-d H:i:s')
+                ]);
+            }catch (\Exception $e){}
+        }
+
+        $link_key = $request->get('link','2019041501');
+        return redirect()->to($links[$link_key]);
+    }
 }

+ 4 - 3
app/Http/Controllers/Wap/Advertises/ShareController.php

@@ -94,6 +94,7 @@ class ShareController extends BaseController
 
     public function jump(Request $request){
         $distribution_channel_id = $request->input('distribution_channel_id',0);
+        //$distribution_channel_id = decodeDistributionChannelId($distribution_channel_id);
         $uid = $request->input('uid','');
         $cid = $request->input('cid','');
         $bid_encode = $request->input('bid','');
@@ -106,9 +107,9 @@ class ShareController extends BaseController
         $bid=$bid_encode;
         $sign_str = arr_to_url(compact('distribution_channel_id','uid','cid','bid','share_user_id','timestamp'));
         $my_sign = md5($sign_str);
-        if($sign != $my_sign) {
+        /*if($sign != $my_sign) {
             return response()->error('WAP_SIGN_ERROR');
-        }
+        }*/
         $bid = Hashids::decode($bid_encode)[0];
         $buid = $this->uid;
         $data = compact('uid','bid','cid','share_user_id','buid');
@@ -158,7 +159,7 @@ class ShareController extends BaseController
             $url_format,
             env('PROTOCOL'),
             //TODO 上线时改成加密
-            $distribution_channel_id,//encodeDistributionChannelId($distribution_channel_id),
+            encodeDistributionChannelId($distribution_channel_id),
             env('CUSTOM_HOST')
         );
         $link .= 'share/jump?'.$sign_str.'&sign='.$sign;

+ 202 - 146
app/Http/Controllers/Wap/Pay/OrdersController.php

@@ -67,11 +67,13 @@ class OrdersController extends Controller
         $product_id = $request->has('product_id') ? $request->get('product_id') : '';
         $uid = $request->has('uid') ? $request->get('uid') : '';
         $distribution_channel_id = $request->has('distribution_channel_id') ? $request->get('distribution_channel_id') : '';
+        $p_channel_id = $request->has('p_channel_id') ? $request->get('p_channel_id') : 0;
         $pay_redirect_url = $request->has('pay_redirect_url') ? $request->get('pay_redirect_url') : '';
         $send_order_id = $request->has('send_order_id') ? $request->get('send_order_id') : 0;
         $activity_id = $request->has('activity_id') ? $request->get('activity_id') : 0;
         $ip = $request->has('ip') ? $request->get('ip') : '';
         $n = $request->has('n') ? $request->get('n') : 0;
+
         if ($send_order_id && strlen($send_order_id) > 50) {
             try {
                 $send_order_id = decrypt($send_order_id);
@@ -99,7 +101,7 @@ class OrdersController extends Controller
                 }
             }
         }
-        $suid= $request->get('suid',0);
+        $suid = $request->get('suid', 0);
 
         if ($suid) {
             $user_info = UserService::getById($uid);
@@ -109,7 +111,7 @@ class OrdersController extends Controller
         if (empty($product_id) || empty($uid) || empty($distribution_channel_id) || empty($pay_redirect_url)) {
             return response()->error('WAP_PARAM_ERROR');
         }
-        if($suid && $suid == $uid){
+        if ($suid && $suid == $uid) {
             return back();
         }
         $openid = $request->has('openid') ? $request->get('openid') : '';
@@ -128,18 +130,26 @@ class OrdersController extends Controller
             $fromtype = 'main';
         }
 
+        if (!$openid) {
+            $transfer_channel_id = $this->transfer($distribution_channel_id);
+            if ($transfer_channel_id) {
+                $p_channel_id = $distribution_channel_id;
+                $distribution_channel_id = $transfer_channel_id;
+            }
+        }
         //根据分校id获取支付配置id
         Log::info($request->all());
         $channel = ChannelService::getById($distribution_channel_id);
         if (!$channel || !$channel->pay_merchant_id) {
             return response()->error('WAP_PARAM_ERROR');
         }
+
         //获取支付类型
-        $pay_merchant = DB::table('pay_merchants')->select('id','appid', 'source', 'config_info')->where('id', $channel->pay_merchant_id)->where('is_enabled', 1)->first();
+        $pay_merchant = DB::table('pay_merchants')->select('id', 'appid', 'source', 'config_info')->where('id', $channel->pay_merchant_id)->where('is_enabled', 1)->first();
         if (!$pay_merchant || !$pay_merchant->appid || !$pay_merchant->source) return response()->error('WAP_PARAM_ERROR');
-        if($pay_merchant->source == 'PALMPAYV2'){
+        if ($pay_merchant->source == 'PALMPAYV2') {
 
-            return redirect()->to($this->paympay($request,$pay_merchant));
+            return redirect()->to($this->paympay($request, $pay_merchant));
         }
         //重定向 获取用户信息的次数
         $n++;
@@ -151,12 +161,13 @@ class OrdersController extends Controller
         }
         if (empty($openid)) {
             $trade_no = date("YmdHis") . str_shuffle(hexdec(uniqid()));
-            if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']){
+            if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
                 $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
-            }else{
+            } else {
                 $ip = get_client_ip();
             }
-            $params = compact('uid', 'product_id', 'distribution_channel_id', 'send_order_id', 'bid', 'trade_no', 'pay_redirect_url', 'fromtype', 'activity_id', 'n','suid','ip');
+
+            $params = compact('uid', 'product_id', 'distribution_channel_id', 'send_order_id', 'bid', 'trade_no', 'pay_redirect_url', 'fromtype', 'activity_id', 'n', 'suid', 'ip', 'p_channel_id');
 
             $redirect_url = env('CREATE_PAY_URL') . '?' . http_build_query($params);
             //$redirect_url  = env('CREATE_PAY_URL').'?uid='.$uid.'&product_id='.$product_id.'&distribution_channel_id='
@@ -172,10 +183,10 @@ class OrdersController extends Controller
         if ($order_info) return response()->error('WAP_SYS_ERROR');
 
         $cid = $request->has('cid') ? $request->get('cid') : '';
-        $product_info = ProductService::getProductSingle($product_id,false);
+        $product_info = ProductService::getProductSingle($product_id, false);
         //新用户只能冲一次
         //Log::info('新用户只能冲一次:' .$product_info->type);
-        if($this->isNewUserSecondCharge($product_info->type,$product_id,$uid)){
+        if ($this->isNewUserSecondCharge($product_info->type, $product_id, $uid)) {
             $url = env('PROTOCOL', 'https') . '://site' . encodeDistributionChannelId($distribution_channel_id) . '.' . env('CUSTOM_HOST', 'leyuee') . '.com/pay';
             return redirect()->to($url);
         }
@@ -186,16 +197,19 @@ class OrdersController extends Controller
 
         try {
             $send_order_id = (int)Redis::hget('book_read:' . $uid, 'send_order_id');
-        } catch (\Exception $e) {}
+        } catch (\Exception $e) {
+        }
 
-        $this->updateUserSendOrderId($uid,$send_order_id);
+        $this->updateUserSendOrderId($uid, $send_order_id);
         if (in_array($uid, explode(',', env('TEST_UID')))) {
             $price = 1;
         }
         if ($bid) {
             try {
                 $bid = Hashids::decode($bid)[0];
-            } catch (\Exception $e) {$bid = 0;}
+            } catch (\Exception $e) {
+                $bid = 0;
+            }
         }
 
         try {
@@ -221,7 +235,7 @@ class OrdersController extends Controller
         $data['openid'] = $openid;//
 
         $data['body'] = 'novel read';
-        $official_name = $this->getSubscribeOfficialName($uid,$distribution_channel_id);
+        $official_name = $this->getSubscribeOfficialName($uid, $distribution_channel_id);
         if ($official_name) {
             $data['body'] = '搜索公众号' . $official_name . ',请继续阅读';
         }
@@ -245,9 +259,9 @@ class OrdersController extends Controller
             $order_type = 'BOOK';
         } elseif ($product_info->type == 'TICKET_RECHARGE') {
             $order_type = 'RECHARGE';
-        } elseif($product_info->type == 'NEW_USER'){
+        } elseif ($product_info->type == 'NEW_USER') {
             $order_type = 'RECHARGE';
-        }else{
+        } else {
             $order_type = 'UNKNOWN';
         }
         /*
@@ -272,7 +286,7 @@ class OrdersController extends Controller
                 $send_order_name = $send_order_info->name;
             }
         }
-        if($suid){
+        if ($suid) {
             $user_info = UserService::getById($uid);
             $distribution_channel_id = $user_info->distribution_channel_id;
         }
@@ -294,15 +308,20 @@ class OrdersController extends Controller
             'from_bid' => $from_bid,
             'from_type' => $fromtype,
             'activity_id' => $activity_id,
-            'inner_send_order_id'=>$inner_send_order_id
+            'inner_send_order_id' => $inner_send_order_id
         ];
         $result = $this->createUnPayOrder($init_order);
 
         //订单创建成功后增加统计
-        if($result)
-        {
+        if ($result) {
             $this->orderCreated($init_order);
             $this->recordOtherParam($result->id, $uid);
+            if($p_channel_id){
+                //miwa 转换
+                OrderParamService::createByParam([
+                    'order_id'=>$result->id,'gxhp'=>'mw_transfer','appid'=>'','bid'=>$bid,'data_hour_key'=>'','times'=>'','distribution_channel_id'=>$p_channel_id
+                ]);
+            }
         }
 
         if ($request->get('suid')) {
@@ -336,7 +355,7 @@ class OrdersController extends Controller
 //        }
 
         if ($suid) {
-            $prize_fee = (int)(($product_info->price*100)*0.1);
+            $prize_fee = (int)(($product_info->price * 100) * 0.1);
             $help_pay_page_channel_id = env('HELP_PAY_PAGE_CHANNEL_ID', 123);
             $help_pay_page_channel_id = $distribution_channel_id;
             $url_format = '%s://site%s.%s.com/helppay?back=%s&su=%s';
@@ -359,45 +378,46 @@ class OrdersController extends Controller
         Log::info($pay_info);
         Log::info('jsSdkSign---- :' . $jsSdkSign);
         $pay_order = $trade_no;
-        
+
         // 注册动作-》创建订单
         $action_type = 'CreateOrder';
         $param = [
-	        'openid' => isset($openid)?$openid:'0',
-	        'uid' =>isset($uid)?$uid:'0',
-	        'order_sn' => isset($trade_no)?$trade_no:'0',
-	        'amount' => isset($price)?$price:'0',
+            'openid' => isset($openid) ? $openid : '0',
+            'uid' => isset($uid) ? $uid : '0',
+            'order_sn' => isset($trade_no) ? $trade_no : '0',
+            'amount' => isset($price) ? $price : '0',
         ];
-        UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
-        
+        UserService::PushUserActionToQueue($action_type, $distribution_channel_id, $param);
+
         return view('pay.order.index', compact('pay_info', 'referer', 'jsSdkSign', 'pay_order'));
     }
 
 
-    private function paympay(Request $request,$pay_merchant){
-        $product_id =  $request->get('product_id');
+    private function paympay(Request $request, $pay_merchant)
+    {
+        $product_id = $request->get('product_id');
         $uid = $request->get('uid');
         $distribution_channel_id = $request->get('distribution_channel_id');
         $pay_redirect_url = $request->get('pay_redirect_url');
-        $send_order_id = $request->get('send_order_id',0) ;
-        $activity_id = $request->get('activity_id',0) ;
-        $suid= $request->get('suid',0);
+        $send_order_id = $request->get('send_order_id', 0);
+        $activity_id = $request->get('activity_id', 0);
+        $suid = $request->get('suid', 0);
         $bid = $request->has('bid') ? $request->get('bid') : 0;
         $hash_bid = $bid;
-        $fromtype = $request->has('fromtype') ? $request->get('fromtype') : $request->get('from','main');
+        $fromtype = $request->has('fromtype') ? $request->get('fromtype') : $request->get('from', 'main');
 
         //根据分校id获取支付配置id
         Log::info($request->all());
 
-        $trade_no =$trade_no = date("YmdHis") . str_shuffle(hexdec(uniqid()));
+        $trade_no = $trade_no = date("YmdHis") . str_shuffle(hexdec(uniqid()));
         $order_info = OrderService::getByTradeNo($trade_no);
         if ($order_info) return response()->error('WAP_SYS_ERROR');
 
         $cid = $request->has('cid') ? $request->get('cid') : '';
-        $product_info = ProductService::getProductSingle($product_id,false);
+        $product_info = ProductService::getProductSingle($product_id, false);
         //新用户只能冲一次
         //Log::info('新用户只能冲一次:' .$product_info->type);
-        if($this->isNewUserSecondCharge($product_info->type,$product_id,$uid)){
+        if ($this->isNewUserSecondCharge($product_info->type, $product_id, $uid)) {
             $url = env('PROTOCOL', 'https') . '://site' . encodeDistributionChannelId($distribution_channel_id) . '.' . env('CUSTOM_HOST', 'leyuee') . '.com/pay';
             return redirect()->to($url);
         }
@@ -408,9 +428,10 @@ class OrdersController extends Controller
         if (!$send_order_id) {
             try {
                 $send_order_id = (int)Redis::hget('book_read:' . $uid, 'send_order_id');
-            } catch (\Exception $e) {}
+            } catch (\Exception $e) {
+            }
         }
-        $this->updateUserSendOrderId($uid,$send_order_id);
+        $this->updateUserSendOrderId($uid, $send_order_id);
         if (in_array($uid, explode(',', env('TEST_UID')))) {
             $price = 1;
         }
@@ -427,9 +448,9 @@ class OrdersController extends Controller
         } catch (\Exception  $e) {
 
         }
-        if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']){
+        if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
             $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
-        }else{
+        } else {
             $ip = get_client_ip();
         }
         $data = [];
@@ -437,7 +458,7 @@ class OrdersController extends Controller
         $data['price'] = $price;
         $data['create_ip'] = $ip;
         $data['body'] = 'novel read';
-        $official_name = $this->getSubscribeOfficialName($uid,$distribution_channel_id);
+        $official_name = $this->getSubscribeOfficialName($uid, $distribution_channel_id);
         if ($official_name) {
             $data['body'] = '搜索公众号' . $official_name . ',请继续阅读';
         }
@@ -450,9 +471,9 @@ class OrdersController extends Controller
             $order_type = 'BOOK';
         } elseif ($product_info->type == 'TICKET_RECHARGE') {
             $order_type = 'RECHARGE';
-        } elseif($product_info->type == 'NEW_USER'){
+        } elseif ($product_info->type == 'NEW_USER') {
             $order_type = 'RECHARGE';
-        }else{
+        } else {
             $order_type = 'UNKNOWN';
         }
 
@@ -463,7 +484,7 @@ class OrdersController extends Controller
                 $send_order_name = $send_order_info->name;
             }
         }
-        if($suid){
+        if ($suid) {
             $user_info = UserService::getById($uid);
             $distribution_channel_id = $user_info->distribution_channel_id;
         }
@@ -485,13 +506,12 @@ class OrdersController extends Controller
             'from_bid' => $from_bid,
             'from_type' => $fromtype,
             'activity_id' => $activity_id,
-            'inner_send_order_id'=>$inner_send_order_id
+            'inner_send_order_id' => $inner_send_order_id
         ];
         $result = $this->createUnPayOrder($init_order);
 
         //订单创建成功后增加统计
-        if($result)
-        {
+        if ($result) {
             $this->orderCreated($init_order);
             $this->recordOtherParam($result->id, $uid);
         }
@@ -500,7 +520,7 @@ class OrdersController extends Controller
         }
 
         if ($suid) {
-            $prize_fee = (int)(($product_info->price*100)*0.1);
+            $prize_fee = (int)(($product_info->price * 100) * 0.1);
             //$help_pay_page_channel_id = env('HELP_PAY_PAGE_CHANNEL_ID', 123);
             $help_pay_page_channel_id = $distribution_channel_id;
             $url_format = '%s://site%s.%s.com/helppay?back=%s&su=%s';
@@ -533,19 +553,19 @@ class OrdersController extends Controller
         \Log::info('$wechatPay ok-------------------');
         $pay_info = $wechatPay->send($data);
         \Log::info('send ok-------------------');
-        
+
         // 注册动作-》创建订单
         $action_type = 'CreateOrder';
         $param = [
-	        'openid' => isset($openid)?$openid:'0',
-	        'uid' =>isset($uid)?$uid:'0',
-	        'order_sn' => isset($trade_no)?$trade_no:'0',
-	        'amount' => isset($price)?$price:'0',
+            'openid' => isset($openid) ? $openid : '0',
+            'uid' => isset($uid) ? $uid : '0',
+            'order_sn' => isset($trade_no) ? $trade_no : '0',
+            'amount' => isset($price) ? $price : '0',
         ];
         \Log::info('FUCK_PALMPAYV2');
-        UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
-         
-        
+        UserService::PushUserActionToQueue($action_type, $distribution_channel_id, $param);
+
+
         return $pay_info;
     }
 
@@ -554,8 +574,8 @@ class OrdersController extends Controller
         $order = $request->get('order');
         $order = (string)$order;
         $url = urldecode($request->get('redirect'));
-        if(substr_count($url,'?') >1){
-            $url = str_replace_last('?','&',$url);
+        if (substr_count($url, '?') > 1) {
+            $url = str_replace_last('?', '&', $url);
         }
         $url_info = parse_url($url);
         if (isset($url_info['query']) && !empty($url_info['query'])) {
@@ -569,20 +589,21 @@ class OrdersController extends Controller
                 return redirect($url);
             }
         }
-        if(isset($url_info['path']) && str_contains($url_info['path'], 'pay')){
+        if (isset($url_info['path']) && str_contains($url_info['path'], 'pay')) {
             $url = sprintf('%s://%s/recent', $url_info['scheme'], $url_info['host']);
             return redirect($url);
         }
         return view('pay.order.wait', compact('order', 'url'));
     }
 
-    private  function isNewUserSecondCharge($charge_type,$product_id,$uid){
+    private function isNewUserSecondCharge($charge_type, $product_id, $uid)
+    {
         //Log::info('新用户只能冲一次:' .$charge_type);
-        if($charge_type == 'NEW_USER'){
-            $result = OrderService::getUserOrderByProductId($uid,$product_id);
+        if ($charge_type == 'NEW_USER') {
+            $result = OrderService::getUserOrderByProductId($uid, $product_id);
             //Log::info('isNewUserSecondCharge-------------------------');
             //Log::info($result);
-            if($result){
+            if ($result) {
                 return true;
             }
         }
@@ -593,15 +614,13 @@ class OrdersController extends Controller
     private function orderCreated($init_order)
     {
         try {
-            if(isset($init_order['pay_merchant_id']))
-            {
-                $key = 'pay_merchant:'.$init_order['pay_merchant_id'];
-                Redis::hincrby($key,'unpaid_num',1);
-                Redis::hset($key,'last_create_time', time());
+            if (isset($init_order['pay_merchant_id'])) {
+                $key = 'pay_merchant:' . $init_order['pay_merchant_id'];
+                Redis::hincrby($key, 'unpaid_num', 1);
+                Redis::hset($key, 'last_create_time', time());
             }
 
-        }catch (\Exception $e)
-        {
+        } catch (\Exception $e) {
 
         }
     }
@@ -610,14 +629,12 @@ class OrdersController extends Controller
     private function orderPaid($init_order)
     {
         try {
-            if(isset($init_order['pay_merchant_id']))
-            {
-                $key = 'pay_merchant:'.$init_order['pay_merchant_id'];
-                Redis::hset($key,'unpaid_num',0);
+            if (isset($init_order['pay_merchant_id'])) {
+                $key = 'pay_merchant:' . $init_order['pay_merchant_id'];
+                Redis::hset($key, 'unpaid_num', 0);
             }
 
-        }catch (\Exception $e)
-        {
+        } catch (\Exception $e) {
 
         }
     }
@@ -750,9 +767,11 @@ class OrdersController extends Controller
                 $price = $product->price;
                 $bid = $remarks['bid'];
                 //$this->updateOrderTotal($trade_no,$transaction_id);
-                $prize_fee = (int)(($product->price*100)*0.1);
-                $this->substituteOrderPrice($order->id,$prize_fee);
-                $this->smartPushTestBookPaidUv($order->from_bid,$order->uid,$order->price);
+                $prize_fee = (int)(($product->price * 100) * 0.1);
+                $this->substituteOrderPrice($order->id, $prize_fee);
+                $this->smartPushTestBookPaidUv($order->from_bid, $order->uid, $order->price);
+                //获取用户充值次数
+                $order->pay_type = $this->getChargeTimes($order->uid);
                 // 更新其他定制Order表
                 if ($product->type == 'YEAR_ORDER') {
                     Log::info('YEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDER');
@@ -812,6 +831,7 @@ class OrdersController extends Controller
                     $order->status = 'PAID';
                     $order->pay_end_at = date('Y-m-d H:i:s');
                     $order->transaction_id = $transaction_id;
+
                     $order->save();
                 } else {
                     DB::rollback();
@@ -822,15 +842,15 @@ class OrdersController extends Controller
                 $key = 'leyuee:to_send_not_pay_uid:distribution_channel_id:' . $distribution_channel_id;
                 Redis::hdel($key, $uid);
                 DB::commit();
-                
+
                 // 注册动作-》回调订单
                 $action_type = 'CallBackOrder';
                 $param = [
-                   'order_sn' => isset($trade_no)?$trade_no:'0',
-                   'openid' => isset($uid)?$uid:'0',// 没有openid,用uid写log
+                    'order_sn' => isset($trade_no) ? $trade_no : '0',
+                    'openid' => isset($uid) ? $uid : '0',// 没有openid,用uid写log
                 ];
-                UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
-                
+                UserService::PushUserActionToQueue($action_type, $distribution_channel_id, $param);
+
                 return true;
             } catch (\Exception $e) {
                 DB::rollback();
@@ -907,9 +927,11 @@ class OrdersController extends Controller
                     Log::info($product);
 
                     Log::info('product_type:' . $product->type);
-                    $prize_fee = (int)(($product->price*100)*0.1);
-                    $this->substituteOrderPrice($order->id,$prize_fee);
-                    $this->smartPushTestBookPaidUv($order->from_bid,$order->uid,$order->price);
+                    $prize_fee = (int)(($product->price * 100) * 0.1);
+                    $this->substituteOrderPrice($order->id, $prize_fee);
+                    $this->smartPushTestBookPaidUv($order->from_bid, $order->uid, $order->price);
+                    //获取用户充值次数
+                    $order->pay_type = $this->getChargeTimes($order->uid);
                     // 更新其他定制Order表
                     if ($product->type == 'YEAR_ORDER') {
                         Log::info('YEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDER');
@@ -945,7 +967,7 @@ class OrdersController extends Controller
                                 'pay_merchant_id','create_ip','bid','transaction_id'
                             )
                         );*/
-                    } elseif ($product->type == 'TICKET_RECHARGE' || $product->type=='NEW_USER') {
+                    } elseif ($product->type == 'TICKET_RECHARGE' || $product->type == 'NEW_USER') {
                         Log::info('TICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGE');
                         $order_type = 'RECHARGE';
                         $this->userCharge($product, $uid);
@@ -993,7 +1015,7 @@ class OrdersController extends Controller
             Log::info('receive_allinpay_ept:' . $e->getMessage());
             Log::info('pay_callback_end fail');
             echo 'fail';
-            return ;
+            return;
         }
         Log::info('pay_callback_end');
 
@@ -1037,9 +1059,11 @@ class OrdersController extends Controller
             try {
                 $product = ProductService::getProductSingle($order->product_id);
                 $transaction_id = $data['oid_paybill'];
-                $prize_fee = (int)(($product->price*100));
-                $this->substituteOrderPrice($order->id,$prize_fee);
-                $this->smartPushTestBookPaidUv($order->from_bid,$order->uid,$order->price);
+                $prize_fee = (int)(($product->price * 100));
+                $this->substituteOrderPrice($order->id, $prize_fee);
+                $this->smartPushTestBookPaidUv($order->from_bid, $order->uid, $order->price);
+                //获取用户充值次数
+                $order->pay_type = $this->getChargeTimes($order->uid);
                 // 更新其他定制Order表
                 if ($product->type == 'YEAR_ORDER') {
                     Log::info('YEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDER');
@@ -1059,7 +1083,7 @@ class OrdersController extends Controller
                     $order->pay_end_at = date('Y-m-d H:i:s');
                     $order->transaction_id = $transaction_id;
                     $order->save();
-                } elseif ($product->type == 'TICKET_RECHARGE'  || $product->type=='NEW_USER') {
+                } elseif ($product->type == 'TICKET_RECHARGE' || $product->type == 'NEW_USER') {
                     Log::info('TICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGE');
                     $order_type = 'RECHARGE';
                     $this->userCharge($product, $uid);
@@ -1089,7 +1113,7 @@ class OrdersController extends Controller
                 DB::rollBack();
                 Log::info('lianlian:' . $e->getMessage());
                 echo 'fail';
-                return ;
+                return;
             }
         }
         echo 'success';
@@ -1149,9 +1173,11 @@ class OrdersController extends Controller
                     Log::info($product);
 
                     Log::info('product_type:' . $product->type);
-                    $prize_fee = (int)(($product->price*100)*0.1);
-                    $this->substituteOrderPrice($order->id,$prize_fee);
-                    $this->smartPushTestBookPaidUv($order->from_bid,$order->uid,$order->price);
+                    $prize_fee = (int)(($product->price * 100) * 0.1);
+                    $this->substituteOrderPrice($order->id, $prize_fee);
+                    $this->smartPushTestBookPaidUv($order->from_bid, $order->uid, $order->price);
+                    //获取用户充值次数
+                    $order->pay_type = $this->getChargeTimes($order->uid);
                     // 更新其他定制Order表
                     if ($product->type == 'YEAR_ORDER') {
                         Log::info('YEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDER');
@@ -1171,7 +1197,7 @@ class OrdersController extends Controller
                         $order->pay_end_at = date('Y-m-d H:i:s');
                         $order->transaction_id = $transaction_id;
                         $order->save();
-                    } elseif ($product->type == 'TICKET_RECHARGE'  || $product->type=='NEW_USER') {
+                    } elseif ($product->type == 'TICKET_RECHARGE' || $product->type == 'NEW_USER') {
                         Log::info('TICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGE');
                         $order_type = 'RECHARGE';
                         $this->userCharge($product, $uid);
@@ -1201,14 +1227,14 @@ class OrdersController extends Controller
                         Log::info('redis remote error-----------------------');
                         Log::info($e);
                     }
-                    
+
                     // 注册动作-》回调订单
                     $action_type = 'CallBackOrder';
                     $param = [
-	                    'order_sn' => isset($trade_no)?$trade_no:'0',
-	                    'openid' => isset($uid)?$uid:'0',// 没有openid,用uid写log
+                        'order_sn' => isset($trade_no) ? $trade_no : '0',
+                        'openid' => isset($uid) ? $uid : '0',// 没有openid,用uid写log
                     ];
-                    UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
+                    UserService::PushUserActionToQueue($action_type, $distribution_channel_id, $param);
 
                 }
             } else {
@@ -1426,7 +1452,7 @@ class OrdersController extends Controller
                 $delay = 0;
                 $url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($data->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/continue';;
                 $content = sprintf($content_format, $data->nickname ? $data->nickname : '匿名', $uid, $money_text, $url);
-                foreach ($force_sub_info as $item){
+                foreach ($force_sub_info as $item) {
                     $res['openid'] = $item->openid;
                     $res['appid'] = $item->appid;
                     $res['content'] = $content;
@@ -1463,26 +1489,27 @@ class OrdersController extends Controller
         }
 
         //灵界的推送统计\App\Modules\Statistic\Services\WapVisitStatService::customerAllStats
-        try{
-            if($order->from_type){
-                $pv = Redis::hget('push:distribution_channel_id:allpv' ,$order->from_type);
-                if($pv){
-                    Redis::sadd('push:all:paidnum:from:' . $order->from_type,$order->uid);
-                    $old = Redis::hget('push:all:paidamount' ,$order->from_type);
-                    if($old){
-                        Redis::hset('push:all:paidamount' ,$order->from_type,$old+$order->price);
-                    }else{
-                        Redis::hset('push:all:paidamount' ,$order->from_type,$order->price);
+        try {
+            if ($order->from_type) {
+                $pv = Redis::hget('push:distribution_channel_id:allpv', $order->from_type);
+                if ($pv) {
+                    Redis::sadd('push:all:paidnum:from:' . $order->from_type, $order->uid);
+                    $old = Redis::hget('push:all:paidamount', $order->from_type);
+                    if ($old) {
+                        Redis::hset('push:all:paidamount', $order->from_type, $old + $order->price);
+                    } else {
+                        Redis::hset('push:all:paidamount', $order->from_type, $order->price);
                     }
                 }
             }
 
-            if(isset($order->pay_merchant_id) && $order->pay_merchant_id)//临时统计队列清0 用于报警
+            if (isset($order->pay_merchant_id) && $order->pay_merchant_id)//临时统计队列清0 用于报警
             {
-                $key = 'pay_merchant:'.$order->pay_merchant_id;
-                Redis::hset($key,'unpaid_num',0);
+                $key = 'pay_merchant:' . $order->pay_merchant_id;
+                Redis::hset($key, 'unpaid_num', 0);
             }
-        }catch (\Exception $e){}
+        } catch (\Exception $e) {
+        }
 
     }
 
@@ -1493,10 +1520,10 @@ class OrdersController extends Controller
 
     private function getSubscribeV2($uid)
     {
-        return DB::table('force_subscribe_users')->where('uid',$uid)->where('is_subscribed', 1)->get();
+        return DB::table('force_subscribe_users')->where('uid', $uid)->where('is_subscribed', 1)->get();
     }
 
-    public function getSubscribeOfficialName($uid,$distribution_channel_id)
+    public function getSubscribeOfficialName($uid, $distribution_channel_id)
     {
         $subscribe = $this->getSubscribe($uid);
         if ($subscribe && isset($subscribe->appid)) {
@@ -1509,16 +1536,17 @@ class OrdersController extends Controller
         if (isset($res->nickname) && !empty($res->nickname)) {
             return $res->nickname;
         }
-        try{
+        try {
             $official = DB::table('official_accounts')
                 ->where('distribution_channel_id', $distribution_channel_id)
-                ->where('is_auth',1)
-                ->orderBy('id','desc')
+                ->where('is_auth', 1)
+                ->orderBy('id', 'desc')
                 ->select('nickname')->first();
             if ($official && isset($official->nickname)) {
                 return $official->nickname;
             }
-        }catch (\Exception $e){}
+        } catch (\Exception $e) {
+        }
         return '';
     }
 
@@ -1541,7 +1569,7 @@ class OrdersController extends Controller
             $phone_arr = ['15868100210', '18072713392', '15088790066', '13858057394', '18668029091', '18668420256'];
             //$phone_arr = ['18668029091'];
 
-            $param = ['pay_id'=>$pay_merchant_id];
+            $param = ['pay_id' => $pay_merchant_id];
             if ($n) {
                 $template_type = 'pay_channel_remind';
                 //$content = '支付通道:' . $pay_merchant_id . ',获取授权信息失败';
@@ -1551,10 +1579,10 @@ class OrdersController extends Controller
             }
             if ($change) {
                 $template_type = 'pay_channel_change';
-                $param = ['pay_id'=>$pay_merchant_id,'new_pay_id'=>$change_pay_id];
+                $param = ['pay_id' => $pay_merchant_id, 'new_pay_id' => $change_pay_id];
             }
             foreach ($phone_arr as $phone) {
-                AliSMS::send($phone, $template_type,$param);
+                AliSMS::send($phone, $template_type, $param);
             }
 
         } catch (\Exception $e) {
@@ -1567,23 +1595,25 @@ class OrdersController extends Controller
         SubstituteOrderService::createOrder($order_id, $uid, $pay_uid);
     }
 
-    private function recordOtherParam($order_id, $uid){
-        $gxhp = ReadRecordService::getByField($uid,'gxhp');
-        if($gxhp){
-            OrderParamService::create($order_id,$gxhp);
-}
-}
+    private function recordOtherParam($order_id, $uid)
+    {
+        $gxhp = ReadRecordService::getByField($uid, 'gxhp');
+        if ($gxhp) {
+            OrderParamService::create($order_id, $gxhp);
+        }
+    }
 
-    private function substituteOrderPrice($order_id,$prize_fee=500)
+    private function substituteOrderPrice($order_id, $prize_fee = 500)
     {
         SubstituteOrderService::SubstituteOrderPrize($order_id, $prize_fee);
     }
 
-    private function updateUserSendOrderId(int $uid,$send_order_id){
-        if($send_order_id && $uid){
+    private function updateUserSendOrderId(int $uid, $send_order_id)
+    {
+        if ($send_order_id && $uid) {
             $user = UserService::getById($uid);
-            if($user && !$user->send_order_id){
-                UserService::updateInfo($uid,compact('send_order_id'));
+            if ($user && !$user->send_order_id) {
+                UserService::updateInfo($uid, compact('send_order_id'));
             }
         }
     }
@@ -1594,19 +1624,45 @@ class OrdersController extends Controller
      * @param $uid
      * @param $price
      */
-    private function smartPushTestBookPaidUv($bid,$uid,$price){
+    private function smartPushTestBookPaidUv($bid, $uid, $price)
+    {
         $smart_bid = ReadRecordService::getSmartPush($uid);
-        if( $smart_bid && in_array($bid,$smart_bid) ){
-            try{
+        if ($smart_bid && in_array($bid, $smart_bid)) {
+            try {
                 $key = 'smartPushTestBookPaidUv:bid:%s';
-                Redis::sadd(sprintf($key,$bid),$uid);
-                $now_amount = Redis::hget('smartPushTestBookPaidAmount',$bid);
-                if(!$now_amount){
+                Redis::sadd(sprintf($key, $bid), $uid);
+                $now_amount = Redis::hget('smartPushTestBookPaidAmount', $bid);
+                if (!$now_amount) {
                     $now_amount = 0;
                 }
-                Redis::hset('smartPushTestBookPaidAmount',$bid,$now_amount+$price);
-            }catch (\Exception $e){
+                Redis::hset('smartPushTestBookPaidAmount', $bid, $now_amount + $price);
+            } catch (\Exception $e) {
+            }
+        }
+    }
+
+    /**
+     * 获取用户第几次充值
+     * @param $uid
+     * @return int
+     */
+    private function getChargeTimes($uid)
+    {
+        $count = OrderService::getUserChargeTimes($uid);
+        return $count + 1;
+    }
+
+    //米玩 订单转移
+    private function transfer($distribution_channel_id)
+    {
+        if (in_array($distribution_channel_id, explode(',', redisEnv('MIWAN_TRANSFER_CHANNEL_ID', 1)))) {
+            $random = random_int(1, 100);
+            $miwan_transfer_probability = redisEnv('MIWAN_TRANSFER_PROBABILITY', 0);
+            $miwan_transfer_to_channel_id = redisEnv('MIWAN_TRANSFER_TO_CHANNEL_ID', 0);
+            if ($miwan_transfer_to_channel_id && $random <= $miwan_transfer_probability) {
+                return $miwan_transfer_to_channel_id;
             }
         }
+        return 0;
     }
 }

+ 2 - 1
app/Http/Controllers/Wap/User/ReadRecordController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers\Wap\User;
 
 use App\Modules\Cpa\Services\AdvertiseUserQueueService;
+use App\Modules\ShareFree\Services\ShareUsersService;
 use Illuminate\Http\Request;
 use App\Http\Controllers\Wap\BaseController;
 use App\Modules\Book\Services\BookConfigService;
@@ -106,7 +107,7 @@ class ReadRecordController extends BaseController
         $res = json_encode($res);
         $res = json_decode($res);
         foreach ($res as $key=>&$each){
-            $rec = AdvertiseUserQueueService::getUserAdvertiseSubscribe($this->uid,$each->bid);
+            $rec = ShareUsersService::getUnlocked($this->uid,$each->bid);// ($this->uid,$each->bid);
             if($rec) {
                 $each->is_advertise_sub=1;
             }else {

+ 34 - 2
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -95,6 +95,12 @@ class WelcomeController extends BaseController
         $adTargetId = false;
         if ($ad_status) {
             $adTargetId = $this->cpcAd();
+            if($adTargetId && !$is_show_activity){
+                $pdd_ad = $this->pddAd();
+                $is_show_activity = 1;
+                $url = isset($pdd_ad['url'])?$pdd_ad['url']:'';
+                $activity_img = isset($pdd_ad['img'])?$pdd_ad['img']:'';
+            }
         }
         //广告frame
         $is_show_ad_frame_setting = env('IS_SHOW_AD_FRAME_SETTING', '123');
@@ -514,13 +520,39 @@ class WelcomeController extends BaseController
             $cookie_ad_status = Cookie::get('cpc_ad_status');
             if($cookie_ad_status) return $cookie_ad_status == 'show';
             if(UserService::isCpcUser($this->uid)){
-                Cookie::queue('cpc_ad_status', 'show', 3600);
+                Cookie::queue('cpc_ad_status', 'show');
                 return true;
             }
         }
-        Cookie::queue('cpc_ad_status', 'unshow', 3600);
+        Cookie::queue('cpc_ad_status', 'unshow');
         return false;
     }
+
+    private function pddAd(){
+        $links = [
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041501.jpg','url'=>'/advertise/pdd?link=2019041501'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041502.jpg','url'=>'/advertise/pdd?link=2019041502'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041601.jpg','url'=>'/advertise/pdd?link=2019041601'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041602.jpg','url'=>'/advertise/pdd?link=2019041602'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041603.jpg','url'=>'/advertise/pdd?link=2019041603'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041604.jpg','url'=>'/advertise/pdd?link=2019041604'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041605.jpg','url'=>'/advertise/pdd?link=2019041605'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041606.jpg','url'=>'/advertise/pdd?link=2019041606'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041607.jpg','url'=>'/advertise/pdd?link=2019041607'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041608.jpg','url'=>'/advertise/pdd?link=2019041608'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041609.jpg','url'=>'/advertise/pdd?link=2019041609'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041610.jpg','url'=>'/advertise/pdd?link=2019041610'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041611.jpg','url'=>'/advertise/pdd?link=2019041611'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041612.jpg','url'=>'/advertise/pdd?link=2019041612'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041613.jpg','url'=>'/advertise/pdd?link=2019041613'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041614.jpg','url'=>'/advertise/pdd?link=2019041614'],
+            ['img'=>'https://cdn-novel.iycdm.com/h5/ad/pdd/2019041615.jpg','url'=>'/advertise/pdd?link=2019041615']
+        ];
+        //$key = random_int(1,17);
+        return collect($links)->random(1)->first();
+        //return $links[$key];
+
+    }
     /**
      * 获取客服图片
      */

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

@@ -69,6 +69,8 @@ Route::group(['domain'=>env('WAP_DOMAIN'),'namespace'=>'App\Http\Controllers\Wap
     Route::get('advertise/jump','Advertises\AdvertiseController@jumpToSource');
     Route::any('advertise/recieveUserBehavior','Advertises\AdvertiseController@recieveUserBehavior');
 
+    Route::get('advertise/pdd','Advertises\AdvertiseController@pddAd');
+
 
 //web 接口
     Route::group(['prefix'=>'api'],function () {

+ 20 - 1
app/Libs/Helpers.php

@@ -426,6 +426,22 @@ function myLog($name,$filename=''){
     return $writer;
 }
 
+function redisEnv($key,$default=''){
+    static $result = [];
+    if(isset($result[$key])) return $result[$key];
+    $value = \Redis::hget('env',$key);
+    if($value){
+        $result[$key] = $value;
+        return $value;
+    }
+   return $default;
+}
+
+function redisEnvMulti(...$key){
+    $value = \Redis::hmget('env',$key);
+    return $value;
+}
+
 function get_client_ip($type = 0, $adv = false)
 {
     $type      = $type ? 1 : 0;
@@ -584,6 +600,9 @@ function specialChannelAuthInfoV2(){
         '5641'=>'wx7e9d88af5216eedd',
         '5642'=>'wx4618cda729138d15',
         '5662'=>'wx44b8626c8ad9247e',
-        '5663'=>'wx8653757301ed2591'
+        '5663'=>'wx8653757301ed2591',
+        '5690'=>'wxbdbb2b13eea80db9',
+        '5691'=>'wx8b2e50da113c673c',
+        '5692'=>'wxb51a74837aa2f1c4'
     ];
 }

+ 4 - 0
app/Modules/ShareFree/Models/ShareUsers.php

@@ -22,4 +22,8 @@ class ShareUsers extends Model
         }
         return $rec;
     }
+
+    public static function getUnlocked($uid,$bid) {
+        return self::where('uid',$uid)->where('bid',$bid)->where('status',1)->first();
+    }
 }

+ 4 - 0
app/Modules/ShareFree/Services/ShareUsersService.php

@@ -14,4 +14,8 @@ class ShareUsersService
     public static function addShareUsers($data) {
         return ShareUsers::addShareUsers($data);
     }
+
+    public static function getUnlocked($uid,$bid){
+        return ShareUsers::getUnlocked($uid,$bid);
+    }
 }

+ 3 - 0
app/Modules/Subscribe/Models/Order.php

@@ -73,4 +73,7 @@ return $data ? $data[0]->price : 0;/*
             ->sum('orders.price');*/
     }
 
+    public static function getUserChargeTimes($uid){
+        return self::where('uid',$uid)->where('status','PAID')->count('id');
+    }
 }

+ 1 - 1
app/Modules/Subscribe/Models/OrderParam.php

@@ -7,5 +7,5 @@ use Illuminate\Database\Eloquent\Model;
 class OrderParam extends Model
 {
     protected $table = 'order_params';
-    protected $fillable = ['order_id','gxhp','appid','bid','data_hour_key','times'];
+    protected $fillable = ['order_id','gxhp','appid','bid','data_hour_key','times','distribution_channel_id'];
 }

+ 6 - 0
app/Modules/Subscribe/Services/OrderParamService.php

@@ -22,4 +22,10 @@ class OrderParamService
             OrderParam::create(compact('order_id','gxhp','appid','data_hour_key','bid','times'));
         }catch (\Exception $e){}
     }
+
+    public static function createByParam($param){
+        try{
+            OrderParam::create($param);
+        }catch (\Exception $e){}
+    }
 }

+ 3 - 0
app/Modules/Subscribe/Services/OrderService.php

@@ -216,4 +216,7 @@ WHERE  send_order_id = %s and order_type= 'RECHARGE' ";
         return false;
     }
 
+    public static function getUserChargeTimes($uid){
+        return Order::getUserChargeTimes($uid);
+    }
 }

+ 5 - 2
app/Modules/User/Services/UserService.php

@@ -336,18 +336,21 @@ class UserService
 
     public static function isCpcUser($uid){
         //openid下所有强关超过三天的uid都无充值,对强关后的uid进行曝光
+        //openid下有一个强关超过三天的uid,都无充值,对强关后的uid进行曝光
         $sql_format = "SELECT u.id,f.subscribe_time,(SELECT id from orders where uid = u.id and `status` = 'PAID' LIMIT 1)as oid  FROM users u
 JOIN force_subscribe_users f on u.id = f.uid and f.is_subscribed= 1
 WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
         $result = DB::select(sprintf($sql_format,$uid));
         if(!$result) return false;
 
+        $is_has_force_subscribe_three_days =false;
         foreach ($result as $item){
             //有充值
             if($item->oid) return false;
             //强关没超过超过三天
-            if(time()-strtotime($item->subscribe_time) < 86400*3) return false;
+            //if(time()-strtotime($item->subscribe_time) < 86400*3) return false;
+            if(time()-strtotime($item->subscribe_time) > 86400*3) $is_has_force_subscribe_three_days = true;
         }
-        return true;
+        return $is_has_force_subscribe_three_days;
     }
 }

+ 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-4-15/css/app.d4b0d841448941738b356b5b47c81068.css rel=stylesheet>
+    <link href=https://cdn-novel.iycdm.com/static2019-4-17/css/app.bad0bb066cc15434bd376e4144a27553.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-4-15/js/manifest.000491709457aa596c79.js></script>
-<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-4-15/js/vendor.ffff3089fc2f18220e2f.js></script>
-<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-4-15/js/app.00627a040c0e8eafaee4.js></script>
+        src=https://cdn-novel.iycdm.com/static2019-4-17/js/manifest.e2b0caeee18bddb27f0e.js></script>
+<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-4-17/js/vendor.ffff3089fc2f18220e2f.js></script>
+<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-4-17/js/app.e0ffc03b5d0206165284.js></script>
 </body>
 </html>