作者 刘锟

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

... ... @@ -22,13 +22,30 @@ class CustomModuleCategoryController extends BaseController
* @method :post
* @time :2023/12/4 15:43
*/
public function list(CustomModuleCategory $customModuleCategory){
public function lists(CustomModuleCategory $customModuleCategory){
$this->request->validate([
'module_id'=>['required'],
],[
'module_id.required' => 'module_id不能为空',
]);
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModuleCategory->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :添加/编辑分类时获取分类列表
* @name :getCateList
* @author :lyh
* @method :post
* @time :2023/12/5 17:11
*/
public function getCateList(CustomModuleCategoryLogic $logic){
$list = $logic->getCateList();
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :获取当前数据详情
* @name :info
* @author :lyh
... ... @@ -39,9 +56,9 @@ class CustomModuleCategoryController extends BaseController
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
'id.required' => '主键不能为空',
]);
$info = $logic->getCustomModuleCategoryInfo();
$info = $logic->categoryInfo();
$this->response('success',Code::SUCCESS,$info);
}
... ... @@ -53,7 +70,16 @@ class CustomModuleCategoryController extends BaseController
* @time :2023/12/4 15:45
*/
public function save(CustomModuleCategoryLogic $logic){
$logic->customModuleCategorySave();
$this->request->validate([
'name'=>['required'],
'route'=>['required'],
'module_id'=>['required']
],[
'name.required' => '分类名称不能为空',
'route.required' => '分类路由不能为空',
'module_id.required' => '所选模块id不能为空'
]);
$logic->categorySave();
$this->response('success');
}
... ... @@ -70,7 +96,7 @@ class CustomModuleCategoryController extends BaseController
],[
'id.required' => 'ID不能为空',
]);
$logic->customModuleCategoryDel();
$logic->categoryDel();
$this->response('success');
}
}
... ...
... ... @@ -22,7 +22,12 @@ class CustomModuleContentController extends BaseController
* @method :post
* @time :2023/12/4 15:43
*/
public function list(CustomModuleContent $customModuleContent){
public function lists(CustomModuleContent $customModuleContent){
$this->request->validate([
'module_id'=>['required'],
],[
'module_id.required' => 'module_id不能为空',
]);
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModuleContent->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
... ... @@ -53,6 +58,15 @@ class CustomModuleContentController extends BaseController
* @time :2023/12/4 15:45
*/
public function save(CustomModuleContentLogic $logic){
$this->request->validate([
'name'=>['required'],
'route'=>['required'],
'module_id'=>['required']
],[
'name.required' => '分类名称不能为空',
'route.required' => '分类路由不能为空',
'module_id.required' => '所选模块id不能为空'
]);
$logic->customModuleContentSave();
$this->response('success');
}
... ...
... ... @@ -30,7 +30,7 @@ class CustomModuleController extends BaseController
* @method :post
* @time :2023/12/4 15:43
*/
public function list(CustomModule $customModule){
public function lists(CustomModule $customModule){
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModule->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
... ... @@ -61,10 +61,22 @@ class CustomModuleController extends BaseController
* @time :2023/12/4 15:45
*/
public function save(CustomModuleLogic $logic){
$this->request->validate([
'name'=>['required'],
],[
'name.required' => '模块名称不能为空',
]);
$logic->customModuleSave();
$this->response('success');
}
/**
* @remark :删除
* @name :del
* @author :lyh
* @method :post
* @time :2023/12/5 9:53
*/
public function del(CustomModuleLogic $logic){
$this->request->validate([
'id'=>['required'],
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Inquiry;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Inquiry\InquiryLogic;
use App\Models\Inquiry\InquiryForm;
use App\Rules\Ids;
use App\Services\BatchExportService;
use Illuminate\Http\Request;
... ... @@ -20,9 +21,24 @@ use Illuminate\Support\Facades\Storage;
class InquiryController extends BaseController
{
public function form_list(){
$list = InquiryForm::where('is_default', 0)->get();
$data = $list->toArray();
foreach ($data as &$item){
$field_text = [];
foreach ($item['field'] as $v){
$field_text[$v] = InquiryForm::fieldMap($v);
}
$item['field_text'] = $field_text;
}
return $this->success($data);
}
public function index(InquiryLogic $logic)
{
if(($this->param['type']??'') == 'other'){
if(!empty($this->param['form_id'])){
$data = $logic->getFormDataList();
}elseif(($this->param['type']??'') == 'other'){
$data = $logic->getOtherList();
}else{
$data = $logic->getApiList();
... ... @@ -36,7 +52,10 @@ class InquiryController extends BaseController
],[
'id.required' => 'ID不能为空'
]);
if(($this->param['type']??'') == 'other'){
if(!empty($this->param['form_id'])){
$data = $logic->getFormDataInfo($this->param['id'], $this->param['form_id']);
}elseif(($this->param['type']??'') == 'other'){
$data = $logic->getOtherInfo($this->param['id']);
}else{
$data = $logic->getInfo($this->param['id']);
... ... @@ -52,7 +71,9 @@ class InquiryController extends BaseController
],[
'ids.required' => 'ID不能为空'
]);
if(($this->param['type']??'') == 'other'){
if(!empty($this->param['form_id'])){
$logic->deleteFormData($this->param['ids'], ['form_id' => $this->param['form_id']]);
}elseif(($this->param['type']??'') == 'other'){
$logic->deleteOther($this->param['ids']);
}else{
$logic->delete($this->param['ids']);
... ... @@ -71,13 +92,24 @@ class InquiryController extends BaseController
*/
public function export(InquiryLogic $logic)
{
if(($this->param['type']??'') == 'other'){
if(!empty($this->param['form_id'])){
$data = $logic->getFormDataList(true);
$field = InquiryForm::getField($this->param['form_id']);
$map = [
'submit_time' => '询盘发送时间',
];
foreach ($field as $v) {
$map[$v] = InquiryForm::fieldMap($v);
}
$map['ip_address'] = '访问国家/地区(IP)';
$map['refer'] = '发送页面';
}elseif(($this->param['type']??'') == 'other'){
$data = $logic->getOtherList(true);
$map = [
'submit_time' => '询盘发送时间',
'email' => '邮箱',
'ip_address' => '访问国家/地区(IP)',
'referer' => '发送页面',
'refer' => '发送页面',
];
}else{
$data = $logic->getApiList(true);
... ... @@ -95,6 +127,10 @@ class InquiryController extends BaseController
$data = $data['list'] ?? [];
foreach ($data as &$item){
$item['ip_address'] = "{$item['country']}({$item['ip']})";
if(!empty($this->param['form_id'])){
$item = array_merge($item, $item['data']);
}
}
//生成文件,发送到客户端
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Template;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BTemplateModuleLogic;
use App\Http\Logic\Bside\BTemplate\BTemplateModuleProjectLogic;
use App\Models\Template\BModuleProject;
/**
... ... @@ -22,15 +23,14 @@ class BTemplateModuleController extends BaseController
* @method :post
* @time :2023/6/29 11:33
*/
public function lists(BTemplateModuleLogic $BTemplateModuleLogic){
public function lists(BTemplateModuleLogic $bTemplateModuleLogic,BTemplateModuleProjectLogic $bTemplateModuleProjectLogic){
if(!isset($this->map['test_model'])){
$this->map['test_model'] = ['in',[0,1]];
}
$data = [];
$list = $BTemplateModuleLogic->ModuleList($this->map,$this->order);
$list = $bTemplateModuleLogic->ModuleList($this->map,$this->order);
$data['list'] = $list;
$moduleProjectModel = new BModuleProject();
$module_list = $moduleProjectModel->list(['project_id'=>$this->user['project_id']]);
$module_list = $bTemplateModuleProjectLogic->ModuleList(['project_id'=>$this->user['project_id']]);
$data['module_list'] = $module_list;
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -195,6 +195,9 @@ class ImageController extends Controller
//保存路径
$url = $this->config['root'].$this->path;
$image_type = $files->getClientOriginalExtension();
if(strlen($image_type) > 7){
$this->response('不支持当前格式',Code::SYSTEM_ERROR);
}
$fileName = uniqid().rand(10000,99999).'.'.$image_type;
//上传到cos
if($this->upload_location == 1){
... ...
... ... @@ -22,6 +22,19 @@ class BTemplateModuleProjectLogic extends BaseLogic
}
/**
* @remark :获取左侧模块列表
* @name :ModuleList
* @author :lyh
* @method :post
* @time :2023/6/29 13:35
*/
public function ModuleList($map,$order = 'created_at',$filed = ['id','name','sort','status','image','html']){
$map['status'] = 0;
$lists = $this->model->list($map,$order,$filed);
return $this->success($lists);
}
/**
* @remark :保存私有化左侧模块
* @name :moduleProjectSave
* @author :lyh
... ...
... ... @@ -284,46 +284,71 @@ class VisualizationLogic extends BaseLogic
$type = $this->getType($this->param['source'],$this->param['source_id']);
try {
if(in_array($type,$page_array)){//定制页面
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
'template_id'=>0
]);
if($templateInfo === false){
$this->param['project_id'] = $this->user['project_id'];
$this->param['template_id'] = 0;
$bTemplateModel->add($this->param);
}else{
$bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'template_id'=>0]);
}
$this->saveVisualizationHtml();
}else{
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
'template_id'=>$this->param['template_id'],
]);
$this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
$this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
//保存头部
$this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
if($templateInfo === false){
$this->param['project_id'] = $this->user['project_id'];
$bTemplateModel->add($this->param);
}else{
$bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
}
$this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']);
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
$this->saveTemplateHtml();
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :保存定制界面
* @name :saveVisualizationHtml
* @author :lyh
* @method :post
* @time :2023/12/5 15:42
*/
public function saveVisualizationHtml(){
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'], 'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'], 'template_id'=>0
]);
if($templateInfo === false){
$this->param['project_id'] = $this->user['project_id'];
$this->param['template_id'] = 0;
// $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
// $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$bTemplateModel->add($this->param);
}else{
// $param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
// $param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$param['html'] = $this->param['html'];
$bTemplateModel->edit($param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'template_id'=>0]);
}
return $this->success();
}
/**
* @remark :非定制界面保存数据
* @name :saveTemplateHtml
* @author :lyh
* @method :post
* @time :2023/12/5 15:44
*/
public function saveTemplateHtml(){
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
'template_id'=>$this->param['template_id'],
]);
$this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
$this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
//保存头部
$this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
if($templateInfo === false){
$this->param['project_id'] = $this->user['project_id'];
$bTemplateModel->add($this->param);
}else{
$bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
}
$this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']);
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
}
/**
... ...
... ... @@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\CustomModule;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\RouteMap\RouteMap;
class CustomModuleCategoryLogic extends BaseLogic
{
... ... @@ -22,14 +23,65 @@ class CustomModuleCategoryLogic extends BaseLogic
}
/**
* @remark :添加/编辑获取分类列表
* @name :getCateList
* @author :lyh
* @method :post
* @time :2023/12/5 17:12
*/
public function getCateList(){
$this->param['status'] = 0;
if(isset($this->param['id']) && !empty($this->param['id'])){
$str = [];
//排序掉当前id下所有子集
$str = $this->getAllSub($this->param['id'],$str);
$str[] = (int)$this->param['id'];
$this->param['id'] = ['not in',$str];
}
$menu = array();
$list = $this->model->list($this->param);
if(!empty($list)){
foreach ($list as $k => $v){
if($v['pid'] == 0){
$v['sub'] = _get_child($v['id'],$list);
$menu[] = $v;
}
}
}
return $this->success($menu);
}
/**
* @remark :获取当前id下所有子集
* @name :getAllSub
* @author :lyh
* @method :post
* @time :2023/10/18 15:10
*/
public function getAllSub($id,&$str = []){
$list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
$str[] = $v['id'];
$this->getAllSub($v['id'],$str);
}
}
return $str;
}
/**
* @remark :获取当前数据详情
* @name :getCustomModuleInfo
* @author :lyh
* @method :post
* @time :2023/12/4 16:10
*/
public function getCustomModuleCategoryInfo(){
public function categoryInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
return $this->success($info);
}
/**
... ... @@ -39,8 +91,97 @@ class CustomModuleCategoryLogic extends BaseLogic
* @method :post
* @time :2023/12/4 15:47
*/
public function customModuleCategorySave(){
public function categorySave(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->categoryEdit();
}else{
$this->categoryAdd();
}
return $this->success();
}
/**
* @remark :添加分类
* @name :categoryAdd
* @author :lyh
* @method :post
* @time :2023/12/5 10:55
*/
public function categoryAdd(){
try {
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
$this->edit(['url' => $route], ['id' => $id]);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :编辑分类
* @name :categoryEdit
* @author :lyh
* @method :post
* @time :2023/12/5 10:55
*/
public function categoryEdit(){
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $this->param['id'], $this->user['project_id']);
$this->editNewsRoute($this->param['id'],$route);
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请连续管理员');
}
return $this->success();
}
/**
* @remark :查看是否编辑路由
* @name :editCategoryRoute
* @author :lyh
* @method :post
* @time :2023/9/7 11:05
*/
public function editNewsRoute($id, $route)
{
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'route']);
if ($info['route'] != $route) {
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
$this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
}
return true;
}
/**
* @name :(添加分类时处理子集分类)addProcessingSon
* @author :lyh
* @method :post
* @time :2023/6/13 11:34
*/
public function addProcessingSon($cate_id){
if(isset($this->param['pid']) && !empty($this->param['pid'])) {
$this->param['pid'] = 0;
}
//判断为子分类时
if($this->param['pid'] != 0) {
//查看当前上级分类下是否有其他分类
$cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);
if ($cate_info === false) {
//查看当前上一级分类下是否有关联模块内容
$newsModel = new NewsModel();
$news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
if ($news_count > 0) {
$replacement = ',' . $cate_id . ',';
$old = ',' . $this->param['pid'] . ',';
//更新所有商品到当前分类
$newsModel->where('category_id', 'like', '%' . $old . '%')
->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
}
}
}
return $this->success();
}
/**
... ... @@ -50,7 +191,15 @@ class CustomModuleCategoryLogic extends BaseLogic
* @method :post
* @time :2023/12/4 15:47
*/
public function customModuleCategoryDel(){
public function categoryDel(){
$info = $this->model->read(['pid' => $this->param['id']], ['id', 'route']);
if($info === false){
$this->fail('当前分类拥有下级');
}
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('系统错误,请连续管理员');
}
return $this->success();
}
}
... ...
... ... @@ -29,7 +29,11 @@ class CustomModuleContentLogic extends BaseLogic
* @time :2023/12/4 16:10
*/
public function getCustomModuleContentInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
return $this->success($info);
}
/**
... ...
... ... @@ -11,6 +11,8 @@ namespace App\Http\Logic\Bside\CustomModule;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
class CustomModuleLogic extends BaseLogic
{
... ... @@ -29,7 +31,11 @@ class CustomModuleLogic extends BaseLogic
* @time :2023/12/4 16:10
*/
public function getCustomModuleInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
return $this->success($info);
}
/**
... ... @@ -40,7 +46,42 @@ class CustomModuleLogic extends BaseLogic
* @time :2023/12/4 15:47
*/
public function customModuleSave(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->moduleEdit();
}else{
$this->moduleAdd();
}
return $this->success();
}
/**
* @remark :新增
* @name :moduleAdd
* @author :lyh
* @method :post
* @time :2023/12/5 9:39
*/
public function moduleAdd(){
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :编辑
* @name :moduleEdit
* @author :lyh
* @method :post
* @time :2023/12/5 9:39
*/
public function moduleEdit(){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
... ... @@ -51,6 +92,21 @@ class CustomModuleLogic extends BaseLogic
* @time :2023/12/4 15:47
*/
public function customModuleDel(){
//查看当前模块是否拥有数据
$contentModel = new CustomModuleContent();
$contentInfo = $contentModel->read(['module_id'=>$this->param['id']],['id']);
if($contentInfo !== false){
$this->fail('当前模块拥有内容不允许删除');
}
$categoryModel = new CustomModuleCategory();
$categoryInfo = $categoryModel->read(['module_id'=>$this->param['id']],['id']);
if($categoryInfo !== false){
$this->fail('当前模块拥有分类不允许删除');
}
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
}
... ...
... ... @@ -8,8 +8,9 @@ use App\Helper\Translate;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryForm;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Inquiry\InquiryOther;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
/**
... ... @@ -68,7 +69,6 @@ class InquiryLogic extends BaseLogic
if($search){
$map['email'] = ['like','%'.$search.'%'];
}
ProjectServer::useProject($this->user['project_id']);
$data = (new InquiryOther())->lists($map,$page,$page_size,'id',
['id', 'email', 'ip', 'country', 'domain', DB::raw('referer as refer'), DB::raw('status as read_status'), 'submit_time']
... ... @@ -77,6 +77,27 @@ class InquiryLogic extends BaseLogic
return $this->success($data);
}
public function getFormDataList($export = false){
$page_size = $export ? 1000 : 20;
$search = $this->request['search'] ?: '';
$page = $this->request['page'] ?: 1;
$form_id = $this->request['form_id'] ?? '';
$field = InquiryForm::getField($form_id);
$map = [
'form_id' => $form_id
];
if($search){
foreach ($field as $v){
$map['data->' . $v] = $search;
}
}
$fields = ['id', 'data', 'ip', 'country', 'domain', DB::raw('referer as refer'), DB::raw('status as read_status'), DB::raw('submit_at as submit_time')];
$lists = InquiryFormData::select($fields)->orderBy('id')->paginate($page_size, ['*'], 'page', $page);
$data = $lists->toArray();
return $this->success($data);
}
public function getInfo($id)
{
$project = (new ProjectLogic())->getProjectInfo($this->user['project_id']);
... ... @@ -93,10 +114,22 @@ class InquiryLogic extends BaseLogic
return $this->success(['trans_message' => $trans_message]);
}
public function getFormDataInfo($id, $form_id){
//修改状态为已读
if($this->request['read_status']){
(new InquiryFormData())->edit(['status' => 1], ['id' => $id, 'form_id' => $form_id]);
}
//翻译
$trans_message = '';
if($this->request['message']){
$trans_message = Translate::tran($this->request['message'], 'zh');
}
return $this->success(['trans_message' => $trans_message]);
}
public function getOtherInfo($id){
//修改状态为已读
if($this->request['read_status']){
ProjectServer::useProject($this->user['project_id']);
(new InquiryOther())->edit(['status' => 1], ['id' => $id]);
}
return $this->success(['trans_message' => '']);
... ... @@ -120,11 +153,21 @@ class InquiryLogic extends BaseLogic
if(!$ids){
$this->fail('ID不能为空');
}
ProjectServer::useProject($this->user['project_id']);
(new InquiryOther())->del(['id'=>['in',$ids]]);
return $this->success();
}
public function deleteFormData($ids, $map = [])
{
$ids = array_filter(Arr::splitFilterToArray($ids), 'intval');
if(!$ids){
$this->fail('ID不能为空');
}
$map['id'] = ['in',$ids];
(new InquiryFormData())->del($map);
return $this->success();
}
}
... ...
... ... @@ -14,4 +14,6 @@ use App\Models\Base;
class CustomModule extends Base
{
protected $table = 'gl_custom_module';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -14,4 +14,6 @@ use App\Models\Base;
class CustomModuleCategory extends Base
{
protected $table = 'gl_custom_module_category';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -14,4 +14,6 @@ use App\Models\Base;
class CustomModuleContent extends Base
{
protected $table = 'gl_custom_module_content';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -14,4 +14,6 @@ use App\Models\Base;
class CustomModuleExtend extends Base
{
protected $table = 'gl_custom_module_extent';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
<?php
namespace App\Models\Inquiry;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Cache;
/**
* Class InquiryForm
* @package App\Models\Inquiry
* @author zbj
* @date 2023/12/5
*/
class InquiryForm extends Base
{
use SoftDeletes;
//设置关联表名
/**
* @var mixed
*/
protected $connection = "custom_mysql";
protected $table = 'gl_inquiry_form';
/**
* 预设字段名称
* @author zbj
* @date 2023/12/5
*/
public static function fieldMap($field = ''){
$map = [
'name' => '姓名',
'email' => '邮箱',
'phone' => '电话',
'mobile' => '电话',
'message' => '询盘内容',
'company' => '公司名称'
];
if($field){
return $map[$field] ?? $field;
}
return $map;
}
public function getFieldAttribute($value)
{
return json_decode($value, true);
}
/**
* @author zbj
* @date 2023/12/5
*/
public static function getField($form_id){
$cache_key = 'inquiry_form_field_' . $form_id;
$field = Cache::get($cache_key);
if(!$field){
$field = self::where('id', $form_id)->value('field');
$field && Cache::set($cache_key, $field, 3600);
}
return $field;
}
}
... ...
<?php
namespace App\Models\Inquiry;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class InquiryFormData
* @package App\Models\Inquiry
* @author zbj
* @date 2023/12/4
*/
class InquiryFormData extends Base
{
use SoftDeletes;
//设置关联表名
/**
* @var mixed
*/
protected $connection = "custom_mysql";
protected $table = 'gl_inquiry_form_data';
public function getDataAttribute($value)
{
return json_decode($value, true);
}
}
... ...
... ... @@ -38,6 +38,11 @@ class RouteMap extends Base
const SOURCE_NAV = 'nav';
//自定义模块
const SOURCE_MODULE = 'module_';
//自定义模块分类
const SOURCE_MODULE_CATE = 'module_cate_';
/**
* 生成路由标识
* @param $title
... ... @@ -78,9 +83,17 @@ class RouteMap extends Base
if(in_array($route, $fixed)){
return true;
}
$path = '';
if($source == self::SOURCE_NEWS){
$path = self::SOURCE_NEWS;
}elseif ($source == self::SOURCE_BLOG){
$path = self::SOURCE_BLOG.'s';
}
$where = [
'project_id' => $project_id,
'route' => $route,
'path' => $path,
];
$route = self::where($where)->first();
if($route){
... ...
... ... @@ -271,6 +271,7 @@ Route::middleware(['bloginauth'])->group(function () {
//精准询盘
Route::prefix('inquiry')->group(function () {
Route::get('/', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'index'])->name('inquiry');
Route::get('/form_list', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'form_list'])->name('inquiry_form_list');
Route::get('/info', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'info'])->name('inquiry_info');
Route::any('/delete', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'delete'])->name('inquiry_delete');
Route::any('/export', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'export'])->name('inquiry_export');
... ... @@ -422,6 +423,28 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('language')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\LanguageController::class, 'lists'])->name('language_lists');
});
//自定义模板
Route::prefix('custom')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists');
Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save');
Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del');
Route::prefix('category')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'lists'])->name('custom_category_lists');
Route::any('/getCateList', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'getCateList'])->name('custom_category_getCateList');
Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'info'])->name('custom_category_info');
Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'save'])->name('custom_category_save');
Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'del'])->name('custom_category_del');
});
Route::prefix('content')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'lists'])->name('custom_content_lists');
Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'info'])->name('custom_content_info');
Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_content_save');
Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del');
});
});
});
//无需登录验证的路由组
Route::group([], function () {
... ...