|
...
|
...
|
@@ -11,7 +11,12 @@ namespace App\Http\Controllers\Bside\BCom; |
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Http\Controllers\Bside\BaseController;
|
|
|
|
use App\Models\HomeCount\Count;
|
|
|
|
use App\Models\HomeCount\MonthCount;
|
|
|
|
use App\Models\News\News;
|
|
|
|
use App\Models\Product\Category;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
|
|
|
class MonthReportController extends BaseController
|
|
|
|
{
|
|
...
|
...
|
@@ -40,24 +45,42 @@ class MonthReportController extends BaseController |
|
|
|
$monthCountModel = new MonthCount();
|
|
|
|
$this->map['project_id'] = $this->user['project_id'];
|
|
|
|
$info = $monthCountModel->read($this->map);
|
|
|
|
foreach ($info as $k => $v){
|
|
|
|
if(!empty($v['source_country'])){
|
|
|
|
$v['source_country'] = json_decode($v['source_country']);
|
|
|
|
if(!empty($info['source_country'])){
|
|
|
|
$info['source_country'] = json_decode($info['source_country']);
|
|
|
|
}
|
|
|
|
if(!empty($v['referrer_port'])){
|
|
|
|
$v['referrer_port'] = json_decode($v['referrer_port']);
|
|
|
|
if(!empty($info['referrer_port'])){
|
|
|
|
$info['referrer_port'] = json_decode($info['referrer_port']);
|
|
|
|
}
|
|
|
|
if(!empty($v['referrer_url'])){
|
|
|
|
$v['referrer_url'] = json_decode($v['referrer_url']);
|
|
|
|
if(!empty($info['referrer_url'])){
|
|
|
|
$info['referrer_url'] = json_decode($info['referrer_url']);
|
|
|
|
}
|
|
|
|
if(!empty($v['source'])){
|
|
|
|
$v['source'] = json_decode($v['source']);
|
|
|
|
if(!empty($info['source'])){
|
|
|
|
$info['source'] = json_decode($info['source']);
|
|
|
|
}
|
|
|
|
if(!empty($v['country'])){
|
|
|
|
$v['country'] = json_decode($v['country']);
|
|
|
|
}
|
|
|
|
$lists[$k] = $v;
|
|
|
|
if(!empty($info['country'])){
|
|
|
|
$info['country'] = json_decode($info['country']);
|
|
|
|
}
|
|
|
|
// 获取上个月的开始时间
|
|
|
|
$startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
|
|
|
|
// 获取上个月的结束时间
|
|
|
|
$endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
|
|
|
|
$param = [
|
|
|
|
'date' => ['between',[$startTime,$endTime]],
|
|
|
|
'project_id' => $this->user['project_id']
|
|
|
|
];
|
|
|
|
$info['pv_ip'] = (new Count())->list($param,'date',['id','pv_num','ip_num','date']);
|
|
|
|
$categoryModel = new Category();
|
|
|
|
$info['category_num'] = $categoryModel->formatQuery(['status'=>1])->count();
|
|
|
|
$productModel = new Product();
|
|
|
|
$info['products_num'] = $productModel->formatQuery(['status'=>1])->count();
|
|
|
|
$info['products_num_last_30'] = $productModel->formatQuery(
|
|
|
|
['status'=>1,'created_at'=>['between',[now()->subDays(30)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]]
|
|
|
|
])->count();
|
|
|
|
$newsModel = new News();
|
|
|
|
$info['news_num'] = $newsModel->formatQuery(['status'=>0])->count();
|
|
|
|
$info['news_num_last_7'] = $newsModel->formatQuery(
|
|
|
|
['status'=>1,'created_at'=>['between',[now()->subDays(7)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]]
|
|
|
|
])->count();
|
|
|
|
$this->response('success',Code::SUCCESS,$info);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|