作者 刘锟

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

... ... @@ -80,7 +80,7 @@ class TemplateLog extends Command
* @time :2024/11/13 16:19
*/
public function deleteUserLog(){
$date = date('Y-m-d H:i:s', strtotime('-30 days'));
$date = date('Y-m-d H:i:s', strtotime('-60 days'));
$userLogModel = new UserLog();
return $userLogModel->del(['created_at'=>['<=',$date]]);
}
... ...
... ... @@ -39,6 +39,7 @@ class RemainDay extends Command
378,
649,
1283,
1893,
2066
];//需要单独处理的项目
/**
... ...
... ... @@ -338,7 +338,7 @@ class RelayInquiry extends Command
$re_website = 'https://' . $domain . '/';
//urls
list($urls, $lang) = $this->getUrls($is_v6, $domain, $re_website, $form, $task);
list($urls, $lang, $inquiry_product_url) = $this->getUrls($is_v6, $domain, $re_website, $form, $task);
if(!$urls){
continue;
}
... ... @@ -349,7 +349,7 @@ class RelayInquiry extends Command
$country_name = $ip_data->ip_area;
//message
list($message, $message_id, $msg_lang) = $this->getMessage($task, $form->message, $domain);
list($message, $message_id, $msg_lang) = $this->getMessage($task, $form->message, $domain, $inquiry_product_url);
$lang = $lang ?: $msg_lang;
$this->output('获取转发设备信息');
... ... @@ -406,6 +406,7 @@ class RelayInquiry extends Command
$ip_data = $this->getIpData($form->country_name);
$ip = $ip_data->ip;
$country_name = $ip_data->ip_area;
//message
list($message, $message_id, $lang) = $this->getMessage($task, $form->message, $domain);
... ... @@ -477,7 +478,7 @@ class RelayInquiry extends Command
return $ip_data;
}
public function getMessage($task, $message, $domain){
public function getMessage($task, $message, $domain, $inquiry_product_url = ''){
$this->output('转发内容');
$form_message = $message;
$message_id = 0;
... ... @@ -486,7 +487,7 @@ class RelayInquiry extends Command
//AI生成
$error = 0;
while ($error<3){
$message = $this->ai_send($task['ai_param'], $message);
$message = $this->ai_send($task['ai_param'], $message, $inquiry_product_url);
if(!$message){
$this->output('AI文案生成失败');
$error++;
... ... @@ -580,7 +581,13 @@ class RelayInquiry extends Command
$urls[] = Arr::random($inquiry_urls);
}
}
return [$urls, $lang];
//着陆页是否是产品页面或产品列表页
$inquiry_product_url = '';
if(in_array(Arr::last($urls), $product_url) || in_array(Arr::last($urls), $product_cate_url)){
$inquiry_product_url = Arr::last($urls);
}
return [$urls, $lang, $inquiry_product_url];
}
/**
* 获取待处理询盘表单
... ... @@ -693,7 +700,7 @@ class RelayInquiry extends Command
}
}
public function ai_send($ai_param, $incontent)
public function ai_send($ai_param, $incontent, $inquiry_product_url)
{
$ai_command = AiCommand::where('key', 'fb_inquiry_text')->value('ai');
if (!$ai_command) {
... ... @@ -707,6 +714,16 @@ class RelayInquiry extends Command
}else{
$language = Translate::getTls($lang);
}
//着陆页是否是产品页面或产品列表页
if($inquiry_product_url){
$title = Common::getUrlTitle($inquiry_product_url);
if($title){
$ai_command = str_replace('{mkeywords}', $title, $ai_command);
}
}
$ai_command = str_replace('{mkeywords}', Arr::random(explode("\r\n", $ai_param['mkeywords'])), $ai_command);
$ai_command = str_replace('{incontent}', Arr::random(explode("\r\n", $incontent)), $ai_command);
$ai_command = str_replace('{characters}', Arr::random(explode("\r\n", $ai_param['characters'])), $ai_command);
... ...
... ... @@ -219,7 +219,7 @@ class postInquiry extends Command
} else {
$data['__amp_source_origin'] = trim($website, '/');
}
$res = Http::withoutVerifying()->timeout(10)->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd/', $data)->json();
$res = Http::withoutVerifying()->timeout(10)->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd?source=5', $data)->json();
if (empty($res['code']) || $res['code'] != 200) {
$log->status = ReInquiryDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
... ...
<?php
/**
* @remark :
* @name :CreateProject.php
* @author :lyh
* @method :post
* @time :2025/1/6 10:34
*/
namespace App\Console\Commands\Project;
use App\Helper\Arr;
use App\Models\Channel\Channel;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateVisit;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\Manage\Mobile;
use App\Models\Project\After;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Payment;
use App\Models\Project\Project;
use App\Models\User\User as UserModel;
use App\Services\ProjectServer;
use Hashids\Hashids;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class CreateProject extends Command
{
protected $signature = 'create_project';
protected $description = '创建项目';
public function handle(){
return $this->sync();
}
public function sync($is_update = 0){
$title = date('Ymd') . '-广东威美建材科技有限公司';
$data = [
'project'=>[
'title' => $title,
'company' => '广东威美建材科技有限公司',
'lead_name' => '蔡伟文',
'mobile' => '13929953235',
'mysql_id'=>Project::MYSQL_ID,
'serve_id'=>9,
'qq' => '',
'channel' => '{"user_id": "53", "zone_id": "4", "channel_id": "4"}',
'requirement' => '',
'cooperate_date' => '2019-04-01',
'from_order_id' => '',
'type' => $is_update,
'is_upgrade'=>$is_update,
],
'deploy_build' => [
'service_duration' => 0,
'plan' => $this->versionData('标准版'),
'login_mobile'=>'13929953235'
],
'deploy_optimize' => [
// 'api_no' => 0
],
'project_after' => [],
'payment' => [
'amount' => 0,
'contract'=>[],
'bill'=>[]
],
];
DB::beginTransaction();
try {
$id = $this->saveProject($data['project']);
$this->setPostId($data['deploy_build']['plan'],$id);
$this->savePayment($data['payment'],$id);
$this->saveDeployBuild($data['deploy_build'],$id);
$this->saveDeployOptimize($data['deploy_optimize'],$id);
$this->saveAfter($data['project_after'],$id);
$serversIpModel = new ServersIp();
$serversModel = new Servers();
$serversIpModel->where(['id'=>9])->increment('total',1);
$serversModel->where(['id'=>7])->increment('being_number',1);
if($is_update == 1){
//4.0或5.0更新到6.0
//初始化数据库
$this->initializationMysql($id);
//初始账号
$this->createUser($data['project']['mobile'],$id,$data['project']['lead_name']);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
throw new \Exception($e->getMessage());
}
}
/**
* @remark :获取版本
* @name :versionData
* @author :lyh
* @method :post
* @time :2023/8/9 14:46
*/
public function versionData($param){
$data = Project::planMap();
$data = array_flip($data);
if(isset($data[$param])){
return $data[$param];
}else{
return 1;
}
}
/**
* @remark :保存项目
* @name :saveProject
* @author :lyh
* @method :post
* @time :2023/8/30 15:53
*/
public function saveProject($param){
$projectModel = new Project();
return $projectModel->addReturnId($param);
}
/**
* @remark :设置post_id
* @name :setPostId
* @author :lyh
* @method :post
* @time :2023/8/9 14:47
*/
public function setPostId($plan,$id){
$length = strlen((string)$id); // 获取变量的位数
$paddingLength = Project::TYPE_FIVE - $length; // 计算填充前面的 0 的位数
$zeros = str_repeat("0", $paddingLength);
$number = Project::TYPE_SIX.$plan.$zeros.$id;
$projectModel = new Project();
$projectModel->edit(['post_id'=>$number],['id'=>$id]);
return true;
}
/**
* 保存优化部署
* @author zbj
* @date 2023/4/26
*/
protected function saveAfter($param,$id){
$param['project_id'] = $id;
//查询数据是否存在
$afterModel = new After();
$info = $afterModel->read(['project_id'=>$id]);
if($info !== false){
$afterModel->edit($param,['id'=>$info['id']]);
}else{
$afterModel->add($param);
}
}
/**
* @remark :保存付款续费
* @name :savePayment
* @author :lyh
* @method :post
* @time :2023/8/29 16:19
*/
protected function savePayment($param,$id){
$param['project_id'] = $id;
$paymentModel= new Payment();
$param['contract'] = Arr::a2s($param['contract']);
$param['bill'] = Arr::a2s($param['bill']);
if(!isset($param['renewal_record'])){
$param['renewal_record'] = Arr::a2s([["amount"=> null, "remark"=> null, "expire_at"=> null]]);
}
$info = $paymentModel->read(['project_id'=>$id]);
if($info !== false){
$paymentModel->edit($param,['id'=>$info['id']]);
}else{
$paymentModel->add($param);
}
}
/**
* @remark :保存建站部署
* @name :saveDeployBuild
* @author :lyh
* @method :post
* @time :2023/8/29 16:19
*/
protected function saveDeployBuild($param,$id){
$param['project_id'] = $id;
$hashids = new Hashids('test_domain', 5, 'abcdefghjkmnpqrstuvwxyz1234567890');
$code = $hashids->encode($id);
$param['test_domain'] = 'https://v6-' . $code . '.globalso.site/';
$deployBuildModel = new DeployBuild();
$info = $deployBuildModel->read(['project_id'=>$id]);
if($info !== false){
$deployBuildModel->edit($param,['id'=>$info['id']]);
}else{
$deployBuildModel->add($param);
}
}
/**
* @remark :保存优化信息
* @name :saveDeployOptimize
* @author :lyh
* @method :post
* @time :2023/8/30 16:11
*/
protected function saveDeployOptimize($param,$id){
$param['project_id'] = $id;
$deployOptimizeModel = new DeployOptimize();
$info = $deployOptimizeModel->read(['project_id'=>$id]);
if($info !== false){
//存在就不处理了
// $deployOptimizeModel->edit($param,['id'=>$info['id']]);
}else{
$deployOptimizeModel->add($param);
}
}
/**
* 初始化数据库
* @param $project_id
* @author Akun
* @date 2023/09/19 15:12
*/
public function initializationMysql($project_id){
//切换数据库配置
$project = ProjectServer::useProject($project_id);
//创建数据库
ProjectServer::createDatabase($project);
//创建表
ProjectServer::initTable();
//初始数据
ProjectServer::saveInitParam($project_id);
}
/**
* 创建用户
* @param $mobile
* @param $project_id
* @param $lead_name
* @author Akun
* @date 2023/09/19 15:12
*/
public function createUser($mobile,$project_id,$lead_name){
$userModel = new UserModel();
//查看当前项目是否存在号码库中
$mobileModel = new Mobile();
$mobileInfo = $mobileModel->read(['mobile'=>$mobile]);
if($mobileInfo === false){
//查看当前用户是否存在
$info = $userModel->read(['mobile'=>$mobile,'project_id'=>$project_id]);
if($info === false){
$data = [
'mobile'=>$mobile,
'password'=>base64_encode(md5('123456')),
'project_id'=>$project_id,
'name'=>$lead_name,
'type'=>UserModel::TYPE_ONE
];
$userModel->add($data);
}
}
return true;
}
}
... ...
... ... @@ -9,6 +9,7 @@ use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel;
use App\Services\SyncSubmitTaskService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
... ... @@ -68,6 +69,7 @@ class SyncSubmitTask extends Command
$this->output('任务完成');
} catch (\Exception $e) {
$task_info->retry = $task_info->retry + 1;
if ($task_info->retry >= 3) {
$task_info->status = 2;
... ... @@ -76,7 +78,7 @@ class SyncSubmitTask extends Command
Redis::lpush('sync_submit_task', $task_id);
}
$task_info->save();
Log::channel('inquiry')->error($task_id . '处理失败', [$e->getMessage(), $e->getFile(), $e->getLine()]);
$this->output('任务失败:' . $e->getMessage());
}
... ...
<?php
/**
* @remark :
* @name :SendAutoEmail.php
* @author :lyh
* @method :post
* @time :2024/12/30 15:39
*/
namespace App\Console\Commands\Task;
use App\Mail\TextMail;
use App\Models\Project\AutoEmailLog;
use App\Models\Subscribe\Smtp;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Mail;
class SendAutoEmail extends Command
{
protected $signature = 'send_auto_email';
protected $description = '自动发送回复邮件';
/**
* @remark :脚本
* @name :handle
* @author :lyh
* @method :post
* @time :2024/12/30 15:43
*/
public function handle()
{
$autoEmailLogModel = new AutoEmailLog();
$list = $autoEmailLogModel->list(['status'=>AutoEmailLog::STATUS_PENDING],'id',['*'],'asc',100);
if(!empty($list)){
$ids = array_column($list,'id');
$autoEmailLogModel->edit(['status'=>AutoEmailLog::STATUS_ON],['id'=>['in',$ids]]);
foreach ($list as $value) {
$this->output('开始执行任务:' . $value['id']);
$smtpModel = new Smtp();
$smtpInfo = $smtpModel->read(['project_id'=>$value['project_id']]);
if($smtpInfo === false){
$status = AutoEmailLog::STATUS_ERROR;
$this->output('任务:' . $smtpInfo['id'] . '失败,未配置SMTP');
}else{
$status = $this->toQueue($value,$smtpInfo);
}
$autoEmailLogModel = new AutoEmailLog();
$rs = $autoEmailLogModel->edit(['status'=>$status],['id'=>$value['id']]);
$this->output('保存状态:' . $rs . 'status=>'.$status);
}
}
return true;
}
/**
* @remark :发送邮件
* @name :toQueue
* @author :lyh
* @method :post
* @time :2024/12/30 15:43
*/
public function toQueue($info,$smtpInfo){
Config::set('mail.mailers.smtp.host', $smtpInfo['host']);
Config::set('mail.mailers.smtp.username', $smtpInfo['email']);
Config::set('mail.mailers.smtp.password', $smtpInfo['password']);
Config::set('mail.from.address', $smtpInfo['email']);
Config::set('mail.from.name', $smtpInfo['from_name']);
try {
$status = AutoEmailLog::STATUS_SUCCESS;
Mail::to([$info['email']])->send(new TextMail(['subject' => $info['title'], 'text' => $info['content']]));
} catch (\Exception $e) {
$status = AutoEmailLog::STATUS_ERROR;
$this->output('任务:' . $info['id'] . ' 邮箱' . $info['email'] . '发送失败,' . $e->getMessage());
}
return $status;
}
/**
* 输出处理日志
*/
public function output($message): bool
{
echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
return true;
}
}
... ...
... ... @@ -59,11 +59,11 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>['=',0],'id'=>874]);
$list = $projectModel->list(['delete_status'=>['=',0],'id'=>2902]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->setProductKeyword();
$this->getProduct();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
... ... @@ -291,7 +291,7 @@ class UpdateRoute extends Command
public function getProduct(){
$productModel = new Product();
$lists = $productModel->list(['status'=>['!=',2]]);
$lists = $productModel->list();
if(!empty($lists)){
foreach ($lists as $v){
if(!empty($v['route'])){
... ... @@ -313,7 +313,7 @@ class UpdateRoute extends Command
}else{
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
$v['title'] = Translate::tran($v['title'], 'en');
$v['title'] = str_replace('.','',$v['title']).'-product';
$v['title'] = str_replace('.','',$v['title']);
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']);
$productModel->edit(['route'=>$route],['id'=>$v['id']]);
}
... ...
... ... @@ -8,6 +8,7 @@ use App\Models\User\UserLog as UserLogModel;
use App\Models\User\UserLogin as UserLoginModel;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
/**
* @name:
... ... @@ -225,4 +226,24 @@ class Common
public static function deal_str($str){
return str_replace(['{','}','”','“','"'],'',$str);
}
/**
* 获取网页 title
* @param $url
* @author zbj
* @date 2024/12/31
*/
public static function getUrlTitle($url)
{
try {
$response = Http::withoutVerifying()->get($url);
$html = $response->body();
$dom = new \DOMDocument();
@$dom->loadHTML($html); // 加载 HTML
$title = $dom->getElementsByTagName('title')->item(0); // 获取 <title> 标签
return $title->nodeValue;
} catch (\Exception $e) {
return '';
}
}
}
... ...
... ... @@ -140,7 +140,7 @@ class FormGlobalsoApi
* @author zbj
* @date 2024/1/20
*/
public function submitInquiry($ip, $referer, $submit_at, $data)
public function submitInquiry($ip, $referer, $submit_at, $data, $traffic = 0)
{
$api_url = $this->url . '/api/external-interface/add/fa043f9cbec6b38f';
... ... @@ -148,7 +148,7 @@ class FormGlobalsoApi
$data['token'] = md5($referer . $data['name'] . $ip . date("Y-m-d"));
$data['refer'] = $referer;
$data['submit_time'] = date('Y-m-d H:i:s', strtotime($submit_at));
$data['source'] = 1; //固定
$data['source'] = $traffic ? 5 : 1; //1 固定 5 FB广告
try {
$res = HttpUtils::post($api_url, $data);
... ...
... ... @@ -41,7 +41,8 @@ class PayStripeApi
// 构造函数设置密钥
public function __construct()
{
$this->secretKey = 'sk_test_51MyseXIWCYVeLww1tbPZzRe1Qk4lS5d2VLiDjpju7G0ToiX1RJcFinQXNlftq9eCjZE0n2gjaz1mfy1g0mxTusdf00m636Gv62';
// $this->secretKey = 'sk_test_51MyseXIWCYVeLww1tbPZzRe1Qk4lS5d2VLiDjpju7G0ToiX1RJcFinQXNlftq9eCjZE0n2gjaz1mfy1g0mxTusdf00m636Gv62';
$this->secretKey = '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';
}
/**
... ... @@ -89,7 +90,8 @@ class PayStripeApi
$data = [
'amount' => $amount,
'currency' => $currency,
'automatic_payment_methods[enabled]' => 'true',
'payment_method_types' => $this->currency_types[$currency],
// 'automatic_payment_methods[enabled]' => 'true',
];
return $this->sendRequest($url, 'POST', $data);
}
... ... @@ -148,7 +150,8 @@ class PayStripeApi
{
try {
// Webhook 签名密钥(从 Stripe 仪表盘获取)
$endpointSecret = 'whsec_garhW2TrCIrduyM3rve9mFS2sn69B9Yt';
// $endpointSecret = 'whsec_garhW2TrCIrduyM3rve9mFS2sn69B9Yt';
$endpointSecret = 'whsec_YPuQn3XPuJ0xyiN6XFoF0ZLaxfRM3wnS';
// 获取原始请求内容
$payload = request()->getContent();
// 获取 Stripe 签名头
... ...
... ... @@ -289,7 +289,7 @@ class AdsController extends BaseController
*/
public function fbInquiryChart(Request $request)
{
$start_date = $request->input('start_date', date('Y-m-d', strtotime('-1 month')));
$start_date = $request->input('start_date', date('Y-m-d', strtotime('-3 month')));
$end_date = $request->input('end_date', date('Y-m-d'));
$result = ReInquiryForm::select(DB::raw('DATE(inquiry_date) as date'), DB::raw('COUNT(*) as count'))
->whereBetween('inquiry_date', [$start_date, date('Y-m-d', strtotime($end_date . ' +1 day'))])
... ... @@ -297,7 +297,7 @@ class AdsController extends BaseController
->pluck('count', 'date')->toArray();
$data = [];
while ($start_date <= $end_date) {
$data[$start_date] = $result[$start_date]??0;
$data[$start_date] = ($result[$start_date]??0) * 3 ;
$start_date = date('Y-m-d', strtotime($start_date . ' + 1 day'));
}
... ...
... ... @@ -13,16 +13,27 @@ use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Controllers\Bside\BaseController;
use App\Jobs\UpdatePageJob;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory;
use App\Models\Com\Notify;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateNotify;
use App\Models\Com\UpdateProgress;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainInfo;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\Country as CountryModel;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\WebSetting\SettingNum;
use App\Models\WebSetting\WebLanguage;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
... ... @@ -38,6 +49,157 @@ use Illuminate\Support\Facades\DB;
class CNoticeController extends BaseController
{
/**
* @remark :统计所有小语种
* @name :countLanguagePage
* @author :lyh
* @method :post
* @time :2025/1/4 10:13
*/
public function countLanguagePage(){
$this->request->validate([
'language'=>'required',
],[
'language.required' => 'language不能为空',
]);
$lang_num = count($this->param['language']);
$keyword_num = (new Keyword())->counts(['route'=>['!=',null]]);
$data_num = $this->productNum() + $this->CustomNum() + $this->newsNum() + $this->blogNum();
$number = $keyword_num * 18 + $lang_num * $data_num;
if($number >= 450000){
$this->response('success',Code::SUCCESS,['msg'=>'翻译数量过多, 大概页面数量:'.$number.', 磁盘空间占用可能会超过40G,请联系管理员操作!']);
}
$this->response('success');
}
/**
* @remark :产品分类页面数量
* @name :productCateNum
* @author :lyh
* @method :post
* @time :2025/1/4 10:43
*/
public function productNum(){
$number = (new Product())->counts(['status'=>1]);
$settingModel = new SettingNum();
$info = $settingModel->read(['type'=>1]);
if($info === false){
$product_page_number = 15;
}else{
$product_page_number = $info['num'];
}
$productCateModel = new Category();
$productCateList = $productCateModel->list(['status'=>1]);
if(!empty($productCateList)){
$cateReModel = new CategoryRelated();
foreach ($productCateList as $v){
$cate_num = $cateReModel->counts(['cate_id'=>$v['id']]);
if($cate_num == 0){
$number += 1;
}else{
$number += ceil($cate_num / $product_page_number);
}
}
}
return $number;
}
/**
* @remark :新闻数量
* @name :newsNum
* @author :lyh
* @method :post
* @time :2025/1/4 11:21
*/
public function newsNum(){
$newsModel = new News();
$number = $newsModel->counts(['status'=>1]);
$settingModel = new SettingNum();
$info = $settingModel->read(['type'=>2]);
if($info === false){
$news_page_number = 10;
}else{
$news_page_number = $info['num'];
}
$newsCateModel = new NewsCategory();
$newsCateList = $newsCateModel->list(['status'=>0]);
if(!empty($newsCateList)){
foreach ($newsCateList as $v){
$cate_num = $newsModel->counts(['category_id'=>['like',','.$v['id'].',']]);
if($cate_num == 0){
$number += 1;
}else{
$number += ceil($cate_num / $news_page_number);
}
}
}
return $number;
}
/**
* @remark :博客数量
* @name :blogNum
* @author :lyh
* @method :post
* @time :2025/1/4 11:21
*/
public function blogNum(){
$blogModel = new Blog();
$number = $blogModel->counts(['status'=>1]);
$settingModel = new SettingNum();
$info = $settingModel->read(['type'=>3]);
if($info === false){
$news_page_number = 10;
}else{
$news_page_number = $info['num'];
}
$blogCateModel = new BlogCategory();
$blogCateList = $blogCateModel->list(['status'=>0]);
if(!empty($blogCateList)){
foreach ($blogCateList as $v){
$cate_num = $blogModel->counts(['category_id'=>['like',','.$v['id'].',']]);
if($cate_num == 0){
$number += 1;
}else{
$number += ceil($cate_num / $news_page_number);
}
}
}
return $number;
}
/**
* @remark :扩展模块数量
* @name :blogNum
* @author :lyh
* @method :post
* @time :2025/1/4 11:21
*/
public function CustomNum(){
$contentModel = new CustomModuleContent();
$number = $contentModel->counts(['status'=>0]);
$settingModel = new SettingNum();
$info = $settingModel->read(['type'=>2]);
if($info === false){
$news_page_number = 10;
}else{
$news_page_number = $info['num'];
}
$cateModel = new CustomModuleCategory();
$cateList = $cateModel->list(['status'=>0]);
if(!empty($cateList)){
foreach ($cateList as $v){
$cate_num = $contentModel->counts(['category_id'=>['like',','.$v['id'].',']]);
if($cate_num == 0){
$number += 1;
}else{
$number += ceil($cate_num / $news_page_number);
}
}
}
return $number;
}
/**
* 更新通知C端
* @param Request $request
* @return \Illuminate\Http\JsonResponse
... ...
... ... @@ -23,6 +23,7 @@ class BaseController extends Controller
protected $row = 20;//每页条数
protected $header = [];//设置请求头参数
protected $order = 'created_at';
protected $order_type = 'desc';
protected $map = [];//处理后的参数
protected $uid = 0;
protected $user = [];//当前登录用户详情
... ... @@ -79,6 +80,9 @@ class BaseController extends Controller
case "order":
$this->order = $v;
break;
case "order_type":
$this->order_type = $v;
break;
case 'page':
$this->page = $v;
break;
... ... @@ -168,12 +172,15 @@ class BaseController extends Controller
/**
* 是否post请求
* @return bool
* @remark :是否是post请求
* @name :isPost
* @author :lyh
* @method :post
* @time :2024/12/30 14:17
*/
protected final function isPost()
{
return \Illuminate\Support\Facades\Request::isMethod('post');
return Request::isMethod('post');
}
... ...
... ... @@ -62,25 +62,49 @@ class FileManageController extends BaseController
* @method :post
* @time :2023/12/28 17:18
*/
public function downLoad(){
if(!isset($this->param['path']) || empty($this->param['path'])){
$this->response('参数错误',Code::SYSTEM_ERROR);
public function downLoad()
{
// 检查参数
if (!isset($this->param['path']) || empty($this->param['path'])) {
$this->response('参数错误', Code::SYSTEM_ERROR);
}
$username = basename($this->param['path']);
$parsed_url = parse_url($this->param['path']);
if(isset($parsed_url['scheme'])){
$fileUrl = $this->param['path'];
} else {
$fileUrl = 'https://file.globalso.com'.$this->param['path'];
// 构造文件 URL
$fileUrl = isset($parsed_url['scheme'])
? $this->param['path']
: 'https://file.globalso.com' . $this->param['path'];
// 初始化 curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fileUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, false);
// 跳过 SSL 验证
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// 执行 curl 请求
$fileContent = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
$curlError = curl_error($ch);
curl_close($ch);
// 检查 curl 错误或 HTTP 状态码
if ($fileContent === false || $httpCode != 200) {
$errorMsg = $fileContent === false ? "Curl Error: $curlError" : "HTTP Error: $httpCode";
$this->response("文件下载失败 - $errorMsg", Code::SYSTEM_ERROR);
}
// 设置响应头
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Type: ' . ($contentType ?: 'application/octet-stream'));
header('Content-Disposition: attachment; filename="' . $username . '"');
// 下载文件
readfile($fileUrl);
header('Content-Length: ' . strlen($fileContent));
// 输出文件内容
echo $fileContent;
exit;
}
public function upload(Request $request, FileManage $fileManage){
$request->validate([
'file'=>['required'],
... ...
... ... @@ -49,8 +49,8 @@ class ProductController extends BaseController
{
$filed = ['id', 'project_id', 'title', 'sort' ,'thumb' ,'product_type' , 'route' ,
'category_id', 'keyword_id', 'status', 'created_uid', 'is_upgrade' ,'created_at', 'updated_at','six_read'];
$this->order = 'sort';
$query = $product->orderBy($this->order ,'desc')->orderBy('id','desc');
$this->order = $this->order ?? 'sort';
$query = $product->orderBy($this->order ,$this->order_type)->orderBy('id','desc');
$query = $this->searchParam($query);
$lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
... ... @@ -68,9 +68,12 @@ class ProductController extends BaseController
$v = $this->getHandleFileImage($v);
$lists['list'][$k] = $v;
}
$lists['order_type'] = $this->order_type;
$lists['order'] = $this->order;
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :列表
* @name :index
... ...
... ... @@ -105,6 +105,8 @@ class TranslateController extends BaseController
$translate_data[$value] = '';
}
}
}else{
$translate_data = json_decode($values['translate_data']['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
$resData['data'] = $translate_data ?? [];
$res_data[] = $resData;
... ...
<?php
/**
* @remark :
* @name :AutoEmailContentController.php
* @author :lyh
* @method :post
* @time :2024/12/30 14:09
*/
namespace App\Http\Controllers\Bside\Subscribe;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Project\AutoEmail;
use App\Models\Subscribe\Smtp;
/**
* @remark :项目设置自动回复邮件内容
* @name :AutoEmailContentController
* @author :lyh
* @method :post
* @time :2024/12/30 14:09
*/
class AutoEmailContentController extends BaseController
{
/**
* @remark :获取
* @name :getInfo
* @author :lyh
* @method :post
* @time :2024/12/30 14:10
*/
public function getContent(){
$autoEmailModel = new AutoEmail();
$lists = $autoEmailModel->list(['project_id'=>$this->user['project_id']]);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :保存详情
* @name :saveContent
* @author :lyh
* @method :post
* @time :2024/12/30 14:11
*/
public function saveContent(){
$this->request->validate([
'content' => ['required'],
], [
'content.required' => '内容不能为空',
]);
$smtpModel = new Smtp();
$smtpInfo = $smtpModel->read(['project_id' => $this->user['project_id']]);
if($smtpInfo === false){
$this->fail('请先设置SMTP',Code::USER_ERROR);
}
$autoEmailModel = new AutoEmail();
$info = $autoEmailModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
//执行新增
$data = ['project_id'=>$this->user['project_id'],'title'=>$this->param['title'],'content'=>$this->param['content']];
$id = $autoEmailModel->addReturnId($data);
}else{
$id = $info['id'];
$autoEmailModel->edit(['title'=>$this->param['title'],'content'=>$this->param['content']],['project_id'=>$this->user['project_id']]);
}
$this->response('success',Code::SUCCESS,['id'=>$id]);
}
}
... ...
... ... @@ -17,6 +17,8 @@ use App\Models\WebSetting\TranslateData;
use App\Models\WebSetting\WebLanguage;
use App\Helper\Translate;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class TranslateLogic extends BaseLogic
{
public function __construct()
... ... @@ -75,6 +77,7 @@ class TranslateLogic extends BaseLogic
if($val == ' ' || $val == ''){
continue;
}
$val = trim(trim($val,' '));
if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){
$arr2[] = $val;
}
... ...
... ... @@ -25,7 +25,7 @@ class WebSettingTextLogic extends BaseLogic
*/
public function setting_read(){
$web_setting = new WebSetting();
$setting_info = $web_setting->read(['project_id'=>$this->user['project_id']],['anchor_setting','anchor_is_enable','anchor_num']);
$setting_info = $web_setting->read(['project_id'=>$this->user['project_id']],['anchor_setting','anchor_is_enable','anchor_num','anchor_page_num']);
if($setting_info === false){
$setting_info = [];
}
... ... @@ -63,7 +63,8 @@ class WebSettingTextLogic extends BaseLogic
$data = [
'anchor_setting'=>$this->param['anchor_setting'],
'anchor_is_enable'=>$this->param['anchor_is_enable'],
'anchor_num'=>$this->param['anchor_num']
'anchor_num'=>$this->param['anchor_num'] ?? 0,
'anchor_page_num'=>$this->param['anchor_page_num'] ?? 0
];
$web_setting->edit($data,['project_id'=>$this->user['project_id']]);
$this->model->del(['project_id'=>$this->user['project_id']]);
... ...
... ... @@ -31,6 +31,7 @@ class TextMail extends Mailable
*/
public function build()
{
return $this->subject($this->subject)->view('mail.text', ['text' => $this->text]);
return $this->subject($this->subject)->text('mail.text', ['text' => $this->text])->view('mail.html', ['text' => $this->text]);
}
}
... ...
... ... @@ -41,7 +41,7 @@ class InquiryFormData extends Base
* @author zbj
* @date 2023/12/4
*/
public static function saveData($form_id, $domain, $ip, $country, $referer, $user_agent, $submit_at, $data){
public static function saveData($form_id, $domain, $ip, $country, $referer, $user_agent, $submit_at, $data, $traffic = 0){
if(!empty($data['email'])){
$data['email'] = str_replace(' ', '', $data['email']);
}
... ... @@ -100,7 +100,7 @@ class InquiryFormData extends Base
}
}
if(!$has_file) {
$res = (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data);
$res = (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data, $traffic);
Log::channel('inquiry')->info('询盘发送邮件', [$data, $res]);
}
}
... ...
<?php
/**
* @remark :
* @name :AutoEmail.php
* @author :lyh
* @method :post
* @time :2024/12/30 14:03
*/
namespace App\Models\Project;
use App\Models\Base;
class AutoEmail extends Base
{
protected $table = 'gl_auto_email_content';
}
... ...
<?php
/**
* @remark :
* @name :AutoEmailLog.php
* @author :lyh
* @method :post
* @time :2024/12/30 15:31
*/
namespace App\Models\Project;
use App\Models\Base;
class AutoEmailLog extends Base
{
protected $table = 'gl_auto_email_content_log';
const STATUS_PENDING = 0;//待发送
const STATUS_ON = 1;//执行中
const STATUS_SUCCESS = 2;//执行结束
const STATUS_ERROR = 3;//执行失败
}
... ...
... ... @@ -18,6 +18,7 @@ class WebSettingText extends Base
const TYPE_KEYWORD = 3;
const TYPE_NEWS = 4;
const TYPE_BLOG = 5;
const TYPE_OTHER = 6;
/**
* @var :描文本设置
*/
... ... @@ -27,6 +28,7 @@ class WebSettingText extends Base
self::TYPE_KEYWORD=>'关键词页',
self::TYPE_NEWS=>'新闻页',
self::TYPE_BLOG=>'博客页',
self::TYPE_OTHER=>'其他页',
];
/**
... ...
... ... @@ -4,8 +4,12 @@
namespace App\Services;
use App\Exceptions\InquiryFilterException;
use App\Models\Domain\CountryCode;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryForm;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\AutoEmail;
use App\Models\Project\AutoEmailLog;
use App\Models\Project\InquiryFilterConfig;
use App\Models\Project\Project;
use App\Models\Subscribe\Email;
... ... @@ -61,14 +65,28 @@ class SyncSubmitTaskService
// 项目ID:448, 过滤被刷访问
if ($project['id'] == 448 && $task['type'] == 'visit') {
if ($data['country'] == '约旦' && empty($data['referrer_url'])) {
$url_array = parse_url($data['url']);
if ($data['country'] == '约旦' && empty($data['data']['referrer_url'])) {
$url_array = parse_url($data['data']['url']);
$path_array = explode('/', $url_array['path']);
if (FALSE == empty($path_array[1]) && strlen($path_array[1]) <= 3)
return false;
}
}
//域名 过滤国家或ip
$domain_info = DomainInfo::where('project_id', $project['id'])->first();
if(!empty($domain_info['not_allow_country'])){
$not_allow_countries = CountryCode::whereIn('id', $domain_info['not_allow_country'])->pluck('c_name')->toArray();
if(in_array($data['country'], $not_allow_countries)){
return false;
}
}
if(!empty($domain_info['not_allow_ip'])){
if(in_array($data['ip'], $domain_info['not_allow_ip'])){
return false;
}
}
if(!ProjectServer::useProject($project['id'])){
return false;
}
... ... @@ -89,7 +107,7 @@ class SyncSubmitTaskService
}
$handler = new self();
return $handler->$action($data, $date, $task['id']);
return $handler->$action($data, $date, $task['id'], $task['traffic']);
}
... ... @@ -120,21 +138,47 @@ class SyncSubmitTaskService
* @author zbj
* @date 2024/8/27
*/
public function subscribe($data, $date, $task_id){
public function subscribe($data, $date, $task_id, $traffic = 0){
$email = $data['data']['email'];
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$model = Email::where('email', $email)->first();
if($model){
return true;
}
$model = new Email();
$model->email = $email;
$model->save();
//查询当前项目是否开启自动回复邮件
$this->saveEmailLog($data['project_id'],$email);
}else{
throw new InquiryFilterException( '邮箱格式异常:' . $email);
}
}
/**
* @remark :保存自动发送邮件
* @name :saveEmailLog
* @author :lyh
* @method :post
* @time :2024/12/30 15:36
*/
public function saveEmailLog($project_id,$email){
$autoEmailModel = new AutoEmail();
$info = $autoEmailModel->read(['project_id'=>$project_id]);
if($info !== false){
$paramData = [
'project_id'=>$project_id,
'title'=>$info['title'],
'content'=>$info['content'],
'email'=>$email,
];
$autoEmailLogModel = new AutoEmailLog();
$autoEmailLogModel->addReturnId($paramData);
}
return true;
}
/**
* 询盘
* @param $data
* @return bool
... ... @@ -142,7 +186,7 @@ class SyncSubmitTaskService
* @author zbj
* @date 2023/12/4
*/
public function inquiry($data, $date, $task_id)
public function inquiry($data, $date, $task_id, $traffic = 0)
{
//数组key转为小写
$data['data'] = array_change_key_case($data['data'], CASE_LOWER);
... ... @@ -166,7 +210,7 @@ class SyncSubmitTaskService
$data['referer'] = $this->handle_referer($data['referer']);
$id = InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data']);
$id = InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data'], $traffic);
//转化询盘
... ... @@ -196,7 +240,7 @@ class SyncSubmitTaskService
* @author zbj
* @date 2023/12/4
*/
public function visit($data, $date, $task_id)
public function visit($data, $date, $task_id, $traffic = 0)
{
$visit_data = $data['data'];
... ... @@ -295,7 +339,6 @@ class SyncSubmitTaskService
if(empty($data['referer']) || empty($data['user_agent']) || empty($data['data'])){
throw new InquiryFilterException( '数据异常:' . $data['country']);
}
$config = InquiryFilterConfig::getCacheInfoByProjectId($project_id);
//没配置 则默认开启且使用全局
if(!$config){
... ...
<div class="editor-text-wrap">
{!! $text !!}
</div>
... ...
... ... @@ -166,6 +166,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'save'])->name('web_setting_save');
//通知
Route::any('/sendNotify', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'sendNotify'])->name('web_setting_sendNotify');
Route::any('/countLanguagePage', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'countLanguagePage'])->name('web_setting_countLanguagePage');
//已选择的国家
Route::any('/getCountry', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'getCountry'])->name('web_setting_getCountry');
//第三方代码获取与设置
... ... @@ -641,6 +642,13 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/info', [\App\Http\Controllers\Bside\Comment\CommentController::class, 'info'])->name('comment_info');
Route::any('/status', [\App\Http\Controllers\Bside\Comment\CommentController::class, 'status'])->name('comment_status');
});
//自动邮件设置
Route::prefix('auto_email_content')->group(function () {
Route::any('/getContent', [\App\Http\Controllers\Bside\Subscribe\AutoEmailContentController::class, 'getContent'])->name('auto_email_content_getContent');
Route::any('/saveContent', [\App\Http\Controllers\Bside\Subscribe\AutoEmailContentController::class, 'saveContent'])->name('auto_email_content_saveContent');
});
});
//无需登录验证的路由组
Route::group([], function () {
... ...