|
...
|
...
|
@@ -12,6 +12,7 @@ use App\Helper\Gpt; |
|
|
|
use App\Helper\Translate;
|
|
|
|
use App\Helper\Validate;
|
|
|
|
use App\Models\Ai\AiCommand;
|
|
|
|
use App\Models\Inquiry\InquiryRelayDetailLog;
|
|
|
|
use App\Models\Inquiry\ReInquiryConfig;
|
|
|
|
use App\Models\Inquiry\ReInquiryDetail;
|
|
|
|
use App\Models\Inquiry\ReInquiryDetailLog;
|
|
...
|
...
|
@@ -24,6 +25,7 @@ use App\Models\WebSetting\WebLanguage; |
|
|
|
use GuzzleHttp\Exception\ConnectException;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
...
|
...
|
@@ -433,7 +435,12 @@ class RelayInquiry extends Command |
|
|
|
}
|
|
|
|
//是否有必选的渠道 渠道有一个及以上必选 就在组内随机一个
|
|
|
|
$require_agent_group = [];
|
|
|
|
foreach ($task['target'] as $item) {
|
|
|
|
foreach ($task['target'] as $k=>$item) {
|
|
|
|
//没有广告费的 按频率来 x天一封 发过了先踢掉 优先级高于必选
|
|
|
|
if(!$this->checkFrequency($item)){
|
|
|
|
unset($item[$k]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!empty($item['is_require'])) {
|
|
|
|
$require_agent_group[] = $item['agent_group'];
|
|
|
|
}
|
|
...
|
...
|
@@ -517,7 +524,7 @@ class RelayInquiry extends Command |
|
|
|
|
|
|
|
$pre = 0;
|
|
|
|
$start_time = time();
|
|
|
|
$seconds = $this->delay_seconds($form->inquiry_date);
|
|
|
|
$seconds = $this->delay_seconds($form->inquiry_date, $domain, $task);
|
|
|
|
$email = '';
|
|
|
|
if($is_inquiry) {
|
|
|
|
$exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
|
|
...
|
...
|
@@ -547,6 +554,31 @@ class RelayInquiry extends Command |
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkFrequency($item)
|
|
|
|
{
|
|
|
|
//设置了频率的
|
|
|
|
if (!empty($item['frequency'])) {
|
|
|
|
$item['is_ad_fee'] = 0; //v5都没有
|
|
|
|
if($item['is_v6']){
|
|
|
|
$project = Project::getProjectByDomain($item['url']);
|
|
|
|
if($project && $project->deploy_build){
|
|
|
|
$item['is_ad_fee'] = $project->deploy_build->ads_price ? 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//没有广告费 是否X天内发送过
|
|
|
|
if(!$item['is_ad_fee']){
|
|
|
|
$inquiry_log = InquiryRelayDetailLog::where('type', InquiryRelayDetailLog::TYPE_INQUIRY)
|
|
|
|
->where('start_at', '>', date('Y-m-d H:i:s', strtotime('- ' . $item['frequency'] . ' day')))
|
|
|
|
->first();
|
|
|
|
if($inquiry_log){
|
|
|
|
$this->output('频率限制');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function relayShopDetail($task, $form)
|
|
|
|
{
|
|
|
|
$this->output('获取商城转发对象');
|
|
...
|
...
|
@@ -580,7 +612,7 @@ class RelayInquiry extends Command |
|
|
|
$referrer = $this->getReferer($country_name, $lang);
|
|
|
|
|
|
|
|
$start_time = time();
|
|
|
|
$seconds = $this->delay_seconds($form->inquiry_date);
|
|
|
|
$seconds = $this->delay_seconds($form->inquiry_date, $domain, $task);
|
|
|
|
$exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
|
|
|
|
if($exists){
|
|
|
|
$this->output('转发站点邮件已存在');
|
|
...
|
...
|
@@ -616,7 +648,7 @@ class RelayInquiry extends Command |
|
|
|
$user_agent = $form->email ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
|
|
|
|
|
|
|
|
$start_time = time();
|
|
|
|
$seconds = $this->delay_seconds($form->inquiry_date);
|
|
|
|
$seconds = $this->delay_seconds($form->inquiry_date, $postid, $task);
|
|
|
|
$exists = ReInquiryDetail::where('re_website', $postid)->where('email', $form->email)->first();
|
|
|
|
if($exists){
|
|
|
|
$this->output('转发站点邮件已存在');
|
|
...
|
...
|
@@ -945,8 +977,36 @@ class RelayInquiry extends Command |
|
|
|
* @author zbj
|
|
|
|
* @date 2025/7/16
|
|
|
|
*/
|
|
|
|
public function delay_seconds($inquiry_date)
|
|
|
|
public function delay_seconds($inquiry_date, $domain, $task)
|
|
|
|
{
|
|
|
|
$inquiry_date = Carbon::make($inquiry_date);
|
|
|
|
//当天的
|
|
|
|
if($inquiry_date->isToday()){
|
|
|
|
//广告投放日(周一、二、三) 第一封询盘100%及时推送
|
|
|
|
$is_first = false;
|
|
|
|
if(in_array($inquiry_date->weekday(), [1,2,3])) {
|
|
|
|
//是否今天的第一封询盘
|
|
|
|
$detail = ReInquiryDetail::where('re_website', $domain)->where('start_at', '>=', $inquiry_date->startOfDay()->toDatetimeString())->first();
|
|
|
|
if(!$detail){
|
|
|
|
$is_first = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//非广告投放日第一封询盘
|
|
|
|
if(!$is_first && $task->second_push_rate != 100){
|
|
|
|
//按概率
|
|
|
|
$res = $this->get_rand([$task->second_push_rate, 100 - $task->second_push_rate]);
|
|
|
|
if($res == 1){
|
|
|
|
$this->output('非广告投放日第一封询盘 概率' . (100 - $task->second_push_rate) . '%延迟推送');
|
|
|
|
//随机分配到未投放广告日期
|
|
|
|
$now = Carbon::now();
|
|
|
|
// 随机开始时间(本周四或现在)
|
|
|
|
$startTime = max($now->timestamp, $now->startOfWeek(4)->timestamp);
|
|
|
|
|
|
|
|
$random = mt_rand($startTime, $now->endOfWeek()->timestamp);
|
|
|
|
return $random - $now->timestamp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$seconds = rand(300, 2 * 3600); // 默认 从5分钟-2小时后开始
|
|
|
|
$time_diff = time() - strtotime($inquiry_date); //2小时前-24小时内的 当天发完
|
|
|
|
if ($time_diff > 2 * 3600 && $time_diff <= 24 * 3600) {
|
...
|
...
|
|