Selaa lähdekoodia

Merge branch 'master' of iqiyoo:zhuishuyun_wap

onlinetest 6 vuotta sitten
vanhempi
commit
6328a5cf61

+ 4 - 2
app/Console/Commands/CheckOrderStatus.php

@@ -6,6 +6,7 @@ use App\Jobs\SendTexts;
 use App\Modules\SendOrder\Services\SendOrderService;
 use App\Modules\Subscribe\Services\YearOrderService;
 use App\Modules\User\Models\UserMonthSign;
+use App\Modules\User\Services\ReadRecordService;
 use App\Modules\User\Services\UserMonthService;
 use App\Modules\User\Services\UserService;
 use Illuminate\Console\Command;
@@ -94,7 +95,7 @@ NOT EXISTS (SELECT id FROM user_month_order WHERE user_month_order.uid =user_mon
         if (!UserMonthService::getOrderByOrder($trade_no, $out_trade_no)) {
             Log::info('deal uid is :'.$uid);
             UserMonthService::createLOrder($uid, $plan_id, $money, $trade_no, $out_trade_no);
-            //$this->addOrderAndVip($uid, $out_trade_no, $trade_no, $money);
+            $this->addOrderAndVip($uid, $out_trade_no, $trade_no, $money);
         }
     }
 
@@ -133,6 +134,7 @@ NOT EXISTS (SELECT id FROM user_month_order WHERE user_month_order.uid =user_mon
                 $send_order_name = $send_order_info->name;
             }
         }
+        $from_bid = ReadRecordService::getSimpleFirstReadRecord($uid);
         $init_order = [
             'distribution_channel_id' => $distribution_channel_id,
             'uid' => $uid,
@@ -146,7 +148,7 @@ NOT EXISTS (SELECT id FROM user_month_order WHERE user_month_order.uid =user_mon
             'send_order_id' => $send_order_id,
             'send_order_name' => $send_order_name,
             'order_type' => 'RECHARGE',
-            'from_bid' => '0',
+            'from_bid' => $from_bid,
             'from_type' => 'auto_month',
             'activity_id' => 0,
             'inner_send_order_id' => '',

+ 0 - 103
app/Console/Commands/InnerOuterWeixinStats.php

@@ -1,103 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use Illuminate\Console\Command;
-use DB;
-use Redis;
-
-class InnerOuterWeixinStats extends Command
-{
-    /**
-     * The name and signature of the console command.
-     *
-     * @var string
-     */
-    protected $signature = 'InnerOuterWeixinStats {--day=}';
-
-    /**
-     * The console command description.
-     *
-     * @var string
-     */
-    protected $description = 'Command description';
-
-    /**
-     * Create a new command instance.
-     *
-     * @return void
-     */
-    public function __construct()
-    {
-        parent::__construct();
-    }
-
-    /**
-     * Execute the console command.
-     *
-     * @return mixed
-     */
-    public function handle()
-    {
-        $day = $this->option('day');
-        if(!$day){
-            $day = date('Y-m-d',time()-86400);
-        }
-        $this->getByDay($day);
-    }
-
-    private function getByDay($day)
-    {
-        $keys = Redis::SMEMBERS('InnerOuterWeixinStats:'.$day);
-        if (!$keys) {
-            return ;
-        }
-        $data = [];
-        $i = 0;
-        foreach ($keys as $k){
-
-            list($from,$distribution_channel_id) = explode(':',$k);
-            if(!$from || !$distribution_channel_id) continue;
-            $pv_key = sprintf('InnerOuterWeixinStats:pv:%s:%s',$from,$distribution_channel_id);
-            $uv_key = sprintf('InnerOuterWeixinStats:uv:%s:%s:%s',$from,$distribution_channel_id,$day);
-            $pv = Redis::hget($pv_key,$day);
-            $uv = Redis::scard($uv_key);
-            $type = '';
-            $param = '';
-            if(is_numeric($from)){
-                $type = 'send_order';
-                $param = $from;
-            }
-
-            if(str_contains($from,['template'])){
-                $type = 'template';
-                list($temp,$param) = explode('_',$from);
-            }
-
-            if(str_contains($from,['custom'])){
-                $type = 'custom';
-                list($temp,$param) = explode('_',$from);
-            }
-            Redis::del($uv_key);
-            Redis::hdel($pv_key,$day);
-            if(!$type || !$param || !is_numeric($param)) continue;
-
-            $data[] = [
-                'type'=>$type,
-                'param'=>$param,
-                'pv'=>$pv,
-                'uv'=>$uv,
-                'day'=>$day,
-                'charge'=>0,
-                'updated_at'=>date('Y-m-d H:i:s'),
-                'created_at'=>date('Y-m-d H:i:s')
-            ];
-            if($i++ % 100 == 0){
-                DB::table('inner_outer_weixin_stats')->insert($data);
-                $data = [];
-            }
-        }
-        if($data){DB::table('inner_outer_weixin_stats')->insert($data);}
-        Redis::del('InnerOuterWeixinStats:'.$day);
-    }
-}

+ 0 - 106
app/Console/Commands/LatestCustomerMsg.php

@@ -1,106 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use Illuminate\Console\Command;
-use Redis;
-use DB;
-use Hashids;
-
-class LatestCustomerMsg extends Command
-{
-    /**
-     * The name and signature of the console command.
-     *
-     * @var string
-     */
-    protected $signature = 'LatestCustomerMsg';
-
-    /**
-     * The console command description.
-     *
-     * @var string
-     */
-    protected $description = 'Command description';
-
-    /**
-     * Create a new command instance.
-     *
-     * @return void
-     */
-    public function __construct()
-    {
-        parent::__construct();
-    }
-
-    /**
-     * Execute the console command.
-     *
-     * @return mixed
-     */
-    public function handle()
-    {
-        $this->start();
-    }
-
-    private function start()
-    {
-        Redis::del('latestcustomerinfo');
-        $sites = redisEnv('CUSTOM_CHAPTER_ORDER_SITES', '');
-        if (!$sites) return;
-        $sites = explode(',', $sites);
-        $result = \App\Modules\OfficialAccount\Models\CustomSendMsgs::where('send_time', '>=', date('Y-m-d H:i:s', time() - 10 * 3600 - 3 * 86400))
-            ->where('send_time', '<=', date('Y-m-d H:i:s', time() - 10 * 3600))
-            ->whereIn('distribution_channel_id', $sites)
-            ->select('id', 'redirect_url', 'send_time')
-            ->get();
-        if ($result->isEmpty()) return;
-        foreach ($result as $item) {
-            if (!$item->redirect_url) continue;
-            $url_info = parse_url($item->redirect_url);
-            if (isset($url_info['path']) && isset($url_info['query'])) {
-                if (strpos('/reader', $url_info['path']) === false ||
-                    strpos('/yun', $url_info['path']) === false ||
-                    strpos('/detail', $url_info['path']) === false
-                ) {
-                    continue;
-                }
-                $bid = null;
-                if (strpos('/reader', $url_info['path']) !== false) {
-                    parse_str($url_info['query'], $param);
-                    if (!isset($param['bid'])) {
-                        continue;
-                    }
-                    if ($param['bid'] == 'undefined') continue;
-                    $bid_info = Hashids::decode($param['bid']);
-                    $bid = isset($bid_info[0]) ? $bid_info[0] : 0;
-                }
-
-                /*if (strpos('/detail',$url_info['path']) !== false) {
-                    parse_str($url_info['query'],$param);
-                    if (!isset($param['id'])) {
-                        continue;
-                    }
-                    if($param['id'] == 'undefined') continue;
-                    $bid_info = \Hashids::decode($param['id']);
-                    $bid = isset($bid_info[0])?$bid_info[0]:0;
-                }
-
-                if (strpos($url_info['path'],'/yun/') !== false) {
-                    $send_order_id = str_replace('/yun/','',$url_info['path']);
-                    $send_order_info = \App\Modules\SendOrder\Services\SendOrderService::getById($send_order_id);
-                    if($send_order_info){
-                        $bid = $send_order_info->book_id;
-                    }
-                }*/
-                if (!$bid) continue;
-
-                Redis::hset('latestcustomerinfo', $item->id, json_encode([
-                    'bid' => $bid,
-                    'send_time' => $item->send_time
-                ]));
-            }
-
-        }
-    }
-}

+ 3 - 0
app/Console/Commands/selectCrmSites.php

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
 
 use Illuminate\Console\Command;
 use DB;
+use Redis;
 
 class selectCrmSites extends Command
 {
@@ -60,6 +61,8 @@ class selectCrmSites extends Command
         if($data){
             DB::table('crm_other_channels')->insert($data);
         }
+        Redis::del('crm:out_channel_sites');
+        Redis::sadd('crm:out_channel_sites',$result);
     }
 
     public function selectSites(){

+ 0 - 1
app/Console/Kernel.php

@@ -24,7 +24,6 @@ class Kernel extends ConsoleKernel
         Commands\YqBook::class,
         Commands\channelCpcCode::class,
         Commands\updateFromNewYunqi::class,
-        Commands\InnerOuterWeixinStats::class,
         Commands\CheckOrderStatus::class,
     ];
 

+ 36 - 4
app/Http/Controllers/Wap/Book/ChapterController.php

@@ -399,8 +399,12 @@ class ChapterController extends BaseController
                 'url' => $is_delete
             ]);
         }
