作者 赵彬吉
... ... @@ -69,7 +69,7 @@ class ProjectImport extends Command
$task->status = ImportTask::STATUS_COM;//导入完成
$task->save();
$this->send_mail($task->user_id, $task->created_at, $task->type, 0, 0, '文件编码格式错误,仅支持UTF-8和GBK编码格式');
$this->send_mail($task->user_id, $task->created_at, $task->type, 0, 0, 0, '文件编码格式错误,仅支持UTF-8和GBK编码格式');
return true;
} elseif ($file_code_type === 'GBK') {
$is_gbk = 1;
... ... @@ -89,13 +89,15 @@ class ProjectImport extends Command
$task->status = ImportTask::STATUS_COM;//导入完成
$task->save();
$this->send_mail($task->user_id, $task->created_at, $task->type, 0, 0, '读取文件数据失败');
$this->send_mail($task->user_id, $task->created_at, $task->type, 0, 0, 0, '读取文件数据失败');
return true;
}
$total_count = 0; //总条数
$success_count = 0; //成功导入条数
$repeat_count = 0; //过滤已存在条数
$fail_count = 0;
$fail_line = [];
if (count($line_of_text) > 1) {
//设置数据库
... ... @@ -132,6 +134,8 @@ class ProjectImport extends Command
}
}
} catch (\Exception $e) {
$fail_count += 1;
$fail_line[] = $k + 1;
echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', title: ' . $v[0] . ', import fail, error: ' . $e->getMessage() . PHP_EOL;
}
}
... ... @@ -146,7 +150,7 @@ class ProjectImport extends Command
$task->success_count += $success_count;
$task->save();
$this->send_mail($task->user_id, $task->created_at, $task->type, $success_count, $repeat_count, '');
$this->send_mail($task->user_id, $task->created_at, $task->type, $success_count, $fail_count, $repeat_count, '', $fail_line);
echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import end, total count: ' . $total_count . ', success count: ' . $success_count . PHP_EOL;
... ... @@ -190,7 +194,7 @@ class ProjectImport extends Command
}
//发送站内通知
protected function send_mail($user_list, $time, $type, $success_count, $repeat_count, $reason)
protected function send_mail($user_list, $time, $type, $success_count, $repeat_count, $fail_count, $reason, $fail_line = [])
{
if ($type == ImportTask::TYPE_NEWS) {
$type_content = '新闻';
... ... @@ -202,7 +206,9 @@ class ProjectImport extends Command
$title = '导入结果通知';
$content = '您于 ' . $time . ' 添加的 ' . $type_content . ' 导入任务已执行完成, 成功导入数据:' . $success_count . ' 条';
$repeat_count && $content .= ',过滤已存在数据:' . $repeat_count . ' 条';
$fail_count && $content .= ',导入失败:' . $fail_count . ' 条';
$reason && $content .= ',原因:' . $reason;
$fail_line && $content .= ',失败行数:' . implode(',', $fail_line);
$mail_model = new Mail();
$mail_model->add([
... ...
... ... @@ -36,7 +36,7 @@ class OptimizeController extends BaseController
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id');
$query = $this->searchParam($query)->orderBy('gl_project_deploy_optimize.start_date','desc')->orderBy('gl_project_deploy_optimize.id','desc');
$query = $this->searchParam($query)->orderBy('gl_project_deploy_optimize.start_date','asc')->orderBy('gl_project_deploy_optimize.id','desc');
$lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
if(!empty($lists) && !empty($lists['list'])){
$rankDataModel = new RankData();
... ...
... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Template\ATemplateLogic;
use App\Http\Requests\Aside\Template\ATemplateRequest;
use App\Models\Template\Setting;
/**
* @remark :A端主题模板管理
... ... @@ -35,6 +36,23 @@ class ATemplateController extends BaseController
}
/**
* @remark :获取选择的模版
* @name :getTemplateInfo
* @author :lyh
* @method :post
* @time :2023/11/3 17:19
*/
public function getSettingInfo(ATemplateLogic $aTemplateLogic){
$this->request->validate([
'project_id'=>'required'
],[
'project_id.required' => 'project_id不能为空'
]);
$info = $aTemplateLogic->getSettingInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :获取数据详情
* @name :read
* @author :lyh
... ...
... ... @@ -33,6 +33,7 @@ class BTemplateLogController extends BaseController
* @time :2023/8/23 11:05
*/
public function lists(BTemplateLog $bTemplateLog){
unset($this->map['template_id']);
$this->map['project_id'] = $this->user['project_id'];
$this->map['source'] = 1;
$lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']);
... ...
... ... @@ -185,4 +185,21 @@ class ATemplateLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :获取选择的模版
* @name :getSettingInfo
* @author :lyh
* @method :post
* @time :2023/11/3 17:21
*/
public function getSettingInfo(){
$data = [];
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->param['project_id']],['template_id']);
if($info !== false){
$data = $this->model->read(['id'=>$info['template_id']],['id','name']);
}
return $this->success($data);
}
}
... ...
... ... @@ -14,6 +14,7 @@ use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateLog;
use App\Models\Template\Setting;
class BTemplateLogLogic extends BaseLogic
{
... ... @@ -42,17 +43,26 @@ class BTemplateLogLogic extends BaseLogic
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){
$this->fail('演示项目仅支持演示功能,无法更改首页');
}
//获取当前项目的模版
$bSettingModel = new Setting();
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($settingInfo === false){
$this->fail('请先选择模版');
}
//切换模版
if($info['template_id'] != $settingInfo['template_id']){
$bSettingModel->edit(['template_id'=>$info['template_id']],['id'=>$settingInfo['id']]);
}
try {
$data = $this->setParam($info);
$BTemplateModel = new BTemplate();
$BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
$commonData = $this->setCommonParam($info);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
//同步更新公共头和底
return $this->success();
}
... ... @@ -65,13 +75,8 @@ class BTemplateLogLogic extends BaseLogic
*/
public function setParam($info){
$data = [
'html'=>$info['text'],
'head_html'=>$info['head_html'],
'head_css'=>$info['head_css'],
'main_html'=>$info['main_html'],
'main_css'=>$info['main_css'],
'footer_html'=>$info['footer_html'],
'footer_css'=>$info['footer_css'],
];
return $this->success($data);
}
... ...
... ... @@ -268,11 +268,11 @@ class BTemplateLogic extends BaseLogic
$this->param = $this->stringProcessing($this->param);
//保存头部信息
$this->saveCommonTemplate($this->param);
$this->param = $this->templateSaveParam($this->param);//组装数据
$param = $this->templateSaveParam($this->param);//组装数据
if($info === false){
$this->model->add($this->param);
$this->model->add($param);
}else{
$this->model->edit($this->param,['id'=>$info['id']]);
$this->model->edit($param,['id'=>$info['id']]);
}
//写入操作模版记录
$this->setTemplateLog($this->param);
... ... @@ -302,8 +302,8 @@ class BTemplateLogic extends BaseLogic
'head_css'=>$param['head_css'],
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
];
$other = str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
if($info === false){
$data['template_id'] = $param['template_id'];
$data['project_id'] = $this->user['project_id'];
... ... @@ -312,6 +312,8 @@ class BTemplateLogic extends BaseLogic
}else{
$templateCommonModel->edit($data,['id'=>$info['id']]);
}
//更新所有界面的other
$templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]);
return $this->success();
}
... ... @@ -413,7 +415,7 @@ class BTemplateLogic extends BaseLogic
public function templateSaveParam($param){
$param['project_id'] = $this->user['project_id'];
$param['html'] = $param['main_html'];
// unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
return $this->success($param);
}
... ...
... ... @@ -122,8 +122,8 @@ class CustomTemplateLogic extends BaseLogic
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")),
];
$other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"));
if($info === false){
$data['template_id'] = $bSettingInfo['template_id'];
$data['project_id'] = $this->user['project_id'];
... ... @@ -132,6 +132,8 @@ class CustomTemplateLogic extends BaseLogic
}else{
$templateCommonModel->edit($data,['id'=>$info['id']]);
}
//更新所有界面的other
$templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]);
return $this->success();
}
... ...
... ... @@ -354,7 +354,25 @@ class BlogCategoryLogic extends BaseLogic
}
$return[] = $c_id;
}
return ','.implode(',',$return).',';
return $this->getLastCategory($return);
}
/**
* @remark :获取最后一级分类id
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategory($category){
$str = '';
foreach ($category as $v){
$info = $this->model->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
}
return ','.$str;
}
/**
... ...
... ... @@ -295,7 +295,7 @@ class BlogLogic extends BaseLogic
]
);
//更新路由
$route = RouteMap::setRoute($data[1] ?: $data[0], RouteMap::SOURCE_BLOG, $id, $project_id);
$route = RouteMap::setRoute($data[0], RouteMap::SOURCE_BLOG, $id, $project_id);
$this->edit(['url' => $route], ['id' => $id]);
return true;
... ...
... ... @@ -336,7 +336,25 @@ class NewsCategoryLogic extends BaseLogic
}
$return[] = $c_id;
}
return ','.implode(',',$return).',';
return $this->getLastCategory($return);
}
/**
* @remark :获取最后一级分类id
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategory($category){
$str = '';
foreach ($category as $v){
$info = $this->model->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
}
return ','.$str;
}
/**
... ...
... ... @@ -59,8 +59,8 @@ class NewsLogic extends BaseLogic
public function newsSave()
{
//拼接参数
// DB::beginTransaction();
// try {
DB::beginTransaction();
try {
$this->param = $this->paramProcessing($this->param);
if (isset($this->param['id']) && !empty($this->param['id'])) {
//是否更新路由
... ... @@ -72,11 +72,11 @@ class NewsLogic extends BaseLogic
//更新路由
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
$this->edit(['url' => $route], ['id' => $id]);
// DB::commit();
// } catch (\Exception $e) {
// DB::rollBack();
// $this->fail('系统错误,请联系管理员');
// }
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
$this->fail('系统错误,请联系管理员');
}
//通知更新
$this->updateNotify(['project_id' => $this->user['project_id'], 'type' => RouteMap::SOURCE_NEWS, 'route' => $route]);
return $this->success();
... ... @@ -331,7 +331,7 @@ class NewsLogic extends BaseLogic
]
);
//更新路由
$route = RouteMap::setRoute($data[1] ?: $data[0], RouteMap::SOURCE_NEWS, $id, $project_id);
$route = RouteMap::setRoute($data[0], RouteMap::SOURCE_NEWS, $id, $project_id);
$this->edit(['url' => $route], ['id' => $id]);
return true;
... ...
... ... @@ -319,10 +319,29 @@ class CategoryLogic extends BaseLogic
}
$return[] = $c_id;
}
//清除缓存
Common::del_user_cache('product_category',$project_id);
return ','.implode(',',$return).',';
return $this->getLastCategory($return);
}
/**
* @remark :获取最后一级分类id
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategory($category){
$str = '';
if(isset($category) && !empty($category)){
foreach ($category as $v){
$info = $this->model->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
}
}
return ','.$str;
}
/**
... ...
... ... @@ -549,7 +549,7 @@ class ProductLogic extends BaseLogic
]
);
//更新路由
$route = RouteMap::setRoute($data[1] ?: $data[0], RouteMap::SOURCE_PRODUCT, $id, $project_id);
$route = RouteMap::setRoute($data[0], RouteMap::SOURCE_PRODUCT, $id, $project_id);
$this->edit(['route' => $route], ['id' => $id]);
return true;
... ...
... ... @@ -115,14 +115,12 @@ class UserLoginLogic
$this->fail('该项目未找到注册账号');
}
$info = $this->autoAssembleParam($has_user);
if(!Cache::get($info['token'])){
//生成新token
$token = md5(uniqid().$info['id']);
//存储缓存
$info['token'] = $token;
$info['manager_id'] = $data['manager_id'];//代表自动登录写入日志
Cache::add($token,$info,3600 * 12);
}
//生成新token
$token = md5(uniqid().$info['id']);
//存储缓存
$info['token'] = $token;
$info['manager_id'] = $data['manager_id'];//代表自动登录写入日志
Cache::add($token,$info,3600 * 12);
Common::set_user_login(['user_id'=>$info['id'],'ip'=>request()->ip(),
'project_id'=>$info['project_id'], 'type'=>1 ,'remark' => '自动登录,操作管理员为:'.$data['manager_id']]);
return $info;
... ...
... ... @@ -293,6 +293,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::prefix('template')->group(function () {
Route::any('/', [Aside\Template\ATemplateController::class, 'lists'])->name('admin.ATemplate_lists');
Route::any('/read', [Aside\Template\ATemplateController::class, 'read'])->name('admin.ATemplate_read');
Route::any('/getSettingInfo', [Aside\Template\ATemplateController::class, 'getSettingInfo'])->name('admin.ATemplate_getSettingInfo');
Route::any('/save', [Aside\Template\ATemplateController::class, 'save'])->name('admin.ATemplate_save');
Route::any('/status', [Aside\Template\ATemplateController::class, 'status'])->name('admin.ATemplate_status');
Route::any('/del', [Aside\Template\ATemplateController::class, 'del'])->name('admin.ATemplate_del');
... ...