作者 lyh

gx

@@ -33,8 +33,9 @@ class UpgradeProjectCount extends Command @@ -33,8 +33,9 @@ class UpgradeProjectCount extends Command
33 protected $description = '升级项目统计'; 33 protected $description = '升级项目统计';
34 34
35 public function handle(){ 35 public function handle(){
36 - ProjectServer::useProject(627);  
37 - $this->count(); 36 + $project_id = 600;
  37 + ProjectServer::useProject($project_id);
  38 + $this->count($project_id);
38 DB::disconnect('custom_mysql'); 39 DB::disconnect('custom_mysql');
39 } 40 }
40 41
@@ -45,18 +46,18 @@ class UpgradeProjectCount extends Command @@ -45,18 +46,18 @@ class UpgradeProjectCount extends Command
45 * @method :post 46 * @method :post
46 * @time :2024/1/8 9:05 47 * @time :2024/1/8 9:05
47 */ 48 */
48 - public function count(){ 49 + public function count($project_id){
49 $list = DB::connection('custom_mysql')->table('gl_customer_visit')->select('updated_date') 50 $list = DB::connection('custom_mysql')->table('gl_customer_visit')->select('updated_date')
50 ->groupBy('updated_date')->get()->toArray(); 51 ->groupBy('updated_date')->get()->toArray();
51 $project = new Project(); 52 $project = new Project();
52 - $projectInfo = $project->read(['id'=>627]); 53 + $projectInfo = $project->read(['id'=>$project_id]);
53 if(!empty($list)){ 54 if(!empty($list)){
54 $arr = []; 55 $arr = [];
55 foreach ($list as $k=>$v){ 56 foreach ($list as $k=>$v){
56 $v = (array)$v; 57 $v = (array)$v;
57 echo date('Y-m-d H:i:s') . '时间:'.$v['updated_date'] . PHP_EOL; 58 echo date('Y-m-d H:i:s') . '时间:'.$v['updated_date'] . PHP_EOL;
58 $count = new Count(); 59 $count = new Count();
59 - $arr['project_id'] = 627; 60 + $arr['project_id'] = $project_id;
60 $arr['date'] = $v['updated_date']; 61 $arr['date'] = $v['updated_date'];
61 $arr['pv_num'] = $this->pv_num($v['updated_date']); 62 $arr['pv_num'] = $this->pv_num($v['updated_date']);
62 $arr['ip_num'] = $this->ip_num($v['updated_date']); 63 $arr['ip_num'] = $this->ip_num($v['updated_date']);
@@ -67,7 +68,7 @@ class UpgradeProjectCount extends Command @@ -67,7 +68,7 @@ class UpgradeProjectCount extends Command
67 $arr['service_day'] = $projectInfo['remain_day']; 68 $arr['service_day'] = $projectInfo['remain_day'];
68 $arr['country'] = '{"中国": 12, "丹麦": 6, "伊朗": 4, "南非": 11, "印度": 24, "巴西": 4, "德国": 6, "智利": 7, "法国": 8, "美国": 27, "英国": 13, "乌干达": 6, "加拿大": 12, "墨西哥": 5, "新加坡": 7, "菲律宾": 5, "阿根廷": 7, "澳大利亚": 11, "马来西亚": 4, "哥斯达黎加": 5}'; 69 $arr['country'] = '{"中国": 12, "丹麦": 6, "伊朗": 4, "南非": 11, "印度": 24, "巴西": 4, "德国": 6, "智利": 7, "法国": 8, "美国": 27, "英国": 13, "乌干达": 6, "加拿大": 12, "墨西哥": 5, "新加坡": 7, "菲律宾": 5, "阿根廷": 7, "澳大利亚": 11, "马来西亚": 4, "哥斯达黎加": 5}';
69 //查询当天数据是否存在 存在则更新 70 //查询当天数据是否存在 存在则更新
70 - $info = $count->read(['date'=>$v['updated_date']]); 71 + $info = $count->read(['date'=>$v['updated_date'],'project_id'=>$project_id]);
71 if($info === false){ 72 if($info === false){
72 $arr['created_at'] = $v['updated_date'].' 01:00:00'; 73 $arr['created_at'] = $v['updated_date'].' 01:00:00';
73 $arr['updated_at'] = $v['updated_date'].' 01:00:00'; 74 $arr['updated_at'] = $v['updated_date'].' 01:00:00';
@@ -35,8 +35,10 @@ class UpgradeProjectCount extends Command @@ -35,8 +35,10 @@ class UpgradeProjectCount extends Command
35 protected $description = '升级项目统计'; 35 protected $description = '升级项目统计';
36 36
37 public function handle(){ 37 public function handle(){
38 - ProjectServer::useProject(627);  
39 - $this->count(); 38 + $project_id = 600;
  39 + $url = 'i900.goodao.net';
  40 + ProjectServer::useProject($project_id);
  41 + $this->count($project_id,$url);
40 42
41 DB::disconnect('custom_mysql'); 43 DB::disconnect('custom_mysql');
42 } 44 }
@@ -48,20 +50,20 @@ class UpgradeProjectCount extends Command @@ -48,20 +50,20 @@ class UpgradeProjectCount extends Command
48 * @method :post 50 * @method :post
49 * @time :2024/1/8 9:05 51 * @time :2024/1/8 9:05
50 */ 52 */
51 - public function count(){ 53 + public function count($project_id,$url){
52 $list = DB::connection('custom_mysql')->table('gl_customer_visit') 54 $list = DB::connection('custom_mysql')->table('gl_customer_visit')
53 ->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month')) 55 ->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
54 ->groupBy('month')->get()->toArray(); 56 ->groupBy('month')->get()->toArray();
55 foreach ($list as $k=>$v){ 57 foreach ($list as $k=>$v){
56 $v = (array)$v; 58 $v = (array)$v;
57 $monthCountModel = new MonthCount(); 59 $monthCountModel = new MonthCount();
58 - $info = $monthCountModel->read(['month'=>$v['month']]); 60 + $info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]);
59 // 获取当月开始时间 61 // 获取当月开始时间
60 $start = date('Y-m-01', strtotime($v['month'])); 62 $start = date('Y-m-01', strtotime($v['month']));
61 // 获取当月结束时间 63 // 获取当月结束时间
62 $end = date('Y-m-t', strtotime($v['month'])); 64 $end = date('Y-m-t', strtotime($v['month']));
63 - $arr['project_id'] = 627;  
64 - $res = $this->inquiry('www.airuize.com',$v['month']); 65 + $arr['project_id'] = $project_id;
  66 + $res = $this->inquiry($url,$v['month']);
65 $arr['month_total'] = 0; 67 $arr['month_total'] = 0;
66 if(isset($res['data']['count'])){ 68 if(isset($res['data']['count'])){
67 $arr['month_total'] = $res['data']['count']; 69 $arr['month_total'] = $res['data']['count'];