-
-        //强制导粉
+        if(($result = $this->forceGuidePerson())){
+            return response()->error('WAP_DOMAIN_NOT_MATCH', [
+                'url' => $result
+            ]);
+        }
+        /*//强制导粉
         //$force_guide_sites = redisEnv('FORCE_GUIDE_SITES');
         //$img = redisEnv('GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
         list($force_guide_sites,$img)  = redisEnvMulti('GUIDE_PERSONAL_ACCOUNT_SITES','FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
@@ -416,7 +420,7 @@ class ChapterController extends BaseController
                 'url' => sprintf('/force/guide?bid=%s&cid=%s&book_name=%s&prev_cid=%s',$this->en_bid,$cid,$book_info->book_name,$this->chapter->prev_cid)
             ]);
 
-        }
+        }*/
 
         if($special_user_log && $special_user_log == $this->uid){
             $my_log = myLog('special');
@@ -429,7 +433,9 @@ class ChapterController extends BaseController
 
         $this->is_need_subscribe = !$force_subscribe;
 
-        if($bid == 5254){
+        //if($bid == 5254){
+        if(in_array($bid,[5254,3354,3362,3624,3364,3366,3363,3347,3355,3367,3348,3358]))
+        {
             $this->book_info->promotion_domain = 'leyuee.com';
             if(stripos($this->book_info->promotion_domain, $domain) === false){
                 return response()->error('WAP_DOMAIN_NOT_MATCH', [
@@ -2006,6 +2012,32 @@ class ChapterController extends BaseController
 
     }
 
+    private function forceGuidePerson(){
+        //强制导粉
+        //$force_guide_sites = redisEnv('FORCE_GUIDE_SITES');
+        //$img = redisEnv('GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
+        if(Redis::SISMEMBER('crm:out_channel_sites',$this->distribution_channel_id)){
+            $img  = redisEnv('OUT_FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
+            $force_guide_sites = $this->distribution_channel_id;
+            $group = 'OUT_FORCE';
+        }else{
+            list($force_guide_sites,$img)  = redisEnvMulti('GUIDE_PERSONAL_ACCOUNT_SITES','FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
+            $group = 'FORCE';
+        }
+
+        if($force_guide_sites &&
+            $img &&
+            in_array($this->distribution_channel_id,explode(',',$force_guide_sites)) &&
+            $this->is_paid &&
+            ($this->chapter->sequence == 2 ||  $this->chapter->sequence == 8)&&
+            !UserBindHkWelfareService::isHasGet($this->uid) &&
+            ForceGuidePersonAccountService::isShow($this->uid,$this->book_info->bid,$this->cid)
+        ){
+            return sprintf('/force/guide?bid=%s&cid=%s&book_name=%s&prev_cid=%s',$this->en_bid,$this->cid,$this->book_info->book_name,$this->chapter->prev_cid);
+        }
+        return '';
+    }
+
     public function getWechatJsConfig(Request $request)
     {
         //try {

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

@@ -14,6 +14,7 @@ use App\Modules\SendOrder\Services\SendOrderService;
 use App\Modules\Subscribe\Models\Order;
 use App\Modules\Subscribe\Services\OrderService;
 use App\Modules\Subscribe\Services\YearOrderService;
+use App\Modules\User\Services\ReadRecordService;
 use App\Modules\User\Services\UserMonthService;
 use App\Modules\User\Services\UserService;
 use GuzzleHttp\Client;
@@ -149,6 +150,7 @@ class MonthOrderController extends Controller
         $total_fee = $request->post('total_fee');
         $trade_no = $request->post('trade_no');
         $out_trade_no = $request->post('out_trade_no');
+        $this->recordOrderCallBack($request);
         if ($check = checkParam($request->except('_url'), ['app_id', 'user_id', 'total_fee', 'trade_no', 'out_trade_no'])) {
             return response()->error('PARAM_EMPTY', ['msg' => $check]);
         }
@@ -217,6 +219,7 @@ class MonthOrderController extends Controller
                 $send_order_name = $send_order_info->name;
             }
         }
+        $from_bid = ReadRecordService::getSimpleFirstReadRecord($uid);
         $init_order = [
             'distribution_channel_id' => $distribution_channel_id,
             'uid' => $uid,
@@ -230,7 +233,7 @@ class MonthOrderController extends Controller
             'send_order_id' => $send_order_id,
             'send_order_name' => $send_order_name,
             'order_type' => 'RECHARGE',
-            'from_bid' => '0',
+            'from_bid' => $from_bid,
             'from_type' => 'auto_month',
             'activity_id' => 0,
             'inner_send_order_id' => '',
@@ -267,6 +270,31 @@ class MonthOrderController extends Controller
         return response()->error('WAP_SYS_ERROR');
     }
 
+    private function recordOrderCallBack(Request $request){
+        $app_id = $request->post('app_id','');
+        $plan_id = $request->post('plan_id',0);
+        $uid = $request->post('user_id','');
+        $total_fee = $request->post('total_fee',0);
+        $trade_no = $request->post('trade_no','');
+        $out_trade_no = $request->post('out_trade_no','');
+        $result_code = $request->post('result_code',-1);
+        $sign = $request->post('sign',-1);
+        $created_at = date('Y-m-d H:i:s');
+        $updated_at = date('Y-m-d H:i:s');
+        $origin_data = json_encode($request->except('_url'));
+        try{
+            DB::table('user_month_order_callback')->insert([
+                compact('uid','app_id','plan_id','total_fee','out_trade_no','origin_data',
+                    'trade_no','result_code','sign','created_at','updated_at'
+                )
+            ]);
+        }catch (\Exception $e){
+            Log::error();
+        }
+
+
+    }
+
     protected function successPayPushMsg($uid)
     {
         try {

+ 198 - 13
app/Http/Controllers/Wap/User/CoflController.php

@@ -484,6 +484,95 @@ class CoflController extends Controller
         return [0,0];
     }
 
+    private function getUsersV3($openid){
+        //5204
+        //\Log::info($inner_channels);
+        $users = User::where('openid',$openid)->select('id','distribution_channel_id')->get();
+
+        if($users->isEmpty()) return [0,0];
+
+        if(count($users) == 1){
+            return [$users->first()->id,$users->first()->distribution_channel_id];
+        }
+        $temp = null;
+
+        //筛选包年UID
+        $uid_list = [];
+        foreach ($users as $item) {
+            $uid_list[] =$item->id;
+        }
+        $year_order = YearOrder::whereIn('uid',$uid_list)->orderBy('end_time','desc')->first();
+        if($year_order) {
+            foreach ($users as $item) {
+                if($item->id == $year_order->uid) {
+                    //筛选包年结束时间最后的UID
+                    return [$item->id,$item->distribution_channel_id];
+                }
+            }
+        }
+        //按订阅章节数最多的筛选
+        $users_select = ['id'=>0,'count'=>0,'user'=>null,'create_time'=>0];
+        foreach ($users as $each){
+            $table_prefix = ($each->id)%512;
+            $chapter_count = DB::connection('chapter_order_mysql')
+                ->table('chapter_orders'.$table_prefix)
+                ->where('created_at','>=',date('Y-m-d H:i:s',strtotime('-3 day')))
+                ->where('uid',$each->id)
+                //->where('bid',$bid)
+                ->count('id');
+            $book_order = BookOrder::where('uid',$each->id)
+                //->where('bid',$bid)
+                ->where('created_at','>=',date('Y-m-d H:i:s',strtotime('-3 day')))
+                ->first();
+            if($book_order) {
+                $chapter_count += 30;
+            }
+            //$each->chapter_count = $chapter_count;
+            if($chapter_count>$users_select['count']) {
+                $users_select['id'] = $each->id;
+                $users_select['count'] = $chapter_count;
+                $users_select['user'] = $each;
+            }
+        }
+        if($users_select['id'] >0) {
+            $insert_data = ['uid'=>$users_select['user']->id,'openid'=>$openid ,'created_at'=>date('Y-m-d H:i:s'),'updated_at'=>date('Y-m-d H:i:s')];
+            return [$users_select['user']->id,$users_select['user']->distribution_channel_id];
+        }
+        //有订阅记录的
+        foreach ($users as $value) {
+            $table_prefix = ($value->id)%512;
+            $chapter_order = DB::connection('chapter_order_mysql')
+                ->table('chapter_orders'.$table_prefix)
+                ->where('uid',$value->id)
+                //->where('bid',$bid)
+                ->orderBy('created_at','desc')
+                ->first();
+            $book_order = BookOrder::where('uid',$value->id)
+                //->where('bid',$bid)
+                ->first();
+            if($chapter_order ){
+                if(strtotime($chapter_order->created_at) > $users_select['create_time']) {
+                    $users_select['id'] = $value->id;
+                    $users_select['create_time'] = strtotime($chapter_order->created_at);
+                    $users_select['user'] = $value;
+                }
+            }
+            if($book_order){
+                if(strtotime($book_order->created_at) > $users_select['create_time']){
+                    $users_select['id']=$value->id;
+                    $users_select['create_time']= strtotime($book_order->created_at);
+                    $users_select['user']= $value;
+                }
+            }
+
+        }
+        if($users_select['id'] >0) {
+            return [$users_select['user']->id,$users_select['user']->distribution_channel_id];
+        }
+        return [0,0];
+    }
+
+
     private function getLink($distribution_channel_id=123){
         $url_format = '%s://site%s.%s.com/';
         return  sprintf(
@@ -622,20 +711,44 @@ class CoflController extends Controller
         $cookie_crm_img = Cookie::get('crm_person_img');
         $cookie_crm_name = Cookie::get('crm_person_name','');
         $get_info = UserBindHkWelfareService::isHasGet($uid);
+        $fee = $request->get('fee',200);
         if($get_info)   return back();
         if($cookie_crm_img){
-            return view('jump.guidePersonalAccountOurs',['img'=>$cookie_crm_img,'name'=>$cookie_crm_name]);
+            return view('jump.guidePersonalAccountOurs',['img'=>$cookie_crm_img,'name'=>$cookie_crm_name,'fee'=>$fee]);
+        }
+
+        //$distribution_channel_id = decodeDistributionChannelId($channel_id);
+        $distribution_channel_id = $channel_id;
+        //if(in_array($distribution_channel_id,Redis::SISMEMBER('')));
+        //$out = false;
+        $group = 'ACTIVE';
+        if(Redis::SISMEMBER('crm:out_channel_sites',$distribution_channel_id)){
+            //$out = true;
+            $group = 'OUT_ACTIVE';
+            $env_config = redisEnvMulti('OUT_ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',
+                'OUT_ACTIVE_GUIDE_PERSONAL_ACCOUNT_MAX_UV','OUT_ACTIVE_GUIDE_PERSONAL_ACCOUNT_ID',
+                'OUT_ACTIVE_GUIDE_PERSONAL_ACCOUNT_MAX_EVERY_UV');
+        }else{
+            $env_config = redisEnvMulti('ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',
+                'ACTIVE_GUIDE_PERSONAL_ACCOUNT_MAX_UV','ACTIVE_GUIDE_PERSONAL_ACCOUNT_ID',
+                'ACTIVE_GUIDE_PERSONAL_ACCOUNT_MAX_EVERY_UV');
         }
-
-        $env_config = redisEnvMulti('ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',
-            'ACTIVE_GUIDE_PERSONAL_ACCOUNT_MAX_UV','ACTIVE_GUIDE_PERSONAL_ACCOUNT_ID',
-            'ACTIVE_GUIDE_PERSONAL_ACCOUNT_MAX_EVERY_UV');
-        $img = empty($env_config[0])?'https://cdn-novel.iycdm.com/h5/personal_account/chenchen.jpg':$env_config[0];
+        if(empty($env_config[0])){
+            return back();
+        }
+        //$img = empty($env_config[0])?'https://cdn-novel.iycdm.com/h5/personal_account/chenchen.jpg':$env_config[0];
+        $img =$env_config[0];
         $max = empty($env_config[1])?100:$env_config[1];
         $max = (int)$max;
         $one_loop_max = empty($env_config[3])?10:$env_config[3];
         $now_id = (int)$env_config[2];
-        $uv = Redis::scard('active_guide_personal_uv');
+
+        if($group == 'OUT_ACTIVE'){
+            $uv_key = 'out_active_guide_personal_uv';
+        }else{
+            $uv_key = 'active_guide_personal_uv';
+        }
+        $uv = Redis::scard($uv_key);
         $personal_info = DB::table('personal_account_list')->where('id',$now_id)->select('count')->first();
         if(!$personal_info){
             return back();
@@ -659,12 +772,12 @@ class CoflController extends Controller
                 ->where('is_enable',1)
                 ->whereIn('status',[1,0])
                 ->select('id','url')
-                ->where('group','ACTIVE')
+                ->where('group',$group)
                 ->where('count','<',$max)
                 ->orderBy('count','asc')
                 ->orderBy('id')
                 ->first();
-            Redis::del('active_guide_personal_uv');
+            Redis::del($uv_key);
             if($account){
                 DB::table('personal_account_list')->where('id',$account->id)->update([
                     'status'=>1,
@@ -672,13 +785,13 @@ class CoflController extends Controller
                 ]);
                 $img = $account->url;
                 $now_id = $account->id;
-                Redis::Hmset('env','ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',$account->url,'ACTIVE_GUIDE_PERSONAL_ACCOUNT_ID',$account->id);
+                Redis::Hmset('env',$group.'_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',$account->url,$group.'_GUIDE_PERSONAL_ACCOUNT_ID',$account->id);
             }else{
-                Redis::Hmset('env','ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE','','ACTIVE_GUIDE_PERSONAL_ACCOUNT_ID','');
+                Redis::Hmset('env',$group.'_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE','',$group.'_GUIDE_PERSONAL_ACCOUNT_ID','');
                 return back();
             }
         }
-        Redis::sadd('active_guide_personal_uv',$uid);
+        Redis::sadd($uv_key,$uid);
 
         if($uid){
             DB::table('ad_pdd')->insert([
@@ -709,7 +822,7 @@ class CoflController extends Controller
         Cookie::queue('crm_person_name', $name,$time);
         //$page = 'jump.guidePersonalAccount';
         //$img = collect($imgs)->random();
-        return view($page,['img'=>$img,'name'=>$name]);
+        return view($page,['img'=>$img,'name'=>$name,'fee'=>$fee]);
     }
 
     public function r(Request $request,$number){
@@ -732,4 +845,76 @@ class CoflController extends Controller
             case 6:
         }
     }
+
+    public function freeCurrencyViewForTransfer(Request $request){
+        $openid = $request->get('openid');
+        //授权
+        $params = $request->except('_url');
+        if(empty($openid)){
+            //$url = str_replace('http://', env('PROTOCOL') . '://', url()->current() . '?' . http_build_query($params));
+            $url = url()->current() . '?' . http_build_query($params);
+            $params['redirect_url'] = urlencode($url);
+            $app = new Application($this->auth($params));
+            return $app->oauth->redirect();
+        }
+
+        $crm = $request->get('crm','treward');
+        $source = $request->get('wx','none');
+        $fee = 500;
+        $type = 'TCRM';
+        $this->stats('treward_500',$crm);
+
+        $crm_transfer_uid_bind = DB::table('crm_transfer')->where('openid',$openid)->first();
+        if($crm_transfer_uid_bind) {
+            $user = User::where('id',$crm_transfer_uid_bind->to_uid)->select('id','distribution_channel_id')->first();
+            $uid = $crm_transfer_uid_bind->to_uid;
+            $distribution_channel_id = 5204;
+        }else{
+            list($ouid,$distribution_channel_id) = $this->getUsersV3($openid);
+            $user = $this->createUser($openid,$openid,5204,0,'');
+            $uid = $user->id;
+            $distribution_channel_id = 5204;
+            UserService::transfer($ouid,$uid,5204);
+        }
+
+        if(!$user || !$user[0] || !$user[1]) return redirect()->to($this->getLink($distribution_channel_id).'?'.http_build_query($params));
+
+        $this->statsDetail($uid,'treward',0);
+
+        $get_free_currency = UserBindHkWelfareService::isHasGet($uid);
+        if($get_free_currency){
+            //已经领过
+            $link = $this->getLink($distribution_channel_id).'recent?'.http_build_query($params);
+            return view('jump.bindHkFreeCurrency',['fee'=>$fee,'url'=>$link,'is_get'=>1,'uid'=>$uid,'source'=>$source]);
+        }else{
+            $link = $this->getLink($distribution_channel_id).'recent?'.http_build_query($params);
+            $this->getReward($uid,$fee,$source,$type);
+            return view('jump.bindHkFreeCurrency',['fee'=>$fee,'url'=>$link,'is_get'=>0,'uid'=>$uid,'source'=>$source]);
+        }
+    }
+
+    private function createUser($openid,$unionid,$distribution_channel_id,$send_order_id,$ip){
+        $user = null;
+        try{
+            $user =  UserService::addUser(
+                ['openid' => $openid,
+                    'unionid' => $unionid,
+                    'distribution_channel_id' =>$distribution_channel_id,
+                    'send_order_id'=>$send_order_id,
+                    'is_new'=>1,
+                    'register_ip'=>$ip
+                ]);
+        }catch (\Exception $e){
+            myLog('user-error')->info($e);
+        }
+
+        // 注册动作
+        $action_type = 'Register';
+        $param = [
+            'openid' => $openid,
+            'uid' => isset($user->id)?$user->id:'0',
+        ];
+        UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
+        return $user;
+    }
 }

+ 18 - 13
app/Http/Controllers/Wap/User/UserController.php

@@ -644,14 +644,19 @@ where bid in (%s) and is_on_shelf =2 ORDER  by field(book_configs.bid,%s)',$bids
         $prev_cid = $request->get('prev_cid');
         $book_name = $request->get('book_name');
         $bid_no = Hashids::decode($bid)[0];
-
-        $env_config = redisEnvMulti('FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE','FORCE_GUIDE_PERSONAL_ACCOUNT_MAX_UV',
-            'FORCE_GUIDE_PERSONAL_ACCOUNT_ID','FORCE_GUIDE_PERSONAL_ACCOUNT_MAX_EVERY_UV');
-        $img = empty($env_config[0])?'https://cdn-novel.iycdm.com/h5/personal_account/chenchen.jpg':$env_config[0];
+        if(Redis::SISMEMBER('crm:out_channel_sites',$this->distribution_channel_id)){
+            $group = 'OUT_FORCE';
+        }else{
+            $group = 'FORCE';
+        }
+        $env_config = redisEnvMulti($group.'_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',$group.'_GUIDE_PERSONAL_ACCOUNT_MAX_UV',
+            $group.'_GUIDE_PERSONAL_ACCOUNT_ID',$group.'_GUIDE_PERSONAL_ACCOUNT_MAX_EVERY_UV');
+        if(empty($env_config[0])) return back();
+        $img = $env_config[0];
         $max = empty($env_config[1])?100:$env_config[1];
         $one_loop_max = empty($env_config[3])?10:$env_config[3];
         $now_id = (int)$env_config[2];
-        $uv = Redis::scard('force_guide_personal_uv');
+        $uv = Redis::scard(strtolower($group).'_guide_personal_uv');
         $personal_info = DB::table('personal_account_list')->where('id',$now_id)->select('count')->first();
         $total_max = $personal_info->count+$uv;
         //Log::info('$total_max is: '.);
@@ -673,11 +678,11 @@ where bid in (%s) and is_on_shelf =2 ORDER  by field(book_configs.bid,%s)',$bids
                 ->whereIn('status',[1,0])
                 ->select('id','url')
                 ->where('count','<',$max)
-                ->where('group','FORCE')
+                ->where('group',$group)
                 ->orderBy('count','asc')
                 ->orderBy('id')
                 ->first();
-            Redis::del('force_guide_personal_uv');
+            Redis::del(strtolower($group).'_guide_personal_uv');
             if($account){
                 DB::table('personal_account_list')->where('id',$account->id)->update([
                     'status'=>1,
@@ -685,16 +690,16 @@ where bid in (%s) and is_on_shelf =2 ORDER  by field(book_configs.bid,%s)',$bids
                 ]);
                 $img = $account->url;
                 $now_id = $account->id;
-                Redis::Hmset('env','FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',$account->url,'FORCE_GUIDE_PERSONAL_ACCOUNT_ID',$account->id);
+                Redis::Hmset('env',$group.'_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',$account->url,$group.'_GUIDE_PERSONAL_ACCOUNT_ID',$account->id);
             }else{
-                Redis::Hmset('env','FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE','','FORCE_GUIDE_PERSONAL_ACCOUNT_ID','');
+                Redis::Hmset('env',$group.'_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE','',$group.'_GUIDE_PERSONAL_ACCOUNT_ID','');
             }
         }
-        Redis::sadd('force_guide_personal_uv',$this->uid);
-
+        Redis::sadd(strtolower($group).'_guide_personal_uv',$this->uid);
+        $personal_info = DB::table('personal_account_list')->where('id',$now_id)->select('name')->first();
         DB::table('ad_pdd')->insert([
             'uid'=>$this->uid,
-            'img'=>'FORCE_GUIDE_PERSONAL_ACCOUNT_'.$now_id,
+            'img'=>$group.'_GUIDE_PERSONAL_ACCOUNT_'.$now_id,
             'date'=>date('Y-m-d'),
             'created_at'=>date('Y-m-d H:i:s'),
             'updated_at'=>date('Y-m-d H:i:s')
@@ -706,7 +711,7 @@ where bid in (%s) and is_on_shelf =2 ORDER  by field(book_configs.bid,%s)',$bids
         $link['prev'] = sprintf('/reader?bid=%s&cid=%s',$bid,$prev_cid);
         $link['catalog'] = sprintf('/catalog?id=%s',$bid);
 
-        return view('jump.forceGuidePersonalAccount',['img'=>$img,'link'=>$link,'title'=>$book_name]);
+        return view('jump.forceGuidePersonalAccountV2',['img'=>$img,'link'=>$link,'title'=>$book_name,'name'=>$personal_info->name]);
     }
     
 }

+ 19 - 3
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -322,6 +322,9 @@ class WelcomeController extends BaseController
 
     private function outstandingYearOrder(){
         $outstanding_year_order = false;
+        if(in_array($this->distribution_channel_id,explode(',',env('CAN_NOT_OUTSTANDING_YEAR_ORDER_SITE')))){
+            return $outstanding_year_order;
+        }
         //if( in_array($this->distribution_channel_id,explode(',',env('OUTSTANDING_YEAR_ORDER_SITE'))) ){
             //if($this->uid%2 == 0){
                 //$userDivisionProperty = UserDivisionPropertyService::getUserProperty($this->uid);
@@ -2124,10 +2127,14 @@ class WelcomeController extends BaseController
     private function guidePersonalAccount(){
         //weidian
         $other_crm_config = Redis::hmget('channel:setting:'.$this->distribution_channel_id,['crm_status','crm_link']);
-        $crm_config = redisEnvMulti('GUIDE_PERSONAL_ACCOUNT_SITES','ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
-        if(empty($other_crm_config[0]) && empty($other_crm_config[1]) && empty($crm_config[0]) && empty($crm_config[1])){
+        $crm_config = redisEnvMulti('GUIDE_PERSONAL_ACCOUNT_SITES','ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE','OUT_ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
+
+        $out_status = Redis::SISMEMBER('crm:out_channel_sites',$this->distribution_channel_id);
+
+        if(empty($other_crm_config[0]) && empty($other_crm_config[1]) && empty($crm_config[0]) && empty($crm_config[1]) && empty($out_status)){
             return '';
         }
+
         //Log::info('guidePersonalAccount1111111111111111111111');
         $get_info = UserBindHkWelfareService::isHasGet($this->uid);
         if($get_info)   return '';
@@ -2137,11 +2144,20 @@ class WelcomeController extends BaseController
             $charge = true;
         }
 
+        if(!$charge) return '';
+        //其他渠道自己导粉
         if($other_crm_config[0] && $other_crm_config[1]){
             if($charge)
                 return ['title'=>'点击领取200书币>>','link'=>$other_crm_config[1]];
             return '';
         }
+        //站外导粉
+        if($out_status){
+            if($crm_config[2]){
+                return ['title'=>'您有500书币待领取>>','link'=>'/guidestrem?uid='.$this->uid.'&fee=500'];
+            }
+            return '';
+        }
         //Log::info('guidePersonalAccount33333333333333333');
         if(empty($crm_config[0]) || empty($crm_config[1])) return '';
         //Log::info('guidePersonalAccount4444444444444444');
@@ -2150,7 +2166,7 @@ class WelcomeController extends BaseController
         }
         //Log::info('guidePersonalAccount555555555555555');
         if($charge){
-            return ['title'=>'您有500书币待领取>>','link'=>'/guidestrem?uid='.$this->uid];
+            return ['title'=>'您有500书币待领取>>','link'=>'/guidestrem?uid='.$this->uid.'&fee=500'];
         }
         return '';
     }

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

@@ -72,6 +72,7 @@ Route::group(['domain'=>env('FRIEND_LINK_DOMAIN'),'namespace'=>'App\Http\Control
     Route::get('guidepersonal','User\CoflController@guidePersonal');
     Route::get('friendactivitylink','User\CoflController@activity');
     Route::get('freecurrency','User\CoflController@freeCurrencyView');
+    Route::get('fcandt','User\CoflController@freeCurrencyViewForTransfer');
     Route::get('wfreecurrency','User\CoflController@freeCurrencyView');
     Route::get('freethrhcurrency','User\CoflController@freeCurrencyView');
     Route::get('frocefreethrhcurrency','User\CoflController@freeCurrencyView');

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

@@ -369,6 +369,10 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
     }
 
     public static function transfer(int $from,int $to,int $distribution_channel_id){
+        $transfer_record = DB::table('crm_transfer')->where('from_uid',$from)->first();
+        if($transfer_record){
+            return ;
+        }
         //阅读记录迁移***************************************
         $record = Redis::hgetall('book_read:'.$from);
         $not_uid_key = ['last_read','sign_counts','sign_info','sign_day'];
@@ -378,6 +382,8 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
                 $data[$k] = $item;
             }
         }
+        //\Log::info('read record is');
+        //\Log::info($data);
         if($data) Redis::hmset('book_read:'.$to,$data);
         //签到记录
         $user_sign_model = new UserSign();
@@ -395,6 +401,8 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
                     'updated_at'=>date('Y-m-d H:i:s'),
                 ];
             }
+            //\Log::info('user_sign  is');
+            //\Log::info($temp);
             DB::table('user_sign'.date('Ym'))->insert($temp);
         }
         //订阅记录(按本)
@@ -413,6 +421,8 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
                     'updated_at'=>date('Y-m-d H:i:s'),
                 ];
             }
+            //\Log::info('book_order  is');
+            //\Log::info($temp);
             DB::table('book_orders')->insert($temp);
         }
         //订阅记录(按章)
@@ -436,6 +446,8 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
                     'updated_at'=>date('Y-m-d H:i:s')
                 ];
             }
+            //\Log::info('chapter order  is');
+            //\Log::info($temp);
             $chapter_model->insert($temp);
         }
         //打赏记录
@@ -456,6 +468,8 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
                     'updated_at'=>date('Y-m-d H:i:s')
                 ];
             }
