作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -77,7 +77,7 @@ class AiBlogTask extends Command
if($route != $result['data']['url']){
$aiBlogService->updateDetail(['route'=>$route,'task_id'=>$item['task_id']]);
}
$aiBlogModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'], 'route'=>$route ,'status'=>2], ['task_id'=>$item['task_id']]);
$aiBlogModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'],'seo_title'=>$result['data']['title'],'seo_keyword'=>$result['data']['keyword'],'seo_description'=>$result['data']['description'], 'route'=>$route ,'status'=>2], ['task_id'=>$item['task_id']]);
DB::disconnect('custom_mysql');
$aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]);
}
... ...
... ... @@ -71,6 +71,8 @@ class GeneratePage extends Command
}
$this->output(' taskID: ' . $noticeInfo['id'] . ' end');
} catch (\Exception $e) {
$noticeModel->edit(['status'=>3],['id'=>$noticeInfo['id']]);
@file_put_contents(storage_path('logs/lyh/lyh_error.log'), var_export('通知C端生成任务:'.date('Y-m-d H:i:s') . ' taskID: ' . $noticeInfo['id'] . ', error: ' . $e->getMessage() . PHP_EOL) . PHP_EOL, FILE_APPEND);
$this->output(' taskID: ' . $noticeInfo['id'] . ', error: ' . $e->getMessage());
}
sleep(2);
... ...
... ... @@ -9,7 +9,9 @@
namespace App\Console\Commands\RequestUrlLog;
use App\Helper\FormGlobalsoApi;
use App\Models\Com\RequestUrl;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use Illuminate\Console\Command;
... ... @@ -40,22 +42,87 @@ class RequestUrlLog extends Command
//获取需要请求的接口
$requestUrlModel = new RequestUrl();
$urlList = $requestUrlModel->list(['status'=>0]);
//随机获取一个项目,需要验证的其他方法
$projectModel = new Project();
$projectInfo = $projectModel->formatQuery(['type'=>2,'delete_status'=>0])->inRandomOrder()->first();
//获取对应项目的域名
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['project_id'=>$projectInfo['id']]);
foreach ($urlList as $v){
//需要单独验证的方法
if($v['url'] == 'getMonthInquiry'){
$result = $this->getMonthInquiry($domainInfo['domain'],date('Y-m'), 0);
$requestUrlModel->edit(['text'=>json_encode($result,true),'time'=>$result['$requestTime'],'http_code'=>$result['http_code']],['id'=>$v['id']]);
continue;
}
//循环请求设置
if($v['method'] == 'get'){
}else{
$url = $v['url'];
$result = $this->postRequest($url,$v['param']);
echo '执行的url:' . $url . PHP_EOL . '返回的结果:'.json_encode($result,true) . date('Y-m-d H:i:s').PHP_EOL;
if($v['method'] == 'post'){
$result = $this->postRequest($v['url'],$v['param']);
echo '执行的url:' . $v['url'] . PHP_EOL . '返回的结果:'.json_encode($result,true) . date('Y-m-d H:i:s').PHP_EOL;
//更新请求结果
$requestUrlModel->edit(['text'=>json_encode($result,true)],['id'=>$v['id']]);
$requestUrlModel->edit(['text'=>json_encode($result,true),'time'=>$result['$requestTime'],'http_code'=>$result['http_code']],['id'=>$v['id']]);
continue;
}
}
return true;
}
/**
* @remark :按月统计xunpan
* @name :getMonthInquiry
* @author :lyh
* @method :post
* @time :2025/3/10 14:15
*/
public function getMonthInquiry($url,$month,$is_upgrade = 0){
$url = 'https://'.$url.'/';
$token = md5($url.date("Y-m-d"));
$data = [
'domain' => $url,
'token' => $token,
'source'=> $is_upgrade ? '1,2,3,4,5' : '1,3,5',
'model' => 'month',
'sta_date'=>$month,
];
$queryString = http_build_query($data);
$url = 'https://www.globalso.site/api/external-interface/country_con/15243d63ed5a5738?'.$queryString;
$res = $this->getRequest($url);
return $res;
}
/**
* @remark :http_get请求
* @name :getRequest
* @author :lyh
* @method :post
* @time :2025/3/10 14:35
*/
public function getRequest($url){
$header[] = "content-type: application/json";
$ch1 = curl_init();
$timeout = 0;
curl_setopt($ch1, CURLOPT_URL, $url);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_ENCODING, '');
curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch1, CURLOPT_TIMEOUT, 120);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$access_txt = curl_exec($ch1);
$total_time = curl_getinfo($ch1, CURLINFO_TOTAL_TIME); // 获取请求总时间
$httpCode = curl_getinfo($ch1, CURLINFO_HTTP_CODE);
if (curl_errno($ch1)) {
curl_error($ch1);
}
curl_close($ch1);
$response = json_decode($access_txt, true);
return ['response' => $response, 'http_code' => $httpCode, 'request_time_ms' => $total_time];
}
/**
* @remark :请求设置
* @name :postRequest
* @author :lyh
... ... @@ -64,12 +131,10 @@ class RequestUrlLog extends Command
*/
public function postRequest($url, $postData)
{
if (empty($header)) {
$header = array(
"Accept: application/json",
"Content-Type:application/json;charset=utf-8",
);
}
$header = array(
"Accept: application/json",
"Content-Type:application/json;charset=utf-8",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
... ... @@ -81,18 +146,15 @@ class RequestUrlLog extends Command
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 记录请求开始时间
$startTime = microtime(true);
$res = curl_exec($ch);
// 记录请求结束时间
$endTime = microtime(true);
$total_time = curl_getinfo($ch, CURLINFO_TOTAL_TIME); // 获取请求总时间
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
curl_error($ch);
}
$requestTime = round(($endTime - $startTime) * 1000, 2); // 转换为毫秒
curl_close($ch);
return ['response' => $res, 'http_code' => $httpCode, 'request_time_ms' => $requestTime];
$response = json_decode($res, true);
return ['response' => $response, 'http_code' => $httpCode, 'request_time_ms' => $total_time];
}
}
... ...
... ... @@ -11,6 +11,7 @@ namespace App\Console\Commands\Suppliers;
use App\Models\Product\Keyword;
use App\Models\Project\DeployBuild;
use App\Models\Project\Project;
use App\Models\Purchaser\Purchaser;
use App\Models\Purchaser\PurchaserInfo;
use App\Services\ProjectServer;
... ... @@ -33,6 +34,10 @@ class RecommendedSuppliers extends Command
*/
protected $description = '推荐供应商';
public $deployBuildModel;
public $projectModel;
/**
* Create a new command instance.
*
... ... @@ -40,7 +45,8 @@ class RecommendedSuppliers extends Command
*/
public function __construct()
{
parent::__construct();
$this->deployBuildModel = new DeployBuild();
parent::__construct(); // 确保调用父类构造函数
}
... ... @@ -49,15 +55,42 @@ class RecommendedSuppliers extends Command
*/
public function handle()
{
$projectModel = new DeployBuild();
$project_list = $projectModel->list(['is_supplier'=>1]);//TODO::已开启推荐供应商
$project_list = $this->deployBuildModel->list(['is_supplier'=>1]);//TODO::已开启推荐供应商
foreach ($project_list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['project_id'] . PHP_EOL;
ProjectServer::useProject($v['project_id']);
$title = $this->getKeywords($v['project_id']);
echo date('Y-m-d H:i:s') . '开始:'.$v['project_id'] . PHP_EOL;
$this->savePurchaser($v['project_id'],$title);
DB::disconnect('custom_mysql');
$result = $this->countPurchaser($v);
if($result !== false){
ProjectServer::useProject($v['project_id']);
$title = $this->getKeywords($v['project_id']);
echo date('Y-m-d H:i:s') . '开始:'.$v['project_id'] . PHP_EOL;
$this->savePurchaser($v['project_id'],$title);
DB::disconnect('custom_mysql');
}
}
return true;
}
/**
* @remark :当前项目拥有的
* @name :countPurchaser
* @author :lyh
* @method :post
* @time :2025/3/10 16:29
* @param :is_purchaser_count;1->开启后已达到上线关闭过 0->未关闭过
* @param :plan(1->专业版 2->标准版 3->商务版 10->旗舰版)
*/
public function countPurchaser($v){
if($v['is_purchaser_count'] == 0){
$purchaserInfoModel = new PurchaserInfo();
$count = $purchaserInfoModel->counts(['project_id'=>$v['project_id']]);
//获取项目版本
$plan = ['专业版'=>300, '标准版'=>500, '商务版'=>800, '旗舰版'=>1200];
$total_number = $plan[Project::planMap()[$v['plan']]] ?? 300;
if($count > $total_number){
//更新数量上限字段,并关闭推荐供应商
$this->deployBuildModel->edit(['is_purchaser_count'=>1,'is_supplier'=>0],['project_id'=>$v['project_id']]);
return false;
}
}
return true;
}
... ...
... ... @@ -62,10 +62,14 @@ class Validate
*/
public static function check_data($data,$type)
{
if($type == 1){
$res = HttpUtils::get('https://fob.ai.cc/api/check_email', ['email' => $data]);
}else{
$res = HttpUtils::get('https://fob.ai.cc/api/check_phone', ['phone' => $data]);
try {
if($type == 1){
$res = HttpUtils::get('https://fob.ai.cc/api/check_email', ['email' => $data]);
}else{
$res = HttpUtils::get('https://fob.ai.cc/api/check_phone', ['phone' => $data]);
}
}catch (\Exception $e){
return [];
}
return Arr::s2a($res);
}
... ...
... ... @@ -71,8 +71,8 @@ class AutoTaskController extends BaseController
}
// 映射信息 以及解析信息
$val['type'] = $type[$val['type']] ?? '';
$val['route'] = $route[$val['route']];
$val['status'] = $status[$val['status']];
$val['route'] = $route[$val['route']] ?? '';
$val['status'] = $status[$val['status']] ?? '';
$val['project_title'] = $projects[$val['project_id']] ?? '';
$val['domain'] = $data['domain'] ?? '';
$val['url'] = FALSE == empty($data['url']) ? $data['url'] : [];
... ...
... ... @@ -411,8 +411,6 @@ class ComController extends BaseController
$data[] = ['project_id'=>$v['id'],'company'=>$v['company']];
}
}
//登录选择项目的有效时间
Cache::add('login-project-'.$this->user['mobile'],1,300);
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -270,4 +270,21 @@ class InquiryController extends BaseController
// return Storage::disk('runtime')->download($file); //直接下载
$this->response('success',Code::SUCCESS,['url' => $fileurl]);
}
/**
* @remark :翻译国家
* @name :tranCountry
* @author :lyh
* @method :post
* @time :2025/3/11 14:18
*/
public function tranCountry(InquiryLogic $logic){
$this->request->validate([
'phone_region' => 'required',
],[
'phone_region.required' => '国家译文不能为空'
]);
$data = $logic->tranCountry();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -35,7 +35,7 @@ class LoginController extends BaseController
{
/**
* @remark :登录
* @remark :登录返回所属项目
* @name :login
* @author :lyh
* @method :post
... ...
... ... @@ -154,12 +154,12 @@ class ProjectLogic extends BaseLogic
* @author :lyh
* @method :post
* @time :2023/8/30 11:57
* @param :1->建站中 2->优化中 3->建站完成 6-》错误单
*/
public function projectSave(){
DB::beginTransaction();
try {
if($this->param['type'] == Project::TYPE_SEVEN){
//错误单直接返回,单独处理
$this->setTypeSevenEdit($this->param);
}else{
//初始化项目
... ... @@ -196,6 +196,32 @@ class ProjectLogic extends BaseLogic
}
/**
* @remark :开启推荐供应商设置
* @name :isPurchaser
* @author :lyh
* @method :post
* @time :2025/3/10 15:33
*/
public function isPurchaser($project_id){
if($this->param['type'] == Project::TYPE_TWO){
if(empty($this->param['uptime'])){
$this->param['deploy_build']['is_supplier'] = 1;
}else{
//获取项目的上线时间
$projectInfo = $this->model->read(['id'=>$project_id],['uptime']);
//查看上线时间是否大于3天
$threeDaysAgo = date('Y-m-d H:i:s', strtotime('-3 days'));
if($projectInfo['uptime'] > $threeDaysAgo){
//上线时间大于当前时间的3天钱,默认不允许关闭推荐供应商
$this->param['deploy_build']['is_supplier'] = 1;
}
}
return true;
}
}
/**
* @remark :开启AI博客后
* @name :setAiBlog
* @author :lyh
... ... @@ -206,8 +232,7 @@ class ProjectLogic extends BaseLogic
if(empty($main_lang_id) || empty($is_ai_blog)){
return true;
}
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$project_id],['title','is_ai_blog','main_lang_id','company']);
$projectInfo = $this->model->read(['id'=>$project_id],['title','is_ai_blog','main_lang_id','company']);
//获取项目主语种
$languageModel = new WebLanguage();
$languageInfo = $languageModel->read(['id'=>$main_lang_id],['short']);
... ... @@ -277,8 +302,7 @@ class ProjectLogic extends BaseLogic
return $this->success();
}
//查看當前項目服務器是否有更改
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$project_id],['serve_id']);
$projectInfo = $this->model->read(['id'=>$project_id],['serve_id']);
$serversIpModel = new ServersIp();
$serversModel = new Servers();
if(!empty($projectInfo['serve_id'])){
... ...
... ... @@ -212,10 +212,29 @@ class InquiryLogic extends BaseLogic
'country_code'=>$data['country_code'] ?? '',
'phone_region'=>$data['phone_region'] ?? '',
];
if(!empty($param['phone_region'])){
$param['country'] = Translate::tran($this->param['phone_region'], 'zh') ?? '';
}
(new PhoneData())->addReturnId($param);
return $this->success($param);
}
}
return $this->success($data);
}
/**
* @remark :翻译国家
* @name :tranCountry
* @author :lyh
* @method :post
* @time :2025/3/11 14:11
*/
public function tranCountry(){
$country = Translate::tran($this->param['phone_region'], 'zh') ?? '';
if(!empty($country)){
$phoneDataModel = new PhoneData();
$phoneDataModel->edit(['country'=>$country],['phone_region'=>$this->param['phone_region']]);
}
return $this->success(['country'=>$country]);
}
}
... ...
... ... @@ -54,15 +54,19 @@ class WebSettingTextLogic extends BaseLogic
*/
public function setting_text_save(){
$web_setting = new WebSetting();
if(count($this->param['data']) > $this->param['anchor_num']){
$this->fail('超过最大设置限制');
if(isset($this->param['data']) && !empty($this->param['data'])){
if(count($this->param['data']) > $this->param['anchor_num']){
$this->fail('超过最大设置限制');
}
}
//更新描文本设置
if($this->param['anchor_is_enable'] == 0){
$this->param['anchor_keyword_is_enable'] = 0;
$web_setting->edit($this->param,['project_id'=>$this->user['project_id']]);
return $this->success();
}
DB::beginTransaction();
try {
//更新描文本设置
if($this->param['anchor_is_enable'] == 0){
$this->param['anchor_keyword_is_enable'] = 0;
}
$data = [
'anchor_setting'=>$this->param['anchor_setting'] ?? [],
'anchor_is_enable'=>$this->param['anchor_is_enable'],
... ... @@ -72,7 +76,7 @@ class WebSettingTextLogic extends BaseLogic
];
$web_setting->edit($data,['project_id'=>$this->user['project_id']]);
$this->model->del(['project_id'=>$this->user['project_id']]);
if(!empty($this->param['data'])){
if(isset($this->param['data']) && !empty($this->param['data'])){
foreach ($this->param['data'] as $k => $v){
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
... ... @@ -86,6 +90,6 @@ class WebSettingTextLogic extends BaseLogic
DB::rollBack();
$this->fail('更新失败');
}
$this->success();
return $this->success();
}
}
... ...
... ... @@ -22,10 +22,8 @@ class UserLoginLogic
public function __construct()
{
//验证账号密码
$this->param = request()->all();
$this->model = new User();
}
/**
... ... @@ -86,7 +84,6 @@ class UserLoginLogic
if(isset($info['token']) && !empty($info['token'])){
//清除上一次用户缓存
Cache::pull($info['token']);
Cache::pull('login-project-'.$this->param['mobile']);
}
//生成新token
$token = md5(uniqid().$info['id']);
... ... @@ -178,7 +175,7 @@ class UserLoginLogic
/**
* @remark :组装返回数据
* @name :getProjectInfo
* @name :assembleParam
* @author :lyh
* @method :post
* @time :2023/8/29 15:26
... ... @@ -343,10 +340,7 @@ class UserLoginLogic
public function wechatLogin($wechat){
$info = $this->model->read(['wechat'=>$wechat]);
if($info === false){
$data = [
'code'=>0,
'message'=>'当前用户未绑定账户,请绑定后登录',
];
$data = ['code'=>0, 'message'=>'当前用户未绑定账户,请绑定后登录',];
}else {
//获取项目详情
$info = $this->autoAssembleParam($info,User::LOGIN_PASSWORD_SOURCE);
... ... @@ -366,8 +360,7 @@ class UserLoginLogic
'message'=>'登陆成功',
'data'=>$info
];
Common::set_user_login(['user_id'=>$info['id'],'ip'=>request()->ip(),
'project_id'=>$info['project_id'], 'type'=>2 ,'remark' => '自动登录,用户微信扫码']);
Common::set_user_login(['user_id'=>$info['id'],'ip'=>request()->ip(), 'project_id'=>$info['project_id'], 'type'=>2 ,'remark' => '自动登录,用户微信扫码']);
}
return $this->success($data);
}
... ...
... ... @@ -40,7 +40,7 @@ class Notify extends Base
const ROUTE_PRODUCT_KEYWORD = 4;
const ROUTE_NOT_TRANSLATE = 5;
const ROUTE_PRODUCT_VIDEO_KEYWORD = 6;
const ROUTE_AI_BLOG = 7;
/**
* 是否拉取HTML压缩包
* 0:默认不拉取
... ... @@ -74,7 +74,8 @@ class Notify extends Base
self::ROUTE_URL => '指定路由',
self::ROUTE_PRODUCT_KEYWORD => '聚合页面',
self::ROUTE_NOT_TRANSLATE => '漏翻检查',
self::ROUTE_PRODUCT_VIDEO_KEYWORD => '视频聚合页'
self::ROUTE_PRODUCT_VIDEO_KEYWORD => '视频聚合页',
self::ROUTE_AI_BLOG => 'AI博客'
];
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Models\Workchat;
use App\Models\Base;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Services\ProjectServer;
use App\Utils\LogUtils;
... ... @@ -40,12 +41,15 @@ class MessagePush extends Base
* @param $name
* @param $submit_at
* @return bool
* @param : is_forward_inquiry:0未开启转发询盘 1:开启转发询盘
*/
public static function addInquiryMessage($id, $project_id, $country, $name, $submit_at){
// if(!ProjectServer::useProject($project_id)){
// return false;
// }
//查看项目是否开启转发询盘
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$project_id],['is_forward_inquiry']);
if($projectInfo['is_forward_inquiry'] == 0){
return false;
}
//项目是否有绑定群
$friend_id = ProjectAssociation::where('project_id', $project_id)
->where('status', ProjectAssociation::STATUS_NORMAL)
... ...
... ... @@ -371,6 +371,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/export', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'export'])->name('inquiry_export');
Route::any('/send', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'sendMobileVerifyData'])->name('inquiry_sendMobileVerifyData');
Route::any('/checkEmail', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'checkEmail'])->name('inquiry_checkEmail');
Route::any('/tranCountry', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'tranCountry'])->name('inquiry_tranCountry');
});
//生成路由
... ...