|
@@ -6,6 +6,8 @@ use App\Modules\Book\Services\BookConfigService;
|
|
|
use App\Modules\Channel\Models\YqMoveChannel;
|
|
|
use App\Modules\Channel\Services\ChannelService;
|
|
|
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\Services\ReadRecordService;
|
|
|
use App\Modules\User\Services\UserService;
|
|
@@ -101,12 +103,15 @@ class ReadOauth
|
|
|
}
|
|
|
return redirect()->to($redirect);
|
|
|
}
|
|
|
-
|
|
|
+ $uri_send_order_id = 0;
|
|
|
if (strpos($uri, '/yun/') !== false) {
|
|
|
$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)) {
|
|
|
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);*/
|
|
|
$back = $request->get('back', '');
|
|
|
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);
|
|
|
$is_yq_move = $this->isQyMove($channel, $distribution_channel_id);
|
|
|
if ($is_yq_move) {
|
|
@@ -324,7 +329,7 @@ class ReadOauth
|
|
|
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]);
|
|
|
if (!$appid_info)
|
|
@@ -336,19 +341,19 @@ class ReadOauth
|
|
|
$res = ForceSubscribeService::forceSubscribeUsersByUidAndAppid($appid, $uid);
|
|
|
if ($res) return false;
|
|
|
|
|
|
- /*$forcesubuser = ForceSubscribeService::forceSubscribeUsersByOpenid(['openid' => $openid]);
|
|
|
+ $forcesubuser = ForceSubscribeService::forceSubscribeUsersByOpenid(['openid' => $openid]);
|
|
|
if ($forcesubuser) {
|
|
|
return false;
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
- $send_order_id = ReadRecordService::getSendOrderId($uid);
|
|
|
+ /*$send_order_id = ReadRecordService::getSendOrderId($uid);
|
|
|
if ($send_order_id) {
|
|
|
try {
|
|
|
Redis::hset('force_subscribe_from_send_order_id', $appid . '_' . $uid, $send_order_id);
|
|
|
} catch (\Exception $e) {
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ }*/
|
|
|
$user_info = ForceSubscribeService::getUserInfoAll($appid, $openid);
|
|
|
$forcesubuserdata = [
|
|
|
'appid' => $appid,
|
|
@@ -358,6 +363,9 @@ class ReadOauth
|
|
|
'openid' => $openid,
|
|
|
'official_account_id' => 1
|
|
|
];
|
|
|
+ if($send_order_id){
|
|
|
+ $forcesubuserdata['send_order_id'] = $send_order_id;
|
|
|
+ }
|
|
|
if ($user_info) {
|
|
|
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'];
|
|
@@ -762,6 +770,21 @@ class ReadOauth
|
|
|
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)
|
|
|
{
|
|
|
if (!$request->has('fromtype')) return '';
|
|
@@ -997,4 +1020,67 @@ class ReadOauth
|
|
|
}
|
|
|
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 ;
|
|
|
+ }
|
|
|
}
|