作者 lyh

gx

... ... @@ -67,7 +67,7 @@ class InquiryMonthlyCount extends Command
$arr['month_total'] = 0;
$countryArr = [];
foreach ($data as $v){
if(($startTime <= $v['submit_time']) && $v['submit_time'] <= $endTime){
if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){
$arr['month_total']++;
}
if(isset($countryArr[$v['country']])){
... ... @@ -97,8 +97,8 @@ class InquiryMonthlyCount extends Command
public function flowCount($startTime,$endTime,$project_id){
DB::table('gl_count')
->where(['project_id'=>$project_id])
->where('date','>=',$startTime)
->where('date','<=',$endTime)
->where('date','>=',$startTime.' 00:00:00')
->where('date','<=',$endTime.' 23:59:59')
->sum('pv_num');
}
}
... ...
... ... @@ -147,39 +147,17 @@ class ComController extends BaseController
}
public function ceshi(){
$arr = [];
$inquiry_list = (new FormGlobalsoApi())->getInquiryList('https://demomark.globalso.com/','',1,100000000);
//总数
$arr['total'] = $inquiry_list['data']['total'];
//数据详情
$data = $inquiry_list['data']['data'];
// 获取上个月的开始时间
$currentDateTime = Carbon::now();
$startTime = $currentDateTime->subMonth()->startOfMonth()->toDateString();
// 获取上个月的结束时间
$endTime = $currentDateTime->subMonth()->endOfMonth()->toDateString();
$arr['month_total'] = 0;
$countryArr = [];
foreach ($data as $v){
if(($startTime <= $v['submit_time']) && $v['submit_time'] <= $endTime){
$arr['month_total']++;
}
if(isset($countryArr[$v['country']])){
$countryArr[$v['country']]++;
}else{
$countryArr[$v['country']] = 0;
}
}
// 获取当前日期时间
$arr['month'] = Carbon::now()->subMonth()->format('Y-m');
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 15, true);
$arr['country'] = json_encode($top20);
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
$arr['project_id'] = 1;
DB::table('gl_inquiry_month_count')->insert($arr);
$this->response('success',Code::SUCCESS,$startTime);
$pv = DB::table('gl_count')
->where(['project_id'=>1])
->where('date','>=',$startTime.' 00:00:00')
->where('date','<=',$endTime.' 23:59:59')
->sum('pv_num');
$this->response('success',Code::SUCCESS,$pv);
}
/**
... ...