+            //\Log::info('book gift   is');
+            //\Log::info($temp);
             DB::table('book_gifts_send')->insert($tmp);
         }
         //书架
@@ -471,7 +485,39 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
                     'updated_at'=>date('Y-m-d H:i:s')
                 ];
             }
+            //\Log::info('user book shelf  is');
+            //\Log::info($temp);
             DB::table('user_shelf_books')->insert($tmp);
         }
+        //包年
+        $result = DB::table('year_orders')->where('uid',$from)->where('end_time','>=',date('Y-m-d H:i:s'))->first();
+        if($result){
+            DB::table('year_orders')->insert([
+                'uid'=>$to,
+                'begin_time'=>$result->begin_time,
+                'end_time'=>$result->end_time,
+                'distribution_channel_id'=>$distribution_channel_id,
+                'send_order_id'=>$result->send_order_id,
+                'fee'=>$result->fee,
+                'created_at'=>date('Y-m-d H:i:s'),
+                'updated_at'=>$result->updated_at,
+            ]);
+            //\Log::info('year_orders  is');
+            //print_r($result);
+        }
+
+        //书币
+        $from_user = self::getById($from);
+        $to_user = self::getById($to);
+        $to_user->balance += $from_user->balance;
+        $to_user->reward_balance +=   $from_user->balance;
+        $to_user->save();
+        DB::table('crm_transfer')->insert([
+            'from_uid'=>$from,
+            'to_uid'=>$to,
+            'is_enable'=>1,
+            'created_at'=>date('Y-m-d H:i:s'),
+            'updated_at'=>date('Y-m-d H:i:s')
+        ]);
     }
 }

