作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !3045
  1 +<?php
  2 +
  3 +namespace App\Console\Commands\Inquiry;
  4 +
  5 +use App\Models\Inquiry\ForwardCount;
  6 +use App\Models\Inquiry\InquiryInfo;
  7 +use Illuminate\Console\Command;
  8 +
  9 +class InquiryForwardDayCount extends Command
  10 +{
  11 + /**
  12 + * The name and signature of the console command.
  13 + *
  14 + * @var string
  15 + */
  16 + protected $signature = 'inquiry_forward_day_count';
  17 +
  18 + /**
  19 + * The console command description.
  20 + *
  21 + * @var string
  22 + */
  23 + protected $description = '每日统计询盘转发数量';
  24 +
  25 + /**
  26 + * Create a new command instance.
  27 + *
  28 + * @return void
  29 + */
  30 + public function __construct()
  31 + {
  32 + parent::__construct();
  33 + }
  34 +
  35 + public function handle()
  36 + {
  37 + $day_start = date('Y-m-d', strtotime('-1 day'));
  38 + $day_arr = explode('-', $day_start);
  39 +
  40 + $year = $day_arr[0];
  41 + $month = $day_arr[1];
  42 + $day = $day_arr[2];
  43 +
  44 + $manage_ids = InquiryInfo::select('operator_id')->where('status', InquiryInfo::STATUS_FINISH)->where('operator_id', '>', 0)->orderBy('operator_id', 'asc')->distinct()->pluck('operator_id')->toArray();
  45 + foreach ($manage_ids as $mid) {
  46 + $day_count = ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->where('day', $day)->first();
  47 + if (!$day_count) {
  48 + $day_count = new ForwardCount();
  49 + $day_count->manage_id = $mid;
  50 + $day_count->year = $year;
  51 + $day_count->month = $month;
  52 + $day_count->day = $day;
  53 + }
  54 + $day_count->count = InquiryInfo::where('status', InquiryInfo::STATUS_FINISH)->where('operator_id', $mid)->where('updated_at', 'like', $day_start . '%')->count('id') ?? 0;
  55 + $day_count->save();
  56 + }
  57 +
  58 + $this->output('success');
  59 + }
  60 +
  61 + public function output($message)
  62 + {
  63 + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
  64 + }
  65 +}
@@ -160,6 +160,17 @@ class HtmlCollect extends Command @@ -160,6 +160,17 @@ class HtmlCollect extends Command
160 //437项目单词替换 160 //437项目单词替换
161 $html = str_replace('Forenia', 'Tourle', $html); 161 $html = str_replace('Forenia', 'Tourle', $html);
162 } 162 }
  163 + if ($project_id == 565) {
  164 + //565项目单词替换
  165 + $html = str_replace('Screwfix', '', $html);
  166 + $html = str_replace('Fungsi', '', $html);
  167 + $html = str_replace('Turlen', '', $html);
  168 + }
  169 + if ($project_id == 2078) {
  170 + //2078项目单词替换
  171 + $html = str_replace('Broflanilide', '', $html);
  172 + $html = str_replace('broflanilide', '', $html);
  173 + }
163 $collect_info->html = $html; 174 $collect_info->html = $html;
164 $collect_info->status = CollectTask::STATUS_COM; 175 $collect_info->status = CollectTask::STATUS_COM;
165 $collect_info->save(); 176 $collect_info->save();
@@ -134,6 +134,10 @@ class ProjectUpdate extends Command @@ -134,6 +134,10 @@ class ProjectUpdate extends Command
134 //565项目单词替换 134 //565项目单词替换
135 $replace = ['Screwfix' => '', 'Fungsi' => '', 'Turlen' => '']; 135 $replace = ['Screwfix' => '', 'Fungsi' => '', 'Turlen' => ''];
136 } 136 }
  137 + if ($project_id == 2078) {
  138 + //2078项目单词替换
  139 + $replace = ['Broflanilide' => '', 'broflanilide' => ''];
  140 + }
137 141
138 //设置数据库 142 //设置数据库
139 $project = ProjectServer::useProject($project_id); 143 $project = ProjectServer::useProject($project_id);
@@ -252,4 +252,16 @@ class InquiryForwardController extends BaseController @@ -252,4 +252,16 @@ class InquiryForwardController extends BaseController
252 $data = $inquiryForwardLogic->inquiryCount(); 252 $data = $inquiryForwardLogic->inquiryCount();
253 $this->response('success', Code::SUCCESS, $data); 253 $this->response('success', Code::SUCCESS, $data);
254 } 254 }
  255 +
  256 + /**
  257 + * 获取按操作人的询盘统计
  258 + * @param InquiryForwardLogic $inquiryForwardLogic
  259 + * @author Akun
  260 + * @date 2025/10/28 15:22
  261 + */
  262 + public function getInquiryManageCount(InquiryForwardLogic $inquiryForwardLogic)
  263 + {
  264 + $data = $inquiryForwardLogic->inquiryManageCount();
  265 + $this->response('success', Code::SUCCESS, $data);
  266 + }
