root пре 6 година
родитељ
комит
cf17f79049

+ 35 - 1
app/Console/Commands/BookAfterSpider.php

@@ -30,6 +30,8 @@ class BookAfterSpider extends Command
      *
      *
      * @return void
      * @return void
      */
      */
+     private $update_info = [];
+
     public function __construct()
     public function __construct()
     {
     {
         parent::__construct();
         parent::__construct();
@@ -54,12 +56,13 @@ class BookAfterSpider extends Command
                 $this->starts($value);
                 $this->starts($value);
             }
             }
         }
         }
+        $this->recordUpdateInfo();
     }
     }
 
 
     private function starts($bid)
     private function starts($bid)
     {
     {
-        $this->bookChapterInfo($bid);
         $this->addbookConfig($bid);
         $this->addbookConfig($bid);
+        $this->bookChapterInfo($bid);
         $this->adjustSequentOne($bid);
         $this->adjustSequentOne($bid);
     }
     }
 
 
@@ -98,6 +101,11 @@ class BookAfterSpider extends Command
             if ($vip && isset($vip->sequence)) {
             if ($vip && isset($vip->sequence)) {
                 $vip_seq = $vip->sequence;
                 $vip_seq = $vip->sequence;
             }
             }
+            $this->update_info[$bid] = [];
+            $this->update_info[$bid]['add'] = true;
+            $this->update_info[$bid]['channel_name'] = $book_info->category_id >=13 ? '女频':'男频';
+            $this->update_info[$bid]['update_type'] = 'add_book';
+            $this->update_info[$bid]['book_name'] = $book_info->name;
             DB::table('book_configs')->insert([
             DB::table('book_configs')->insert([
                 'bid' => $bid,
                 'bid' => $bid,
                 'force_subscribe_chapter_seq' => 10,
                 'force_subscribe_chapter_seq' => 10,
@@ -123,6 +131,10 @@ class BookAfterSpider extends Command
         $res3 = DB::table('chapters')->where('bid', $bid)->count();
         $res3 = DB::table('chapters')->where('bid', $bid)->count();
 
 
         $res4 = DB::table('chapters')->where('bid', $bid)->sum('size');
         $res4 = DB::table('chapters')->where('bid', $bid)->sum('size');
+        if(isset($this->update_info[$bid])){
+            $this->update_info[$bid]['update_words'] = $res4;
+            $this->update_info[$bid]['update_chapter_count'] = $res3;
+        }
         DB::table('books')->where('id', $bid)->update(
         DB::table('books')->where('id', $bid)->update(
             [
             [
                 'chapter_count' => $res3,
                 'chapter_count' => $res3,
@@ -161,4 +173,26 @@ class BookAfterSpider extends Command
             $prev = $chapter->id;
             $prev = $chapter->id;
         }
         }
     }
     }
+
+    private function recordUpdateInfo()
+    {
+        if(!$this->update_info) {
+            return;
+        }
+        foreach ($this->update_info as $k=>$v){
+            if(!$v['add']) continue;
+            // 2 book_updates 的更新记录
+            DB::table('book_updates')->insert([
+                'bid' => $k,
+                'book_name' => $v['book_name'],
+                'channel_name' => $v['channel_name'],
+                'update_date' => date('Y-m-d'),
+                'update_chapter_count' => $v['update_chapter_count'],
+                'update_words' => $v['update_words'],
+                'update_type' => $v['update_type'],
+                'created_at' => date('Y-m-d H:i:s'),
+                'updated_at' => date('Y-m-d H:i:s')
+            ]);
+        }
+    }
 }
 }

+ 28 - 0
app/Console/Commands/BookUpdateOne.php

@@ -8,6 +8,8 @@ use App\Modules\Book\Models\Book;
 use App\Modules\Book\Models\Chapter;
 use App\Modules\Book\Models\Chapter;
 use App\Modules\Book\Services\ChapterService;
 use App\Modules\Book\Services\ChapterService;
 use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Book\Services\BookConfigService;
+use DB;
+
 class BookUpdateOne extends Command
 class BookUpdateOne extends Command
 {
 {
     /**
     /**
@@ -80,8 +82,10 @@ class BookUpdateOne extends Command
         $res = $this->client->get(sprintf($chapter_list_fromat,$book_info->ly_bid));
         $res = $this->client->get(sprintf($chapter_list_fromat,$book_info->ly_bid));
         $res = $res->getBody()->getContents();
         $res = $res->getBody()->getContents();
         if(!$res) return '';
         if(!$res) return '';
+        $book_config_info = DB::table('book_configs')->where('bid',$bid)->first();
         $res = json_decode($res,true);
         $res = json_decode($res,true);
         $j = 0;
         $j = 0;
+        $size = 0;
         $local_count = Chapter::where('bid',$bid)->count();
         $local_count = Chapter::where('bid',$bid)->count();
         $remote_count = 0;
         $remote_count = 0;
 
 
@@ -119,6 +123,7 @@ class BookUpdateOne extends Command
                     $cahpter_content = json_decode($cahpter_content, true);
                     $cahpter_content = json_decode($cahpter_content, true);
                     $temp['size'] = ceil(strlen($cahpter_content['data']['chapter_content']) / 3);
                     $temp['size'] = ceil(strlen($cahpter_content['data']['chapter_content']) / 3);
                     $temp['content'] = $cahpter_content['data']['chapter_content'];
                     $temp['content'] = $cahpter_content['data']['chapter_content'];
+                    $size += $temp['size'];
                 }
                 }
                 $insert_res = Chapter::create($temp);
                 $insert_res = Chapter::create($temp);
                 Chapter::where('id', $max_sequence_chapter_id)->update(['next_cid' => $insert_res->id]);
                 Chapter::where('id', $max_sequence_chapter_id)->update(['next_cid' => $insert_res->id]);
@@ -131,6 +136,13 @@ class BookUpdateOne extends Command
         $chapter_size = Chapter::where('bid',$bid)->sum('size');
         $chapter_size = Chapter::where('bid',$bid)->sum('size');
         if($j>0){
         if($j>0){
             Book::where('id',$bid)->update(['chapter_count'=>$chapter_count,'last_cid'=>$max_sequence_chapter_id,'size'=>$chapter_size,'last_chapter'=>$v['chapter_name']]);
             Book::where('id',$bid)->update(['chapter_count'=>$chapter_count,'last_cid'=>$max_sequence_chapter_id,'size'=>$chapter_size,'last_chapter'=>$v['chapter_name']]);
+            $this->recordUpdateInfo($bid,[
+                'book_name'=>$book_config_info->book_name,
+                'update_chapter_count'=>$j,
+                'update_words'=>$size,
+                'update_type'=>'add_chapter',
+                'channel_name'=>$book_info->category_id >=13 ? '女频':'男频'
+            ]);
         }
         }
         return $j;
         return $j;
     }
     }
@@ -195,4 +207,20 @@ class BookUpdateOne extends Command
             }
             }
         }
         }
     }
     }
+
+    private function recordUpdateInfo($bid, $data)
+    {
+        // 2 book_updates 的更新记录
+        DB::table('book_updates')->insert([
+            'bid' => $bid,
+            'book_name' => $data['book_name'],
+            'channel_name' => $data['channel_name'],
+            'update_date' => date('Y-m-d'),
+            'update_chapter_count' => $data['update_chapter_count'],
+            'update_words' => $data['update_words'],
+            'update_type' => $data['update_type'],
+            'created_at' => date('Y-m-d H:i:s'),
+            'updated_at' => date('Y-m-d H:i:s')
+        ]);
+    }
 }
 }

+ 41 - 0
app/Console/Commands/WapVisitStat.php

@@ -87,6 +87,9 @@ class WapVisitStat extends Command
             case 11:
             case 11:
                 $this->substituteStats();
                 $this->substituteStats();
                 break;
                 break;
+            case 12:
+                $this->StylePushStats();
+                break;
         }
         }
         return false;
         return false;
     }
     }
@@ -653,4 +656,42 @@ class WapVisitStat extends Command
         }
         }
         Redis::del('substitutepagepvuv'.$day);
         Redis::del('substitutepagepvuv'.$day);
     }
     }
+
+    private function StylePushStats(){
+        $date = date('Y-m-d',time()-86400);
+        $record = Redis::SMEMBERS(sprintf('push:stylepush:date:%s',$date));
+        if(!$record)return ;
+        $i = 0;
+        $data = [];
+        foreach ($record as $item){
+            $item_array = explode('_',$item);
+            $distribution_channel_id = $item_array[0];
+            $gxhp = $item_array[1];
+            $uv_key = sprintf('push:stylepush:uv:%s:gxhp:%s:date:%s',$distribution_channel_id,$gxhp,$date);
+            $pv_key = sprintf('push:stylepush:pv:%s:gxhp:%s:date:%s',$distribution_channel_id,$gxhp,$date);
+            $uv = Redis::scard($uv_key);
+            $pv = Redis::get($pv_key);
+            $data[] = [
+                'day' => $date,
+                'key' => $distribution_channel_id,
+                'from_type' => $gxhp,
+                'pv' => $pv,
+                'uv' => $uv,
+                'type' => 8,
+                'created_at' => date('Y-m-d H:i:s'),
+                'updated_at' => date('Y-m-d H:i:s')
+            ];
+            Redis::del($uv_key);
+            Redis::del($pv_key);
+            if($i && $i%100 == 0){
+                DB::table('wap_visit_stats')->insert($data);
+                $data = [];
+            }
+            $i++;
+        }
+        if($data){
+            DB::table('wap_visit_stats')->insert($data);
+        }
+        Redis::del(sprintf('push:stylepush:date:%s',$date));
+    }
 }
 }

+ 22 - 5
app/Http/Controllers/Wap/Book/ChapterController.php

@@ -135,6 +135,9 @@ class ChapterController extends BaseController
      */
      */
     public function getCatalog(Request $request, $t, $domain, $bid)
     public function getCatalog(Request $request, $t, $domain, $bid)
     {
     {
+        if (!$this->checkUid()) {
+            return response()->error('WAP_NOT_LOGIN');
+        }
         $this->en_bid = $bid;
         $this->en_bid = $bid;
         $bid = Hashids::decode($bid)[0];
         $bid = Hashids::decode($bid)[0];
         $lists = ChapterService::getChapterLists($bid);
         $lists = ChapterService::getChapterLists($bid);
@@ -229,6 +232,9 @@ class ChapterController extends BaseController
      */
      */
     public function getCatalogPerPage(Request $request, $t, $domain, $bid)
     public function getCatalogPerPage(Request $request, $t, $domain, $bid)
     {
     {
+        if (!$this->checkUid()) {
+            return response()->error('WAP_NOT_LOGIN');
+        }
         $this->en_bid = $bid;
         $this->en_bid = $bid;
 
 
         $bid_array = Hashids::decode($bid);
         $bid_array = Hashids::decode($bid);
@@ -244,7 +250,7 @@ class ChapterController extends BaseController
         }
         }
         $this->book_info = $book_info;
         $this->book_info = $book_info;
         $page_size = $request->input('page_size', 15);
         $page_size = $request->input('page_size', 15);
-
+        if($page_size>=100) $page_size=100;
         $res = ChapterService::getChapterListsPage($bid, $page_size);
         $res = ChapterService::getChapterListsPage($bid, $page_size);
         $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
         $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
         foreach ($res as $v) {
         foreach ($res as $v) {
@@ -389,8 +395,8 @@ class ChapterController extends BaseController
 
 
         $this->is_need_subscribe = !$force_subscribe;
         $this->is_need_subscribe = !$force_subscribe;
 
 
-        //图书域名,book_configs表的promotion_domain 要跟当前的主机名匹配 在强关章节后
-        if ($this->is_need_subscribe && $this->isVisitDomainEqualBookDomain($domain)) {
+        //图书域名,book_configs表的promotion_domain 要跟当前的主机名匹配 在强关章节后3章
+        if ($chapter->sequence > $subscribe_seq + 3 && $this->isVisitDomainEqualBookDomain($domain)) {
             if($special_user_log && $special_user_log == $this->uid){
             if($special_user_log && $special_user_log == $this->uid){
                 $my_log = myLog('special');
                 $my_log = myLog('special');
                 $my_log->info('book domain not match------------------------');
                 $my_log->info('book domain not match------------------------');
@@ -1223,12 +1229,23 @@ class ChapterController extends BaseController
     private function getSubscribeChapterNum($book)
     private function getSubscribeChapterNum($book)
     {
     {
         $hour = date('G');
         $hour = date('G');
-        if($this->send_order_id && $hour <=5 && in_array($this->send_order_id,[392216,392218])){
+        $send_order_info = null;
+        if(in_array($this->distribution_channel_id,[123,211]) && $this->send_order_id){
+            //开启落地页强关的需求有变,需要在链接实际推广1小时后就开启功能
+            $send_order_info = SendOrderService::getById($this->send_order_id);
+            if($send_order_info && $send_order_info->send_time && time()-strtotime($send_order_info->send_time) > 3600){
+                return 1;
+            }
+        }
+        if($this->send_order_id && $hour <=5 && in_array($this->send_order_id,[392216,392218,415200,415212,415163])){
+            return 1;
+        }
+        if($this->send_order_id && $hour <=5 && time()>1552233600 && in_array($this->send_order_id,[424454,424453,424452,424451,424450,424449,424448,424447,424446,424445,424444,424443,424442,424441,424440,424439,424438,424437,424436,424435,424434,424433,424432,424431,424430])){
             return 1;
             return 1;
         }
         }
         //派单强关
         //派单强关
         if ($this->send_order_id) {
         if ($this->send_order_id) {
-            $send_order_info = SendOrderService::getById($this->send_order_id);
+            $send_order_info || $send_order_info = SendOrderService::getById($this->send_order_id);
             if ($send_order_info && $send_order_info->book_id == $book->bid && $send_order_info->subscribe_chapter_seq) {
             if ($send_order_info && $send_order_info->book_id == $book->bid && $send_order_info->subscribe_chapter_seq) {
                 return $send_order_info->subscribe_chapter_seq;
                 return $send_order_info->subscribe_chapter_seq;
             }
             }

+ 18 - 0
app/Http/Controllers/Wap/Oauth/UsersController.php

@@ -73,6 +73,15 @@ class UsersController extends Controller
                     'send_order_id' => Cookie::get('send_order_id')
                     'send_order_id' => Cookie::get('send_order_id')
                 ]
                 ]
             );
             );
+            
+            // 注册动作
+            $action_type = 'Register';
+            $param = [
+               'openid' => $openid,
+               'uid' => isset($user->id)?$user->id:'0',
+            ];
+            UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
+            
         }
         }
 
 
 
 
@@ -111,6 +120,15 @@ class UsersController extends Controller
                     'send_order_id' => Cookie::get('send_order_id')
                     'send_order_id' => Cookie::get('send_order_id')
                 ]
                 ]
             );
             );
+            
+            // 注册动作
+            $action_type = 'Register';
+            $param = [
+	            'openid' => $openid,
+	            'uid' => isset($user->id)?$user->id:'0',
+            ];
+            UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
+            
         }
         }
 
 
         Cookie::queue(env('COOKIE_AUTH_WEB_WECHAT'), $user->id, env('U_COOKIE_EXPIRE'), null, null, false, false);
         Cookie::queue(env('COOKIE_AUTH_WEB_WECHAT'), $user->id, env('U_COOKIE_EXPIRE'), null, null, false, false);

+ 39 - 5
app/Http/Controllers/Wap/Pay/OrdersController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers\Wap\Pay;
 namespace App\Http\Controllers\Wap\Pay;
 
 
 use App\Modules\Book\Services\ChapterService;
 use App\Modules\Book\Services\ChapterService;
+use App\Modules\Subscribe\Services\OrderParamService;
 use App\Modules\Subscribe\Services\SubstituteOrderService;
 use App\Modules\Subscribe\Services\SubstituteOrderService;
 use App\Modules\User\Services\ReadRecordService;
 use App\Modules\User\Services\ReadRecordService;
 use Illuminate\Routing\Controller;
 use Illuminate\Routing\Controller;
@@ -146,7 +147,7 @@ class OrdersController extends Controller
             return redirect()->to($back_url);
             return redirect()->to($back_url);
         }
         }
         if (empty($openid)) {
         if (empty($openid)) {
-            $trade_no = date("YmdHis") . hexdec(uniqid());
+            $trade_no = date("YmdHis") . str_shuffle(hexdec(uniqid()));
             $params = compact('uid', 'product_id', 'distribution_channel_id', 'send_order_id', 'bid', 'trade_no', 'pay_redirect_url', 'fromtype', 'activity_id', 'n','suid');
             $params = compact('uid', 'product_id', 'distribution_channel_id', 'send_order_id', 'bid', 'trade_no', 'pay_redirect_url', 'fromtype', 'activity_id', 'n','suid');
 
 
             $redirect_url = env('CREATE_PAY_URL') . '?' . http_build_query($params);
             $redirect_url = env('CREATE_PAY_URL') . '?' . http_build_query($params);
@@ -298,6 +299,7 @@ class OrdersController extends Controller
         if($result)
         if($result)
         {
         {
             $this->orderCreated($init_order);
             $this->orderCreated($init_order);
+            $this->recordOtherParam($result->id, $uid);
         }
         }
 
 
         if ($request->get('suid')) {
         if ($request->get('suid')) {
@@ -354,6 +356,17 @@ class OrdersController extends Controller
         Log::info($pay_info);
         Log::info($pay_info);
         Log::info('jsSdkSign---- :' . $jsSdkSign);
         Log::info('jsSdkSign---- :' . $jsSdkSign);
         $pay_order = $trade_no;
         $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',
+        ];
+        UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
+        
         return view('pay.order.index', compact('pay_info', 'referer', 'jsSdkSign', 'pay_order'));
         return view('pay.order.index', compact('pay_info', 'referer', 'jsSdkSign', 'pay_order'));
     }
     }
 
 
@@ -373,7 +386,7 @@ class OrdersController extends Controller
         //根据分校id获取支付配置id
         //根据分校id获取支付配置id
         Log::info($request->all());
         Log::info($request->all());
 
 
-        $trade_no =$trade_no = date("YmdHis") . hexdec(uniqid());;
+        $trade_no =$trade_no = date("YmdHis") . str_shuffle(hexdec(uniqid()));
         $order_info = OrderService::getByTradeNo($trade_no);
         $order_info = OrderService::getByTradeNo($trade_no);
         if ($order_info) return response()->error('WAP_SYS_ERROR');
         if ($order_info) return response()->error('WAP_SYS_ERROR');
 
 
@@ -473,6 +486,7 @@ class OrdersController extends Controller
         if($result)
         if($result)
         {
         {
             $this->orderCreated($init_order);
             $this->orderCreated($init_order);
+            $this->recordOtherParam($result->id, $uid);
         }
         }
         if ($suid) {
         if ($suid) {
             $this->createSubstituteOrder($result->id, $uid, $suid);
             $this->createSubstituteOrder($result->id, $uid, $suid);
@@ -535,6 +549,10 @@ class OrdersController extends Controller
                 return redirect($url);
                 return redirect($url);
             }
             }
         }
         }
+        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'));
         return view('pay.order.wait', compact('order', 'url'));
     }
     }
 
 
