Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into lyh-server
正在显示
4 个修改的文件
包含
136 行增加
和
18 行删除
| @@ -252,13 +252,16 @@ class SyncInquiryRelay extends Command | @@ -252,13 +252,16 @@ class SyncInquiryRelay extends Command | ||
| 252 | //关键词查询项目着陆页:先精准匹配,没有数据再全文索引匹配 | 252 | //关键词查询项目着陆页:先精准匹配,没有数据再全文索引匹配 |
| 253 | $inquiryForwardLogic = new InquiryForwardLogic(); | 253 | $inquiryForwardLogic = new InquiryForwardLogic(); |
| 254 | $forward_list = $inquiryForwardLogic->searchKeywords($ai_keyword, 2, 3); | 254 | $forward_list = $inquiryForwardLogic->searchKeywords($ai_keyword, 2, 3); |
| 255 | - if (empty($forward_list)) { | ||
| 256 | - $forward_list = $inquiryForwardLogic->searchKeywords($ai_keyword, 1, 3); | ||
| 257 | - if (empty($forward_list)) { | ||
| 258 | - $this->output('询盘ID:' . $form_id . ',根据关键词[' . $ai_keyword . ']查询项目着陆页为空'); | ||
| 259 | - return true; | 255 | + if (count($forward_list) < 3) { |
| 256 | + $forward_list_against = $inquiryForwardLogic->searchKeywords($ai_keyword, 1, 3 - count($forward_list)); | ||
| 257 | + foreach ($forward_list_against as $against) { | ||
| 258 | + array_push($forward_list, $against); | ||
| 260 | } | 259 | } |
| 261 | } | 260 | } |
| 261 | + if (empty($forward_list)) { | ||
| 262 | + $this->output('询盘ID:' . $form_id . ',根据关键词[' . $ai_keyword . ']查询项目着陆页为空'); | ||
| 263 | + return true; | ||
| 264 | + } | ||
| 262 | 265 | ||
| 263 | //重写询盘内容 | 266 | //重写询盘内容 |
| 264 | $ai_message_list = []; | 267 | $ai_message_list = []; |
| @@ -54,7 +54,7 @@ class ExternalLinkMake extends Command | @@ -54,7 +54,7 @@ class ExternalLinkMake extends Command | ||
| 54 | continue; | 54 | continue; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | - $yesterday = RankDataLog::where(['project_id' => $project->id, 'date' => date('Y-m-d', '-1 day')])->first(); | 57 | + $yesterday = RankDataLog::where(['project_id' => $project->id, 'date' => date('Y-m-d', strtotime('-1 day'))])->first(); |
| 58 | if (FALSE == empty($yesterday) && $yesterday->is_compliance == 1){ | 58 | if (FALSE == empty($yesterday) && $yesterday->is_compliance == 1){ |
| 59 | $this->output('项目昨日达标: ' . $project->id . ', 跳过'); | 59 | $this->output('项目昨日达标: ' . $project->id . ', 跳过'); |
| 60 | continue; | 60 | continue; |
| @@ -3,13 +3,19 @@ | @@ -3,13 +3,19 @@ | ||
| 3 | namespace App\Console\Commands\Test; | 3 | namespace App\Console\Commands\Test; |
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | +use App\Helper\Common; | ||
| 7 | +use App\Helper\Gpt; | ||
| 8 | +use App\Http\Logic\Aside\Optimize\InquiryForwardLogic; | ||
| 6 | use App\Http\Logic\Bside\Product\CategoryLogic; | 9 | use App\Http\Logic\Bside\Product\CategoryLogic; |
| 10 | +use App\Models\Ai\AiCommand; | ||
| 7 | use App\Models\Com\Notify; | 11 | use App\Models\Com\Notify; |
| 8 | use App\Models\CustomModule\CustomModuleContent; | 12 | use App\Models\CustomModule\CustomModuleContent; |
| 9 | use App\Models\Devops\ServerConfig; | 13 | use App\Models\Devops\ServerConfig; |
| 10 | use App\Models\Devops\ServersIp; | 14 | use App\Models\Devops\ServersIp; |
| 11 | use App\Models\Domain\DomainCreateTask; | 15 | use App\Models\Domain\DomainCreateTask; |
| 12 | use App\Models\Domain\DomainInfo; | 16 | use App\Models\Domain\DomainInfo; |
| 17 | +use App\Models\Inquiry\InquiryInfo; | ||
| 18 | +use App\Models\Inquiry\InquiryRelayAi; | ||
| 13 | use App\Models\Product\Category; | 19 | use App\Models\Product\Category; |
| 14 | use App\Models\Product\CategoryRelated; | 20 | use App\Models\Product\CategoryRelated; |
| 15 | use App\Models\Product\Keyword; | 21 | use App\Models\Product\Keyword; |
| @@ -43,7 +49,81 @@ class Temp extends Command | @@ -43,7 +49,81 @@ class Temp extends Command | ||
| 43 | 49 | ||
| 44 | public function handle() | 50 | public function handle() |
| 45 | { | 51 | { |
| 52 | + $this->inquiryAiCheck(17259, 27468); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * AI预处理询盘 | ||
| 57 | + * @param $start_id | ||
| 58 | + * @param $end_id | ||
| 59 | + * @return bool | ||
| 60 | + * @author Akun | ||
| 61 | + * @date 2025/10/10 15:45 | ||
| 62 | + */ | ||
| 63 | + public function inquiryAiCheck($start_id, $end_id) | ||
| 64 | + { | ||
| 65 | + //AI匹配询盘关键词 | ||
| 66 | + $ai_info = AiCommand::select(['ai'])->where('key', 'inquiry_keyword_extract')->first(); | ||
| 67 | + if (!$ai_info) { | ||
| 68 | + $this->output('AI重写指令[inquiry_keyword_extract]未配置'); | ||
| 69 | + return true; | ||
| 70 | + } | ||
| 46 | 71 | ||
| 72 | + InquiryInfo::select(['id', 'message', 'url_title', 'url_keyword'])->whereBetween('id', [$start_id, $end_id])->where('status', InquiryInfo::STATUS_INIT)->chunk(100, function ($inquiries) use ($ai_info) { | ||
| 73 | + foreach ($inquiries as $inquiry) { | ||
| 74 | + $inquiry_ai_info = InquiryRelayAi::where('form_id', $inquiry['id'])->first(); | ||
| 75 | + if (!$inquiry_ai_info) { | ||
| 76 | + | ||
| 77 | + $ai_command = $ai_info['ai']; | ||
| 78 | + $ai_command = str_replace('{title}', $inquiry['url_title'], $ai_command); | ||
| 79 | + $ai_command = str_replace('{keywords}', $inquiry['url_keyword'], $ai_command); | ||
| 80 | + $ai_command = str_replace('{content}', $inquiry['message'], $ai_command); | ||
| 81 | + $ai_keyword = Common::deal_str(Gpt::instance()->openai_chat_qqs($ai_command)); | ||
| 82 | + if (!$ai_keyword) { | ||
| 83 | + $this->output('询盘ID:' . $inquiry['id'] . ',AI提取询盘关键词失败'); | ||
| 84 | + continue; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + //关键词查询项目着陆页:先精准匹配,没有数据再全文索引匹配 | ||
| 88 | + $inquiryForwardLogic = new InquiryForwardLogic(); | ||
| 89 | + $forward_list = $inquiryForwardLogic->searchKeywords($ai_keyword, 2, 3); | ||
| 90 | + if (count($forward_list) < 3) { | ||
| 91 | + $forward_list_against = $inquiryForwardLogic->searchKeywords($ai_keyword, 1, 3 - count($forward_list)); | ||
| 92 | + foreach ($forward_list_against as $against) { | ||
| 93 | + array_push($forward_list, $against); | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + if (empty($forward_list)) { | ||
| 97 | + $this->output('询盘ID:' . $inquiry['id'] . ',根据关键词[' . $ai_keyword . ']查询项目着陆页为空'); | ||
| 98 | + continue; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + //重写询盘内容 | ||
| 102 | + $ai_message_list = []; | ||
| 103 | + for ($i = 0; $i < count($forward_list); $i++) { | ||
| 104 | + $message_re = $inquiryForwardLogic->aiRewrite($inquiry['message'], $inquiry['url_title'], $inquiry['url_keyword']); | ||
| 105 | + if (isset($message_re['ai_message']) && $message_re['ai_message']) { | ||
| 106 | + $ai_message_list[] = $message_re['ai_message']; | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + if (empty($ai_message_list)) { | ||
| 110 | + $this->output('询盘ID:' . $inquiry['id'] . ',AI重写询盘内容失败'); | ||
| 111 | + continue; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + $inquiry_ai_info = new InquiryRelayAi(); | ||
| 115 | + $inquiry_ai_info->form_id = $inquiry['id']; | ||
| 116 | + $inquiry_ai_info->keywords = $ai_keyword; | ||
| 117 | + $inquiry_ai_info->forward_url = Arr::a2s($forward_list); | ||
| 118 | + $inquiry_ai_info->message_ai = Arr::a2s($ai_message_list); | ||
| 119 | + $inquiry_ai_info->save(); | ||
| 120 | + | ||
| 121 | + $this->output('询盘ID:' . $inquiry['id'] . ',success'); | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + }); | ||
| 125 | + | ||
| 126 | + return true; | ||
| 47 | } | 127 | } |
| 48 | 128 | ||
| 49 | /** | 129 | /** |
| @@ -14,6 +14,7 @@ use App\Models\Inquiry\InquiryProjectRoute; | @@ -14,6 +14,7 @@ use App\Models\Inquiry\InquiryProjectRoute; | ||
| 14 | use App\Models\Inquiry\InquiryRelayAi; | 14 | use App\Models\Inquiry\InquiryRelayAi; |
| 15 | use App\Models\Inquiry\InquiryRelayDetail; | 15 | use App\Models\Inquiry\InquiryRelayDetail; |
| 16 | use App\Models\Inquiry\InquiryRelayDetailLog; | 16 | use App\Models\Inquiry\InquiryRelayDetailLog; |
| 17 | +use App\Models\Manage\Manage; | ||
| 17 | use Illuminate\Support\Arr; | 18 | use Illuminate\Support\Arr; |
| 18 | use Illuminate\Support\Facades\DB; | 19 | use Illuminate\Support\Facades\DB; |
| 19 | use Illuminate\Support\Str; | 20 | use Illuminate\Support\Str; |
| @@ -139,16 +140,28 @@ class InquiryForwardLogic extends BaseLogic | @@ -139,16 +140,28 @@ class InquiryForwardLogic extends BaseLogic | ||
| 139 | $this->fail('当前询盘状态无法转发'); | 140 | $this->fail('当前询盘状态无法转发'); |
| 140 | } | 141 | } |
| 141 | 142 | ||
| 143 | + if (is_array($this->param['message'])) { | ||
| 144 | + $message_list = $this->param['message']; | ||
| 145 | + } else { | ||
| 146 | + $message_list = [$this->param['message']]; | ||
| 147 | + } | ||
| 148 | + $message_count = count($message_list); | ||
| 149 | + if ($message_count == 0) { | ||
| 150 | + $this->fail('内容不能为空'); | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + if (is_array($this->param['forward_url'])) { | ||
| 154 | + $forward_url = $this->param['forward_url']; | ||
| 155 | + } else { | ||
| 156 | + $forward_url = explode(',', $this->param['forward_url']); | ||
| 157 | + } | ||
| 158 | + | ||
| 142 | DB::beginTransaction(); | 159 | DB::beginTransaction(); |
| 143 | try { | 160 | try { |
| 144 | $num = 0; | 161 | $num = 0; |
| 145 | $now = date('Y-m-d H:i:s'); | 162 | $now = date('Y-m-d H:i:s'); |
| 146 | - if (is_array($this->param['forward_url'])) { | ||
| 147 | - $forward_url = $this->param['forward_url']; | ||
| 148 | - } else { | ||
| 149 | - $forward_url = explode(',', $this->param['forward_url']); | ||
| 150 | - } | ||
| 151 | - foreach ($forward_url as $url) { | 163 | + |
| 164 | + foreach ($forward_url as $key => $url) { | ||
| 152 | $url = trim($url); | 165 | $url = trim($url); |
| 153 | $domain_array = parse_url($url); | 166 | $domain_array = parse_url($url); |
| 154 | $website = $domain_array['host'] ?? ''; | 167 | $website = $domain_array['host'] ?? ''; |
| @@ -217,7 +230,10 @@ class InquiryForwardLogic extends BaseLogic | @@ -217,7 +230,10 @@ class InquiryForwardLogic extends BaseLogic | ||
| 217 | $start_at = $now; | 230 | $start_at = $now; |
| 218 | } | 231 | } |
| 219 | 232 | ||
| 220 | - InquiryRelayDetail::createInquiry($info['id'], $website, $country, $this->param['ip'], $this->param['name'], $this->param['email'], $this->param['phone'] ?? '', $this->param['message'], $is_v6, json_encode([$url]), $start_at); | 233 | + //获取询盘内容 |
| 234 | + $message = $message_list[$key % $message_count] ?? $message_list[0]; | ||
| 235 | + | ||
| 236 | + InquiryRelayDetail::createInquiry($info['id'], $website, $country, $this->param['ip'], $this->param['name'], $this->param['email'], $this->param['phone'] ?? '', $message, $is_v6, json_encode([$url]), $start_at); | ||
| 221 | 237 | ||
| 222 | $num += 1; | 238 | $num += 1; |
| 223 | } | 239 | } |
| @@ -315,7 +331,8 @@ class InquiryForwardLogic extends BaseLogic | @@ -315,7 +331,8 @@ class InquiryForwardLogic extends BaseLogic | ||
| 315 | 'route' => $vp->domain . $route, | 331 | 'route' => $vp->domain . $route, |
| 316 | 'recent_inquiry' => $vp->recent_inquiry, | 332 | 'recent_inquiry' => $vp->recent_inquiry, |
| 317 | 'remark' => $vp->remark ?: '', | 333 | 'remark' => $vp->remark ?: '', |
| 318 | - 'version' => $vp->version | 334 | + 'version' => $vp->version, |
| 335 | + 'type' => $type | ||
| 319 | ]; | 336 | ]; |
| 320 | } | 337 | } |
| 321 | } | 338 | } |
| @@ -421,6 +438,23 @@ class InquiryForwardLogic extends BaseLogic | @@ -421,6 +438,23 @@ class InquiryForwardLogic extends BaseLogic | ||
| 421 | { | 438 | { |
| 422 | $model = new InquiryRelayDetail(); | 439 | $model = new InquiryRelayDetail(); |
| 423 | $lists = $model->listsWith($map, $page, $row, $order, $filed, 'desc', ['detailLog']); | 440 | $lists = $model->listsWith($map, $page, $row, $order, $filed, 'desc', ['detailLog']); |
| 441 | + | ||
| 442 | + //获取操作人 | ||
| 443 | + $inquiry_info_model = new InquiryInfo(); | ||
| 444 | + $manage_model = new Manage(); | ||
| 445 | + foreach ($lists['list'] as $k => $v) { | ||
| 446 | + $operator_name = ''; | ||
| 447 | + $inquiry_info = $inquiry_info_model->read(['id' => $v['form_id']], ['operator_id']); | ||
| 448 | + if ($inquiry_info) { | ||
| 449 | + $manage_info = $manage_model->read(['id' => $inquiry_info['operator_id']], ['name']); | ||
| 450 | + if ($manage_info) { | ||
| 451 | + $operator_name = $manage_info['name']; | ||
| 452 | + } | ||
| 453 | + } | ||
| 454 | + | ||
| 455 | + $lists['list'][$k]['operator_name'] = $operator_name; | ||
| 456 | + } | ||
| 457 | + | ||
| 424 | return $this->success($lists); | 458 | return $this->success($lists); |
| 425 | } | 459 | } |
| 426 | 460 | ||
| @@ -467,7 +501,8 @@ class InquiryForwardLogic extends BaseLogic | @@ -467,7 +501,8 @@ class InquiryForwardLogic extends BaseLogic | ||
| 467 | $data[$s_date] = [ | 501 | $data[$s_date] = [ |
| 468 | 'total' => 0, | 502 | 'total' => 0, |
| 469 | 'invalid' => 0, | 503 | 'invalid' => 0, |
| 470 | - 'init' => 0 | 504 | + 'init' => 0, |
| 505 | + 'finish' => 0 | ||
| 471 | ]; | 506 | ]; |
| 472 | $s_date = date('Y-m-d', strtotime($s_date . ' + 1 day')); | 507 | $s_date = date('Y-m-d', strtotime($s_date . ' + 1 day')); |
| 473 | } | 508 | } |
| @@ -480,10 +515,10 @@ class InquiryForwardLogic extends BaseLogic | @@ -480,10 +515,10 @@ class InquiryForwardLogic extends BaseLogic | ||
| 480 | 515 | ||
| 481 | if ($value['status'] == InquiryInfo::STATUS_INVALID) { | 516 | if ($value['status'] == InquiryInfo::STATUS_INVALID) { |
| 482 | $data[$inquiry_date]['invalid'] += 1; | 517 | $data[$inquiry_date]['invalid'] += 1; |
| 483 | - } | ||
| 484 | - | ||
| 485 | - if ($value['status'] == InquiryInfo::STATUS_INIT) { | 518 | + } elseif ($value['status'] == InquiryInfo::STATUS_INIT) { |
| 486 | $data[$inquiry_date]['init'] += 1; | 519 | $data[$inquiry_date]['init'] += 1; |
| 520 | + } else { | ||
| 521 | + $data[$inquiry_date]['finish'] += 1; | ||
| 487 | } | 522 | } |
| 488 | } | 523 | } |
| 489 | 524 |
-
请 注册 或 登录 后发表评论