+ 262 - 0
resources/views/jump/forceGuidePersonalAccountV2.blade.php

@@ -0,0 +1,262 @@
+<html lang="en">
+<head>
+    <meta charset="UTF-8" />
+    <meta
+            name="viewport"
+            content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
+    />
+    <link
+            rel="icon"
+            type="image/png"
+            href="data:image/png;base64,iVBORw0KGgo="
+    />
+    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
+    <title>{{$title or '阅读福利'}}</title>
+    <style>
+        body,
+        html,
+        p {
+            margin: 0;
+            padding: 0;
+        }
+
+        html {
+            background: white;
+        }
+
+        i {
+            font-style: normal;
+        }
+
+        .title-wrap {
+            text-align: center;
+            margin-top: 25px;
+        }
+
+        .title-wrap .title {
+            font-size: 20px;
+            color: #1a1a1a;
+            margin-bottom: 10px;
+        }
+
+        .title-wrap span {
+            font-size: 15px;
+            color: #666;
+            padding: 5px 10px;
+            background: rgba(255, 255, 255, 0.3);
+            border-radius: 12px;
+        }
+
+        .title-wrap span i {
+            font-weight: bold;
+            color: #eb2a2b;
+            font-size: 17px;
+            background-image: linear-gradient(to bottom, #ffffff, #faeaea);
+        }
+
+        .qrcode-wrap {
+            font-size: 0;
+            margin-top: 20px;
+            text-align: center;
+        }
+
+        .qrcode-wrap img {
+            width: 152px;
+            height: 152px;
+            margin-bottom: 10px;
+        }
+
+        .qrcode-wrap .qrcode-title {
+            font-size: 14px;
+            color: #333;
+            margin-bottom: 4px;
+        }
+
+        .qrcode-title-red {
+            font-weight: bold;
+            color: #ff6060;
+        }
+
+        .qrcode-wrap span {
+            font-size: 12px;
+            /* color: #999; */
+        }
+
+        .toast {
+            width: 100%;
+            text-align: center;
+        }
+
+        .toast img {
+            width: 95%;
+        }
+
+        .notice-wrap {
+            margin: 35px 10px 40px;
+            background: #faeaea;
+            padding: 20px 12px;
+            margin-bottom: 70px;
+        }
+
+        .notice-wrap .title {
+            font-size: 16px;
+            color: #7e2a2a;
+            margin-bottom: 15px;
+            font-weight: bold;
+        }
+
+        .notice-wrap .line {
+            font-size: 16px;
+            color: #7e2a2a;
+            line-height: 1.8;
+            text-align: justify;
+            display: flex;
+        }
+
+        .notice-wrap .line .dian {
+            font-size: 18px;
+            font-weight: bold;
+            margin-right: 10px;
+        }
+
+        .notice-wrap .line .info {
+        }
+
+        .notice-wrap .line span {
+            color: #ff6060;
+            font-weight: bold;
+            font-size: 13px;
+        }
+
+        .operator-wrap {
+            /* margin: 0 10px 20px; */
+            padding: 10px 0;
+            width: 100%;
+            display: -webkit-box;
+            display: -ms-flexbox;
+            display: flex;
+            -webkit-box-pack: justify;
+            -ms-flex-pack: justify;
+            justify-content: space-between;
+            -webkit-box-align: center;
+            -ms-flex-align: center;
+            align-items: center;
+            position: fixed;
+            bottom: 0;
+            background: white;
+        }
+
+        .operator-wrap a {
+            color: #666;
+            text-decoration: none;
+            text-align: center;
+            height: 40px;
+            line-height: 40px;
+            border-radius: 4px;
+            background: #e6e6e6;
+            font-size: 15px;
+        }
+
+        .operator-wrap a:nth-child(1) {
+            margin-left: 10px;
+        }
+
+        .operator-wrap a:nth-child(3) {
+            margin-right: 10px;
+        }
+
+        .operator-wrap a:not(:last-child) {
+            margin-right: 12px;
+        }
+
+        .operator-wrap .prev,
+        .operator-wrap .catalog {
+            width: 82px;
+        }
+
+        .operator-wrap .ignore {
+            -webkit-box-flex: 1;
+            -ms-flex: 1;
+            flex: 1;
+        }
+
+        @media screen and (max-width: 320px) {
+            .operator-wrap .prev,
+            .operator-wrap .catalog {
+                width: 62px;
+            }
+        }
+    </style>
+</head>
+
+<body>
+<div class="title-wrap">
+    <p class="title">— 添加微信阅读小管家{{$name}} —</p>
+    <span><i>即可赠送500书币</i></span>
+</div>
+<div class="qrcode-wrap">
+    <img
+            src="{{$img}}"
+            alt=""
+    />
+    <p class="qrcode-title">微信阅读小管家{{$name}}</p>
+    <p class="qrcode-title">(长按图片,识别二维码添加微信好友)</p>
+    <p class="qrcode-title qrcode-title-red" style="color:#EB2A2B">
+        我是9:00-21:00在线处理好友申请和赠送书币~
+    </p>
+</div>
+<div class="toast">
+    <img src="https://cdn-novel.iycdm.com/crm/guide2019072401.png" alt="" />
+</div>
+<div class="notice-wrap">
+    <p class="title">我是微信阅读小管家{{$name}}:</p>
+    <div class="line">
+        <div class="dian">·</div>
+        <div class="info">
+            免费书币:成功添加微信好友即可赠送500书币,我一般都9-21点在线哦,晚上添加的话,需要明天早上上班才能通过好友哦,感谢谅解;
+        </div>
+    </div>
+    <div class="line">
+        <div class="dian">·</div>
+        <div class="info">
+            优先答疑:找不到看过的书啦?看书没钱啦?我都可以帮您哦!
+        </div>
+    </div>
+    <div class="line">
+        <div class="dian">·</div>
+        <div class="info">
+            帮您找书:总裁豪门、婚恋出轨、甜蜜宠文、虐心宫斗、文学名著等,提供最新优质小说,拒绝书荒!
+        </div>
+    </div>
+    <div class="line">
+        <div class="dian">·</div>
+        <div class="info">
+            书币福利:每月获得免费书币,不要钱!
+        </div>
+    </div>
+    <div class="line">
+        <div class="dian">·</div>
+        <div class="info">
+            更多福利,只要您想要,我们就有!
+        </div>
+    </div>
+</div>
+<div class="operator-wrap">
+    <a
+            href="{{$link['prev']}}"
+            class="operator-item prev"
+    >&lt;上一章</a
+    >
+    <a
+            href="{{$link['catalog']}}"
+            class="operator-item catalog"
+    >目录</a
+    >
+    <a
+            href="{{$link['next']}}"
+            class="operator-item ignore"
+    >点击忽略,继续阅读&gt;</a
+    >
+</div>
+</body>
+</html>

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 2 - 2
resources/views/jump/guidePersonalAccountOurs.blade.php