@@ -784,6 +802,15 @@ class OrdersController extends Controller
                 $key = 'leyuee:to_send_not_pay_uid:distribution_channel_id:' . $distribution_channel_id;
                 $key = 'leyuee:to_send_not_pay_uid:distribution_channel_id:' . $distribution_channel_id;
                 Redis::hdel($key, $uid);
                 Redis::hdel($key, $uid);
                 DB::commit();
                 DB::commit();
+                
+                // 注册动作-》回调订单
+                $action_type = 'CallBackOrder';
+                $param = [
+                   'order_sn' => isset($trade_no)?$trade_no:'0',
+                   'openid' => isset($uid)?$uid:'0',// 没有openid,用uid写log
+                ];
+                UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
+                
                 return true;
                 return true;
             } catch (\Exception $e) {
             } catch (\Exception $e) {
                 DB::rollback();
                 DB::rollback();
@@ -1455,9 +1482,9 @@ class OrdersController extends Controller
 
 
     private function payAlert($pay_merchant_id, $trade_no = '', $pay_info = '', $n = 0)
     private function payAlert($pay_merchant_id, $trade_no = '', $pay_info = '', $n = 0)
     {
     {
-        $change_pay_id = 9;
-        if ($pay_merchant_id == 9) {
-            //$change_pay_id = 12;
+        $change_pay_id = 40;
+        if ($pay_merchant_id == 40) {
+            $change_pay_id = 9;
         }
         }
         try {
         try {
             $time = (int)date('G');
             $time = (int)date('G');
@@ -1498,6 +1525,13 @@ class OrdersController extends Controller
         SubstituteOrderService::createOrder($order_id, $uid, $pay_uid);
         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 substituteOrderPrice($order_id,$prize_fee=500)
     private function substituteOrderPrice($order_id,$prize_fee=500)
     {
     {
         SubstituteOrderService::SubstituteOrderPrize($order_id, $prize_fee);
         SubstituteOrderService::SubstituteOrderPrize($order_id, $prize_fee);

+ 16 - 1
app/Http/Controllers/Wap/User/UserController.php

@@ -142,7 +142,22 @@ class UserController extends BaseController
      *   }
      *   }
      */
      */
     public function signRecord(Request $request){
     public function signRecord(Request $request){
-        return response()->pagination(new SignRecordTransformer(),UserSignService::getUserSignRecord($this->uid));
+        $sign_result = paginationTransform(new SignRecordTransformer(),UserSignService::getUserSignRecord($this->uid));
+        $sign_status = UserSignService::isSign($this->uid);
+        $sign_today = [];
+        if($sign_status){
+            $sign_today = ReadRecordService::getByField($this->uid,'sign_info');
+            if($sign_today) $sign_today = json_decode($sign_today,1);
+            isset($sign_today['sign_time']) && $sign_today['sign_time'] = date('Y-m-d H:i:s',$sign_today['sign_time']);
+            isset($sign_today['sign_at']) && $sign_today['sign_time'] = $sign_today['sign_at'];
+            isset($sign_today['price']) && $sign_today['reward'] = $sign_today['price'];
+        }
+        $result = [
+            'sign_status'=>$sign_status,
+            'sign_result'=>$sign_result,
+            'sign_today'=>$sign_today
+        ];
+        return response()->success($result);
     }
     }
 
 
     public function getCoupons(Request $request){
     public function getCoupons(Request $request){

+ 52 - 6
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -803,6 +803,7 @@ class WelcomeController extends BaseController
     {
     {
         $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
         $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
         $token = $request->input('token');
         $token = $request->input('token');
+        $img = 'https://cdn-novel.iycdm.com/h5/activity-chanel-custom/btn68.jpg';
         $activity_info = ActivityService::getByToken($token);
         $activity_info = ActivityService::getByToken($token);
         if ($activity_info && $activity_info->product_id) {
         if ($activity_info && $activity_info->product_id) {
             $from = $request->input('fromtype', 'main');
             $from = $request->input('fromtype', 'main');
@@ -815,15 +816,15 @@ class WelcomeController extends BaseController
             //$order = Order::where('uid',$this->uid)->where('status','PAID')->where('activity_id',$activity_info->id)->count();
             //$order = Order::where('uid',$this->uid)->where('status','PAID')->where('activity_id',$activity_info->id)->count();
             //渠道不符合
             //渠道不符合
             if ($activity_info->distribution_channel_id != $this->distribution_channel_id) {
             if ($activity_info->distribution_channel_id != $this->distribution_channel_id) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img,'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
             }
             }
             //活动未开始
             //活动未开始
             if (time() < strtotime($activity_info->start_time)) {
             if (time() < strtotime($activity_info->start_time)) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'code' => -3, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -3, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
             }
             //活动结束
             //活动结束
             if (time() > strtotime($activity_info->end_time)) {
             if (time() > strtotime($activity_info->end_time)) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -1, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
             }
 
 
             if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
             if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
@@ -837,10 +838,55 @@ class WelcomeController extends BaseController
                     'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
                     'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
                 ];
                 ];
                 $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
                 $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
-                return view('pay.order.longactivitysixtyeight', ['url' => $url, 'code' => 0, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => $url, 'img'=>$img, 'code' => 0, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
             }
         }
         }
-        return view('pay.order.longactivitysixtyeight', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
+        return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
+    }
+
+    public function channelActivityFortyEight(Request $request)
+    {
+        $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
+        $token = $request->input('token');
+        $activity_info = ActivityService::getByToken($token);
+        $img = 'https://cdn-novel.iycdm.com/h5/activity-chanel-custom/btn48.jpg';
+        if ($activity_info && $activity_info->product_id) {
+            $from = $request->input('fromtype', 'main');
+            $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
+            $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
+            $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
+            $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
+            Redis::sadd($uv_key, $this->uid);
+            Redis::hincrby($pv_key, date('Y-m-d'), 1);
+            //$order = Order::where('uid',$this->uid)->where('status','PAID')->where('activity_id',$activity_info->id)->count();
+            //渠道不符合
+            if ($activity_info->distribution_channel_id != $this->distribution_channel_id) {
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img,'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
+            }
+            //活动未开始
+            if (time() < strtotime($activity_info->start_time)) {
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -3, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+            }
+            //活动结束
+            if (time() > strtotime($activity_info->end_time)) {
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -1, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+            }
+
+            if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
+                $param = [
+                    'uid' => $this->uid,
+                    'distribution_channel_id' => $this->distribution_channel_id,
+                    'product_id' => $activity_info->product_id,
+                    'activity_id' => $activity_info->id,
+                    'fromtype' => $from,
+                    'limit' => 100,
+                    'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
+                ];
+                $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
+                return view('pay.order.longactivitysixtyeight', ['url' => $url, 'img'=>$img, 'code' => 0, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+            }
+        }
+        return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
     }
     }
 
 
     /**
     /**
@@ -1389,7 +1435,7 @@ class WelcomeController extends BaseController
         $param = [
         $param = [
             'uid' => $this->uid,
             'uid' => $this->uid,
             'distribution_channel_id' => $this->distribution_channel_id,
             'distribution_channel_id' => $this->distribution_channel_id,
-            'product_id' => 1624,
+            'product_id' => 1450,
             'activity_id' => 0,
             'activity_id' => 0,
             'fromtype' => 'tempC',
             'fromtype' => 'tempC',
             'limit' => 10,
             'limit' => 10,

+ 94 - 8
app/Http/Middleware/ReadOauth.php

@@ -6,6 +6,8 @@ use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Channel\Models\YqMoveChannel;
 use App\Modules\Channel\Models\YqMoveChannel;
 use App\Modules\Channel\Services\ChannelService;
 use App\Modules\Channel\Services\ChannelService;
 use App\Modules\OfficialAccount\Services\ForceSubscribeService;
 use App\Modules\OfficialAccount\Services\ForceSubscribeService;
+use App\Modules\SendOrder\Services\SendOrderService;
+use App\Modules\Statistic\Services\WapVisitStatService;
 use App\Modules\User\Models\YqMove;
 use App\Modules\User\Models\YqMove;
 use App\Modules\User\Services\ReadRecordService;
 use App\Modules\User\Services\ReadRecordService;
 use App\Modules\User\Services\UserService;
 use App\Modules\User\Services\UserService;
@@ -101,12 +103,15 @@ class ReadOauth
             }
             }
             return redirect()->to($redirect);
             return redirect()->to($redirect);
         }
         }
-
+        $uri_send_order_id = 0;
         if (strpos($uri, '/yun/') !== false) {
         if (strpos($uri, '/yun/') !== false) {
             $uri_send_order_id = (int)str_ireplace('/yun/', '', $uri);
             $uri_send_order_id = (int)str_ireplace('/yun/', '', $uri);
-            Redis::hset('book_read:' . $uid_cookie, 'send_order_id', $uri_send_order_id);
+            //Redis::hset('book_read:' . $uid_cookie, 'send_order_id', $uri_send_order_id);
         }
         }
 
 
+        //个性化推送
+        $this->stylePush($request,$uid_cookie,$distribution_channel_id);
+
         //禁止明文访问
         //禁止明文访问
         if ($this->isForbidPrimaryNumberChannleID($origin_distribution_channel_id, $uid_cookie)) {
         if ($this->isForbidPrimaryNumberChannleID($origin_distribution_channel_id, $uid_cookie)) {
             return response('<html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><title>该网站地址暂停访问</title></head><body style="padding:0;margin:0;font-size:0"><div style="width:300px;height:100px;margin: 20px auto"><p style="font-size:20px;color:red;text-align:center">该网站地址暂停访问,请联系客服微信获取新地址:wuxinchao12</p></body></html>');
             return response('<html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><title>该网站地址暂停访问</title></head><body style="padding:0;margin:0;font-size:0"><div style="width:300px;height:100px;margin: 20px auto"><p style="font-size:20px;color:red;text-align:center">该网站地址暂停访问,请联系客服微信获取新地址:wuxinchao12</p></body></html>');
@@ -122,7 +127,7 @@ class ReadOauth
              Log::info($user_info);*/
              Log::info($user_info);*/
             $back = $request->get('back', '');
             $back = $request->get('back', '');
             if ($openid && $appid && $distribution_channel_id && $uid_cookie) {
             if ($openid && $appid && $distribution_channel_id && $uid_cookie) {
-                $this->apidAndOpenId($distribution_channel_id, $appid, $openid, $uid_cookie);
+                $this->apidAndOpenId($distribution_channel_id, $appid, $openid, $uid_cookie,$uri_send_order_id);
                 $channel = ChannelService::getById($distribution_channel_id);
                 $channel = ChannelService::getById($distribution_channel_id);
                 $is_yq_move = $this->isQyMove($channel, $distribution_channel_id);
                 $is_yq_move = $this->isQyMove($channel, $distribution_channel_id);
                 if ($is_yq_move) {
                 if ($is_yq_move) {
@@ -324,7 +329,7 @@ class ReadOauth
         return $arg;
         return $arg;
     }
     }
 
 
-    private function apidAndOpenId($distribution_channel_id, $appid, $openid, $uid)
+    private function apidAndOpenId($distribution_channel_id, $appid, $openid, $uid,$send_order_id)
     {
     {
         $appid_info = OfficialAccountService::officialAccountByAppid(['appid' => $appid]);
         $appid_info = OfficialAccountService::officialAccountByAppid(['appid' => $appid]);
         if (!$appid_info)
         if (!$appid_info)
@@ -336,19 +341,19 @@ class ReadOauth
         $res = ForceSubscribeService::forceSubscribeUsersByUidAndAppid($appid, $uid);
         $res = ForceSubscribeService::forceSubscribeUsersByUidAndAppid($appid, $uid);
         if ($res) return false;
         if ($res) return false;
 
 
-        /*$forcesubuser = ForceSubscribeService::forceSubscribeUsersByOpenid(['openid' => $openid]);
+        $forcesubuser = ForceSubscribeService::forceSubscribeUsersByOpenid(['openid' => $openid]);
         if ($forcesubuser) {
         if ($forcesubuser) {
             return false;
             return false;
-        }*/
+        }
 
 
-        $send_order_id = ReadRecordService::getSendOrderId($uid);
+        /*$send_order_id = ReadRecordService::getSendOrderId($uid);
         if ($send_order_id) {
         if ($send_order_id) {
             try {
             try {
                 Redis::hset('force_subscribe_from_send_order_id', $appid . '_' . $uid, $send_order_id);
                 Redis::hset('force_subscribe_from_send_order_id', $appid . '_' . $uid, $send_order_id);
             } catch (\Exception $e) {
             } catch (\Exception $e) {
             }
             }
 
 
-        }
+        }*/
         $user_info = ForceSubscribeService::getUserInfoAll($appid, $openid);
         $user_info = ForceSubscribeService::getUserInfoAll($appid, $openid);
         $forcesubuserdata = [
         $forcesubuserdata = [
             'appid' => $appid,
             'appid' => $appid,
@@ -358,6 +363,9 @@ class ReadOauth
             'openid' => $openid,
             'openid' => $openid,
             'official_account_id' => 1
             'official_account_id' => 1
         ];
         ];
+        if($send_order_id){
+            $forcesubuserdata['send_order_id'] = $send_order_id;
+        }
         if ($user_info) {
         if ($user_info) {
             isset($user_info['province']) && !empty($user_info['province']) && $forcesubuserdata['province'] = $user_info['province'];
             isset($user_info['province']) && !empty($user_info['province']) && $forcesubuserdata['province'] = $user_info['province'];
             isset($user_info['nickname']) && !empty($user_info['nickname']) && $forcesubuserdata['nickname'] = $user_info['nickname'];
             isset($user_info['nickname']) && !empty($user_info['nickname']) && $forcesubuserdata['nickname'] = $user_info['nickname'];
@@ -762,6 +770,21 @@ class ReadOauth
         return $redirect;
         return $redirect;
     }
     }
 
 
+    //个性化推送
+    private function stylePush(Request $request,$uid,$distribution_channel_id){
+        $gxhp = $request->get('gxhp');
+        if(!$gxhp || !$uid || !$distribution_channel_id) return ;
+
+        $date = date('Y-m-d');
+        $uv_key = sprintf('push:stylepush:uv:%s:gxhp:%s:date:%s',$distribution_channel_id,$gxhp,$date);
+        $pv_key = sprintf('push:stylepush:pv:%s:gxhp:%s:date:%s',$distribution_channel_id,$gxhp,$date);
+        try{
+            Redis::hset('book_read:' . $uid, 'gxhp', $gxhp);
+            Redis::sadd($uv_key, $uid);
+            Redis::incr($pv_key);
+            Redis::sadd(sprintf('push:stylepush:date:%s',$date),sprintf('%s_%s',$distribution_channel_id,$gxhp));
+        }catch (\Exception $e){}
+    }
     private function yqTest(Request $request, $uid,$channel_id)
     private function yqTest(Request $request, $uid,$channel_id)
     {
     {
         if (!$request->has('fromtype')) return '';
         if (!$request->has('fromtype')) return '';
@@ -997,4 +1020,67 @@ class ReadOauth
         }
         }
         return $area;
         return $area;
     }
     }
+
+    private function yun(Request $request,$uid,$distribution_channel_id){
+        $param = $request->get('yun');
+        if(!$param) return ;
+        $bid = $request->get('bid');
+        if($bid){
+            $bid_arr = Hashids::decode($bid);
+            isset($bid_arr[0]) && $bid = $bid_arr[0];
+            is_numeric($bid) && $this->specialChannelIdStats($param,$distribution_channel_id,$uid,$bid);
+        }
+        $key = date('Y-m-d');
+        Cookie::queue('send_order_id', $param, env('U_COOKIE_EXPIRE'), null, null, false, false);
+        $send_order_flag = Cookie::get('send_order_flag');
+        $send_orders = explode(',', $send_order_flag);
+        //uv
+        if (!Cookie::get('send_order_flag_' . $param) && !in_array($param, $send_orders)) {
+            Redis::hincrby('send_order_uv_' . $param, $key, 1);
+            Redis::hincrby('send_order_uv_' . $param, 'total', 1);
+            //Cookie::queue('send_order_flag_'.$param,$param, env('U_COOKIE_EXPIRE'), null, null, false, false);
+            array_push($send_orders, $param);
+            $str = implode(',', $send_orders);
+            Cookie::queue('send_order_flag', $str, env('U_COOKIE_EXPIRE'), null, null, false, false);
+        }
+
+        if (Cookie::get('send_order_flag_' . $param)) {
+            array_push($send_orders, $param);
+            $str = implode(',', $send_orders);
+            Cookie::queue('send_order_flag', $str, env('U_COOKIE_EXPIRE'), null, null, false, false);
+            Cookie::queue('send_order_flag_' . $param, null, -1);
+        }
+        //pv
+        Redis::hincrby('send_order_pv_' . $param, $key, 1);//每天
+        Redis::hincrby('send_order_pv_' . $param, 'total', 1);//汇总
+        Redis::sadd('send_order' . $key, $param);
+
+        $uv = Redis::hget('send_order_uv_' . $param, $key);
+
+        $uv && $uv>=20 && SendOrderService::updateSendOrderTime($param);
+    }
+
+    /**
+     * 用户从A连接推送的书,进入后,被标记bookid+派单id,之后所有的统计计算到该派单下
+     * @param int $send_order_id
+     * @param int $distribution_channel_id
+     * @param int $uid
+     * @param int $bid
+     */
+    private function specialChannelIdStats(
+        int $send_order_id,
+        int $distribution_channel_id,
+        int $uid,
+        int $bid
+    ):void{
+
+        if(!$bid || !$distribution_channel_id || !$uid || !$send_order_id)
+            return ;
+        $specialChannelIdStats = env('SPECIAL_CHANNEL_STATS',211);
+        if(!in_array($distribution_channel_id,explode(',',$specialChannelIdStats)) ){
+            return ;
+        }
+        WapVisitStatService::specialChannelIdStatsMarkUser($uid,$bid,$send_order_id);
+        return ;
+    }
 }
 }

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

@@ -180,6 +180,7 @@ Route::group(['domain'=>env('WAP_DOMAIN'),'namespace'=>'App\Http\Controllers\Wap
 
 
         Route::get('sale/channelsalenine','Web\WelcomeController@channelActivityNine');
         Route::get('sale/channelsalenine','Web\WelcomeController@channelActivityNine');
         Route::get('sale/channelsalesixty','Web\WelcomeController@channelActivitySixtyEight');
         Route::get('sale/channelsalesixty','Web\WelcomeController@channelActivitySixtyEight');
+        Route::get('sale/channelsaleforty','Web\WelcomeController@channelActivityFortyEight');
         Route::get('sale/qingMingActivity','Web\WelcomeController@qingMingActivity');
         Route::get('sale/qingMingActivity','Web\WelcomeController@qingMingActivity');
         Route::get('sale/readDayActivity','Web\WelcomeController@readDayActivity');
         Route::get('sale/readDayActivity','Web\WelcomeController@readDayActivity');
         Route::get('sale/laborDayActivity','Web\WelcomeController@readDayActivity');
         Route::get('sale/laborDayActivity','Web\WelcomeController@readDayActivity');

+ 51 - 0
app/Jobs/ActionTrigger.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Jobs;
+
+use Artisan;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+/**
+ * 动作触发器,兼容所有扔队列需要异步处理的请求
+ * @author zhoulingjie
+ *
+ */
+class ActionTrigger implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    protected $data;
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct($data)
+    {
+        //
+        \Log::info('action_trigger_init');
+        $this->data = $data;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+//     	$data =  json_encode($this->data);
+//         try {
+//         	\Log::info('ActionTrigger:'.$data['action_type'].' start');
+
+//             Artisan::call('ActionTrigger:'.$data['action_type'],['data'=>$data]);
+
+//         } catch (\Exception $e) {
+//             \Log::info('action_trigger_ept:'.$e->getMessage());
+//         }
+    }
+}

+ 26 - 5
app/Libs/Helpers.php

@@ -202,7 +202,27 @@ function collectionTransform($trans, $data){
     return $ret_data;
     return $ret_data;
 }
 }
 
 
+function paginationTransform ($trans, $paginator) {
+    $ret = [];
+    $ret['list'] = [];
+    if($paginator)
+    {
+        foreach ($paginator as $item)
+        {
+            $ret['list'][] = $trans->transform($item);
+        }
 
 
+        $ret['meta']= [
+            'total'=>(int)$paginator->total(),
+            'per_page'=>(int)$paginator->perPage(),
+            'current_page'=>(int)$paginator->currentPage(),
+            'last_page'=>(int)$paginator->lastPage(),
+            'next_page_url'=>(string)$paginator->nextPageUrl(),
+            'prev_page_url'=>(string)$paginator->previousPageUrl()
+        ];
+    }
+    return $ret;
+}
 function ImageNewsToArray($datas){
 function ImageNewsToArray($datas){
     if(empty($datas)) return null;
     if(empty($datas)) return null;
     if(!is_array($datas)){
     if(!is_array($datas)){
@@ -223,7 +243,7 @@ function ImageNewsToArray($datas){
  * 加密site id
  * 加密site id
  */
  */
 function encodeDistributionChannelId($id){
 function encodeDistributionChannelId($id){
-    $encrypt_pool = ['14'=>'xyvz5MEXLL52Mzn4','13'=>'laosiji','4372'=>'qhyeyue','365'=>'vciam5tg71'];
+    $encrypt_pool = ['14'=>'xyvz5mexll52mzn4','13'=>'laosiji','4372'=>'qhyeyue','365'=>'vciam5tg71','384'=>'sdxisd'];
     if(isset($encrypt_pool[$id])){
     if(isset($encrypt_pool[$id])){
         return $encrypt_pool[$id];
         return $encrypt_pool[$id];
     }
     }
@@ -244,7 +264,7 @@ function encodeDistributionChannelId($id){
  * 解密密site id
  * 解密密site id
  */
  */
 function decodeDistributionChannelId($code){
 function decodeDistributionChannelId($code){
-    $encrypt_pool = ['xyvz5MEXLL52Mzn4'=>'14','laosiji'=>'13','qhyeyue'=>'4372','vciam5tg71'=>'365'];
+    $encrypt_pool = ['xyvz5mexll52mzn4'=>'14','laosiji'=>'13','qhyeyue'=>'4372','vciam5tg71'=>'365','sdxisd'=>'384'];
     if(isset($encrypt_pool[$code])){
     if(isset($encrypt_pool[$code])){
         return $encrypt_pool[$code];
         return $encrypt_pool[$code];
     }
     }
@@ -474,7 +494,7 @@ function specialChannelAuthInfo(){
         '157'=>'wx5ebe6187c0fb0bd5',
         '157'=>'wx5ebe6187c0fb0bd5',
         '4175'=>'wx64cf3051ceb145ae',
         '4175'=>'wx64cf3051ceb145ae',
         '4217'=>'wxdb15f8db194bf6f4',
         '4217'=>'wxdb15f8db194bf6f4',
-        //'4604'=>'wxc177995c55b5e75e'
+        '4604'=>'wxc177995c55b5e75e'
     ];
     ];
 }
 }
 
 
@@ -488,7 +508,7 @@ function specialChannelAuthInfoV2(){
         '4578'=>'wx3beda81dba0b450b',
         '4578'=>'wx3beda81dba0b450b',
         '4580'=>'wxb4bb620409a96ed7',
         '4580'=>'wxb4bb620409a96ed7',
         '4603'=>'wxf9df2ce5ea94fa4e',
         '4603'=>'wxf9df2ce5ea94fa4e',
-        '4604'=>'wxb479d38891b14286',
+        //'4604'=>'wxb479d38891b14286',
         '4605'=>'wx72569a8f18599cdb',
         '4605'=>'wx72569a8f18599cdb',
         '4606'=>'wxb17c22779a821271',
         '4606'=>'wxb17c22779a821271',
         '4607'=>'wx2bc3eaf8840f81a8',
         '4607'=>'wx2bc3eaf8840f81a8',
@@ -515,6 +535,7 @@ function specialChannelAuthInfoV2(){
         '4909'=>'wx2c62f7f4a02176d7',
         '4909'=>'wx2c62f7f4a02176d7',
         '4910'=>'wx7ee2ad6685e3d5b3',
         '4910'=>'wx7ee2ad6685e3d5b3',
         '4820'=>'wx30ecb35d13959f8d',
         '4820'=>'wx30ecb35d13959f8d',
-        '4980'=>'wx002be80fb65d808e'
+        '4980'=>'wx002be80fb65d808e',
+        '5148'=>'wx8e9ff7a97fa67675'
     ];
     ];
 }
 }

+ 19 - 8
app/Modules/Book/Models/BookConfig.php

@@ -670,17 +670,17 @@ class BookConfig extends Model
     	// 判断渠道男女频
     	// 判断渠道男女频
     	$user = User::getById($uid);
     	$user = User::getById($uid);
     	$distribution_channel_id = isset($user->distribution_channel_id)?$user->distribution_channel_id:'';
     	$distribution_channel_id = isset($user->distribution_channel_id)?$user->distribution_channel_id:'';
-    	// 男频强制推广男频书
+    	// 男频强制推广男频书
     	$channel_sex = ChannelService::getChannelCompanySex($distribution_channel_id);
     	$channel_sex = ChannelService::getChannelCompanySex($distribution_channel_id);
-    	$channel_name = '';
-    	if($channel_sex == 1){
-    		$channel_name = '男频';
-    	}else{
+    	$channel_name = '';
+    	if($channel_sex == 1){
+    		$channel_name = '男频';
+    	}else{
 	    	$sex = ForceSubscribeService::getSimpleSexByUid($uid);
 	    	$sex = ForceSubscribeService::getSimpleSexByUid($uid);
-	    	$channel_name = $sex==1?'男频':'女频';
+	    	$channel_name = $sex==1?'男频':'女频';
     	}
     	}
-
-    	\Log::info('getH5RecommendBooks:pos:'.$pos.' uid:'.$uid.' num:'.$num.' channel_name:'.$channel_name.' channel_sex:'.$channel_sex.' distribution_channel_id:'.$distribution_channel_id);
+
+    	\Log::info('getH5RecommendBooks:pos:'.$pos.' uid:'.$uid.' num:'.$num.' channel_name:'.$channel_name.' channel_sex:'.$channel_sex.' distribution_channel_id:'.$distribution_channel_id);
     	
     	
     	$bids = [];
     	$bids = [];
     	$random_recommend = true;
     	$random_recommend = true;
@@ -713,6 +713,14 @@ class BookConfig extends Model
      * 获取随机的推荐书籍bid
      * 获取随机的推荐书籍bid
      */
      */
     public static function  getRandomRecommendBooks($channel_name, $num){
     public static function  getRandomRecommendBooks($channel_name, $num){
+        if($channel_name == '男频'){
+            $channel_name_replace = 'male';
+        }else{
+            $channel_name_replace = 'female';
+        }
+        $redis_key = sprintf('channel_name:%s:num:%s',$channel_name_replace,$num);
+        $cache = Redis::get($redis_key);
+        if($cache) return explode(',',$cache);
 	    $bids = self::join('books', 'book_configs.bid', '=', 'books.id')
 	    $bids = self::join('books', 'book_configs.bid', '=', 'books.id')
 	    ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
 	    ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
 	    ->select('book_configs.bid')
 	    ->select('book_configs.bid')
@@ -723,6 +731,9 @@ class BookConfig extends Model
 	    ->inRandomOrder()
 	    ->inRandomOrder()
 	    ->limit($num)
 	    ->limit($num)
 	    ->get()->pluck('bid')->all();
 	    ->get()->pluck('bid')->all();
+        if($bids){
+            Redis::setex($redis_key,7200,implode(',',$bids));
+        }
 	    return $bids;
 	    return $bids;
     }
     }
 
 

+ 1 - 1
app/Modules/OfficialAccount/Models/ForceSubscribeUsers.php

@@ -45,7 +45,7 @@ class ForceSubscribeUsers extends Model
     static function forceSubscribeUsersByUid($uid)
     static function forceSubscribeUsersByUid($uid)
     {
     {
 
 
-        return self::where(['uid' => $uid, 'is_subscribed' => 1])->first();
+        return self::where(['uid' => $uid, 'is_subscribed' => 1])->orderBy('id','desc')->first();
 
 
     }
     }
 
 

+ 12 - 5
app/Modules/OfficialAccount/Services/ForceSubscribeService.php

@@ -203,13 +203,20 @@ class ForceSubscribeService
                     if (empty($bid)) {
                     if (empty($bid)) {
                         # code...
                         # code...
                         $bid = '0';
                         $bid = '0';
+                    }else{
+                        Redis::hdel('force_subscribe_from_bid',$forceSubscribeUsersPrams['appid'].'_'.$forceSubscribeUsersPrams['uid']);
                     }
                     }
-
-                    $sendOrderId = Redis::hget('force_subscribe_from_send_order_id',$forceSubscribeUsersPrams['appid'].'_'.$forceSubscribeUsersPrams['uid']);
-                    if (empty($sendOrderId)) {
-                        # code...
-                        $sendOrderId = '0';
+                    if(isset($forceSubscribeUsersPrams['send_order_id']) && !empty($forceSubscribeUsersPrams['send_order_id'])){
+                        $sendOrderId = $forceSubscribeUsersPrams['send_order_id'];
+                    }else{
+                        $sendOrderId = Redis::hget('force_subscribe_from_send_order_id',$forceSubscribeUsersPrams['appid'].'_'.$forceSubscribeUsersPrams['uid']);
+                        if (empty($sendOrderId)) {
+                            $sendOrderId = '0';
+                        }else{
+                            Redis::hdel('force_subscribe_from_send_order_id',$forceSubscribeUsersPrams['appid'].'_'.$forceSubscribeUsersPrams['uid']);
+                        }
                     }
                     }
+
                     if($bid && $sendOrderId){
                     if($bid && $sendOrderId){
                         $send_order_bid = Redis::hget('sendOrderIdToBid',$sendOrderId);
                         $send_order_bid = Redis::hget('sendOrderIdToBid',$sendOrderId);
                         if(!$send_order_bid){
                         if(!$send_order_bid){

+ 11 - 0
app/Modules/Subscribe/Models/OrderParam.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Modules\Subscribe\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class OrderParam extends Model
+{
+    protected $table = 'order_params';
+    protected $fillable = ['order_id','gxhp','appid','bid','data_hour_key','times'];
+}

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

@@ -0,0 +1,25 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: z-yang
+ * Date: 2019/2/26
+ * Time: 18:52
+ */
+
+namespace App\Modules\Subscribe\Services;
+
+use App\Modules\Subscribe\Models\OrderParam;
+
+class OrderParamService
+{
+    public static function create($order_id,$gxhp){
+        try{
+            $other_param = explode('_',$gxhp);
+            $appid = isset($other_param[0])?$other_param[0]:0;
+            $data_hour_key = isset($other_param[1])?$other_param[1]:'';
+            $bid = isset($other_param[2])?$other_param[2]:0;
+            $times = isset($other_param[3])?$other_param[3]:0;
+            OrderParam::create(compact('order_id','gxhp','appid','data_hour_key','bid','times'));
+        }catch (\Exception $e){}
+    }
+}

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

@@ -34,6 +34,6 @@ class UserSign extends Model
      * 用户签到记录
      * 用户签到记录
      */
      */
     public static function getUserSignRecord($uid){
     public static function getUserSignRecord($uid){
-        return self::where('uid',$uid)->select('price','sign_time')->orderBy('sign_time','desc')->paginate();
+        return self::where('uid',$uid)->where('day','<',date('Y-m-d'))->select('price','sign_time')->orderBy('sign_time','desc')->paginate();
     }
     }
 }
 }

+ 15 - 1
app/Modules/User/Services/ReadRecordService.php

@@ -17,7 +17,7 @@ use DB;
 class ReadRecordService
 class ReadRecordService
 {
 {
 
 
-    private static $not_uid_key = ['last_read','send_order_id','sign_count','sign_counts','sign_day','smart_push','inner_send_order_id'];
+    private static $not_uid_key = ['last_read','send_order_id','sign_count','sign_counts','sign_info','sign_day','smart_push','inner_send_order_id','gxhp'];
 
 
     /**
     /**
      * 获取
      * 获取
@@ -467,6 +467,11 @@ class ReadRecordService
         Redis::hset('book_read:' . $uid,'sign_counts',$count);
         Redis::hset('book_read:' . $uid,'sign_counts',$count);
     }
     }
 
 
+
+    public static function setSignInfo(int $uid,string $info){
+        Redis::hset('book_read:' . $uid,'sign_info',$info);
+    }
+
     public static function setSmartPush($uid,$bid){
     public static function setSmartPush($uid,$bid){
         $old = self::getSmartPush($uid);
         $old = self::getSmartPush($uid);
         if($old && !in_array($bid,$old)){
         if($old && !in_array($bid,$old)){
@@ -485,4 +490,13 @@ class ReadRecordService
         }
         }
         return [];
         return [];
     }
     }
+
+    public static function getByField(int $uid,$field){
+        try{
+            return Redis::hget('book_read:' . $uid,$field);
+
+        }catch (\Exception $e){
+        }
+        return '';
+    }
 }
 }

+ 46 - 0
app/Modules/User/Services/UserService.php

@@ -10,6 +10,8 @@ namespace App\Modules\User\Services;
 
 
 use App\Modules\User\Models\User;
 use App\Modules\User\Models\User;
 use DB;
 use DB;
+use App\Jobs\ActionTrigger;
+use App\Modules\OfficialAccount\Models\DistributionSelfDefineConfig;
 
 
 class UserService
 class UserService
 {
 {
@@ -257,4 +259,48 @@ class UserService
 
 
         return User::updateInfo($from_uid, ['balance' => 0, 'reward_balance' => 0, 'charge_balance' => 0]);
         return User::updateInfo($from_uid, ['balance' => 0, 'reward_balance' => 0, 'charge_balance' => 0]);
     }
     }
+    
+    // 扔用户一些动作到队列,异步处理一些额外逻辑
+    static function PushUserActionToQueue($action_type,$distribution_channel_id,$param){
+    	try{
+    		// 判断站点是否需要额外逻辑
+    		$distribution_self_define_config = DistributionSelfDefineConfig::getDistributionSelfDefineConfig($distribution_channel_id,'action_call_ycsd');
+    		if(empty($distribution_self_define_config)){
+//     			\Log::info('not_action_call_ycsd:'.$distribution_channel_id);
+    			return '';
+    		}else{
+    			\Log::info('action_call_ycsd:'.$distribution_channel_id);
+    		}
+    		
+    		$data = [];
+    		$data['send_time'] = date("Y-m-d H:i:s");
+    		$data['action_type'] = $action_type;
+    		if($action_type == 'Register'){
+    			$data['openid'] =  $param['openid'];
+    			$data['uid'] = $param['uid'];
+    		}elseif($action_type == 'CreateOrder'){
+    			$data['orderSn'] =  $param['order_sn'];
+    			$data['amount'] = $param['amount'];
+    			$data['openid'] =  $param['openid'];
+    			$data['uid'] = $param['uid'];
+    		}elseif($action_type == 'CallBackOrder'){
+    			$data['orderSn'] =  $param['order_sn'];
+    			$data['openid'] =  $param['openid'];
+    		}
+    		 
+    		$send_data=array(
+    				'send_time'=>date("Y-m-d H:i:s"),
+    				'data' => $data
+    		);
+    		\Log::info('PushUserActionToQueue_openid:'.$data['openid'].' action_type:'.$action_type);
+    		\Log::info('$send_data');\Log::info($send_data);
+    		
+    		$delay = 0;
+    		
+    		$job = (new ActionTrigger($send_data))->onConnection('rabbitmq')->delay($delay)->onQueue('action_trigger_list');
+    		dispatch($job);
+    	}catch(\Exception $e){
+    		\Log::info('ept:'.$e->getMessage());
+    	}
+    }
 }
 }

+ 2 - 1
app/Modules/User/Services/UserSignService.php

@@ -125,8 +125,9 @@ class UserSignService
         	$sign_data = ['uid'=>$uid,'price'=>$fee,'day'=>$day,'sign_time'=>time(),'created_at'=>date('Y-m-d H:i:s'),'updated_at'=>date('Y-m-d H:i:s')];
         	$sign_data = ['uid'=>$uid,'price'=>$fee,'day'=>$day,'sign_time'=>time(),'created_at'=>date('Y-m-d H:i:s'),'updated_at'=>date('Y-m-d H:i:s')];
         	Redis::sadd('user_sign:uid',$uid);
         	Redis::sadd('user_sign:uid',$uid);
         	Redis::hset('user_sign:uid:info',$uid,json_encode($sign_data));
         	Redis::hset('user_sign:uid:info',$uid,json_encode($sign_data));
+            ReadRecordService::setSignInfo($uid,json_encode($sign_data));
         }else{
         }else{
-        	UserSign::sign($uid, $day,$fee);
+        	UserSign::sign($uid, $day,$fee);
         }
         }
         return $return_fee;
         return $return_fee;
     }
     }

+ 1 - 1
resources/views/pay/order/longactivitysixtyeight.blade.php

@@ -69,7 +69,7 @@
     <img src="https://cdn-novel.iycdm.com/h5/activity-chanel-custom/banner.jpg" alt="" />
     <img src="https://cdn-novel.iycdm.com/h5/activity-chanel-custom/banner.jpg" alt="" />
     <p class="time">活动有效期:{{$start_time or '-'}}至{{$end_time or '-'}}</p>
     <p class="time">活动有效期:{{$start_time or '-'}}至{{$end_time or '-'}}</p>
     <div class="recharge-item">
     <div class="recharge-item">
-        <img src="https://cdn-novel.iycdm.com/h5/activity-chanel-custom/btn68.jpg" alt="">
+        <img src="{{$img}}" alt="">
     </div>
     </div>
     <div class="recharge_box_one">
     <div class="recharge_box_one">
     @if($code == 0)
     @if($code == 0)

+ 5 - 5
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.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>
     <script>(window.Vue && window.VueLazyload) || document.write('<script src="https://cdn-novel.iycdm.com/static/vue-lazyload.js"><\/script>')</script>
     <title>{{$title}}</title>
     <title>{{$title}}</title>
-    <link href=https://cdn-novel.iycdm.com/static2019-3-1/css/app.fd2357d617a7a11ad95efb3fbdf2a634.css rel=stylesheet>
+    <link href=https://cdn-novel.iycdm.com/static2019-3-14/css/app.98e72397dd216cfd0dac351872544ff3.css rel=stylesheet>
 </head>
 </head>
 <body>
 <body>
 <div id=app></div>
 <div id=app></div>
@@ -32,8 +32,8 @@
     })();</script>
     })();</script>
 <script id=options>window.options = {!! $options!!};</script>
 <script id=options>window.options = {!! $options!!};</script>
 <script type=text/javascript
 <script type=text/javascript
-        src=https://cdn-novel.iycdm.com/static2019-3-1/js/manifest.72754c9021dc9cfa2068.js></script>
-<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-3-1/js/vendor.ffff3089fc2f18220e2f.js></script>
-<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-3-1/js/app.95f84aabec96764be987.js></script>
+        src=https://cdn-novel.iycdm.com/static2019-3-14/js/manifest.bf3acaf77cad8fe47289.js></script>
+<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-3-14/js/vendor.ffff3089fc2f18220e2f.js></script>
+<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-3-14/js/app.5858f87e7fc4af004e72.js></script>
 </body>
 </body>
-</html>
+</html>