作者 赵彬吉
... ... @@ -47,6 +47,27 @@ class PostInquiryForward extends Command
parent::__construct();
}
/**
* 芯片网站
* @var array
*/
protected $xp_websites = [
'www.shinecomponents.com',
'www.hk-allchips.com',
'www.xinjiada-ic.com',
'www.sic-components.com',
'www.chip1-vip.com',
'www.flash-turtle.com',
'www.xinteerchip.com',
'www.conevoelec.com'
];
/**
* 5.0询盘转发到自己站点的网站
* @var array
*/
protected $self_websites = [205570, 64532, 150535, 292114, 124579, 237114, 194809, 278184, 166223, 366238, 277923, 297045, 309218, 75191, 57616];
public function handle()
{
... ... @@ -129,21 +150,23 @@ class PostInquiryForward extends Command
'referrer_url' => $detail['referrer'],
'user_agent' => $detail['user_agent'],
];
$res = Http::withoutVerifying()->timeout(30)->post($website . 'api/traffic_visit/', $data)->json();
$url = $website . 'api/traffic_visit/';
$res = Http::withoutVerifying()->timeout(30)->post($url, $data)->json();
if (empty($res['status']) || $res['status'] != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward visit error', [$res, $website . 'api/traffic_visit/', $data]);
Log::channel('inquiry_forward')->error('post_inquiry_forward visit error', [$res, $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward visit success', [$res, $url, $data]);
} else {
//v4 v5分离项目 往测试链接推
$project_info = InquiryProject::select(['is_split', 'test_domain'])->where('domain', 'like', '%' . $detail['website'] . '%')->first();
if (!$project_info) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = '获取域名对应项目失败';
$log->remark = '获取分离项目测试域名失败';
$log->save();
return false;
... ... @@ -161,16 +184,19 @@ class PostInquiryForward extends Command
'user_agent' => $detail['user_agent'],
"ip" => $detail['ip'],
];
$res = Http::get($website . 'wp-admin/admin-ajax.php', $data);
$url = $website . 'wp-admin/admin-ajax.php';
$res = Http::withoutVerifying()->timeout(30)->get($url, $data);
$status = $res->status();
if ($status != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res->body() ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 visit error', [$res->body(), $website . 'wp-admin/admin-ajax.php', $data]);
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 visit error', [$res->body(), $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 visit success', [$res->body(), $url, $data]);
}
$log->status = InquiryRelayDetailLog::STATUS_SUCCESS;
$log->save();
... ... @@ -179,11 +205,17 @@ class PostInquiryForward extends Command
public function inquiry(InquiryRelayDetail $detail, InquiryRelayDetailLog $log)
{
// v6
if ($detail['is_v6']) {
$res = $this->v6Inquiry($detail, $log);
if (in_array($detail['website'], $this->xp_websites)) {
// 芯片网站
$res = $this->xpInquiry($detail, $log);
} else {
$res = $this->v5Inquiry($detail, $log);
if ($detail['is_v6']) {
// v6
$res = $this->v6Inquiry($detail, $log);
} else {
// v5
$res = $this->v5Inquiry($detail, $log);
}
}
if (!$res) {
... ... @@ -196,6 +228,47 @@ class PostInquiryForward extends Command
return true;
}
public function xpInquiry($detail, $log)
{
$data = [
'refer' => $log['url'],
'contact_name' => $detail['name'],
'email' => $detail['email'],
'tel' => $detail['phone'],
'ip' => $detail['ip'],
'remark' => $detail['message'],
'submit_time' => date('Y-m-d H:i:s', time() + 20),
];
$url = 'https://' . $detail['website'] . '/api/store/webmail?flag=opencart';
$post_data = json_encode($data);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36');
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($post_data)));
$curl_response = curl_exec($curl);
curl_close($curl);
$res = json_decode($curl_response, true);
if (empty($res['code']) || $res['code'] != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['msg'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward xp inquiry error', [$res, $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward xp inquiry success', [$res, $url, $data]);
return false;
}
public function v6Inquiry($detail, $log)
{
$website = 'https://' . $detail['website'] . '/';
... ... @@ -211,45 +284,70 @@ class PostInquiryForward extends Command
} else {
$data['__amp_source_origin'] = trim($website, '/');
}
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd?source=5', $data)->json();
$url = $website . 'api/inquiryQd?source=5';
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json();
if (empty($res['code']) || $res['code'] != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward v6 inquiry error', [$res, $website . 'api/inquiryQd/', $data]);
Log::channel('inquiry_forward')->error('post_inquiry_forward v6 inquiry error', [$res, $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward v6 inquiry success', [$res, $url, $data]);
return true;
}
public function v5Inquiry($detail, $log)
{
$data = [
'name' => $detail['name'],
'phone' => $detail['phone'],
'message' => $detail['message'],
'email' => $detail['email'],
'ip' => $detail['ip'],
'token' => md5($log['url'] . $detail['name'] . $detail['ip'] . date("Y-m-d")),
'refer' => $log['url'],
'submit_time' => date('Y-m-d H:i:s'),
'source' => 5,
];
$result = Http::withoutVerifying()->timeout(30)->post('https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f', $data);
$res['data'][0]['status'] = 'success';
//兼容接口返回格式
if (!empty($res['data'][0]['status'])) {
$res['data'][0]['code'] = $res['data'][0]['status'] == 'success' ? 200 : 400;
!empty($res['data'][0]['msg']) && $res['message'] = $res['data'][0]['msg'];
}
if (empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200, 300])) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
$project_id = InquiryProject::where('version', '<', 6)->where('domain', 'like', '%' . $detail['website'] . '%')->value('primary_id') ?? 0;
if (in_array($project_id, $this->self_websites)) {
//发送到自己站点项目
$data = [
'Name' => $detail['name'],
'Phone' => $detail['phone'],
'Message' => $detail['message'],
'Email' => $detail['email'],
'submit_ip' => $detail['ip'],
'refer' => $log['url'],
'submit_time' => date('Y-m-d H:i:s', time() + 60)
];
$url = 'https://' . $detail['website'] . '/wp-admin/admin-ajax.php?action=live_remort_receive';
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data);
$status = $res->status();
if ($status != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res->body() ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 inquiry error', [$result->body(), 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f', $data]);
return false;
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 inquiry error', [$res->body(), $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 inquiry success', [$res->body(), $url, $data]);
} else {
$data = [
'name' => $detail['name'],
'phone' => $detail['phone'],
'message' => $detail['message'],
'email' => $detail['email'],
'ip' => $detail['ip'],
'token' => md5($log['url'] . $detail['name'] . $detail['ip'] . date("Y-m-d")),
'refer' => $log['url'],
'submit_time' => date('Y-m-d H:i:s'),
'source' => 5,
];
$url = 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f';
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json();
if (empty($res['status']) || $res['status'] != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 inquiry error', [$res, $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 inquiry success', [$res, $url, $data]);
}
return true;
}
... ...
... ... @@ -153,6 +153,20 @@ class RelayInquiryForward extends Command
protected $otherzb = [700, 300]; //模拟访问来源占比 (非美国) google.com|google.其他后缀
/**
* 芯片网站
* @var array
*/
protected $xp_websites = [
'www.shinecomponents.com',
'www.hk-allchips.com',
'www.xinjiada-ic.com',
'www.sic-components.com',
'www.chip1-vip.com',
'www.flash-turtle.com',
'www.xinteerchip.com',
'www.conevoelec.com'
];
public function handle()
{
... ... @@ -207,9 +221,14 @@ class RelayInquiryForward extends Command
public function completeDetail($inquiry_detail)
{
//visit urls
$visit_urls = $this->getUrls($inquiry_detail['is_v6'], $inquiry_detail['website'], $inquiry_detail['email']);
$inquiry_url = json_decode($inquiry_detail['urls'], true);
$urls = array_merge($visit_urls, $inquiry_url);
if (in_array($inquiry_detail['website'], $this->xp_websites)) {
//芯片网站无需模拟访问,直接发送询盘
$urls = $inquiry_url;
} else {
$visit_urls = $this->getUrls($inquiry_detail['is_v6'], $inquiry_detail['website'], $inquiry_detail['email']);
$urls = array_merge($visit_urls, $inquiry_url);
}
//lang
if (is_numeric($inquiry_detail['message'])) { //数字会被识别为中文
... ... @@ -303,8 +322,8 @@ class RelayInquiryForward extends Command
$all_urls = array_merge($urls, $product_url, $product_cate_url, $keywords_url, $page_url);
if (count($all_urls) > 1) {
// 随机访问1-6个页面
$deep = rand(1, 6);
// 随机访问1-5个页面
$deep = rand(1, 5);
$visit_urls = Arr::random($all_urls, $deep > count($all_urls) ? count($all_urls) : $deep);
$urls = array_merge($urls, $visit_urls);
}
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Console\Commands\Inquiry;
use App\Helper\Translate;
use App\Helper\Validate;
use App\Models\Inquiry\InquiryInfo;
use App\Services\InquiryRelayService;
use Illuminate\Console\Command;
... ... @@ -43,7 +44,9 @@ class SyncInquiryRelay extends Command
public function handle()
{
$this->output('开始同步表单系统询盘');
$this->getInquiryForm();
$this->output('开始同步asp采集询盘');
$this->getInquirySzcm();
}
... ... @@ -62,6 +65,9 @@ class SyncInquiryRelay extends Command
//+86区号过滤
continue;
}
if (strpos($item['refer'], 'findsupply.com') !== false) {
$item['source_type'] = InquiryInfo::TYPE_FIND_SUPPLY;
}
$this->saveDate($item, $item['source_type']);
}
}
... ... @@ -162,7 +168,20 @@ class SyncInquiryRelay extends Command
$data['image'] = '';
}
$model->createInquiry($data['name'], $data['phone'], $data['email'], $data['ip'], $country, $data['message'], $message_cn, $type, $data['time'], $data['refer'], $data['title'], $keywords, $message_sign, $data['origin_key'], $data['image']);
//判断手机和邮箱是否有效
$email_status = 0;
if ($data['email']) {
$check_email = Validate::email($data['email']);
$email_status = $check_email ? 1 : 0;
}
$phone_status = 0;
if ($data['phone']) {
$num_phone = preg_replace('/\D/', '', $data['phone']) ?? ''; // \D 匹配所有非数字字符
$check_phone = Validate::phone($num_phone);
$phone_status = $check_phone ? 1 : 0;
}
$model->createInquiry($data['name'], $data['phone'], $data['email'], $data['ip'], $country, $data['message'], $message_cn, $type, $data['time'], $data['refer'], $data['title'], $keywords, $message_sign, $data['origin_key'], $data['image'], $email_status, $phone_status);
return true;
}
... ... @@ -184,4 +203,9 @@ class SyncInquiryRelay extends Command
}
return $ip;
}
public function output($message)
{
echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
}
}
... ...
... ... @@ -209,6 +209,7 @@ class DownloadProject extends Command
// }
public function workChatMessage($data,$project_id){
$data['main_lang_id'] = 8;
$arr = [];
$content = '';
$content1 = '';
... ... @@ -223,10 +224,12 @@ class DownloadProject extends Command
$data['inquiry_country'] = array_slice($data['inquiry_country'], 0, 4, true);
$country = '';
foreach ($data['inquiry_country'] as $k => $v){
$country .= $k.'';
$country .= $k.',';
};
$country = trim($country,'、');
$content1 .= '询盘主要来源于'.$country.'等国家地区';
$country = trim($country,',');
if(!empty($country)){
$content1 .= '询盘主要来源于'.$country.'等国家地区';
}
}
$content1 .= '如有高质量客户,请您密切关注与跟进;';
}
... ... @@ -236,14 +239,27 @@ class DownloadProject extends Command
$content2 = '';
if(!empty($data['google_indexed_num']) || !empty($data['google_links_num']) || !empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num']) || !empty($data['daily_average_num'])){
$content2 .= '项目截止目前';
if($data['main_lang_id'] == 8){
$title = 'Yandex';
}else{
$title = '谷歌';
}
if(!empty($data['google_indexed_num'])){
$content2 .= '谷歌收录量:'.$data['google_indexed_num'].'条,';
$content2 .= $title.'收录量:'.$data['google_indexed_num'].'条,';
}
if(!empty($data['google_links_num'])){
$content2 .= '外链量:'.$data['google_links_num'].'条,';
//获取上一次的外链数
$latestRecord = V6WeeklyReport::where(['project_id'=>$project_id])->orderBy('id', 'desc')->first();
if(!empty($latestRecord)){
if($latestRecord['google_links_num'] != $data['google_links_num']){
$content2 .= '外链量:'.$data['google_links_num'].'条,';
}
}else{
$content2 .= '外链量:'.$data['google_links_num'].'条,';
}
}
if(!empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num'])){
$content2 .= '谷歌搜索排名';
$content2 .= $title.'搜索排名';
if(!empty($data['keyword_home_num'])){
$content2 .= '首页关键词数量为:'.$data['keyword_home_num'].'个,';
}
... ... @@ -285,10 +301,12 @@ class DownloadProject extends Command
$content3 .= '新闻:'.$data['week_news_num'].'条。';
}
}
$content3 .= '全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';
}
$content3 .= '全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';
$arr[] = $content3;
$content4 = '本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。';
if(!empty($content3)){
$arr[] = $content3;
}
$content4 = '';
if(!empty($data['main_update_num'])){
$content4 .= '网站加载速度维护及主站页面更新'.$data['main_update_num'].'次。';
}
... ... @@ -304,17 +322,29 @@ class DownloadProject extends Command
if(!empty($data['aggregation_minor_update_num'])){
$content4 .= '聚合页小语种站页面'.$data['aggregation_minor_update_num'].'次。';
}
$arr[] = $content4;
if(!empty($content4)){
$content4 = '本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。'.$content4;
}
if(!empty($content4)){
$arr[] = $content4;
}
if(empty($arr)){
return true;
}
foreach ($arr as $key => $val){
$content .= ($key+1).','.$val."\n";
$content .= ($key+1).','.$val.PHP_EOL;
}
$timestamp = strtotime('tomorrow 9:00 AM');
$tomorrowNineAM = date('Y-m-d H:i:s', $timestamp);
if(empty($content)){
return true;
}
$tips = 'Tips:'.PHP_EOL.'1、全球搜V6.0系统提供网页TDK、H标签、Img标签等用户自定义编辑接口且辅以AI创作工具,用户可进一步对相关优化设置进行精细化优化与调整;'.PHP_EOL.'2、全球搜V6.0系统提供小语种页面精准校对翻译功能,用户可进一步对已翻译小语种页面进行人工翻译校对;'.PHP_EOL.'3、全球搜V6.0系统支持绑定Facebook、LinkedIn、X(原Twitter)等社媒账号,可一键同步转发网站上发布的产品和新闻至社媒账号动态,建议用户用起来哦;'.PHP_EOL.'4、如用户有较丰富的企业、产品、服务相关视频素材,全球搜建议用户及时创建YouTube主页,并在YouTube和网站相关网页上同步发布视频;';
$param = [
'project_id'=>$project_id,
'friend_id'=>17667,
'type'=>MessagePush::TYPE_WEEK,
'content'=>"【全球搜V6.0周报】--项目id:$project_id"."\n".$content,
'content'=>"【全球搜V6.0周报】--项目id:$project_id".PHP_EOL.$content.PHP_EOL.$tips,
'ref_ids'=>'',
'send_time'=>$tomorrowNineAM,
'status'=>0,
... ... @@ -323,5 +353,6 @@ class DownloadProject extends Command
$messagePushModel = new MessagePush();
$messagePushModel->add($param);
echo date('Y-m-d H:i:s') . '数据:'. $content . PHP_EOL;
return true;
}
}
... ...
... ... @@ -13,6 +13,8 @@ use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\CustomModule\CustomModuleExtentContent;
use App\Models\News\News;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Models\Template\Template;
... ... @@ -36,7 +38,7 @@ class LyhImportTest extends Command
*/
protected $description = '导入数据';
public $data = '';
/**
* @remark :统一更新路由
... ... @@ -46,15 +48,87 @@ class LyhImportTest extends Command
* @time :2023/11/20 15:13
*/
public function handle(){
ProjectServer::useProject(2385);
ProjectServer::useProject(3283);
echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
// $this->importCustomModule($this->data);
$this->newsImportCustom();
$this->importProduct('https://ecdn6.globalso.com/upload/p/1/file/2025-03/zy_boss_price_copy1.csv',3283);
DB::disconnect('custom_mysql');
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :导入分类
* @name :importProductCategory
* @author :lyh
* @method :post
* @time :2025/3/3 15:59
*/
public function importProduct($url,$project_id){
$line_of_text = [];
$opts = [
'http' => [
'method' => 'GET',
'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
],
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false
]
];
$file_handle = fopen($url, 'r', null, stream_context_create($opts));
while (!feof($file_handle)) {
$line_of_text[] = fgetcsv($file_handle, 0, ',');
}
fclose($file_handle);
$cateModel = new Category();
$productModel = new Product();
foreach ($line_of_text as $k => $val){
if($k < 2){
continue;
}
$saveData = [];
if($val[1] ?? ''){
$saveData['title'] = $val[1];
}else{
continue;
}
if($val[0] ?? ''){
$cateInfo = $cateModel->read(['seo_title'=>trim($val[0])]);
if($cateInfo !== false){
$saveData['category_id'] = $cateInfo['id'];
}
}
$saveData['intro'] = $val[2];
$saveData['content'] = $val[3];
$seo = ['seo_title'=>$val[5]];
$saveData['seo_mate'] = json_encode($seo,true);
$thumb = ['alt'=>'主图','url'=>str_replace('/public','',$val[6])];
$gallery = [['alt'=>'主图','url'=>str_replace('/public','',$val[6])]];
$saveData['thumb'] = json_encode($thumb,true);
$saveData['gallery'] = json_encode($gallery,true);
}
}
public function handleCatePid(){
$cateModel = new Category();
$list = $cateModel->list([],'id',['*'],'asc');
foreach ($list as $k => $v){
if($v['seo_des'] == 0){
$pid = 0;
}else{
$info = $cateModel->read(['seo_title'=>$v['seo_des']],['id']);
if($info !== false){
$pid = $info['id'];
}else{
$pid = 0;
}
}
//更新pid
$cateModel->edit(['pid'=>$pid],['id'=>$v['id']]);
}
return true;
}
/**
* @remark :导入扩展模块数据
* @name :importCustomModule
* @author :lyh
... ...
... ... @@ -206,7 +206,6 @@ class CopyProject extends Command
}
return true;
}
//复制数据库
public function copyMysql($project_id,$new_project_id){
//切换数据库配置
... ... @@ -267,7 +266,6 @@ class CopyProject extends Command
}
return true;
}
/**
* @param $message
* @return bool
... ...
... ... @@ -9,9 +9,11 @@
namespace App\Console\Commands\ProjectWeeklyReport;
use App\Helper\FormGlobalsoApi;
use App\Models\Blog\Blog;
use App\Models\Com\Notify;
use App\Models\Com\V6WeeklyReport;
use App\Models\Domain\DomainInfo;
use App\Models\HomeCount\Count;
use App\Models\News\News;
use App\Models\Product\Product;
... ... @@ -52,9 +54,16 @@ class WeekProject extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0,'type'=>['in',[1,2,3,4,6]]],'id',['id','title']);
$list = $projectModel->list(['delete_status'=>0,'type'=>['in',[1,2,3,4,6]]],'id',['id','title','is_weekly_report','main_lang_id']);
$domainModel = new DomainInfo();
foreach ($list as $k => $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
$domainInfo = $domainModel->read(['project_id'=>$v['id']]);
if($domainInfo === false){
echo date('Y-m-d H:i:s') . '域名不存在,跳过:'.$v['title'] . PHP_EOL;
continue;
}
$v['domain'] = $domainInfo['domain'];
ProjectServer::useProject($v['id']);
$this->weekData($v);
DB::disconnect('custom_mysql');
... ... @@ -74,6 +83,7 @@ class WeekProject extends Command
$data = [
'project_id'=>$value['id'],
'title'=>$value['title'],
'main_lang_id'=>$value['main_lang_id'],
];
// 上一周的开始时间(周一 00:00:00)
$startOfLastWeek = strtotime("last week monday");
... ... @@ -84,11 +94,18 @@ class WeekProject extends Command
$data['end_date'] = $endOfLastWeekFormatted = date('Y-m-d', $endOfLastWeek);
$countModel = new Count();
$startOfThisWeek = date('Y-m-d', strtotime("monday this week"));
$startOfLastWeekFormattedInfo = $countModel->read(['date'=>$startOfLastWeekFormatted,'project_id'=>$value['id']],['inquiry_num','country']);
$endOfLastWeekFormattedInfo = $countModel->read(['date'=>$startOfThisWeek,'project_id'=>$value['id']],['inquiry_num','country']);
$data['inquiry_total'] = $endOfLastWeekFormattedInfo['inquiry_num'] ?? 0;//询盘数量
$data['inquiry_country'] = $endOfLastWeekFormattedInfo['country'] ?? json_encode([]);
$data['week_inquiry_total'] = ($endOfLastWeekFormattedInfo['inquiry_num'] ?? 0) - ($startOfLastWeekFormattedInfo['inquiry_num'] ?? 0);
$data['inquiry_total'] = $endOfLastWeekFormattedInfo['inquiry_num'] ?? 0;//询盘总数量
$data['inquiry_country'] = $endOfLastWeekFormattedInfo['country'] ?? json_encode([]);//询盘国家
//获取上一周询盘数量
$result = (new FormGlobalsoApi())->getDateInquiry($value['domain'],$data['start_date'],$data['end_date']);
if(isset($result['status'])){
$data['week_inquiry_total'] = $result['data'];
echo date('Y-m-d H:i:s') . '项目id:'.$value['id'].',域名:'.$value['domain'].',上周询盘数量data:'.$result['data'] . PHP_EOL;
}else{
$data['week_inquiry_total'] = 0;
echo date('Y-m-d H:i:s') . '项目id:'.$value['id'].',域名:'.$value['domain'].',请求询盘错误。' . PHP_EOL;
}
$rankDataModel = new RankData();
$rankInfo = $rankDataModel->read(['project_id'=>$value['id'],'lang'=>''],['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num','indexed_pages_num']);
$data['google_indexed_num'] = $rankInfo['indexed_pages_num'] ?? 0;
... ... @@ -115,13 +132,15 @@ class WeekProject extends Command
//日均访问量
$data['daily_average_num'] = 0;
$pv_num_count = $countModel->where('project_id',$value['id'])->whereBetween('date', [$startOfLastWeekFormatted,$endOfLastWeekFormatted])->sum('pv_num');
echo date('Y-m-d H:i:s') . 'pv总量:'.$pv_num_count . PHP_EOL;
if($pv_num_count != 0){
$data['daily_average_num'] = round($pv_num_count / 7,2);
}
if(isset($value['is_weekly_report']) && $value['is_weekly_report'] != 0){
$this->workChatMessage($data,$value['id']);
}
$v6WeeklyReportModel = new V6WeeklyReport();
$v6WeeklyReportModel->add($data);
$this->workChatMessage($data,$value['id']);
return true;
}
... ... @@ -143,6 +162,7 @@ class WeekProject extends Command
echo date('Y-m-d H:i:s') . '没有绑定企微群:'.$project_id . PHP_EOL;
return false;
}
$content = '';
$content1 = '';
if(!empty($data['inquiry_total'])){
$content1 .= '项目共计已收到询盘 '.$data['inquiry_total'].'条,';
... ... @@ -150,15 +170,17 @@ class WeekProject extends Command
$content1 .= '本周新收 '.$data['week_inquiry_total'].' 封询盘。';
}
if(!empty($data['inquiry_country'])){
$data['inquiry_country'] = json_decode($data['inquiry_country']);
arsort($data);
$data['inquiry_country'] = array_slice($data, 0, 4, true);
$data['inquiry_country'] = json_decode($data['inquiry_country'],true);
arsort($data['inquiry_country']);
$data['inquiry_country'] = array_slice($data['inquiry_country'], 0, 4, true);
$country = '';
foreach ($data['inquiry_country'] as $k => $v){
$country .= $k.'';
$country .= $k.',';
};
$country = trim($country,'、');
$content1 .= '询盘主要来源于'.$country.'等国家地区';
$country = trim($country,',');
if(!empty($country)){
$content1 .= '询盘主要来源于'.$country.'等国家地区。';
}
}
$content1 .= '如有高质量客户,请您密切关注与跟进;';
}
... ... @@ -168,14 +190,27 @@ class WeekProject extends Command
$content2 = '';
if(!empty($data['google_indexed_num']) || !empty($data['google_links_num']) || !empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num']) || !empty($data['daily_average_num'])){
$content2 .= '项目截止目前';
if($data['main_lang_id'] == 8){
$title = 'Yandex';
}else{
$title = '谷歌';
}
if(!empty($data['google_indexed_num'])){
$content2 .= '谷歌收录量:'.$data['google_indexed_num'].'条,';
$content2 .= $title.'收录量:'.$data['google_indexed_num'].'条,';
}
if(!empty($data['google_links_num'])){
$content2 .= '外链量:'.$data['google_links_num'].'条,';
//获取上一次的外链数
$latestRecord = V6WeeklyReport::where(['project_id'=>$project_id])->orderBy('id', 'desc')->first();
if(!empty($latestRecord)){
if($latestRecord['google_links_num'] != $data['google_links_num']){
$content2 .= '外链量:'.$data['google_links_num'].'条,';
}
}else{
$content2 .= '外链量:'.$data['google_links_num'].'条,';
}
}
if(!empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num'])){
$content2 .= '谷歌搜索排名';
$content2 .= $title.'搜索排名';
if(!empty($data['keyword_home_num'])){
$content2 .= '首页关键词数量为:'.$data['keyword_home_num'].'个,';
}
... ... @@ -217,10 +252,12 @@ class WeekProject extends Command
$content3 .= '新闻:'.$data['week_news_num'].'条。';
}
}
$content3 .= '全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';
}
$content3 .= '全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';
$arr[] = $content3;
$content4 = '本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。';
if(!empty($content3)){
$arr[] = $content3;
}
$content4 = '';
if(!empty($data['main_update_num'])){
$content4 .= '网站加载速度维护及主站页面更新'.$data['main_update_num'].'次。';
}
... ... @@ -236,23 +273,36 @@ class WeekProject extends Command
if(!empty($data['aggregation_minor_update_num'])){
$content4 .= '聚合页小语种站页面'.$data['aggregation_minor_update_num'].'次。';
}
$arr[] = $content4;
if(!empty($content4)){
$content4 = '本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。'.$content4;
}
if(!empty($content4)){
$arr[] = $content4;
}
if(empty($arr)){
return true;
}
foreach ($arr as $key => $val){
$content .= ($key + 1) .','.$val.PHP_EOL;
$content .= ($key+1).','.$val.PHP_EOL;
}
$timestamp = strtotime('tomorrow 9:00 AM');
$tomorrowNineAM = date('Y-m-d H:i:s', $timestamp);
if(empty($content)){
return true;
}
$tips = 'Tips:'.PHP_EOL.'1、全球搜V6.0系统提供网页TDK、H标签、Img标签等用户自定义编辑接口且辅以AI创作工具,用户可进一步对相关优化设置进行精细化优化与调整;'.PHP_EOL.'2、全球搜V6.0系统提供小语种页面精准校对翻译功能,用户可进一步对已翻译小语种页面进行人工翻译校对;'.PHP_EOL.'3、全球搜V6.0系统支持绑定Facebook、LinkedIn、X(原Twitter)等社媒账号,可一键同步转发网站上发布的产品和新闻至社媒账号动态,建议用户用起来哦;'.PHP_EOL.'4、如用户有较丰富的企业、产品、服务相关视频素材,全球搜建议用户及时创建YouTube主页,并在YouTube和网站相关网页上同步发布视频;';
$param = [
'project_id'=>$project_id,
'friend_id'=>$friend_id,
'type'=>MessagePush::TYPE_WEEK,
'content'=>'【全球搜V6.0周报】'.PHP_EOL.$content,
'content'=>"【全球搜V6.0周报】".PHP_EOL.$content.PHP_EOL.$tips,
'ref_ids'=>'',
'send_time'=>$tomorrowNineAM
'send_time'=>$tomorrowNineAM,
'status'=>0,
];
//写入一条推送消息 自动消费
$messagePushModel = new MessagePush();
echo date('Y-m-d H:i:s') . '生成推送消息:'.$project_id . PHP_EOL;
return $messagePushModel->add($param);
$messagePushModel->add($param);
return true;
}
}
... ...
... ... @@ -9,10 +9,8 @@ use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainCreateTask;
use App\Models\Domain\DomainInfo;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Project\DeployBuild;
use App\Models\Project\Project;
use App\Models\Project\ProjectUpdateTdk;
use App\Models\WebSetting\WebLanguage;
use App\Services\BatchExportService;
use App\Services\ProjectServer;
... ... @@ -37,9 +35,76 @@ class Temp extends Command
public function handle()
{
$this->domain_rewrite_https();
}
/**
* 小语种为二级目录的项目强制跳转https
* @author Akun
* @date 2025/03/01 10:48
*/
public function domain_rewrite_https()
{
$domainModel = new DomainInfo();
$projectModel = new Project();
$buildModel = new DeployBuild();
$serverIpModel = new ServersIp();
$domainCreateTaskModel = new DomainCreateTask();
$list = $domainModel->select(['id', 'domain', 'project_id'])->where('status', '=', 1)->where('project_id', '>', 0)->get();
foreach ($list as $v) {
$project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']);
if (!$project_info) {
continue;
}
$build_info = $buildModel->read(['project_id' => $v['project_id']], ['linking_format']);
if (!$build_info) {
continue;
}
if ($build_info['linking_format'] != 1) {
continue;
}
$servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']);
if (!$servers_ip_info) {
continue;
}
//过滤测试项目域名
if ($servers_ip_info['servers_id'] == ServerConfig::SELF_TEST_ID) {
continue;
}
//过滤自建站项目域名
if ($servers_ip_info['servers_id'] == ServerConfig::SELF_SITE_ID) {
continue;
}
//过滤已解析到别的ip的域名
if (!check_domain_record($v['domain'], $servers_ip_info)) {
continue;
}
//强制跳转https
$v->is_https = 1;
$v->save();
//创建更新站点证书任务
$task_info = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_MAIN, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]);
if (!$task_info) {
$domainCreateTaskModel->add([
'server_id' => $servers_ip_info['servers_id'],
'project_id' => $v['project_id'],
'domain_id' => $v['id'],
'type' => DomainCreateTask::TYPE_MAIN
]);
}
$this->output($v['id'] . ' , success');
}
}
/**
* 240服务器上解析cname的项目迁移
* @author Akun
... ... @@ -128,42 +193,6 @@ class Temp extends Command
}
/**
* 2025-02-05 日以来的项目,重写tdk(keyword_title)
* @author Akun
* @date 2025/02/15 10:58
*/
public function product_keyword_rewrite()
{
$products = ProjectUpdateTdk::where('created_at', '>=', '2025-02-05 00:00:00')->pluck('project_id')->toArray();
$products_ids = array_unique($products);
$success_json = file_get_contents(storage_path('logs/lk/success.log'));
$success = json_decode($success_json, true) ?: [];
foreach ($products_ids as $project_id) {
if (in_array($project_id, $success)) {
$this->output($project_id . ' | 已执行,跳过');
continue;
}
ProjectServer::useProject($project_id);
DB::connection('custom_mysql')->table('gl_product_keyword')->update(['keyword_title' => '']);
try {
ProjectUpdateTdk::add_task($project_id);
} catch (\Exception $e) {
$this->output($project_id . ' | ' . $e->getMessage());
}
DB::disconnect('custom_mysql');
array_push($success, $project_id);
file_put_contents(storage_path('logs/lk/success.log'), json_encode($success));
}
$this->output('success');
}
/**
* 创建所有站点建站任务
* @author Akun
* @date 2025/01/27 9:48
... ... @@ -386,33 +415,6 @@ class Temp extends Command
}
}
/**
* 关联所有项目关键词
* @author Akun
* @date 2024/11/18 15:07
*/
public function relation_all_keywords()
{
$projects = Project::select(['id'])->orderBy('id', 'asc')->get();
foreach ($projects as $project) {
ProjectServer::useProject($project->id);
try {
Product::select(['id', 'keyword_id'])->chunk(1000, function ($query) {
foreach ($query as $item) {
KeywordRelated::saveRelated($item->id, $item->keyword_id);
}
});
} catch (\Exception $e) {
$this->output($e->getMessage());
continue;
}
$this->output('ID:' . $project->id . ',success');
}
}
/**
* 获取指定服务器所有项目
* @author Akun
... ... @@ -692,66 +694,6 @@ class Temp extends Command
}
}
/**
* 创建指定项目聚合页生成任务
* @author Akun
* @date 2025/02/11 13:50
*/
public function create_update_keyword_page()
{
$ids_arr = ["46", "83", "91", "150", "190", "206", "219", "221", "232", "233", "238", "287", "290", "299", "319", "321", "353", "356", "388", "389", "456", "457", "475", "491", "518", "535", "554", "600", "624", "650", "728", "732", "783", "807", "835", "881", "896", "913", "947", "1001", "1320", "1336", "1373", "1424", "1442", "1455", "1466", "1505", "1584", "1597", "1617", "1682", "1770", "1816", "1824", "1835", "1860", "1870", "1896", "1913", "1989", "1991", "1992", "2022", "2037", "2059", "2060", "2062", "2104", "2115", "2129", "2131", "2135", "2191", "2204", "2217", "2245", "2257", "2287", "2309", "2313", "2330", "2336", "2337", "2338", "2351", "2391", "2418", "2423", "2435", "2462", "2496", "2504", "2505", "2660", "2768", "2811", "2874", "3157"];
$project_list = Project::select(['id', 'serve_id'])->whereIn('id', $ids_arr)->get();
$domain_model = new DomainInfo();
$notify_model = new Notify();
$server_ip_model = new ServersIp();
foreach ($project_list as $value) {
$project_id = $value->id;
$domain_info = $domain_model->read(['project_id' => $project_id, 'status' => 1], ['id', 'domain']);
if (!$domain_info) {
//过滤未绑定正式域名的项目
continue;
}
$domain = $domain_info['domain'];
//获取项目所在服务器
$serve_ip_info = $server_ip_model->read(['id' => $value->serve_id], ['domain', 'ip', 'servers_id']);
if (!$serve_ip_info) {
$this->output('项目id:' . $project_id . ' | 未查询到服务器数据');
continue;
}
if ($serve_ip_info['servers_id'] != ServerConfig::SELF_SITE_ID) {
if (!check_domain_record($domain, $serve_ip_info)) {
$this->output('项目id:' . $project_id . ', domain:' . $domain . ' | 未解析到目标服务器');
continue;
}
}
$data = [
'project_id' => $project_id,
'type' => 1,
'route' => 4,
'server_id' => $serve_ip_info['servers_id'],
'status' => ['!=', Notify::STATUS_FINISH_SITEMAP]
];
$notify = $notify_model->read($data, ['id']);
if (!$notify) {
$data['data'] = Arr::a2s(['domain' => $domain, 'url' => null, 'language' => []]);
$data['status'] = Notify::STATUS_INIT;
if ($serve_ip_info['servers_id'] == 2) {
$data['is_pull_html_zip'] = Notify::IS_PULL_HTML_ZIP_TRUE;
}
$notify_model->add($data);
$this->output('项目id:' . $project_id . ', domain:' . $domain . ' | success');
}
}
}
public function output($msg)
{
... ...
... ... @@ -209,7 +209,29 @@ class FormGlobalsoApi
$queryString = http_build_query($data);
$url = 'https://www.globalso.site/api/external-interface/country_con/15243d63ed5a5738?'.$queryString;
$res = http_get($url,['charset=utf-8']);
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
}
/**
* @remark :按时间区间
* @name :getMonthInquiry
* @author :lyh
* @method :post
* @time :2025/3/1 9:49
* https://form.globalso.com/api/external-interface/date_count?sta_date=2025-02-26&end_date=2025-02-28&domain=www.ultrasounddawei.com
*/
public function getDateInquiry($url,$start,$end,$is_upgrade = 0){
$token = md5($url.date("Y-m-d"));
$data = [
'domain' => $url,
'token' => $token,
'source'=> $is_upgrade ? '1,2,3,4,5' : '1,3,5',
'end_date' => $end,
'sta_date'=>$start,
];
$queryString = http_build_query($data);
$url = 'https://www.globalso.site/api/external-interface/date_count?'.$queryString;
$res = http_get($url,['charset=utf-8']);
return $res;
}
}
... ...
... ... @@ -78,7 +78,7 @@ class ServersController extends BaseController
unset($this->map['domain']);
}
$serversModel = new ServersModel();
$data = $serversModel->lists($this->map,$this->page,$this->row,$this->order);
$data = $serversModel->lists($this->map,$this->page,$this->row,$this->order = 'sort');
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -5,12 +5,11 @@ namespace App\Http\Controllers\Aside\Optimize;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Optimize\InquiryForwardLogic;
use App\Models\Inquiry\AreaTimezone;
class InquiryForwardController extends BaseController
{
/**
* 获取询信息发列表
* 获取询列表
* @param InquiryForwardLogic $inquiryForwardLogic
* @author Akun
* @date 2025/02/21 10:55
... ... @@ -29,11 +28,33 @@ class InquiryForwardController extends BaseController
if (isset($this->param['url_keyword'])) {
$this->map['url_keyword'] = ['like', '%' . $this->map['url_keyword'] . '%'];
}
if (isset($this->param['message'])) {
$this->map['message'] = ['like', '%' . $this->map['message'] . '%'];
}
$lists = $inquiryForwardLogic->getInquiryLists($this->map, $this->page, $this->row, $this->order);
$this->response('success', Code::SUCCESS, $lists);
}
/**
* 获取询盘详情
* @param InquiryForwardLogic $inquiryForwardLogic
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
* @author Akun
* @date 2025/03/01 11:21
*/
public function getInquiryInfo(InquiryForwardLogic $inquiryForwardLogic)
{
$this->request->validate([
'id' => 'required',
], [
'id.required' => 'ID不能为空',
]);
$info = $inquiryForwardLogic->infoInquiry();
$this->response('success', Code::SUCCESS, $info);
}
/**
* 获取询盘类型
* @param InquiryForwardLogic $inquiryForwardLogic
* @author Akun
... ... @@ -166,4 +187,22 @@ class InquiryForwardController extends BaseController
$this->response('success');
}
/**
* 获取询盘详情列表
* @param InquiryForwardLogic $inquiryForwardLogic
* @author Akun
* @date 2025/03/01 9:22
*/
public function getInquiryDetailList(InquiryForwardLogic $inquiryForwardLogic)
{
if (isset($this->param['country'])) {
$this->map['country'] = ['like', '%' . $this->map['country'] . '%'];
}
if (isset($this->param['website'])) {
$this->map['website'] = ['like', '%' . $this->map['website'] . '%'];
}
$lists = $inquiryForwardLogic->getInquiryDetailLists($this->map, $this->page, $this->row, $this->order);
$this->response('success', Code::SUCCESS, $lists);
}
}
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Helper\FormGlobalsoApi;
use App\Helper\PayStripeApi;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Models\Ai\AiBlog;
... ... @@ -19,6 +20,7 @@ use App\Models\CustomModule\CustomModuleContent;
use App\Models\CustomModule\CustomModuleExtentContent;
use App\Models\Domain\DomainInfo;
use App\Models\ExtentModule\ExtensionModuleValue;
use App\Models\HomeCount\Count;
use App\Models\Manage\ManageHr;
use App\Models\Project\CountAllProject as AllProject;
use App\Models\Project\Project;
... ... @@ -38,22 +40,8 @@ class TestController extends BaseController
* @time :2025/2/13 16:34
*/
public function ceshi(){
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = '100008';
$aiBlogService->key = '8a9c925bdcca';
$result = $aiBlogService->createTask('apple');
if($result['status'] == 200){
$param = [
'keywords'=>'apple',
'status'=>$result['data']['status'],
'task_id'=>$result['data']['task_id'],
'project_id'=>1,
];
ProjectServer::useProject(1);
$aiBlogModel = new AiBlog();
$aiBlogModel->add($param);
DB::disconnect('custom_mysql');
}
$this->response('success',Code::SUCCESS,$param);
//获取上一周询盘数量
$result = (new FormGlobalsoApi())->getDateInquiry($this->param['domain'],$this->param['start'],$this->param['end']);
$this->response('success',Code::SUCCESS,$result);
}
}
... ...
... ... @@ -14,7 +14,6 @@ use App\Models\Inquiry\InquiryProjectRoute;
use App\Models\Inquiry\InquiryRelayDetail;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
/**
... ... @@ -34,7 +33,7 @@ class InquiryForwardLogic extends BaseLogic
}
/**
* 获取类型
* 获取询盘类型
* @return array
* @author Akun
* @date 2025/02/21 11:19
... ... @@ -53,7 +52,7 @@ class InquiryForwardLogic extends BaseLogic
}
/**
* 获取列表
* 获取询盘列表
* @param $map
* @param $page
* @param $row
... ... @@ -70,6 +69,23 @@ class InquiryForwardLogic extends BaseLogic
}
/**
* 获取询盘详情
* @return array
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
* @author Akun
* @date 2025/03/01 11:20
*/
public function infoInquiry()
{
$info = $this->model->read(['id' => $this->param['id']], ['id', 'url', 'url_title', 'url_keyword', 'name', 'email', 'phone', 'ip', 'country', 'message']);
if ($info === false) {
$this->fail('获取询盘详情失败');
}
return $this->success($info);
}
/**
* 转发询盘
* @return array
* @throws \App\Exceptions\AsideGlobalException
... ... @@ -91,7 +107,13 @@ class InquiryForwardLogic extends BaseLogic
try {
$num = 0;
$now = date('Y-m-d H:i:s');
foreach ($this->param['forward_url'] as $url) {
if (is_array($this->param['forward_url'])) {
$forward_url = $this->param['forward_url'];
} else {
$forward_url = explode(',', $this->param['forward_url']);
}
foreach ($forward_url as $url) {
$url = trim($url);
$domain_array = parse_url($url);
$website = $domain_array['host'] ?? '';
if (!$website) {
... ... @@ -166,7 +188,7 @@ class InquiryForwardLogic extends BaseLogic
} catch (\Exception $e) {
DB::rollback();
Log::error('inquiry_forward error:' . $e->getMessage());
@file_put_contents(storage_path('logs/lk_error.log'), $e->getMessage());
$this->fail('转发询盘失败');
}
... ... @@ -267,12 +289,23 @@ class InquiryForwardLogic extends BaseLogic
*/
public function aiRewrite()
{
$ai_command = AiCommand::where('key', 'inquiry_text_rewrite')->value('ai');
if (!$ai_command) {
$ai_info = AiCommand::select(['ai', 'not_use_probability'])->where('key', 'inquiry_text_rewrite')->first();
if (!$ai_info) {
$this->fail('AI重写指令未配置');
}
$ai_command = $ai_info['ai'];
$not_use_probability = $ai_info['not_use_probability'];
$in_content = $this->param['message'];
// 当原始询盘内容长度大于15个字符, 60%几率直接发送原始内容。
if (strlen($in_content) >= 15) {
$randomNumber = rand(0, 100);
if ($randomNumber < $not_use_probability) {
return $this->success(['ai_message' => $in_content]);
}
}
$translateSl = Translate::translateSl($in_content);
$lang = $translateSl['texts']['sl'] ?? 'en';
if ($lang == 'en' || $lang == 'ja' || $lang == 'ko' || Str::contains($lang, 'zh')) {
... ... @@ -299,11 +332,36 @@ class InquiryForwardLogic extends BaseLogic
*/
public function expiredInquiry()
{
$rs = $this->model->edit(['status' => InquiryInfo::STATUS_INVALID], ['id' => $this->param['id']]);
if (isset($this->param['type']) && $this->param['type'] == 1) {
//启用
$status = InquiryInfo::STATUS_INIT;
} else {
//无效
$status = InquiryInfo::STATUS_INVALID;
}
$rs = $this->model->edit(['status' => $status], ['id' => $this->param['id']]);
if ($rs === false) {
$this->fail('设置无效失败');
$this->fail('设置失败');
}
return $this->success();
}
/**
* 获取询盘转发详情列表
* @param $map
* @param $page
* @param $row
* @param string $order
* @param string[] $filed
* @return array
* @author Akun
* @date 2025/03/01 9:22
*/
public function getInquiryDetailLists($map, $page, $row, $order = 'id', $filed = ['*'])
{
$model = new InquiryRelayDetail();
$lists = $model->listsWith($map, $page, $row, $order, $filed, 'desc', ['detailLog']);
return $this->success($lists);
}
}
... ...
... ... @@ -26,7 +26,7 @@ class UserLogic extends BaseLogic
*/
public function user_info()
{
$info = $this->model->read($this->param, ['id', 'project_id', 'name', 'status', 'role_id' ,'mobile', 'operator_id']);
$info = $this->model->read($this->param, ['id', 'project_id', 'name', 'status', 'role_id' ,'mobile', 'is_password' ,'operator_id']);
if ($info === false) {
$this->fail('当前数据不存在');
}
... ...
... ... @@ -37,7 +37,7 @@ class UserLoginLogic
*/
public function login(){
//先验证手机号是否在项目中存在
$info = $this->model->read(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id']);
$info = $this->model->read(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id','is_password','project_id']);
if($info === false){
$this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE);
}
... ... @@ -46,12 +46,18 @@ class UserLoginLogic
$list = $this->model->list(['mobile'=>$this->param['mobile'],
'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
}else{
$password = base64_encode(md5($this->param['password']));
$list = $this->model->list(['mobile'=>$this->param['mobile'],
'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
if(empty($list)){
if(($info['is_password'] == $this->model::STATUS_ZERO) && ($info['project_id'] != 1)){//查看是否开启了密码登录:默认未开启
//验证code
$list = $this->verifyCode($this->param['mobile'],$this->param['password']);
}else{
//先验证密码是否正确,在验证验证码
$password = base64_encode(md5($this->param['password']));
$list = $this->model->list(['mobile'=>$this->param['mobile'],
'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
if(empty($list)){
//默认只能使用验证码登录
$list = $this->verifyCode($this->param['mobile'],$this->param['password']);
}
}
}
//获取所有项目的项目id
... ... @@ -143,10 +149,10 @@ class UserLoginLogic
$smsInfo = $smsModel->formatQuery(['mobile'=>$mobile,'type'=>$smsModel::TYPE_LOGIN])->orderBy('id','desc')->first();
if(!empty($smsInfo)){
if(($password != $smsInfo['code']) || ($smsInfo['created_at'] < date('Y-m-d H:i:s',time() - 300))){
$this->fail('账号密码错误/验证码错误');
$this->fail('验证码错误,如需账号密码登录,请联系管理员开启');
}
}else{
$this->fail('账号密码错误/验证码错误');
$this->fail('验证码错误,如需账号密码登录,请联系管理员开启');
}
$list = $this->model->list(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id','project_id']);
return $this->success($list);
... ...
... ... @@ -14,6 +14,7 @@ class AutoPullNotify extends Base
1 => '硅谷云服务器',
15 => '硅谷IDC服务器01(6.0美服1)',
14 => '硅谷IDC服务器02(6.0美服2)',
21 => '硅谷IDC服务器03(6.0美服3)',
2 => '俄罗斯服务器',
4 => '阿里云深圳服务器',
5 => '日本服务器',
... ...
... ... @@ -315,4 +315,29 @@ class Base extends Model
return $this->formatQuery($data)->pluck($filed)->toArray();
}
/**
* 带关联的列表数据
* @param $map
* @param $page
* @param $row
* @param string $order
* @param string[] $fields
* @param string $sort
* @param array $with
* @return array
* @author Akun
* @date 2025/03/01 9:19
*/
public function listsWith($map, $page, $row, $order = 'id', $fields = ['*'], $sort = 'desc',$with=[]): array
{
$query = $this->formatQuery($map);
$with && $query->with($with);
$query = $this->sortOrder($query,$order,$sort);
$lists = $query->select($fields)->paginate($row, $fields, 'page', $page);
if (empty($lists)) {
return [];
}
$lists = $lists->toArray();
return $lists;
}
}
... ...
... ... @@ -37,6 +37,7 @@ class InquiryInfo extends Base
const TYPE_ADS = 2;
const TYPE_AI_SITE_GROUP = 3;
const TYPE_SPIDER = 4;
const TYPE_FIND_SUPPLY = 5;
/**
* 状态映射
... ... @@ -60,9 +61,10 @@ class InquiryInfo extends Base
{
return [
self::TYPE_SITE_GROUP => '站群询盘',
self::TYPE_ADS => 'ads采集站询盘',
self::TYPE_AI_SITE_GROUP => 'AI站群询盘',
self::TYPE_SPIDER => '蜘蛛询盘',
self::TYPE_ADS => 'ADS采集站',
self::TYPE_AI_SITE_GROUP => '自建AI站群',
self::TYPE_SPIDER => 'SC平台',
self::TYPE_FIND_SUPPLY => 'FS平台',
];
}
... ... @@ -83,15 +85,19 @@ class InquiryInfo extends Base
* @param $message_sign
* @param $origin_key
* @param string $image
* @param int $email_status
* @param int $phone_status
* @return bool
*/
public function createInquiry($name, $phone, $email, $ip, $country, $message, $message_cn, $type, $inquiry_date, $url, $url_title, $url_keyword, $message_sign, $origin_key, $image = '')
public function createInquiry($name, $phone, $email, $ip, $country, $message, $message_cn, $type, $inquiry_date, $url, $url_title, $url_keyword, $message_sign, $origin_key, $image = '', $email_status = 0, $phone_status = 0)
{
try {
$self = new self();
$self->name = $name;
$self->phone = $phone;
$self->phone_status = $phone_status;
$self->email = $email;
$self->email_status = $email_status;
$self->ip = $ip;
$self->country = $country;
$self->message = $message;
... ...
... ... @@ -8,14 +8,14 @@
namespace App\Models\Inquiry;
use Illuminate\Database\Eloquent\Model;
use App\Models\Base;
/**
* 询盘转发详情
* Class ReInquiryDetail
* @package App\Models\Inquiry
*/
class InquiryRelayDetail extends Model
class InquiryRelayDetail extends Base
{
/**
* @var string
... ...
... ... @@ -8,14 +8,14 @@
namespace App\Models\Inquiry;
use Illuminate\Database\Eloquent\Model;
use App\Models\Base;
/**
* 转发详情日志
* Class ReInquiryDetailLog
* @package App\Models\Inquiry
*/
class InquiryRelayDetailLog extends Model
class InquiryRelayDetailLog extends Base
{
/**
* @var string
... ...
... ... @@ -185,6 +185,12 @@ return [
'level' => 'debug',
'days' => 14,
],
'inquiry_forward' => [
'driver' => 'daily',
'path' => storage_path('logs/inquiry_forward/laravel.log'),
'level' => 'debug',
'days' => 14,
],
],
//操作日志
'operator_log' =>[
... ...
... ... @@ -342,13 +342,15 @@ Route::middleware(['aloginauth'])->group(function () {
//手动转发询盘
Route::prefix('inquiry_forward')->group(function () {
Route::any('/', [Aside\Optimize\InquiryForwardController::class, 'lists'])->name('admin.inquiry_lists');
Route::any('/', [Aside\Optimize\InquiryForwardController::class, 'lists'])->name('admin.inquiry_forward_lists');
Route::any('/getInquiryInfo', [Aside\Optimize\InquiryForwardController::class, 'getInquiryInfo'])->name('admin.inquiry_forward_getInquiryInfo');
Route::any('/getInquiryType', [Aside\Optimize\InquiryForwardController::class, 'getInquiryType'])->name('admin.inquiry_forward_getInquiryType');
Route::any('/forwardInquiry', [Aside\Optimize\InquiryForwardController::class, 'forwardInquiry'])->name('admin.inquiry_forward_forwardInquiry');
Route::any('/getInquiryIp', [Aside\Optimize\InquiryForwardController::class, 'getInquiryIp'])->name('admin.inquiry_forward_getInquiryIp');
Route::any('/searchInquiryKeywords', [Aside\Optimize\InquiryForwardController::class, 'searchInquiryKeywords'])->name('admin.inquiry_forward_searchInquiryKeywords');
Route::any('/aiRewriteInquiry', [Aside\Optimize\InquiryForwardController::class, 'aiRewriteInquiry'])->name('admin.inquiry_forward_aiRewriteInquiry');
Route::any('/setInquiryExpired', [Aside\Optimize\InquiryForwardController::class, 'setInquiryExpired'])->name('admin.inquiry_forward_setInquiryExpired');
Route::any('/getInquiryDetailList', [Aside\Optimize\InquiryForwardController::class, 'getInquiryDetailList'])->name('admin.inquiry_forward_getInquiryDetailList');
});
Route::prefix('custom_module')->group(function () {
... ... @@ -533,7 +535,7 @@ Route::group([], function () {
Route::any('/getProjectInService', [Aside\Project\ProjectController::class, 'getProjectInService'])->name('admin.getProjectInService');//获取项目服务状态
Route::any('/getProjectByChannel', [Aside\Project\ProjectController::class, 'getProjectByChannel'])->name('admin.getProjectByChannel');//获取渠道商的项目
// 提供接口 同步人事信息到5.0后台
Route::any('/get_hr_list', [Aside\Manage\HrController::class , 'getHrList'])->name('admin.get_hr_list');
Route::any('/get_hr_list', [Aside\Manage\HrController::class, 'getHrList'])->name('admin.get_hr_list');
// 提供模板 提单后台查看
Route::any('get_template_list', [Aside\Template\ATemplateController::class, 'getTemplateList'])->name('admin.get_template_list');
Route::any('get_template_detail', [Aside\Template\ATemplateController::class, 'getTemplateDetail'])->name('admin.get_template_detail');
... ...