|
@@ -117,49 +117,18 @@ class ReadOauth
|
|
$uri = $request->input('_url');
|
|
$uri = $request->input('_url');
|
|
$openid = $request->get('openid');
|
|
$openid = $request->get('openid');
|
|
$appid = $request->get('appid');
|
|
$appid = $request->get('appid');
|
|
- /* $user_info = ForceSubscribeService::getUserInfo($appid,$openid);
|
|
|
|
- Log::info('appid user id to userinfo');
|
|
|
|
- Log::info($user_info);*/
|
|
|
|
- $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, $uri_send_order_id);
|
|
$this->apidAndOpenId($distribution_channel_id, $appid, $openid, $uid_cookie, $uri_send_order_id);
|
|
- //$channel = ChannelService::getById($distribution_channel_id);
|
|
|
|
- //$is_yq_move = $this->isQyMove($channel, $distribution_channel_id);
|
|
|
|
- /*if ($is_yq_move) {
|
|
|
|
- $move_user = YqMove::where('zsy_uid', $uid_cookie)->select('zsy_uid')->first();
|
|
|
|
- if (!$move_user) {
|
|
|
|
- if (!$back) {
|
|
|
|
- $yq_home = $this->getYqChannleIdByAppid($appid);
|
|
|
|
- Log::info('$this->getYqChannleIdByAppid($appid) is : ');
|
|
|
|
- Log::info($yq_home);
|
|
|
|
- if ($yq_home) {
|
|
|
|
- $params['zsy_channel_id'] = encodeDistributionChannelId($distribution_channel_id);
|
|
|
|
- $params['pa'] = $uri;
|
|
|
|
- $back_url = $yq_home . 'move?' . http_build_query($params);
|
|
|
|
- Log::info('$yq_home - $back_url is: ' . $back_url);
|
|
|
|
- return redirect()->to($back_url);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- $this->moveUserFromYq($distribution_channel_id, $appid, $openid, $uid_cookie);
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /*//云栖测试
|
|
|
|
- $qy_test_url = $this->yqTest($request,$uid_cookie,$distribution_channel_id);
|
|
|
|
- if($qy_test_url){
|
|
|
|
- //Log::info('url is: '.$qy_test_url);
|
|
|
|
- return redirect()->to($qy_test_url);
|
|
|
|
- }*/
|
|
|
|
|
|
+
|
|
$this->yun($request, $uid_cookie, $distribution_channel_id);
|
|
$this->yun($request, $uid_cookie, $distribution_channel_id);
|
|
//只能推送的统计
|
|
//只能推送的统计
|
|
$this->smartPush($request, $uid_cookie);
|
|
$this->smartPush($request, $uid_cookie);
|
|
- //数据分析 长篇推短片的统计
|
|
|
|
- //$this->dataAnalysis($request, $uid_cookie);
|
|
|
|
//from where的临时统计
|
|
//from where的临时统计
|
|
$this->tempFromWhere($request, $uid_cookie);
|
|
$this->tempFromWhere($request, $uid_cookie);
|
|
- //统计访问site数字的uid记录下
|
|
|
|
- //$this->recordPrimaryNumberChannleIDUser($origin_distribution_channel_id,$uid_cookie);
|
|
|
|
|
|
+
|
|
$response = $next($request);
|
|
$response = $next($request);
|
|
$stats = $request->get('stats', 0);
|
|
$stats = $request->get('stats', 0);
|
|
if ($request->has('fromtype') && $request->input('fromtype')) {
|
|
if ($request->has('fromtype') && $request->input('fromtype')) {
|
|
@@ -220,22 +189,6 @@ class ReadOauth
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private function isQyMove($channel, $distribution_channel_id)
|
|
|
|
- {
|
|
|
|
- $is_yq_move = 0;
|
|
|
|
- // 新站
|
|
|
|
- if (isset($channel->is_yq_move) && $channel->is_yq_move) {
|
|
|
|
-
|
|
|
|
- $is_yq_move = 1;
|
|
|
|
- }
|
|
|
|
- // 已经迁移过的站,回复也要有老站
|
|
|
|
- $yqMoveChannel = YqMoveChannel::get_yq_move_channel($distribution_channel_id, 1);
|
|
|
|
- if (!empty($yqMoveChannel)) {
|
|
|
|
- //\Log::info('old_has_move_site:'.$distribution_channel_id);
|
|
|
|
- $is_yq_move = 1;
|
|
|
|
- }
|
|
|
|
- return $is_yq_move;
|
|
|
|
- }
|
|
|
|
|
|
|
|
private function innerSendOrderIdFromFromtype($uid, $stats, $from, $inner_order_id)
|
|
private function innerSendOrderIdFromFromtype($uid, $stats, $from, $inner_order_id)
|
|
{
|
|
{
|
|
@@ -393,185 +346,6 @@ class ReadOauth
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- private function getYqChannleIdByAppid($appid)
|
|
|
|
- {
|
|
|
|
- $client = new Client(['timeout' => 3.0]);
|
|
|
|
- $url = 'http://help.imycmh.com/help/getLinkByAppid?appid=' . $appid;
|
|
|
|
- Log::info('getYqChannleIdByAppid url is: ' . $url);
|
|
|
|
- try {
|
|
|
|
- $result = $client->request('get', $url)->getBody()->getContents();
|
|
|
|
- $result = json_decode($result, 1);
|
|
|
|
- Log::info('getYqChannleIdByAppid result is.: ');
|
|
|
|
- Log::info($result);
|
|
|
|
- if (isset($result['data']['link']) && !empty($result['data']['link'])) {
|
|
|
|
- return $result['data']['link'];
|
|
|
|
- }
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- }
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private function moveUserFromYq($distribution_channel_id, $appid, $openid, $uid)
|
|
|
|
- {
|
|
|
|
- /*//is_yq_move
|
|
|
|
- $channel = ChannelService::getById($distribution_channel_id);
|
|
|
|
- if(!$channel->is_yq_move){
|
|
|
|
- return ;
|
|
|
|
- }
|
|
|
|
- $move_user = YqMove::where('zsy_uid',$uid)->select('zsy_uid')->first();
|
|
|
|
- if($move_user){
|
|
|
|
- return ;
|
|
|
|
- }*/
|
|
|
|
- $client = new Client(['timeout' => 3.0]);
|
|
|
|
- $url = 'http://help.imycmh.com/getUserInfoByOpenid?openid=' . $openid;
|
|
|
|
- try {
|
|
|
|
- $result = $client->request('get', $url)->getBody()->getContents();
|
|
|
|
- if (!$result) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- $result = json_decode($result, 1);
|
|
|
|
- $result_data = isset($result['data']) ? $result['data'] : '';
|
|
|
|
- if (!$result_data) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (isset($result_data['uid']) && !empty($result_data['uid'])) {
|
|
|
|
- //$result_data['read_count'] = 53;
|
|
|
|
- if ($result_data['read_count'] > 50) {
|
|
|
|
- //不补偿
|
|
|
|
- $pay_for_balance = 500;
|
|
|
|
- $data = [
|
|
|
|
- 'yq_uid' => $result_data['uid'],
|
|
|
|
- 'zsy_uid' => $uid,
|
|
|
|
- 'yq_distribution_channel_id' => $result_data['user']['distribution_channel_id'],
|
|
|
|
- 'zsy_distribution_channel_id' => $distribution_channel_id,
|
|
|
|
- 'read_count' => $result_data['read_count'],
|
|
|
|
- 'yq_balance' => $result_data['user']['balance'],
|
|
|
|
- 'is_pay' => 0,
|
|
|
|
- 'pay_for_balance' => $pay_for_balance,
|
|
|
|
- 'openid' => $openid,
|
|
|
|
- 'appid' => $appid
|
|
|
|
- ];
|
|
|
|
- $special = env('YQ_MOVE_SPECIAL');
|
|
|
|
-
|
|
|
|
- if ($special && in_array($distribution_channel_id, explode(',', $special))) {
|
|
|
|
- //特殊梳理
|
|
|
|
- $yq_charge_amount = $result_data['order_amoun'];
|
|
|
|
- if ($yq_charge_amount > 30) {
|
|
|
|
- $pay_for_balance = 3000;
|
|
|
|
- } else {
|
|
|
|
- $pay_for_balance = $yq_charge_amount * 100;
|
|
|
|
- }
|
|
|
|
- if ($pay_for_balance < 500) {
|
|
|
|
- $pay_for_balance = 500;
|
|
|
|
- }
|
|
|
|
- if ($pay_for_balance > 3000) {
|
|
|
|
- $pay_for_balance = 3000;
|
|
|
|
- }
|
|
|
|
- $pay_for_balance = (int)$pay_for_balance;
|
|
|
|
-
|
|
|
|
- $balance = $pay_for_balance + $result_data['user']['balance'];
|
|
|
|
- $data['pay_for_balance'] = $pay_for_balance;
|
|
|
|
- $data['is_pay'] = 1;
|
|
|
|
- YqMove::create($data);
|
|
|
|
- UserService::addBalance($uid, $balance, 0, $balance);
|
|
|
|
- $flag = false;
|
|
|
|
- if (in_array($distribution_channel_id, [160, 4236, 4237, 4241])) {
|
|
|
|
- //特殊 回复老站
|
|
|
|
- $flag = true;
|
|
|
|
- }
|
|
|
|
- $this->movePush($distribution_channel_id, $pay_for_balance, $appid, $result_data['user']['distribution_channel_id'], $openid, $flag);
|
|
|
|
- } else {
|
|
|
|
- $data['is_pay'] = 1;
|
|
|
|
- YqMove::create($data);
|
|
|
|
- UserService::addBalance($uid, $pay_for_balance, 0, $pay_for_balance);
|
|
|
|
- $this->movePush($distribution_channel_id, $pay_for_balance, $appid, $result_data['user']['distribution_channel_id'], $openid, true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- //补偿
|
|
|
|
- $yq_charge_amount = $result_data['order_amoun'];
|
|
|
|
- if ($yq_charge_amount > 30) {
|
|
|
|
- $pay_for_balance = 3000;
|
|
|
|
- } else {
|
|
|
|
- $pay_for_balance = $yq_charge_amount * 100;
|
|
|
|
- }
|
|
|
|
- if ($pay_for_balance < 500) {
|
|
|
|
- $pay_for_balance = 500;
|
|
|
|
- }
|
|
|
|
- if ($pay_for_balance > 3000) {
|
|
|
|
- $pay_for_balance = 3000;
|
|
|
|
- }
|
|
|
|
- $pay_for_balance = (int)$pay_for_balance;
|
|
|
|
- YqMove::create([
|
|
|
|
- 'yq_uid' => $result_data['uid'],
|
|
|
|
- 'zsy_uid' => $uid,
|
|
|
|
- 'yq_distribution_channel_id' => $result_data['user']['distribution_channel_id'],
|
|
|
|
- 'zsy_distribution_channel_id' => $distribution_channel_id,
|
|
|
|
- 'read_count' => $result_data['read_count'],
|
|
|
|
- 'yq_balance' => $result_data['user']['balance'],
|
|
|
|
- 'is_pay' => 1,
|
|
|
|
- 'pay_for_balance' => $pay_for_balance,
|
|
|
|
- 'openid' => $openid,
|
|
|
|
- 'appid' => $appid
|
|
|
|
- ]);
|
|
|
|
- $balance = $pay_for_balance + $result_data['user']['balance'];
|
|
|
|
- UserService::addBalance($uid, $balance, 0, $balance);
|
|
|
|
- $this->movePush($distribution_channel_id, $pay_for_balance, $appid, $result_data['user']['distribution_channel_id'], $openid);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private function movePush($distribution_channel_id, $pay_for_balance, $appid, $old_channel_id, $openid, $need_old = false)
|
|
|
|
- {
|
|
|
|
- $move_not_need_push_channel_id = env('MOVE_NOT_NEED_PUSH_CHANNEL_ID');
|
|
|
|
- if ($move_not_need_push_channel_id && in_array($distribution_channel_id, explode(',', $move_not_need_push_channel_id))) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- $data = [];
|
|
|
|
- if ($pay_for_balance) {
|
|
|
|
- if ($need_old) {
|
|
|
|
- $format = "亲爱的用户:\r\n由于原小说站进行网站维护中,为了让您能够继续阅读更多优质小说,我们将在新站中补偿您%s书币,以表达我们诚挚的歉意\r\n\r\n<a href='%s'>点此进入新站</a>\r\n\r\n<a href='%s'>继续老站阅读</a>";
|
|
|
|
- $url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/';
|
|
|
|
- $content = sprintf($format, $pay_for_balance, $url);
|
|
|
|
- } else {
|
|
|
|
- $format = "亲爱的用户:\r\n由于原小说站进行网站维护中,为了让您能够继续阅读更多优质小说,我们将在新站中补偿您%s书币,以表达我们诚挚的歉意\r\n\r\n<a href='%s'>点此进入新站</a>";
|
|
|
|
- $url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/';
|
|
|
|
- //$old_url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($old_channel_id) . '.chunnuan555.com/continue';
|
|
|
|
- $old_url = 'http://site' . encodeDistributionChannelId($old_channel_id) . '.imycmh.com/continue';
|
|
|
|
- $content = sprintf($format, $pay_for_balance, $url, $old_url);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- $fromat = "亲爱的用户:\r\n%s新增全新站点,新站拥有海量优质小说,同时原先站点可继续看书\r\n<a href='%s'>点此进入新站</a>\r\n\r\n<a href='%s'>继续老站阅读</a>";
|
|
|
|
- $new_url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/';
|
|
|
|
- //$old_url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($old_channel_id) . '.chunnuan555.com/continue';
|
|
|
|
- $old_url = 'http://site' . encodeDistributionChannelId($old_channel_id) . '.imycmh.com/continue';
|
|
|
|
- $offical = DB::table('official_accounts')->where('appid', $appid)->select('nickname')->first();
|
|
|
|
- $offical_name = '网站';
|
|
|
|
- if ($offical && $offical->nickname) {
|
|
|
|
- $offical_name = $offical->nickname;
|
|
|
|
- }
|
|
|
|
- $content = sprintf($fromat, $offical_name, $new_url, $old_url);
|
|
|
|
- }
|
|
|
|
- $data['openid'] = $openid;
|
|
|
|
- $data['appid'] = $appid;
|
|
|
|
- $data['content'] = $content;
|
|
|
|
- $data['type'] = 'one_task';
|
|
|
|
- $data['task_id'] = 1;
|
|
|
|
- $data['send_time'] = date("Y-m-d H:i:s");
|
|
|
|
- $send_data = array(
|
|
|
|
- 'send_time' => date("Y-m-d H:i:s"),
|
|
|
|
- 'data' => $data
|
|
|
|
- );
|
|
|
|
- Log::info('movePush info');
|
|
|
|
- Log::info($send_data);
|
|
|
|
- $delay = 0;
|
|
|
|
- $job = (new SendTexts($send_data))->onConnection('rabbitmq')->delay($delay)->onQueue('send_texts_list');
|
|
|
|
- dispatch($job);
|
|
|
|
- }
|
|
|
|
|
|
|
|
private function smartPush(Request $request, $uid)
|
|
private function smartPush(Request $request, $uid)
|
|
{
|
|
{
|
|
@@ -625,34 +399,6 @@ class ReadOauth
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //短片推唱片
|
|
|
|
- private function dataAnalysis(Request $request, $uid)
|
|
|
|
- {
|
|
|
|
- if (!$request->has('ru')) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- $su = $request->get('ru');
|
|
|
|
- if (!$su) return;
|
|
|
|
-
|
|
|
|
- $su_array = explode('_', $su);
|
|
|
|
-
|
|
|
|
- if (count($su_array) !== 2) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- $data = [];
|
|
|
|
- $arr = ['title' => 1, 'over' => 2];
|
|
|
|
- if (isset($arr[$su_array[0]])) {
|
|
|
|
- $data['type'] = $arr[$su_array[0]];
|
|
|
|
- $data['material_id'] = $su_array[1];
|
|
|
|
- $data['uid'] = $uid;
|
|
|
|
- $data['created_at'] = $data['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
- try {
|
|
|
|
- DB::table('data_analysis_visit_stats')->insert($data);
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 临时统计
|
|
* 临时统计
|
|
* @param Request $request
|
|
* @param Request $request
|
|
@@ -684,16 +430,6 @@ class ReadOauth
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- private function recordPrimaryNumberChannleIDUser($distribution_channel_id, $uid)
|
|
|
|
- {
|
|
|
|
- if (!is_numeric($distribution_channel_id)) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- Redis::sadd('recordPrimaryNumberChannleIDUser', $uid);
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 禁止site+数字站点的访问 保留已经充值过的用户和4267站点所有用户
|
|
* 禁止site+数字站点的访问 保留已经充值过的用户和4267站点所有用户
|
|
@@ -795,210 +531,6 @@ class ReadOauth
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private function yqTest(Request $request, $uid, $channel_id)
|
|
|
|
- {
|
|
|
|
- if (!$request->has('fromtype')) return '';
|
|
|
|
- $from_type = $request->get('fromtype');
|
|
|
|
- if (empty($from_type)) {
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- if ($from_type == 'main') {
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- if ($request->has('r')) {
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- //Log::info('1111111111111111111111111111111');
|
|
|
|
- $param = $request->except('_url');
|
|
|
|
- if (isset($param['bid'])) unset($param['bid']);
|
|
|
|
- if (isset($param['cid'])) unset($param['cid']);
|
|
|
|
- //unset($param['from_type']);
|
|
|
|
- $other_str = 'r=1';
|
|
|
|
- if ($param) {
|
|
|
|
- $other_str = http_build_query($param) . '&' . $other_str;
|
|
|
|
- }
|
|
|
|
- //$uri = $request->input('_url');
|
|
|
|
- $bid = $request->get('bid');
|
|
|
|
- if (!$bid) return '';
|
|
|
|
- try {
|
|
|
|
- $bid_arr = Hashids::decode($bid);
|
|
|
|
- isset($bid_arr[0]) && $bid = $bid_arr[0];
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- //Log::info('222222222222222222222222222222');
|
|
|
|
- if (!$bid) return '';
|
|
|
|
- //Log::info('333333333333333333333333333333');
|
|
|
|
- //用户是否在样本中
|
|
|
|
- $yq_book_user = BookUserService::selectUser($uid);
|
|
|
|
- if (!$yq_book_user) {
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- $flag = $yq_book_user->flag;
|
|
|
|
- if (empty($flag)) {
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- //Log::info('44444444444444444444444444444');
|
|
|
|
- //如果是group_1 不错操作
|
|
|
|
- if ($flag == 'group_1') {
|
|
|
|
- YqUserBidRelationService::create($uid, $bid, 'GROUP_1', 0);
|
|
|
|
- if ($yq_book_user->type == 'INIT') {
|
|
|
|
- BookUserService::updateUser($uid, ['type' => 'GROUP_1']);
|
|
|
|
- }
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- //Log::info('5555555555555555555555555555');
|
|
|
|
- if ($flag != 'group_2') {
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- //Log::info('66666666666666666666666666666');
|
|
|
|
- //用户的类型是初始类型 区域还没获取
|
|
|
|
- if ($yq_book_user->type == 'INIT') {
|
|
|
|
- if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
|
|
|
|
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
|
|
|
- } else {
|
|
|
|
- $ip = get_client_ip();
|
|
|
|
- }
|
|
|
|
- $area = $this->getIpArea($ip);
|
|
|
|
- $area = $area ? $area : 'unknown';
|
|
|
|
- $type = $this->isLimit($area);
|
|
|
|
- $data = ['area' => $area, 'type' => $type];
|
|
|
|
- if ('ENABLE' == $type) {
|
|
|
|
- $yq_zsy_test = YqZsyTestService::getByBid($bid);
|
|
|
|
- if ($yq_zsy_test) {
|
|
|
|
- YqUserBidRelationService::create($uid, $bid, 'GROUP_2', $bid);
|
|
|
|
- //书在测试列表中
|
|
|
|
- $data['bid'] = $bid;
|
|
|
|
- BookUserService::updateUser($uid, $data);
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- //Log::info('7777777777777777777777777');
|
|
|
|
- //书不在在测试列表中
|
|
|
|
- //获取随机获取一本书,获取不到则返回
|
|
|
|
- $redirect_bids = YqZsyTestService::getRandomBooks($uid, 1);
|
|
|
|
- $redirect_bid = 0;
|
|
|
|
- if ($redirect_bids && isset($redirect_bids[0])) {
|
|
|
|
- $redirect_bid = $redirect_bids[0];
|
|
|
|
- }
|
|
|
|
- if (!$redirect_bid) {
|
|
|
|
- BookUserService::updateUser($uid, $data);
|
|
|
|
- return '';
|
|
|
|
- };
|
|
|
|
- //Log::info('88888888888888888888888888');
|
|
|
|
- //Log::info($redirect_bids);
|
|
|
|
- $redirect_book_info = BookConfigService::getBookById($redirect_bid);
|
|
|
|
- if ($redirect_book_info) {
|
|
|
|
- $redirect = $this->getBookReaderUrl($redirect_bid, $channel_id);
|
|
|
|
- if ($redirect) {
|
|
|
|
- $data['bid'] = $redirect_bid;
|
|
|
|
- }
|
|
|
|
- YqUserBidRelationService::create($uid, $bid, 'GROUP_2', $redirect_bid);
|
|
|
|
- BookUserService::updateUser($uid, $data);
|
|
|
|
- return $redirect . '&' . $other_str;
|
|
|
|
- }
|
|
|
|
- //Log::info('9999999999999999999999999');
|
|
|
|
- return '';
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- if ('DISABLED' == $type) {
|
|
|
|
- //禁止访问的区域
|
|
|
|
- BookUserService::updateUser($uid, $data);
|
|
|
|
- BookUserService::popUser($uid);
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- //Log::info('aaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
|
|
|
|
- }
|
|
|
|
- if ($yq_book_user->type == 'DISABLED') {
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- //Log::info('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
|
|
|
|
- $yq_zsy_test = YqZsyTestService::getByBid($bid);
|
|
|
|
- //如果书在测试样本中 不跳转
|
|
|
|
- if ($yq_zsy_test) {
|
|
|
|
- YqUserBidRelationService::create($uid, $bid, 'GROUP_2', 0);
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- //Log::info('ccccccccccccccccccccccccccccc');
|
|
|
|
- // 用户符合条件 且看的书不样本中
|
|
|
|
- $relate_info = YqUserBidRelationService::getByUidAndBid($uid, $bid);
|
|
|
|
- if ($relate_info && $relate_info->to_bid) {
|
|
|
|
- //已经有对应关系
|
|
|
|
- //如果有阅读记录
|
|
|
|
- $record_url = $this->readerRecpord($uid, $relate_info->to_bid, $channel_id);
|
|
|
|
- if ($record_url) return $record_url . '&' . $other_str;
|
|
|
|
- //没有阅读记录
|
|
|
|
- $book_url = $this->getBookReaderUrl($relate_info->to_bid, $channel_id);
|
|
|
|
- //Log::info('dddddddddddddddddddddddddd');
|
|
|
|
- //Log::info($book_url.'&'.$other_str);
|
|
|
|
- return $book_url . '&' . $other_str;
|
|
|
|
- } else {
|
|
|
|
- //没有对应关系
|
|
|
|
- //随机获取一本书
|
|
|
|
- $redirect_bids = YqZsyTestService::getRandomBooks($uid, 1);
|
|
|
|
- $redirect_bid = 0;
|
|
|
|
- if ($redirect_bids && isset($redirect_bids[0])) {
|
|
|
|
- $redirect_bid = $redirect_bids[0];
|
|
|
|
- }
|
|
|
|
- if (!$redirect_bid) {
|
|
|
|
- return '';
|
|
|
|
- };
|
|
|
|
- //Log::info('eeeeeeeeeeeeeeeeeeeeeeeeeeeee');
|
|
|
|
- $redirect = $this->getBookReaderUrl($redirect_bid, $channel_id);
|
|
|
|
- if ($redirect) {
|
|
|
|
- $data['bid'] = $redirect_bid;
|
|
|
|
- //更新对应关系
|
|
|
|
- BookUserService::updateUser($uid, $data);
|
|
|
|
- //Log::info('ffffffffffffffffffffffff');
|
|
|
|
- YqUserBidRelationService::create($uid, $bid, 'GROUP_2', $redirect_bid);
|
|
|
|
- return $redirect . '&' . $other_str;
|
|
|
|
- }
|
|
|
|
- //Log::info('gggggggggggggggggggggggggggggggg');
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private function getBookReaderUrl($bid, $channel_id)
|
|
|
|
- {
|
|
|
|
- $redirect_book_info = BookConfigService::getBookById($bid);
|
|
|
|
- if ($redirect_book_info) {
|
|
|
|
- //Log::info('getBookReaderUrl');
|
|
|
|
- //Log::info($redirect_book_info);
|
|
|
|
- $redirect = sprintf(
|
|
|
|
- 'https://site%s.iycdm.com/reader?bid=%s&cid=%s',
|
|
|
|
- encodeDistributionChannelId($channel_id),
|
|
|
|
- Hashids::encode($bid),
|
|
|
|
- $redirect_book_info->first_cid
|
|
|
|
- );
|
|
|
|
- return $redirect;
|
|
|
|
- }
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private function readerRecpord($uid, $bid, $channel_id)
|
|
|
|
- {
|
|
|
|
- $record_info = null;
|
|
|
|
- try {
|
|
|
|
- $record_info = ReadRecordService::getRecordByUidBid($uid, $bid);
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!$record_info) return '';
|
|
|
|
- $record_info_arr = explode('_', $record_info);
|
|
|
|
-
|
|
|
|
- if (isset($record_info_arr[0])) {
|
|
|
|
- $cid = $record_info_arr[0];
|
|
|
|
- if (!$cid) return '';
|
|
|
|
- $redirect = sprintf(
|
|
|
|
- 'https://site%s.iycdm.com/reader?bid=%s&cid=%s',
|
|
|
|
- encodeDistributionChannelId($channel_id),
|
|
|
|
- Hashids::encode($bid),
|
|
|
|
- $cid
|
|
|
|
- );
|
|
|
|
- return $redirect;
|
|
|
|
- }
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
|
|
|
|
private function isLimit($area)
|
|
private function isLimit($area)
|
|
{
|
|
{
|