|
@@ -12,6 +12,7 @@ use App\Helper\Gpt; |
|
@@ -12,6 +12,7 @@ use App\Helper\Gpt; |
|
12
|
use App\Helper\Translate;
|
12
|
use App\Helper\Translate;
|
|
13
|
use App\Helper\Validate;
|
13
|
use App\Helper\Validate;
|
|
14
|
use App\Models\Ai\AiCommand;
|
14
|
use App\Models\Ai\AiCommand;
|
|
|
|
15
|
+use App\Models\Inquiry\InquiryRelayDetailLog;
|
|
15
|
use App\Models\Inquiry\ReInquiryConfig;
|
16
|
use App\Models\Inquiry\ReInquiryConfig;
|
|
16
|
use App\Models\Inquiry\ReInquiryDetail;
|
17
|
use App\Models\Inquiry\ReInquiryDetail;
|
|
17
|
use App\Models\Inquiry\ReInquiryDetailLog;
|
18
|
use App\Models\Inquiry\ReInquiryDetailLog;
|
|
@@ -24,6 +25,7 @@ use App\Models\WebSetting\WebLanguage; |
|
@@ -24,6 +25,7 @@ use App\Models\WebSetting\WebLanguage; |
|
24
|
use GuzzleHttp\Exception\ConnectException;
|
25
|
use GuzzleHttp\Exception\ConnectException;
|
|
25
|
use Illuminate\Console\Command;
|
26
|
use Illuminate\Console\Command;
|
|
26
|
use Illuminate\Support\Arr;
|
27
|
use Illuminate\Support\Arr;
|
|
|
|
28
|
+use Illuminate\Support\Carbon;
|
|
27
|
use Illuminate\Support\Facades\Cache;
|
29
|
use Illuminate\Support\Facades\Cache;
|
|
28
|
use Illuminate\Support\Facades\DB;
|
30
|
use Illuminate\Support\Facades\DB;
|
|
29
|
use Illuminate\Support\Facades\Http;
|
31
|
use Illuminate\Support\Facades\Http;
|
|
@@ -433,7 +435,12 @@ class RelayInquiry extends Command |
|
@@ -433,7 +435,12 @@ class RelayInquiry extends Command |
|
433
|
}
|
435
|
}
|
|
434
|
//是否有必选的渠道 渠道有一个及以上必选 就在组内随机一个
|
436
|
//是否有必选的渠道 渠道有一个及以上必选 就在组内随机一个
|
|
435
|
$require_agent_group = [];
|
437
|
$require_agent_group = [];
|
|
436
|
- foreach ($task['target'] as $item) {
|
438
|
+ foreach ($task['target'] as $k=>$item) {
|
|
|
|
439
|
+ //没有广告费的 按频率来 x天一封 发过了先踢掉 优先级高于必选
|
|
|
|
440
|
+ if(!$this->checkFrequency($item)){
|
|
|
|
441
|
+ unset($item[$k]);
|
|
|
|
442
|
+ continue;
|
|
|
|
443
|
+ }
|
|
437
|
if (!empty($item['is_require'])) {
|
444
|
if (!empty($item['is_require'])) {
|
|
438
|
$require_agent_group[] = $item['agent_group'];
|
445
|
$require_agent_group[] = $item['agent_group'];
|
|
439
|
}
|
446
|
}
|
|
@@ -517,7 +524,7 @@ class RelayInquiry extends Command |
|
@@ -517,7 +524,7 @@ class RelayInquiry extends Command |
|
517
|
|
524
|
|
|
518
|
$pre = 0;
|
525
|
$pre = 0;
|
|
519
|
$start_time = time();
|
526
|
$start_time = time();
|
|
520
|
- $seconds = $this->delay_seconds($form->inquiry_date);
|
527
|
+ $seconds = $this->delay_seconds($form->inquiry_date, $domain, $task);
|
|
521
|
$email = '';
|
528
|
$email = '';
|
|
522
|
if($is_inquiry) {
|
529
|
if($is_inquiry) {
|
|
523
|
$exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
|
530
|
$exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
|
|
@@ -547,6 +554,31 @@ class RelayInquiry extends Command |
|
@@ -547,6 +554,31 @@ class RelayInquiry extends Command |
|
547
|
return true;
|
554
|
return true;
|
|
548
|
}
|
555
|
}
|
|
549
|
|
556
|
|
|
|
|
557
|
+ public function checkFrequency($item)
|
|
|
|
558
|
+ {
|
|
|
|
559
|
+ //设置了频率的
|
|
|
|
560
|
+ if (!empty($item['frequency'])) {
|
|
|
|
561
|
+ $item['is_ad_fee'] = 0; //v5都没有
|
|
|
|
562
|
+ if($item['is_v6']){
|
|
|
|
563
|
+ $project = Project::getProjectByDomain($item['url']);
|
|
|
|
564
|
+ if($project && $project->deploy_build){
|
|
|
|
565
|
+ $item['is_ad_fee'] = $project->deploy_build->ads_price ? 1 : 0;
|
|
|
|
566
|
+ }
|
|
|
|
567
|
+ }
|
|
|
|
568
|
+ //没有广告费 是否X天内发送过
|
|
|
|
569
|
+ if(!$item['is_ad_fee']){
|
|
|
|
570
|
+ $inquiry_log = InquiryRelayDetailLog::where('type', InquiryRelayDetailLog::TYPE_INQUIRY)
|
|
|
|
571
|
+ ->where('start_at', '>', date('Y-m-d H:i:s', strtotime('- ' . $item['frequency'] . ' day')))
|
|
|
|
572
|
+ ->first();
|
|
|
|
573
|
+ if($inquiry_log){
|
|
|
|
574
|
+ $this->output('频率限制');
|
|
|
|
575
|
+ return false;
|
|
|
|
576
|
+ }
|
|
|
|
577
|
+ }
|
|
|
|
578
|
+ }
|
|
|
|
579
|
+ return true;
|
|
|
|
580
|
+ }
|
|
|
|
581
|
+
|
|
550
|
public function relayShopDetail($task, $form)
|
582
|
public function relayShopDetail($task, $form)
|
|
551
|
{
|
583
|
{
|
|
552
|
$this->output('获取商城转发对象');
|
584
|
$this->output('获取商城转发对象');
|
|
@@ -580,7 +612,7 @@ class RelayInquiry extends Command |
|
@@ -580,7 +612,7 @@ class RelayInquiry extends Command |
|
580
|
$referrer = $this->getReferer($country_name, $lang);
|
612
|
$referrer = $this->getReferer($country_name, $lang);
|
|
581
|
|
613
|
|
|
582
|
$start_time = time();
|
614
|
$start_time = time();
|
|
583
|
- $seconds = $this->delay_seconds($form->inquiry_date);
|
615
|
+ $seconds = $this->delay_seconds($form->inquiry_date, $domain, $task);
|
|
584
|
$exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
|
616
|
$exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
|
|
585
|
if($exists){
|
617
|
if($exists){
|
|
586
|
$this->output('转发站点邮件已存在');
|
618
|
$this->output('转发站点邮件已存在');
|
|
@@ -616,7 +648,7 @@ class RelayInquiry extends Command |
|
@@ -616,7 +648,7 @@ class RelayInquiry extends Command |
|
616
|
$user_agent = $form->email ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
|
648
|
$user_agent = $form->email ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
|
|
617
|
|
649
|
|
|
618
|
$start_time = time();
|
650
|
$start_time = time();
|
|
619
|
- $seconds = $this->delay_seconds($form->inquiry_date);
|
651
|
+ $seconds = $this->delay_seconds($form->inquiry_date, $postid, $task);
|
|
620
|
$exists = ReInquiryDetail::where('re_website', $postid)->where('email', $form->email)->first();
|
652
|
$exists = ReInquiryDetail::where('re_website', $postid)->where('email', $form->email)->first();
|
|
621
|
if($exists){
|
653
|
if($exists){
|
|
622
|
$this->output('转发站点邮件已存在');
|
654
|
$this->output('转发站点邮件已存在');
|
|
@@ -945,8 +977,36 @@ class RelayInquiry extends Command |
|
@@ -945,8 +977,36 @@ class RelayInquiry extends Command |
|
945
|
* @author zbj
|
977
|
* @author zbj
|
|
946
|
* @date 2025/7/16
|
978
|
* @date 2025/7/16
|
|
947
|
*/
|
979
|
*/
|
|
948
|
- public function delay_seconds($inquiry_date)
|
980
|
+ public function delay_seconds($inquiry_date, $domain, $task)
|
|
949
|
{
|
981
|
{
|
|
|
|
982
|
+ $inquiry_date = Carbon::make($inquiry_date);
|
|
|
|
983
|
+ //当天的
|
|
|
|
984
|
+ if($inquiry_date->isToday()){
|
|
|
|
985
|
+ //广告投放日(周一、二、三) 第一封询盘100%及时推送
|
|
|
|
986
|
+ $is_first = false;
|
|
|
|
987
|
+ if(in_array($inquiry_date->weekday(), [1,2,3])) {
|
|
|
|
988
|
+ //是否今天的第一封询盘
|
|
|
|
989
|
+ $detail = ReInquiryDetail::where('re_website', $domain)->where('start_at', '>=', $inquiry_date->startOfDay()->toDatetimeString())->first();
|
|
|
|
990
|
+ if(!$detail){
|
|
|
|
991
|
+ $is_first = true;
|
|
|
|
992
|
+ }
|
|
|
|
993
|
+ }
|
|
|
|
994
|
+ //非广告投放日第一封询盘
|
|
|
|
995
|
+ if(!$is_first && $task->second_push_rate != 100){
|
|
|
|
996
|
+ //按概率
|
|
|
|
997
|
+ $res = $this->get_rand([$task->second_push_rate, 100 - $task->second_push_rate]);
|
|
|
|
998
|
+ if($res == 1){
|
|
|
|
999
|
+ $this->output('非广告投放日第一封询盘 概率' . (100 - $task->second_push_rate) . '%延迟推送');
|
|
|
|
1000
|
+ //随机分配到未投放广告日期
|
|
|
|
1001
|
+ $now = Carbon::now();
|
|
|
|
1002
|
+ // 随机开始时间(本周四或现在)
|
|
|
|
1003
|
+ $startTime = max($now->timestamp, $now->startOfWeek(4)->timestamp);
|
|
|
|
1004
|
+
|
|
|
|
1005
|
+ $random = mt_rand($startTime, $now->endOfWeek()->timestamp);
|
|
|
|
1006
|
+ return $random - $now->timestamp;
|
|
|
|
1007
|
+ }
|
|
|
|
1008
|
+ }
|
|
|
|
1009
|
+ }
|
|
950
|
$seconds = rand(300, 2 * 3600); // 默认 从5分钟-2小时后开始
|
1010
|
$seconds = rand(300, 2 * 3600); // 默认 从5分钟-2小时后开始
|
|
951
|
$time_diff = time() - strtotime($inquiry_date); //2小时前-24小时内的 当天发完
|
1011
|
$time_diff = time() - strtotime($inquiry_date); //2小时前-24小时内的 当天发完
|
|
952
|
if ($time_diff > 2 * 3600 && $time_diff <= 24 * 3600) {
|
1012
|
if ($time_diff > 2 * 3600 && $time_diff <= 24 * 3600) {
|