|
@@ -53,119 +53,89 @@ class BookSpider extends Command
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function cpc(){
|
|
|
- //32426552
|
|
|
|
|
|
- $sql_format = "SELECT u.id,f.created_at as subscribe_time,u.openid,
|
|
|
-(SELECT ifnull(sum(price),0) from orders where uid = u.id and `status` = 'PAID' LIMIT 1)as amount,
|
|
|
-(SELECT ifnull(sum(price),0) from orders where uid=u.id and `status` = 'PAID' and created_at <= DATE_ADD(f.created_at,INTERVAL 3 day)) as three_day_amount
|
|
|
- FROM users u
|
|
|
-JOIN force_subscribe_users f on u.id = f.uid
|
|
|
-WHERE u.openid in (SELECT openid from users WHERE id = %s)";
|
|
|
- $all = 32427;
|
|
|
- for ($i =0;$i<=$all;$i++){
|
|
|
- $subscribes = DB::table('force_subscribe_users')->where('id','>',$i*1000)->select('uid')->limit(1000)->get();
|
|
|
- if($subscribes->isEmpty()){
|
|
|
- break;
|
|
|
- }
|
|
|
- foreach ($subscribes as $value){
|
|
|
- $result = DB::select(sprintf($sql_format,$value->uid));
|
|
|
- if($result){
|
|
|
- $user_property_info = $this->level($result);
|
|
|
- $this->create($user_property_info);
|
|
|
+ public function cleanRedis()
|
|
|
+ {
|
|
|
+ //accurateSendOrder
|
|
|
+ //$result = Redis::scan($flag,['match'=>'wap:string:chapter:{*','count'=>1000]);
|
|
|
+ $flag = 0;
|
|
|
+ /*while (true){
|
|
|
+ list($flag,$list) = Redis::hscan('push:inner_send_order_id:pv',$flag,['match'=>'*','count'=>100]);
|
|
|
+ $data = [];
|
|
|
+ if($list){
|
|
|
+ foreach ($list as $k=>$item){
|
|
|
+ $uv = Redis::scard('push:inner_send_order_id:uv:' . $k);
|
|
|
+ $data[] =
|
|
|
+ ['stats_type'=>'inner_send_order_id',
|
|
|
+ 'param'=>$k,'pv'=>$item,'uv'=>$uv,
|
|
|
+ 'created_at'=>date('Y-m-d H:i:s'),'updated_at'=>date('Y-m-d H:i:s')];
|
|
|
}
|
|
|
+ DB::table('wap_long_visit_stats')->insert($data);
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- private function level($res){
|
|
|
- $earliest_subscribe_time = $res[0]->subscribe_time;
|
|
|
- $subscribe_three_day_info = [];
|
|
|
- $subscribe_no_three_day_info = [];
|
|
|
- foreach ($res as $v){
|
|
|
- (strtotime($v->subscribe_time) < strtotime($earliest_subscribe_time)) && $earliest_subscribe_time = $v->subscribe_time;
|
|
|
- if(time()-strtotime($v->subscribe_time) >= 86400*3){
|
|
|
- array_push($subscribe_three_day_info,$v->amount);
|
|
|
- }else{
|
|
|
- array_push($subscribe_no_three_day_info,$v->three_day_amount);
|
|
|
+ if(!$flag){
|
|
|
+ break;
|
|
|
}
|
|
|
- }
|
|
|
- $result = [
|
|
|
- 'earliest_subscribe_time'=>$earliest_subscribe_time,
|
|
|
- 'property'=>'',
|
|
|
- 'type'=>'',
|
|
|
- 'openid'=> $res[0]->openid
|
|
|
- ];
|
|
|
- if($subscribe_three_day_info){
|
|
|
- //存量用户
|
|
|
- $result['type'] = 'CUILIANG';
|
|
|
- $amount = round(array_sum($subscribe_three_day_info)/count($subscribe_three_day_info),2);
|
|
|
- if($amount>15){
|
|
|
- $result['property'] = 'high';
|
|
|
- }elseif($amount >2){
|
|
|
- $result['property'] = 'medium';
|
|
|
- } elseif($amount >0){
|
|
|
- $result['property'] = 'low';
|
|
|
- } else{
|
|
|
- $result['property'] = 'none';
|
|
|
+ }*/
|
|
|
+ /*while (true){
|
|
|
+ list($flag,$list) = Redis::scan($flag,['match'=>'accurateSendOrder*','count'=>1000]);
|
|
|
+ if($list){
|
|
|
+ foreach ($list as $item){
|
|
|
+ Redis::del($item);
|
|
|
+ }
|
|
|
}
|
|
|
- }else{
|
|
|
- //新用户
|
|
|
- $result['type'] = 'NEW';
|
|
|
- if($subscribe_no_three_day_info)
|
|
|
- $amount = max($subscribe_no_three_day_info);
|
|
|
- else
|
|
|
- $amount = 0;
|
|
|
- if($amount>50){
|
|
|
- $result['property'] = 'high';
|
|
|
- }elseif($amount >2){
|
|
|
- $result['property'] = 'medium';
|
|
|
- } elseif($amount >0){
|
|
|
- $result['property'] = 'low';
|
|
|
- } else{
|
|
|
- $result['property'] = 'none';
|
|
|
+ if(!$flag){
|
|
|
+ break;
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
- return $result;
|
|
|
- }
|
|
|
-
|
|
|
- private function create($data){
|
|
|
- $old = DB::table('user_division_cpc_property')->where('openid',$data['openid'])->where('is_enable',1)->first();
|
|
|
- if(!$old){
|
|
|
- DB::table('user_division_cpc_property')->insert([
|
|
|
- 'openid'=>$data['openid'] ,
|
|
|
- 'property'=>$data['property'] ,
|
|
|
- 'is_enable'=>1 ,
|
|
|
- 'type'=>$data['type'] ,
|
|
|
- 'earliest_subscribe_time'=>$data['earliest_subscribe_time'] ,
|
|
|
- 'created_at'=>date('Y-m-d H:i:s'),
|
|
|
- 'updated_at'=>date('Y-m-d H:i:s')
|
|
|
- ]);
|
|
|
- }
|
|
|
- }
|
|
|
+ /*while (true){
|
|
|
+ list($flag,$list) = Redis::hscan('specialChannelIdStatsMarkUser:hash:',$flag,['match'=>'*','count'=>100]);
|
|
|
+ if($list){
|
|
|
+ $data = [];
|
|
|
+ foreach ($list as $k=>$send_order_id){
|
|
|
+ list($uid,$bid) = explode('-',$k);
|
|
|
+ //$data[] = ['uid'=>$uid,'bid'=>$bid,'send_order_id'=>$send_order_id,
|
|
|
+ // 'created_at'=>date('Y-m-d H:i:s'),'updated_at'=>date('Y-m-d H:i:s')];
|
|
|
+ Redis::del('specialChannelIdStatsMarkUser:set:'.$uid);
|
|
|
+ }
|
|
|
|
|
|
- public function cleanRedis()
|
|
|
- {
|
|
|
+ //DB::table('special_channel_stats_mark_user')->insert($data);
|
|
|
+ }
|
|
|
+ if(!$flag){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ ///131359
|
|
|
+ //$uv = Redis::scard('push:distribution_channel_id:alluv:from:' . $from);
|
|
|
+ /*$flag = 0;
|
|
|
+ while (true){
|
|
|
+ if($flag*1000 >=131359){
|
|
|
+ break;
|
|
|
+ //$result = DB::table('wap_long_visit_stats')->where('id','>=',$flag*1000)->select('param')->get();
|
|
|
+ }
|
|
|
+ $result = DB::table('wap_long_visit_stats')->where('id','>=',$flag*1000)->select('param')->limit(1000)->get();
|
|
|
+ foreach ($result as $v){
|
|
|
+ Redis::del('push:distribution_channel_id:alluv:from:' . $v->param);
|
|
|
+ }
|
|
|
+ $flag++;
|
|
|
+ }*/
|
|
|
$flag = 0;
|
|
|
- $i = 0;
|
|
|
- do{
|
|
|
- $result = Redis::scan($flag,['match'=>'wap:string:chapter:{*','count'=>1000]);
|
|
|
- if ($result) {
|
|
|
- if (isset($result[0])) {
|
|
|
- $flag = $result[0];
|
|
|
- }
|
|
|
- if (isset($result[1]) && $result[1] ) {
|
|
|
- foreach ($result[1] as $v) {
|
|
|
- Redis::del($v);
|
|
|
- echo $v . PHP_EOL;
|
|
|
- $i++;
|
|
|
- }
|
|
|
+ while (true){
|
|
|
+ //smartPushTestBookPayPageUv:bid:%s
|
|
|
+ list($flag,$list) = Redis::scan($flag,['match'=>'smartPushTestBookPaidUv:bid:*','count'=>100]);
|
|
|
+ if($list){
|
|
|
+ foreach ($list as $k){
|
|
|
+ $bid = str_replace('smartPushTestBookPaidUv:bid:','',$k);
|
|
|
+ //Redis::del($k);
|
|
|
+ DB::table('test_book_smart_push_stats20190709')->where('bid',$bid)->increment('paid_user_num',Redis::scard($k));
|
|
|
+ echo $bid .PHP_EOL;
|
|
|
}
|
|
|
}
|
|
|
- }while($flag);
|
|
|
- echo 'del ' . $i . PHP_EOL;
|
|
|
- return "";
|
|
|
+ if(!$flag){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private function newYunQi($bid){
|