255 } 267 }
@@ -8,6 +8,7 @@ use App\Helper\Translate; @@ -8,6 +8,7 @@ use App\Helper\Translate;
8 use App\Http\Logic\Aside\BaseLogic; 8 use App\Http\Logic\Aside\BaseLogic;
9 use App\Models\Ai\AiCommand; 9 use App\Models\Ai\AiCommand;
10 use App\Models\Inquiry\AreaTimezone; 10 use App\Models\Inquiry\AreaTimezone;
  11 +use App\Models\Inquiry\ForwardCount;
11 use App\Models\Inquiry\InquiryInfo; 12 use App\Models\Inquiry\InquiryInfo;
12 use App\Models\Inquiry\InquiryProject; 13 use App\Models\Inquiry\InquiryProject;
13 use App\Models\Inquiry\InquiryProjectRoute; 14 use App\Models\Inquiry\InquiryProjectRoute;
@@ -515,4 +516,55 @@ class InquiryForwardLogic extends BaseLogic @@ -515,4 +516,55 @@ class InquiryForwardLogic extends BaseLogic
515 516
516 return $this->success($data); 517 return $this->success($data);
517 } 518 }
  519 +
  520 + /**
  521 + * 根据转发人统计询盘数量
  522 + * @return array
  523 + * @author Akun
  524 + * @date 2025/10/28 15:02
  525 + */
  526 + public function inquiryManageCount()
  527 + {
  528 + $type = $this->param['type'] ?? 1;//统计类型:1周统计,2月统计
  529 +
  530 + $manage_ids = ForwardCount::select('manage_id')->orderBy('manage_id', 'asc')->distinct()->pluck('manage_id')->toArray();
  531 + $manageModel = new Manage();
  532 + $data = [];
  533 + if ($type == 1) {
  534 + //周统计
  535 + $now_day = date('Y-m-d');
  536 + $last_week_day = date('Y-m-d', strtotime('-1 week'));
  537 + while ($last_week_day < $now_day) {
  538 + $day_arr = explode('-', $last_week_day);
  539 + $year = $day_arr[0];
  540 + $month = $day_arr[1];
  541 + $day = $day_arr[2];
  542 +
  543 + foreach ($manage_ids as $mid) {
  544 + $name = $manageModel->getName($mid);
  545 + $data[$last_week_day][$name] = ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->where('day', $day)->value('count') ?? 0;
  546 + }
  547 +
  548 + $last_week_day = date('Y-m-d', strtotime($last_week_day . ' +1 day'));
  549 + }
  550 + } else {
  551 + //月统计
  552 + $now_month = date('Y-m');
  553 + $last_year_month = date('Y-m', strtotime('-11 months'));
  554 + while ($last_year_month <= $now_month) {
  555 + $month_arr = explode('-', $last_year_month);
  556 + $year = $month_arr[0];
  557 + $month = $month_arr[1];
  558 +
  559 + foreach ($manage_ids as $mid) {
  560 + $name = $manageModel->getName($mid);
  561 + $data[$last_year_month][$name] = intval(ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->sum('count') ?? 0);
  562 + }
  563 +
  564 + $last_year_month = date('Y-m', strtotime($last_year_month . ' +1 month'));
  565 + }
  566 + }
  567 +
  568 + return $this->success($data);
  569 + }
518 } 570 }
@@ -414,6 +414,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -414,6 +414,7 @@ Route::middleware(['aloginauth'])->group(function () {
414 Route::any('/getInquiryDetailList', [Aside\Optimize\InquiryForwardController::class, 'getInquiryDetailList'])->name('admin.inquiry_forward_getInquiryDetailList'); 414 Route::any('/getInquiryDetailList', [Aside\Optimize\InquiryForwardController::class, 'getInquiryDetailList'])->name('admin.inquiry_forward_getInquiryDetailList');
415 Route::any('/stopForwardInquiry', [Aside\Optimize\InquiryForwardController::class, 'stopForwardInquiry'])->name('admin.inquiry_forward_stopForwardInquiry'); 415 Route::any('/stopForwardInquiry', [Aside\Optimize\InquiryForwardController::class, 'stopForwardInquiry'])->name('admin.inquiry_forward_stopForwardInquiry');
416 Route::any('/getInquiryCount', [Aside\Optimize\InquiryForwardController::class, 'getInquiryCount'])->name('admin.inquiry_forward_getInquiryCount'); 416 Route::any('/getInquiryCount', [Aside\Optimize\InquiryForwardController::class, 'getInquiryCount'])->name('admin.inquiry_forward_getInquiryCount');
  417 + Route::any('/getInquiryManageCount', [Aside\Optimize\InquiryForwardController::class, 'getInquiryManageCount'])->name('admin.inquiry_forward_getInquiryManageCount');
417 }); 418 });
418 419
419 Route::prefix('custom_module')->group(function () { 420 Route::prefix('custom_module')->group(function () {