|
...
|
...
|
@@ -9,9 +9,12 @@ |
|
|
|
|
|
|
|
namespace App\Http\Logic\Aside\Ticket;
|
|
|
|
|
|
|
|
use App\Helper\Arr;
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Blog\Blog;
|
|
|
|
use App\Models\News\News;
|
|
|
|
use App\Models\Product\CategoryRelated;
|
|
|
|
use App\Models\Product\KeywordRelated;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Ticket\TicketUploadData;
|
|
...
|
...
|
@@ -39,46 +42,178 @@ class TicketUploadDataLogic extends BaseLogic |
|
|
|
$this->map['text'] = ['like','%'.$this->map['text'].'%'];
|
|
|
|
}
|
|
|
|
$data = $this->model->lists($map,$page,$row,$order);
|
|
|
|
foreach ($data as &$v){
|
|
|
|
$v = $this->getHandleFileImage($v);
|
|
|
|
}
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存数据详情
|
|
|
|
* @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'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
|
|
|
|
$info['text']['image'][$gallery_k] = $gallery_v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$v['text']['image'] = getImageUrl($v['text']['image'],$this->user['storage_type'],$this->user['project_location']);
|
|
|
|
}
|
|
|
|
return $this->success($v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存数据
|
|
|
|
* @name :saveData
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/25 14:17
|
|
|
|
* @time :2025/9/25 17:01
|
|
|
|
*/
|
|
|
|
public function saveData(){
|
|
|
|
public function saveData()
|
|
|
|
{
|
|
|
|
//获取当前数据详情
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前数据不存在或已被删除');
|
|
|
|
}
|
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
//审核成功执行
|
|
|
|
if($this->param['status'] == 1){
|
|
|
|
if($info['type'] == 1){
|
|
|
|
//产品
|
|
|
|
$this->saveProductData($info);
|
|
|
|
}elseif ($info['type'] == 2){
|
|
|
|
$this->saveBlogData($info);
|
|
|
|
}else{
|
|
|
|
$this->saveNewsData($info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data = $this->model->edit(['status'=>$this->param['status'],'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;
|
|
|
|
}
|
|
|
|
$info['text']['image'] = Arr::a2s($info['text']['image'] ?? []);
|
|
|
|
}else{
|
|
|
|
$info['text']['image'] = Arr::a2s([]);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
$productModel = new Product();
|
|
|
|
$data = [
|
|
|
|
'project_id' => $info['project_id'],
|
|
|
|
'title' => $info['text']['title'],
|
|
|
|
'thumb'=>json_encode($info['text']['gallery'][0] ?? [],true),
|
|
|
|
'gallery'=>json_encode($info['text']['gallery'] ?? [],true),
|
|
|
|
'thumb'=>json_encode($info['text']['image'][0] ?? [],true),
|
|
|
|
'gallery'=>json_encode($info['text']['image'] ?? [],true),
|
|
|
|
'intro'=>$info['text']['remark'],
|
|
|
|
'category_id'=>$info['text']['category_id'],
|
|
|
|
'keyword_id'=>$info['text']['keyword_id'],
|
|
|
|
'category_id'=>$category_id ?? '',
|
|
|
|
'keyword_id'=>$keyword_id ?? '',
|
|
|
|
'status'=>0,
|
|
|
|
];
|
|
|
|
$id = $productModel->addReturnId($data);
|
|
|
|
RouteMap::setRoute($data['title'],RouteMap::SOURCE_PRODUCT,$id,$info['project_id']);
|
|
|
|
}elseif ($info['type'] == 2){
|
|
|
|
//博客
|
|
|
|
$blogModel = new Blog();
|
|
|
|
}else{
|
|
|
|
//新闻
|
|
|
|
$newsModel = new News();
|
|
|
|
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]);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}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 {
|
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
$newsModel = new News();
|
|
|
|
$id = $newsModel->addReturnId($data);
|
|
|
|
$route = RouteMap::setRoute($data['name'],RouteMap::SOURCE_BLOG,$id,$info['project_id']);
|
|
|
|
$this->model->edit(['url'=>$route],['id'=>$id]);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}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 {
|
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
$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]);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|