作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !3045
<?php
namespace App\Console\Commands\Inquiry;
use App\Models\Inquiry\ForwardCount;
use App\Models\Inquiry\InquiryInfo;
use Illuminate\Console\Command;
class InquiryForwardDayCount extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inquiry_forward_day_count';
/**
* The console command description.
*
* @var string
*/
protected $description = '每日统计询盘转发数量';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function handle()
{
$day_start = date('Y-m-d', strtotime('-1 day'));
$day_arr = explode('-', $day_start);
$year = $day_arr[0];
$month = $day_arr[1];
$day = $day_arr[2];
$manage_ids = InquiryInfo::select('operator_id')->where('status', InquiryInfo::STATUS_FINISH)->where('operator_id', '>', 0)->orderBy('operator_id', 'asc')->distinct()->pluck('operator_id')->toArray();
foreach ($manage_ids as $mid) {
$day_count = ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->where('day', $day)->first();
if (!$day_count) {
$day_count = new ForwardCount();
$day_count->manage_id = $mid;
$day_count->year = $year;
$day_count->month = $month;
$day_count->day = $day;
}
$day_count->count = InquiryInfo::where('status', InquiryInfo::STATUS_FINISH)->where('operator_id', $mid)->where('updated_at', 'like', $day_start . '%')->count('id') ?? 0;
$day_count->save();
}
$this->output('success');
}
public function output($message)
{
echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
}
}
... ...
... ... @@ -160,6 +160,17 @@ class HtmlCollect extends Command
//437项目单词替换
$html = str_replace('Forenia', 'Tourle', $html);
}
if ($project_id == 565) {
//565项目单词替换
$html = str_replace('Screwfix', '', $html);
$html = str_replace('Fungsi', '', $html);
$html = str_replace('Turlen', '', $html);
}
if ($project_id == 2078) {
//2078项目单词替换
$html = str_replace('Broflanilide', '', $html);
$html = str_replace('broflanilide', '', $html);
}
$collect_info->html = $html;
$collect_info->status = CollectTask::STATUS_COM;
$collect_info->save();
... ...
... ... @@ -134,6 +134,10 @@ class ProjectUpdate extends Command
//565项目单词替换
$replace = ['Screwfix' => '', 'Fungsi' => '', 'Turlen' => ''];
}
if ($project_id == 2078) {
//2078项目单词替换
$replace = ['Broflanilide' => '', 'broflanilide' => ''];
}
//设置数据库
$project = ProjectServer::useProject($project_id);
... ...
... ... @@ -252,4 +252,16 @@ class InquiryForwardController extends BaseController
$data = $inquiryForwardLogic->inquiryCount();
$this->response('success', Code::SUCCESS, $data);
}
/**
* 获取按操作人的询盘统计
* @param InquiryForwardLogic $inquiryForwardLogic
* @author Akun
* @date 2025/10/28 15:22
*/
public function getInquiryManageCount(InquiryForwardLogic $inquiryForwardLogic)
{
$data = $inquiryForwardLogic->inquiryManageCount();
$this->response('success', Code::SUCCESS, $data);
}
}
... ...
... ... @@ -8,6 +8,7 @@ use App\Helper\Translate;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Ai\AiCommand;
use App\Models\Inquiry\AreaTimezone;
use App\Models\Inquiry\ForwardCount;
use App\Models\Inquiry\InquiryInfo;
use App\Models\Inquiry\InquiryProject;
use App\Models\Inquiry\InquiryProjectRoute;
... ... @@ -515,4 +516,55 @@ class InquiryForwardLogic extends BaseLogic
return $this->success($data);
}
/**
* 根据转发人统计询盘数量
* @return array
* @author Akun
* @date 2025/10/28 15:02
*/
public function inquiryManageCount()
{
$type = $this->param['type'] ?? 1;//统计类型:1周统计,2月统计
$manage_ids = ForwardCount::select('manage_id')->orderBy('manage_id', 'asc')->distinct()->pluck('manage_id')->toArray();
$manageModel = new Manage();
$data = [];
if ($type == 1) {
//周统计
$now_day = date('Y-m-d');
$last_week_day = date('Y-m-d', strtotime('-1 week'));
while ($last_week_day < $now_day) {
$day_arr = explode('-', $last_week_day);
$year = $day_arr[0];
$month = $day_arr[1];
$day = $day_arr[2];
foreach ($manage_ids as $mid) {
$name = $manageModel->getName($mid);
$data[$last_week_day][$name] = ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->where('day', $day)->value('count') ?? 0;
}
$last_week_day = date('Y-m-d', strtotime($last_week_day . ' +1 day'));
}
} else {
//月统计
$now_month = date('Y-m');
$last_year_month = date('Y-m', strtotime('-11 months'));
while ($last_year_month <= $now_month) {
$month_arr = explode('-', $last_year_month);
$year = $month_arr[0];
$month = $month_arr[1];
foreach ($manage_ids as $mid) {
$name = $manageModel->getName($mid);
$data[$last_year_month][$name] = intval(ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->sum('count') ?? 0);
}
$last_year_month = date('Y-m', strtotime($last_year_month . ' +1 month'));
}
}
return $this->success($data);
}
}
... ...
... ... @@ -414,6 +414,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/getInquiryDetailList', [Aside\Optimize\InquiryForwardController::class, 'getInquiryDetailList'])->name('admin.inquiry_forward_getInquiryDetailList');
Route::any('/stopForwardInquiry', [Aside\Optimize\InquiryForwardController::class, 'stopForwardInquiry'])->name('admin.inquiry_forward_stopForwardInquiry');
Route::any('/getInquiryCount', [Aside\Optimize\InquiryForwardController::class, 'getInquiryCount'])->name('admin.inquiry_forward_getInquiryCount');
Route::any('/getInquiryManageCount', [Aside\Optimize\InquiryForwardController::class, 'getInquiryManageCount'])->name('admin.inquiry_forward_getInquiryManageCount');
});
Route::prefix('custom_module')->group(function () {
... ...