作者 刘锟

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

正在显示 33 个修改的文件 包含 389 行增加216 行删除
<?php
/**
* @remark :
* @name :TemplateLog.php
* @author :lyh
* @method :post
* @time :2024/7/10 14:44
*/
namespace App\Console\Commands\DeleteTemplate;
use App\Models\Project\Project;
use App\Models\Template\BTemplateLog;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class TemplateLog extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'delete_template_log';
/**
* The console command description.
*
* @var string
*/
protected $description = '定时清理日志';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->deleteTemplate();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :定时清理可视化日志
* @name :deleteTemplate
* @author :lyh
* @method :post
* @time :2024/7/10 14:48
*/
public function deleteTemplate(){
$startDate = date("Y-m-01 00:00:00");
$endDate = date("Y-m-t 23:59:59");
$templateLogModel = new BTemplateLog();
return $templateLogModel->del(['created_at'=>['not between'=>[$startDate,$endDate]]]);
}
}
... ...
... ... @@ -31,10 +31,18 @@ class SyncSubmitTask extends Command
while (true) {
$task_id = Redis::rpop('sync_submit_task');
if(!$task_id){
sleep(3);
continue;
}
$this->output('任务' . $task_id . '开始');
$time = time();
DB::enableQueryLog(); //启用查询日志
//清除之前的查询日志
DB::flushQueryLog();
$task_info = SyncSubmitTaskModel::find($task_id);
if (empty($task_info) || $task_info->status !=3) {
$this->output('任务不存在或者已执行');
... ... @@ -43,7 +51,6 @@ class SyncSubmitTask extends Command
try {
$project = Project::getProjectByDomain($task_info['data']['domain'] ?? '');
$task_info->project_id = $project->id;
SyncSubmitTaskService::handler($task_info);
$task_info->status = 1;
$task_info->save();
... ... @@ -68,6 +75,14 @@ class SyncSubmitTask extends Command
$this->output('任务失败:' . $e->getMessage());
}
$use_time = time() - $time;
if($use_time > 1){
//数据库查询
$this->output('任务用时:' .$use_time . ' | ' . json_encode(DB::getQueryLog(),JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}
//清除之前的查询日志
DB::flushQueryLog();
}
}
... ...
... ... @@ -44,7 +44,6 @@ class SyncSubmitTaskDistribution extends Command
}
}
}
sleep(3);
}
}
... ...
... ... @@ -59,102 +59,4 @@ class Demo extends Command
}
return true;
}
// public function handle(){
// $keywordVideoModel = new KeywordVideoTask();
// $project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();
// //查看是否有子记录
// foreach ($project_id_arr as $values){
// $logModel = new KeywordVideoTaskLog();
// $logInfo = $logModel->read(['project_id'=>$values]);
// if($logInfo === false){
// echo date('Y-m-d H:i:s') . '开启的项目project_id:'.$values . PHP_EOL;
// $keywordVideoModel->edit(['status'=>0],['project_id'=>$values]);
// }
// }
// $projectModel = new Project();
// $list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);
// $data = [];
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
// ProjectServer::useProject($v['id']);
// $this->getProductList();
// DB::disconnect('custom_mysql');
// }
// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
// }
// public function getProductList(){
// $productModel = new Product();
// $product_all_id = $productModel::whereRaw('LENGTH(keyword_id) > 50')->pluck('id')->toArray();
// if(empty($product_all_id)){
// return true;
// }
// $lists = $productModel->whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get()->toArray();
// foreach ($lists as $k => $v){
// echo date('Y-m-d H:i:s') . '项目id:'.$v['project_id'].'+产品product_id:'.$v['id'] . PHP_EOL;
// $str = ',';
// shuffle($v['keyword_id']);
// foreach ($v['keyword_id'] as $key => $value){
// if($key == 6){
// break;
// }
// $str .= $value.',';
// }
// $productModel->edit(['keyword_id'=>$str],['id'=>$v['id']]);
// }
// return true;
// }
//
// /**
// * @remark :关键字有视频的改为1
// * @name :getProductKeywordInfo
// * @author :lyh
// * @method :post
// * @time :2024/5/31 9:54
// */
// public function saveKeyword(){
// $keywordModel = new Keyword();
// $rs = $keywordModel->edit(['is_video_keyword'=>0],['video'=>'']);
// echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL;
// return true;
// }
// public function handle(){
// //切换数据库配置
// ProjectServer::useProject(1862);
// return $this->initTable(1380,1862);
// }
//
// public function initTable($project_id, $news_project_id)
// {
// config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);
// $database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();
// $tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();
// $tables = array_column($tables, 'Tables_in_' . $database_name);
// foreach ($tables as $table) {
// $has_table = Schema::connection('custom_mysql')->hasTable($table);
// if (!$has_table) {
// $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
// DB::connection('custom_mysql')->statement(array_values((array)$sql[0])[0]); // 修正此处的sql语句获取方式
// }
//
// if ($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form') {
// continue;
// }
// DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据
// DB::connection('custom_mysql')->table($table)->insertUsing(
// [], // 列名数组,留空表示插入所有列
// function ($query) use ($table, $project_id) {
// $name = 'gl_data_' . $project_id . '.' . $table;
// $query->select('*')->from("{$name}");
// }
// );
//
// if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {
// DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);
// }
// }
// return true;
// }
}
... ...
... ... @@ -21,23 +21,9 @@ class Kernel extends ConsoleKernel
// $schedule->command('inspire')->hourly();
$schedule->command('remain_day')->dailyAt('09:00')->withoutOverlapping(1); // 项目剩余服务时长
$schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
// $schedule->command('rank_data')->dailyAt('07:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
// $schedule->command('rank_data')->dailyAt('08:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
// $schedule->command('rank_data_speed')->dailyAt('01:10')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
// $schedule->command('rank_data_external_links')->dailyAt('08:30')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
// $schedule->command('rank_data_external_links')->dailyAt('18:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
// $schedule->command('rank_data_indexed_pages')->dailyAt('07:30')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次
// $schedule->command('rank_data_recomm_domain')->dailyAt('07:40')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
// $schedule->command('rank_data_week')->weeklyOn([1,2], '08:30')->withoutOverlapping(1); // 排名数据,每周一、二早上执行一次
$schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次
$schedule->command('web_traffic_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
$schedule->command('web_traffic_russia_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
// $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
// $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
// $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
// $schedule->command('web_traffic_russia 1')->everyThirtyMinutes(); // 俄语站引流 1-3个月的项目,半小时一次
// $schedule->command('web_traffic_russia 2')->cron('*/18 * * * *'); // 俄语站引流 4-8个月的项目,18分钟一次
// $schedule->command('web_traffic_russia 3')->cron('*/12 * * * *'); // 俄语站引流 大于9个月的项目,12分钟一次
$schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次
$schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
$schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
... ... @@ -48,10 +34,9 @@ class Kernel extends ConsoleKernel
$schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
$schedule->command('update_keyword_route')->dailyAt('01:00')->withoutOverlapping(1); //升级项目--清除路由相同的关键字
$schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
$schedule->command('update_keyword_content')->hourly()->withoutOverlapping(1);
// 每日推送视频任务
$schedule->command('video_task')->hourly()->withoutOverlapping(1);
// 每月15号执行任务
$schedule->command('delete_template_log')->monthlyOn(15, '00:00')->withoutOverlapping();
// 每日推送已完成视频任务项目生成对应界面
$schedule->command('notice_c')->dailyAt('04:00')->withoutOverlapping(1);
}
... ...
... ... @@ -215,6 +215,26 @@ if (!function_exists('_get_child')) {
}
}
if (!function_exists('_get_all_sub')) {
/**
* 獲取所有子集id
* @param int
* @return array
*/
function _get_all_sub($my_id,$id_Arr)
{
$new_arr[] = $my_id;
foreach ($id_Arr as $v) {
if ($v['pid'] == $my_id) {
$new_arr[] = $v['id'];
// 递归查找子节点的子节点
$new_arr = array_merge($new_arr, _get_all_sub($v['id'], $id_Arr));
}
}
return $new_arr ? $new_arr : [];
}
}
if (!function_exists('checkDomain')) {
/**
... ... @@ -624,11 +644,11 @@ if (!function_exists('getFileUrl')) {
* @method :post
* @time :2023/7/20 16:46
*/
function getFileUrl($path,$storage_type = 0,$location = 0){
function getFileUrl($path,$storage_type = 0,$location = 0,$file_cdn = 0){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = getFileUrl($v,$storage_type,$location);
$url[] = getFileUrl($v,$storage_type,$location,$file_cdn);
}
}else{
if(empty($path)){
... ... @@ -642,7 +662,7 @@ if (!function_exists('getFileUrl')) {
}
$file_type = pathinfo($path, PATHINFO_EXTENSION);
$fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
if(in_array(strtolower($file_type),$fileTypeArr)){
if(in_array(strtolower($file_type),$fileTypeArr) && ($file_cdn == 0)){
$cdn2 = config('filesystems.disks.cos')['cdn2'];
return $cdn2.$path;
}
... ...
... ... @@ -42,6 +42,7 @@ class PrivateController extends BaseController
->leftJoin('gl_domain_info as d', 'gl_project.id', '=', 'd.project_id')
->where('gl_project.type', Project::TYPE_TWO)
->where('gl_project.extend_type', 0) // 是否续费是由extend_type字段控制
->where('gl_project.delete_status', Project::IS_DEL_FALSE)
->where(function ($subQuery) {
$subQuery->orwhere('c.qa_status', OnlineCheck::STATUS_ONLINE_TRUE)->orwhere('gl_project.is_upgrade', Project::IS_UPGRADE_TRUE);
})
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Aside\Manage;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Requests\Aside\Manage\ManagerHrRequest;
use App\Models\Manage\ManageHr;
use App\Models\Manage\Menu;
use Illuminate\Http\Request;
... ... @@ -53,7 +54,8 @@ class HrController extends BaseController
* @method :post
* @time :2023/9/6 10:05
*/
public function save(HrLogic $logic){
public function save(ManagerHrRequest $request,HrLogic $logic){
$request->validated();
$logic->hrSave();
$this->response('success');
}
... ...
... ... @@ -417,9 +417,11 @@ class ProjectController extends BaseController
public function save(ProjectLogic $logic)
{
$this->request->validate([
'type'=>'required'
'type'=>'required',
'serve_id'=>'required',
],[
'type.required' => '类型不能为空'
'type.required' => '类型不能为空',
'serve_id.required' => '请选择服务器'
]);
$logic->projectSave();
$this->response('success');
... ...
... ... @@ -39,13 +39,6 @@ class ATemplateTypeController extends BaseController
* @time :2023/7/10 15:49
*/
public function save(ATemplateTypeRequest $ATemplateTypeRequest,ATemplateTypeLogic $ATemplateTypeLogic){
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
}
$ATemplateTypeRequest->validated();
$ATemplateTypeLogic->typeSave();
$this->response('success');
... ...
... ... @@ -90,6 +90,7 @@ class MonthReportController extends BaseController
$info['remain_day'] = $this->user['remain_day'];//剩余服务天数
$info['speed'] = round((0.3 + mt_rand()/mt_getrandmax() * (1-0.3)),2);
$info['month_total'] = (int)$info['month_total'];
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
... ... @@ -85,7 +85,7 @@ class CustomModuleContentController extends BaseController
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['video'])){
$v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location'],$this->user['file_cdn'] ?? 0);
$v['video']['video_image'] = getImageUrl($v['video']['video_image'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
return $this->success($v);
... ...
... ... @@ -133,11 +133,11 @@ class ProductController extends BaseController
}
}
if(!empty($v['video'])){
$v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location'],$this->user['file_cdn'] ?? 0);
$v['video']['video_image'] = getImageUrl($v['video']['video_image'] ?? '',$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['files']) && !empty($v['files']['url'])){
$v['files']['url'] = getFileUrl($v['files']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['files']['url'] = getFileUrl($v['files']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location'],$this->user['file_cdn'] ?? 0);
}
return $this->success($v);
}
... ... @@ -167,6 +167,29 @@ class ProductController extends BaseController
if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){
$query->where('created_at', '>=' ,$this->param['start_at'].' 00:00:00')->where('created_at', '<=' ,$this->param['end_at'].' 59:59:59');
}
$this->param['featured_status'] = $this->param['featured_status'] ?? 0;
if($this->param['featured_status'] != Category::STATUS_ACTIVE) {
$cateModel = new Category();
$featured_ids = $cateModel->where('title', 'like', 'Featured%')->pluck('id')->toArray();
if(!empty($featured_ids)){
$status = [];
if(isset($this->map['status'])){
$status = ['status'=>$this->map['status']];
}
$cateList = $cateModel->list($status,'id',['id','pid']);
//获取当前的子集
$featured_arr = [];
foreach ($featured_ids as $id){
$featured_arr = array_merge($featured_arr,array_unique(_get_all_sub($id,$cateList)));
}
if(!empty($featured_arr)){
$cateRelated = new CategoryRelated();
$product_ids = $cateRelated->whereIn('cate_id',$featured_arr)->pluck('product_id')->unique()->toArray();
$query = $query->whereNotIn('id',$product_ids);
}
}
}
return $query;
}
... ... @@ -356,9 +379,9 @@ class ProductController extends BaseController
foreach ($arr1 as $k1=>$v1){
$v1 = (array)$v1;
if(isset($v1['url'])){
$v1['url'] = getFileUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
$v1['url'] = getFileUrl($v1['url'],$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn'] ?? 0);
}else{
$v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location']);
$v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn'] ?? 0);
}
$arr1[$k1] = $v1;
}
... ... @@ -422,6 +445,11 @@ class ProductController extends BaseController
* @time :2023/8/21 18:33
*/
public function getStatusNumber(ProductLogic $logic){
$this->request->validate([
'featured_status'=>'numeric',
],[
'featured_status.numeric' => 'numeric为数字',
]);
$data = $logic->getStatusNumber();
$this->response('success',Code::SUCCESS,$data);
}
... ... @@ -536,10 +564,9 @@ class ProductController extends BaseController
$setNumModel = new SettingNum();
$info = $setNumModel->read(['type'=>$setNumModel::TYPE_PRODUCT_SORT]);
if($info === false){
$info = [];
}else{
$info['data'] = json_decode($info['data']);
$this->response('success');
}
$info['data'] = json_decode($info['data']);
$this->response('success',Code::SUCCESS,$info);
}
... ... @@ -580,4 +607,21 @@ class ProductController extends BaseController
}
$this->response('success',Code::SUCCESS,$productInfo);
}
/**
* @remark :搜索分类参数
* @name :searchCategory
* @author :lyh
* @method :post
* @time :2024/7/9 14:48
*/
public function getSearchCategoryList(ProductLogic $logic){
$this->request->validate([
'featured_status'=>'numeric',
],[
'featured_status.numeric' => 'numeric为数字',
]);
$data = $logic->getSearchCategoryList();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -342,7 +342,7 @@ class FileController
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$fileUrl = getFileUrl($info['path'],$info['is_cos']);
$fileUrl = getFileUrl($info['path'],$this->cache['storage_type'] ?? 0,$this->cache['project_location'] ?? 0,$this->cache['file_cdn'] ?? 0);
// 设置响应头
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
... ... @@ -392,7 +392,7 @@ class FileController
$fileModel = new File();
$lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at','name']);
foreach ($lists as $k => $v){
$v['file_link'] = getFileUrl($v['path'],$this->cache['storage_type'] ?? 0);
$v['file_link'] = getFileUrl($v['path'],$this->cache['storage_type'] ?? 0,$this->cache['project_location'] ?? 0,$this->cache['file_cdn'] ?? 0);
$lists[$k] = $v;
}
$this->response('success',Code::SUCCESS,$lists);
... ... @@ -408,7 +408,7 @@ class FileController
public function responseData($path, $name){
$data = [
'file'=>$path,
'file_link'=>getFileUrl($path,$this->cache['storage_type'] ?? 0),
'file_link'=>getFileUrl($path,$this->cache['storage_type'] ?? 0,$this->cache['project_location'] ?? 0,$this->cache['file_cdn'] ?? 0),
'name'=>$name,
'file_download'=>url('a/download_files?path='.$path)
];
... ...
... ... @@ -37,15 +37,6 @@ class BaseLogic extends Logic
*/
public function getParam(){
$requestAll = $this->request->all();
foreach ($requestAll as $k => $v){
if(is_array($v)){
continue;
}else{
if(empty($v) && ($v == null)){
unset($requestAll[$k]);
}
}
}
return $this->success($requestAll);
}
}
... ...
... ... @@ -39,7 +39,8 @@ class HrLogic extends BaseLogic
* @time :2023/9/6 10:17
*/
public function hrSave(){
//处理参数
$this->handleParam();
//处理参数
foreach ($this->model::specieField() as $v){
$this->param = $this->setJson($v,$this->param);
}
... ... @@ -52,6 +53,22 @@ class HrLogic extends BaseLogic
}
/**
* @remark :处理字段
* @name :handleParam
* @author :lyh
* @method :post
* @time :2024/7/10 16:32
*/
public function handleParam(){
$this->param['status'] = empty($this->param['status']) ? 1 : $this->param['status'];
$this->param['education'] = empty($this->param['education']) ? 1 : $this->param['education'];
$this->param['entry_position'] = empty($this->param['entry_position']) ? 1 : $this->param['entry_position'];
$this->param['p_level'] = empty($this->param['p_level']) ? 1 : $this->param['p_level'];
$this->param['dept_id'] = empty($this->param['dept_id']) ? 1 : $this->param['dept_id'];
$this->param['belong_group'] = empty($this->param['belong_group']) ? 1 : $this->param['belong_group'];
}
/**
* @remark :添加人事信息时 同步添加管理员账号
* @name :addManager
* @author :lyh
... ... @@ -75,10 +92,8 @@ class HrLogic extends BaseLogic
$managerModel = new Manage();
$this->param['manage_id'] = $managerModel->addReturnId($data);
$this->model->add($this->param);
//同步到B端演示项目
$this->syncBProjectUser($this->param['mobile'], $this->param['mobile'], $this->param['name'], $this->param['status']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -120,7 +135,7 @@ class HrLogic extends BaseLogic
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('系统错误,请联系管理员');
$this->fail('系统错误,请联系管理员'.$e->getMessage());
}
return $this->success();
}
... ...
... ... @@ -148,7 +148,7 @@ class ProjectLogic extends BaseLogic
//初始化项目
$this->createProjectData($this->param);
//双向绑定服务器,需放到保存项目的上方
$this->setServers($this->param['serve_id'] ?? 0,$this->param['id']);
$this->setServers($this->param['serve_id'],$this->param['id']);
//保存项目信息
$this->saveProject($this->param);
//保存建站部署信息
... ... @@ -177,6 +177,9 @@ class ProjectLogic extends BaseLogic
* @time :2024/6/25 15:34
*/
public function setServers($servers_id,$project_id){
if(empty($servers_id)){
return $this->success();
}
//查看當前項目服務器是否有更改
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$project_id],['serve_id']);
... ...
... ... @@ -16,18 +16,15 @@ class TaskOwnerLogic extends BaseLogic
public function __construct()
{
parent::__construct();
$this->model = new TaskOwner();
}
public function save($param){
//获取已分配了的
$manage_ids = $this->model->where('task_id', $param['task_id'])->pluck('manage_id', 'id')->toArray();
//待删除的
$del_manage_ids = array_diff($manage_ids, $param['manage_ids']);
$this->delete(array_keys($del_manage_ids));
//新增的
$add_manage_ids = array_diff($param['manage_ids'], $manage_ids);
foreach ($add_manage_ids as $add_manage_id){
... ...
... ... @@ -66,7 +66,7 @@ class AyrReleaseLogic extends BaseLogic
$arr[] = getImageUrl($v1);
}
}else{
$arr[] = getFileUrl($v);
$arr[] = getFileUrl($v,$this->user['storage_type'] ?? 0,$this->user['project_location'] ?? 0,$this->user['file_cdn'] ?? 0);
}
}
}
... ...
... ... @@ -709,7 +709,7 @@ class BTemplateLogic extends BaseLogic
}
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
$this->addUpdateNotify($type,$route);
return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
return $this->curlDelRoute(['old_route'=>$route,'new_route'=>$route]);
}
/**
... ...
... ... @@ -210,4 +210,5 @@ class BaseLogic extends Logic
];
return http_post($c_url, json_encode($param));
}
}
... ...
... ... @@ -179,16 +179,15 @@ class BlogLogic extends BaseLogic
public function paramProcessing($param){
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}
}else{
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}
}
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}else{
$param['category_id'] = '';
}
return $this->success($param);
}
... ... @@ -201,11 +200,8 @@ class BlogLogic extends BaseLogic
* @time :2023/10/20 9:02
*/
public function getCategory($category){
$str = '';
foreach ($category as $v){
$str .= $v.',';
}
return !empty(trim($str,',')) ? ','.$str.',' : '';
$str = implode(',',$category);
return !empty(trim(trim($str,','),',')) ? ','.$str.',' : '';
}
/**
... ...
... ... @@ -94,7 +94,7 @@ class CustomModuleContentLogic extends BaseLogic
}elseif($v['type'] == 4){
$arr1 = json_decode($info['values']);
foreach ($arr1 as $k1=>$v1){
$v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location']);
$v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn'] ?? 0);
$arr1[$k1] = $v1;
}
$v['values'] = $arr1;
... ...
... ... @@ -60,7 +60,7 @@ class CountLogic extends BaseLogic
public function scheme_info(){
$data = [
'company'=>$this->project['company'] ?? '',
'scheme'=>Project::planMap()[$this->project['deploy_build']['plan']],
'scheme'=>!empty($this->project['deploy_build']['plan']) ? Project::planMap()[$this->project['deploy_build']['plan']] : '',
'service_duration'=>$this->project['deploy_build']['service_duration'],
];
return $this->success($data);
... ...
... ... @@ -191,16 +191,15 @@ class NewsLogic extends BaseLogic
}
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}
}else{
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}
}
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}else{
$param['category_id'] = '';
}
return $this->success($param);
}
... ... @@ -213,11 +212,8 @@ class NewsLogic extends BaseLogic
* @time :2023/10/20 9:02
*/
public function getCategory($category){
$str = '';
foreach ($category as $v){
$str .= $v.',';
}
return !empty(trim($str,',')) ? ','.$str.',' : '';
$str = implode(',',$category);
return !empty(trim(trim($str,','),',')) ? ','.$str.',' : '';
}
/**
... ...
... ... @@ -334,22 +334,6 @@ class ProductLogic extends BaseLogic
/**
* @remark :编辑产品
* @name :editProduct
* @author :lyh
* @method :post
* @time :2023/9/7 10:02
*/
public function editProductRoute($id,$route){
$info = $this->model->read(['id'=>$id]);
if($info['route'] != $route){
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT,$route);
}
$this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
return $route;
}
/**
* @remark :删除数据
* @name :delete
* @author :lyh
... ... @@ -409,10 +393,32 @@ class ProductLogic extends BaseLogic
//三种状态 0:草稿 1:发布 2:回收站
$data = ['dra'=>0,'pub'=>1,'del'=>2,'tal'=>3];
foreach ($data as $k => $v){
$map = [];
$cateModel = new Category();
$status = [];
if($v != 3){
$status = ['status'=>$v];
}
$cateList = $cateModel->list($status,'id',['id','pid']);
$this->param['featured_status'] = $this->param['featured_status'] ?? 0;
if(!empty($cateList) && ($this->param['featured_status'] != $cateModel::STATUS_ACTIVE)){
$featured_ids = $cateModel->where('title', 'like', 'Featured%')->pluck('id')->toArray();
//获取当前的子集
$featured_arr = [];
foreach ($featured_ids as $id){
$featured_arr = array_merge($featured_arr,array_unique(_get_all_sub($id,$cateList)));
}
if(!empty($featured_arr)){
$cateRelated = new CategoryRelated();
$product_ids = $cateRelated->whereIn('cate_id',$featured_arr)->pluck('product_id')->unique()->toArray();
$map['id'] = ['not in',$product_ids];
}
}
if($v == 3){
$data[$k] = $this->model->where(['project_id'=>$this->user['project_id']])->count();
$data[$k] = $this->model->formatQuery($map)->count();
}else{
$data[$k] = $this->model->where(['status'=>$v,'project_id'=>$this->user['project_id']])->count();
$map['status'] = $v;
$data[$k] = $this->model->formatQuery($map)->count();
}
}
return $this->success($data);
... ... @@ -428,16 +434,51 @@ class ProductLogic extends BaseLogic
public function setCopyProduct(){
$info = $this->model->read(['id'=>$this->param['id']]);
$param = $this->setProductParams($info);
$save_id = $this->model->insertGetId($param);
$route = preg_replace('/-product.*/', '', $param['route']);
$route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $save_id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$save_id]);
//同步可视化装修数据
$this->copyTemplate($this->param['id'],$info['project_id'],$save_id);
DB::beginTransaction();
try {
$save_id = $this->model->insertGetId($param);
CategoryRelated::saveRelated($save_id, $info['category_id']);
$route = preg_replace('/-product.*/', '', $param['route']);
//同步分类关联表
$route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $save_id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$save_id]);
//同步可视化装修数据
$this->copyTemplate($this->param['id'],$info['project_id'],$save_id);
//同步扩展字段
$this->copyExtendInfo($info['id'],$save_id);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('复制失败,请联系管理员');
}
return $this->success(['id'=>$save_id]);
}
/**
* @remark :复制项目扩展字段
* @name :copyExtendInfo
* @author :lyh
* @method :post
* @time :2024/7/12 9:23
*/
public function copyExtendInfo($old_id,$new_id){
$extendInfoModel = new ExtendInfo();
$extendList = $extendInfoModel->list(['product_id'=>$old_id],'created_at');
if(!empty($extendList)){
$data = [];
foreach ($extendList as $k => $v){
unset($v['id']);
$v['product_id'] = $new_id;
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$data[] = $v;
}
return $extendList->insert($data);
}
return $this->success();
}
/**
* @remark :同步模版数据
* @name :copyTemplate
* @author :lyh
... ... @@ -847,4 +888,35 @@ class ProductLogic extends BaseLogic
}
return false;
}
/**
* @remark :产品列表搜索参数时分类列表
* @param :
* @name :getSearchCategoryList
* @author :lyh
* @method :post
* @time :2024/7/9 14:56
*/
public function getSearchCategoryList()
{
$data = [];
$categoryModel = new Category();
$this->param['deleted_at'] = null;
$this->param['featured_status'] = $this->param['featured_status'] ?? 0;
if(($this->param['featured_status'] != Category::STATUS_ACTIVE)) {
$this->param['title'] = ['not like','Featured%'];
}
unset($this->param['featured_status']);
$list = $categoryModel->list($this->param, ['sort', 'id'], ['id', 'pid', 'title']);
if (!empty($list)) {
foreach ($list as $v) {
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $list);
$data[] = $v;
}
}
}
return $this->success($data);
}
}
... ...
... ... @@ -80,6 +80,9 @@ class TranslateLogic extends BaseLogic
if(!empty($arr2)){
$i = 0;
TranslateText:
if($languageInfo['short'] == 'zh-ct'){
$languageInfo['short'] = 'zh-TW';
}
$translate_list = Translate::tran($arr2, $languageInfo['short']);
if(empty($translate_list)){
if ($i < 3) {
... ...
... ... @@ -279,6 +279,7 @@ class UserLoginLogic
$info['project_type'] = $project['type'];
$info['storage_type'] = $project['storage_type'];
$info['project_location'] = $project['project_location'];
$info['file_cdn'] = $project['deploy_build']['file_cdn'];
$info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0;
$info['remain_day'] = $project['remain_day'] ?? 0;
if($info['is_customized'] == 1){
... ...
<?php
/**
* @remark :
* @name :ManagerHrRequest.php
* @author :lyh
* @method :post
* @time :2024/7/10 15:59
*/
namespace App\Http\Requests\Aside\Manage;
use App\Models\Manage\Manage;
use App\Rules\Mobile;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ManagerHrRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name'=>'required',
'mobile'=>'required',
// 'status'=>'required',
// 'education'=>'required',
// 'entry_position'=>'required',
// 'p_level'=>'required',
// 'dept_id'=>'required',
// 'belong_group'=>'required',
];
}
public function messages()
{
return [
'name.required' => '名称不能为空',
'mobile.required' => '手机号码不能为空',
// 'status.required' => '请选择用户状态',
// 'education.required' => '请选择学历',
// 'entry_position.required' => '请选择入职岗位',
// 'belong_group.required' => '请选择小组',
// 'p_level.required' => '请选择入职岗位级别',
// 'dept_id.required' => '请选择部门',
];
}
}
... ...
... ... @@ -25,7 +25,7 @@ class NewsRequest extends FormRequest
{
return [
'name'=>'required|max:200',
// 'remark'=>'max:500',
'remark'=>'max:1000',
'url'=>'required',
];
}
... ... @@ -36,7 +36,7 @@ class NewsRequest extends FormRequest
'name.required'=>'请填写名称',
'name.max'=>'名称超过最长长度200',
'url.required'=>'链接不能为空',
// 'remark.max'=>'描述超过最长长度500'
'remark.max'=>'描述超过最长长度1000'
];
}
}
... ...
... ... @@ -175,18 +175,21 @@ class Base extends Model
$query->where($k, $v[0], $v[1]);
}
break;
case 'not like':
$query->where($k, $v[0], $v[1]);
break;
case 'in':
// in查询 ['id'=>['in',[1,2,3]]]
$query->whereIn($k, $v[1]);
break;
case 'or':
// in查询 ['id'=>['or',[1,2,3]]]
$query->orWhere($k, $v[1]);
break;
case 'not in':
// in查询 ['id'=>['not in',[1,2,3]]]
$query->whereNotIn($k, $v[1]);
break;
case 'or':
// in查询 ['id'=>['or',[1,2,3]]]
$query->orWhere($k, $v[1]);
break;
case 'between':
// in查询 ['id'=>['between',[create1,create2]]]
$query->whereBetween($k, $v[1]);
... ...
... ... @@ -169,7 +169,7 @@ return [
],
//操作日志
'operator_log' =>[
'log'=>false,//true开启
'log'=>true,//true开启
'action' => [],//不需要写入日志的方法
],
];
... ...
... ... @@ -255,6 +255,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/copyProduct', [\App\Http\Controllers\Bside\Product\ProductController::class, 'copyProduct'])->name('product_copyProduct');
Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\Product\ProductController::class, 'batchSetCategory'])->name('product_batchSetCategory');
Route::any('/sendAiProduct', [\App\Http\Controllers\Bside\Product\ProductController::class, 'sendAiProduct'])->name('product_sendAiProduct');
Route::any('/getSearchCategoryList', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getSearchCategoryList'])->name('product_getSearchCategoryList');
//产品分类
Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category');
Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info');
... ...