|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :TicketUploadDataLogic.php
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/25 14:03
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Logic\Aside\Ticket;
|
|
|
|
|
|
|
|
use App\Helper\Arr;
|
|
|
|
use App\Http\Logic\Aside\BaseLogic;
|
|
|
|
use App\Models\Blog\Blog;
|
|
|
|
use App\Models\Blog\BlogCategory;
|
|
|
|
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\KeywordRelated;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Ticket\TicketUploadData;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class TicketUploadDataLogic extends BaseLogic
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->param = $this->requestAll;
|
|
|
|
$this->model = new TicketUploadData();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取审核列表
|
|
|
|
* @name :getDataList
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/25 14:17
|
|
|
|
*/
|
|
|
|
public function getDataList($map = [],$page = 1,$row = 20,$order = 'id'){
|
|
|
|
if(isset($this->map['text']) && !empty($this->map['text'])){
|
|
|
|
$this->map['text'] = ['like','%'.$this->map['text'].'%'];
|
|
|
|
}
|
|
|
|
ProjectServer::useProject($map['project_id']);
|
|
|
|
$data = $this->model->lists($map,$page,$row,$order);
|
|
|
|
if(!empty($data) && !empty($data['list'])){
|
|
|
|
foreach ($data['list'] as &$v){
|
|
|
|
$v = $this->getHandleFileImage($v);
|
|
|
|
$v['text']['cate_name'] = $this->cateText($v['type'],$v['text']['category_id'] ?? []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理数据
|
|
|
|
* @name :getHandleFileImage
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/25 16:53
|
|
|
|
*/
|
|
|
|
public function getHandleFileImage($v){
|
|
|
|
if($v['type'] == 1){
|
|
|
|
if(!empty($v['text']['image'])){
|
|
|
|
foreach ($v['text']['image'] as $gallery_k => $gallery_v){
|
|
|
|
$gallery_v['url'] = getImageUrl($gallery_v['url']);
|
|
|
|
$v['text']['image'][$gallery_k] = $gallery_v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(isset($v['text']['image']) && !empty($v['text']['image'])){
|
|
|
|
$v['text']['image'] = getImageUrl($v['text']['image']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取分类名称
|
|
|
|
* @name :cateText
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/29 17:18
|
|
|
|
*/
|
|
|
|
public function cateText($type,$category_id = [],$keyword_id = [],$is_array = false)
|
|
|
|
{
|
|
|
|
if(empty($category_id)){
|
|
|
|
return '';
|
|
|
|
}else{
|
|
|
|
$filed = 'name';
|
|
|
|
if($type == 1){
|
|
|
|
$cateModel = new Category();
|
|
|
|
$keywodModel = new KeyWord();
|
|
|
|
$filed = 'title';
|
|
|
|
}elseif ($type == 2){
|
|
|
|
$cateModel = new BlogCategory();
|
|
|
|
}else{
|
|
|
|
$cateModel = new NewsCategory();
|
|
|
|
}
|
|
|
|
if($is_array){
|
|
|
|
$cate_arr = $cateModel->whereIn('id', (array)$category_id)
|
|
|
|
->pluck($filed, 'id')
|
|
|
|
->toArray();
|
|
|
|
if($type == 1){
|
|
|
|
$keywod_arr = $keywodModel->whereIn('id', (array)$keyword_id)
|
|
|
|
->pluck($filed, 'id')
|
|
|
|
->toArray();
|
|
|
|
return ['keywod_arr' => $keywod_arr, 'cate_arr' => $cate_arr];
|
|
|
|
}
|
|
|
|
return ['cate_arr' => $cate_arr];
|
|
|
|
}else{
|
|
|
|
$cateArr = $cateModel->selectField(['id'=>['in',$category_id]],$filed);
|
|
|
|
return implode(',',$cateArr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取当前数据详情
|
|
|
|
* @name :getDetail
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/26 09:31
|
|
|
|
*/
|
|
|
|
public function getDetail(){
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前数据不存在或已被删除');
|
|
|
|
}
|
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
$info['text']['cate_name'] = $this->cateText($info['type'],$info['text']['category_id'] ?? [],$info['text']['keyword_id'] ?? [],true);
|
|
|
|
$info = $this->getHandleFileImage($info);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
return $this->success($info);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存数据
|
|
|
|
* @name :saveData
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/25 17:01
|
|
|
|
*/
|
|
|
|
public function saveData()
|
|
|
|
{
|
|
|
|
//获取当前数据详情
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前数据不存在或已被删除');
|
|
|
|
}
|
|
|
|
//审核成功执行
|
|
|
|
if($this->param['status'] == 1){
|
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
if($info['type'] == 1){
|
|
|
|
$this->saveProductData($info);
|
|
|
|
}elseif ($info['type'] == 2){
|
|
|
|
$this->saveBlogData($info);
|
|
|
|
}else{
|
|
|
|
$this->saveNewsData($info);
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
$data = $this->model->edit(['status'=>$this->param['status'],'operator_id'=>$this->manager['id'],'remark'=>$this->param['remark'] ?? ''],['id'=>$this->param['id']]);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存数据详情
|
|
|
|
* @name :saveData
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/25 14:17
|
|
|
|
*/
|
|
|
|
public function saveProductData($info){
|
|
|
|
if(isset($info['text']['keyword_id']) && !empty($info['text']['keyword_id'])){
|
|
|
|
$keyword_id = ','.Arr::arrToSet($info['text']['keyword_id']).',';
|
|
|
|
}
|
|
|
|
if(isset($info['text']['category_id']) && !empty($info['text']['category_id'])) {
|
|
|
|
$category_id = ','.Arr::arrToSet($info['text']['category_id']).',';
|
|
|
|
}
|
|
|
|
if(isset($info['text']['image']) && !empty($info['text']['image'])){
|
|
|
|
foreach ($info['text']['image'] as $k => $v){
|
|
|
|
$v['url'] = str_replace_url($v['url']);
|
|
|
|
$info['text']['image'][$k] = $v;
|
|
|
|
}
|
|
|
|
$thumb = Arr::a2s($info['text']['image'][0] ?? []);
|
|
|
|
$info['text']['image'] = Arr::a2s($info['text']['image'] ?? []);
|
|
|
|
}else{
|
|
|
|
$thumb = $info['text']['image'] = Arr::a2s([]);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$productModel = new Product();
|
|
|
|
$data = [
|
|
|
|
'project_id' => $info['project_id'],
|
|
|
|
'title' => $info['text']['title'],
|
|
|
|
'thumb'=>$thumb,
|
|
|
|
'gallery'=>$info['text']['image'] ?? [],
|
|
|
|
'intro'=>$info['text']['remark'],
|
|
|
|
'category_id'=>$category_id ?? '',
|
|
|
|
'keyword_id'=>$keyword_id ?? '',
|
|
|
|
'status'=>0,
|
|
|
|
];
|
|
|
|
$id = $productModel->addReturnId($data);
|
|
|
|
CategoryRelated::saveRelated($id, $info['text']['category_id'] ?? []);//分类关联
|
|
|
|
KeywordRelated::saveRelated($id,$info['text']['keyword_id'] ?? []);//关键字关联
|
|
|
|
$route = RouteMap::setRoute($data['title'],RouteMap::SOURCE_PRODUCT,$id,$info['project_id']);
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存blog数据
|
|
|
|
* @name :saveBlogData
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/25 16:26
|
|
|
|
*/
|
|
|
|
public function saveBlogData($info)
|
|
|
|
{
|
|
|
|
if(isset($info['text']['category_id']) && !empty($info['text']['category_id'])) {
|
|
|
|
$category_id = ','.Arr::arrToSet($info['text']['category_id']).',';
|
|
|
|
}
|
|
|
|
if(isset($info['text']['image'])){
|
|
|
|
$info['text']['image'] = str_replace_url($info['text']['image'] ?? '');
|
|
|
|
}
|
|
|
|
$data = [
|
|
|
|
'project_id' => $info['project_id'],
|
|
|
|
'name' => $info['text']['title'],
|
|
|
|
'image'=>$info['text']['image'],
|
|
|
|
'text'=>$info['text']['remark'],
|
|
|
|
'category_id'=>$category_id ?? '',
|
|
|
|
'status'=>0,
|
|
|
|
];
|
|
|
|
try {
|
|
|
|
$blogModel = new Blog();
|
|
|
|
$id = $blogModel->addReturnId($data);
|
|
|
|
$route = RouteMap::setRoute($data['name'],RouteMap::SOURCE_BLOG,$id,$info['project_id']);
|
|
|
|
$this->model->edit(['url'=>$route],['id'=>$id]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存新闻数据
|
|
|
|
* @name :saveNewsData
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/25 16:34
|
|
|
|
*/
|
|
|
|
public function saveNewsData($info)
|
|
|
|
{
|
|
|
|
if(isset($info['text']['category_id']) && !empty($info['text']['category_id'])) {
|
|
|
|
$category_id = ','.Arr::arrToSet($info['text']['category_id']).',';
|
|
|
|
}
|
|
|
|
if(isset($info['text']['image'])){
|
|
|
|
$info['text']['image'] = str_replace_url($info['text']['image'] ?? '');
|
|
|
|
}
|
|
|
|
$data = [
|
|
|
|
'project_id' => $info['project_id'],
|
|
|
|
'name' => $info['text']['title'],
|
|
|
|
'image'=>$info['text']['image'],
|
|
|
|
'text'=>$info['text']['remark'],
|
|
|
|
'category_id'=>$category_id ?? '',
|
|
|
|
'status'=>0,
|
|
|
|
];
|
|
|
|
try {
|
|
|
|
$newsModel = new News();
|
|
|
|
$id = $newsModel->addReturnId($data);
|
|
|
|
$route = RouteMap::setRoute($data['name'],RouteMap::SOURCE_NEWS,$id,$info['project_id']);
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|