作者 赵彬吉

update

@@ -11,6 +11,7 @@ use App\Helper\Common; @@ -11,6 +11,7 @@ use App\Helper\Common;
11 use App\Helper\Gpt; 11 use App\Helper\Gpt;
12 use App\Helper\Translate; 12 use App\Helper\Translate;
13 use App\Models\Ai\AiCommand; 13 use App\Models\Ai\AiCommand;
  14 +use App\Models\Inquiry\ReInquiryConfig;
14 use App\Models\Inquiry\ReInquiryDetail; 15 use App\Models\Inquiry\ReInquiryDetail;
15 use App\Models\Inquiry\ReInquiryDetailLog; 16 use App\Models\Inquiry\ReInquiryDetailLog;
16 use App\Models\Inquiry\ReInquiryForm; 17 use App\Models\Inquiry\ReInquiryForm;
@@ -353,6 +354,19 @@ class RelayInquiry extends Command @@ -353,6 +354,19 @@ class RelayInquiry extends Command
353 { 354 {
354 //通用过滤规则 355 //通用过滤规则
355 $config = InquiryFilterConfig::getCacheInfoByProjectId(Project::DEMO_PROJECT_ID); 356 $config = InquiryFilterConfig::getCacheInfoByProjectId(Project::DEMO_PROJECT_ID);
  357 + //FB询盘的全局过滤规则
  358 + $fb_config = ReInquiryConfig::getDefaultConfigCache(ReInquiryConfig::TYPE_FILTER_WORDS);
  359 +
  360 + $fb_config['filter_contents'] = array_filter(explode("\r\n", $fb_config['filter_contents']?:''));
  361 + $fb_config['filter_emails'] = array_filter(explode("\r\n", $fb_config['filter_emails']?:''));
  362 + $fb_config['filter_mobiles'] = array_filter(explode("\r\n", $fb_config['filter_mobiles']?:''));
  363 + $fb_config['filter_names'] = array_filter(explode("\r\n", $fb_config['filter_names']?:''));
  364 +
  365 + $config['filter_contents'] = array_unique(array_merge($fb_config['filter_contents'],$config['filter_contents']));
  366 + $config['filter_emails'] = array_unique(array_merge($fb_config['filter_emails'],$config['filter_emails']));
  367 + $config['filter_mobiles'] = array_unique(array_merge($fb_config['filter_mobiles'],$config['filter_mobiles']));
  368 + $config['filter_names'] = array_unique(array_merge($fb_config['filter_names'],$config['filter_names']));
  369 +
356 //过滤内容 370 //过滤内容
357 if(!empty($data['message']) && !empty($config['filter_contents'])) { 371 if(!empty($data['message']) && !empty($config['filter_contents'])) {
358 foreach ($config['filter_contents'] as $filter_content) { 372 foreach ($config['filter_contents'] as $filter_content) {
@@ -98,7 +98,7 @@ class AdsController extends BaseController @@ -98,7 +98,7 @@ class AdsController extends BaseController
98 $item['cost'] = ReInquiryCost::getCostByAdIds($item['ad_id']); 98 $item['cost'] = ReInquiryCost::getCostByAdIds($item['ad_id']);
99 } 99 }
100 $result['relay_site_total'] = $relay_site_total; 100 $result['relay_site_total'] = $relay_site_total;
101 - $result['default_ai_param'] = ReInquiryConfig::getDefaultConfigCache(); 101 + $result['default_ai_param'] = ReInquiryConfig::getDefaultConfigCache(ReInquiryConfig::TYPE_AI_PARAM);
102 102
103 return $this->response('success', Code::SUCCESS, $result); 103 return $this->response('success', Code::SUCCESS, $result);
104 } 104 }
@@ -388,8 +388,9 @@ class AdsController extends BaseController @@ -388,8 +388,9 @@ class AdsController extends BaseController
388 * @author zbj 388 * @author zbj
389 * @date 2025/2/12 389 * @date 2025/2/12
390 */ 390 */
391 - public function fbAdsDefaultSet(){  
392 - $config = ReInquiryConfig::get(); 391 + public function fbAdsDefaultSet(Request $request){
  392 + $type = $request->input('type')?: ReInquiryConfig::TYPE_AI_PARAM;
  393 + $config = ReInquiryConfig::where('type', $type)->get();
393 if($this->request->isMethod('get')){ 394 if($this->request->isMethod('get')){
394 return $this->response('success', Code::SUCCESS, $config); 395 return $this->response('success', Code::SUCCESS, $config);
395 } 396 }
@@ -397,7 +398,7 @@ class AdsController extends BaseController @@ -397,7 +398,7 @@ class AdsController extends BaseController
397 DB::beginTransaction(); 398 DB::beginTransaction();
398 try { 399 try {
399 foreach ($config as $item){ 400 foreach ($config as $item){
400 - if(empty($this->param[$item->key])){ 401 + if($type == ReInquiryConfig::TYPE_AI_PARAM && empty($this->param[$item->key])){
401 throw new \Exception($item->title . '不能为空!'); 402 throw new \Exception($item->title . '不能为空!');
402 } 403 }
403 $item->content = $this->param[$item->key]; 404 $item->content = $this->param[$item->key];
@@ -418,7 +419,7 @@ class AdsController extends BaseController @@ -418,7 +419,7 @@ class AdsController extends BaseController
418 * @date 2025/2/12 419 * @date 2025/2/12
419 */ 420 */
420 public function fbAdsSetBatch(){ 421 public function fbAdsSetBatch(){
421 - $config = ReInquiryConfig::find($this->param['id']); 422 + $config = ReInquiryConfig::where('type', ReInquiryConfig::TYPE_AI_PARAM)->where('id', $this->param['id'])->first();
422 if(!$config){ 423 if(!$config){
423 return $this->response('配置不存在', Code::USER_ERROR, []); 424 return $this->response('配置不存在', Code::USER_ERROR, []);
424 } 425 }
@@ -15,21 +15,23 @@ use Illuminate\Support\Facades\Cache; @@ -15,21 +15,23 @@ use Illuminate\Support\Facades\Cache;
15 */ 15 */
16 class ReInquiryConfig extends Base 16 class ReInquiryConfig extends Base
17 { 17 {
  18 + const TYPE_AI_PARAM = 'ai_param';
  19 + const TYPE_FILTER_WORDS = 'filter_words';
18 20
19 //设置关联表名 21 //设置关联表名
20 protected $table = 'gl_re_inquiry_config'; 22 protected $table = 'gl_re_inquiry_config';
21 23
22 24
23 - public static function getDefaultConfigCache(){ 25 + public static function getDefaultConfigCache($type){
24 $cache_key = 'ReInquiryDefaultConfigCache'; 26 $cache_key = 'ReInquiryDefaultConfigCache';
25 $data = Cache::get($cache_key); 27 $data = Cache::get($cache_key);
26 if(!$data){ 28 if(!$data){
27 - $data = self::pluck('content', 'key'); 29 + $data = self::all();
28 if($data){ 30 if($data){
29 Cache::put($cache_key, $data); 31 Cache::put($cache_key, $data);
30 } 32 }
31 } 33 }
32 - return $data; 34 + return $data->where('type', $type)->pluck('content', 'key');
33 } 35 }
34 36
35 public static function delCache(){ 37 public static function delCache(){
@@ -92,6 +92,6 @@ class ReInquiryTask extends Base @@ -92,6 +92,6 @@ class ReInquiryTask extends Base
92 92
93 public function getAiParamAttribute($value) 93 public function getAiParamAttribute($value)
94 { 94 {
95 - return Arr::s2a($value) ?: ReInquiryConfig::getDefaultConfigCache(); 95 + return Arr::s2a($value) ?: ReInquiryConfig::getDefaultConfigCache(ReInquiryConfig::TYPE_AI_PARAM);
96 } 96 }
97 } 97 }