作者 lyh

变更数据

@@ -60,7 +60,7 @@ class TicketUploadDataController extends BaseController @@ -60,7 +60,7 @@ class TicketUploadDataController extends BaseController
60 'status.required' => '提交状态不能为空', 60 'status.required' => '提交状态不能为空',
61 'id.required' => '主键ID不能为空', 61 'id.required' => '主键ID不能为空',
62 ]); 62 ]);
63 - $data = $this->logic->saveData($this->param); 63 + $data = $this->logic->saveData();
64 $this->response('success',Code::SUCCESS,$data); 64 $this->response('success',Code::SUCCESS,$data);
65 } 65 }
66 } 66 }
@@ -9,9 +9,12 @@ @@ -9,9 +9,12 @@
9 9
10 namespace App\Http\Logic\Aside\Ticket; 10 namespace App\Http\Logic\Aside\Ticket;
11 11
  12 +use App\Helper\Arr;
12 use App\Http\Logic\Bside\BaseLogic; 13 use App\Http\Logic\Bside\BaseLogic;
13 use App\Models\Blog\Blog; 14 use App\Models\Blog\Blog;
14 use App\Models\News\News; 15 use App\Models\News\News;
  16 +use App\Models\Product\CategoryRelated;
  17 +use App\Models\Product\KeywordRelated;
15 use App\Models\Product\Product; 18 use App\Models\Product\Product;
16 use App\Models\RouteMap\RouteMap; 19 use App\Models\RouteMap\RouteMap;
17 use App\Models\Ticket\TicketUploadData; 20 use App\Models\Ticket\TicketUploadData;
@@ -39,46 +42,178 @@ class TicketUploadDataLogic extends BaseLogic @@ -39,46 +42,178 @@ class TicketUploadDataLogic extends BaseLogic
39 $this->map['text'] = ['like','%'.$this->map['text'].'%']; 42 $this->map['text'] = ['like','%'.$this->map['text'].'%'];
40 } 43 }
41 $data = $this->model->lists($map,$page,$row,$order); 44 $data = $this->model->lists($map,$page,$row,$order);
  45 + foreach ($data as &$v){
  46 + $v = $this->getHandleFileImage($v);
  47 + }
42 return $this->success($data); 48 return $this->success($data);
43 } 49 }
44 50
45 /** 51 /**
46 - * @remark :保存数据详情 52 + * @remark :处理数据
  53 + * @name :getHandleFileImage
  54 + * @author :lyh
  55 + * @method :post
  56 + * @time :2025/9/25 16:53
  57 + */
  58 + public function getHandleFileImage($v){
  59 + if($v['type'] == 1){
  60 + if(!empty($v['text']['image'])){
  61 + foreach ($v['text']['image'] as $gallery_k => $gallery_v){
  62 + $gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
  63 + $info['text']['image'][$gallery_k] = $gallery_v;
  64 + }
  65 + }
  66 + }else{
  67 + $v['text']['image'] = getImageUrl($v['text']['image'],$this->user['storage_type'],$this->user['project_location']);
  68 + }
  69 + return $this->success($v);
  70 + }
  71 +
  72 + /**
  73 + * @remark :保存数据
47 * @name :saveData 74 * @name :saveData
48 * @author :lyh 75 * @author :lyh
49 * @method :post 76 * @method :post
50 - * @time :2025/9/25 14:17 77 + * @time :2025/9/25 17:01
51 */ 78 */
52 - public function saveData(){ 79 + public function saveData()
  80 + {
53 //获取当前数据详情 81 //获取当前数据详情
54 $info = $this->model->read(['id'=>$this->param['id']]); 82 $info = $this->model->read(['id'=>$this->param['id']]);
55 if($info === false){ 83 if($info === false){
56 $this->fail('当前数据不存在或已被删除'); 84 $this->fail('当前数据不存在或已被删除');
57 } 85 }
58 - ProjectServer::useProject($info['project_id']);  
59 - if($info['type'] == 1){  
60 - //产品 86 + //审核成功执行
  87 + if($this->param['status'] == 1){
  88 + if($info['type'] == 1){
  89 + $this->saveProductData($info);
  90 + }elseif ($info['type'] == 2){
  91 + $this->saveBlogData($info);
  92 + }else{
  93 + $this->saveNewsData($info);
  94 + }
  95 + }
  96 + $data = $this->model->edit(['status'=>$this->param['status'],'remark'=>$this->param['remark'] ?? ''],['id'=>$this->param['id']]);
  97 + return $this->success($data);
  98 + }
  99 +
  100 + /**
  101 + * @remark :保存数据详情
  102 + * @name :saveData
  103 + * @author :lyh
  104 + * @method :post
  105 + * @time :2025/9/25 14:17
  106 + */
  107 + public function saveProductData($info){
  108 + if(isset($info['text']['keyword_id']) && !empty($info['text']['keyword_id'])){
  109 + $keyword_id = ','.Arr::arrToSet($info['text']['keyword_id']).',';
  110 + }
  111 + if(isset($info['text']['category_id']) && !empty($info['text']['category_id'])) {
  112 + $category_id = ','.Arr::arrToSet($info['text']['category_id']).',';
  113 + }
  114 + if(isset($info['text']['image']) && !empty($info['text']['image'])){
  115 + foreach ($info['text']['image'] as $k => $v){
  116 + $v['url'] = str_replace_url($v['url']);
  117 + $info['text']['image'][$k] = $v;
  118 + }
  119 + $info['text']['image'] = Arr::a2s($info['text']['image'] ?? []);
  120 + }else{
  121 + $info['text']['image'] = Arr::a2s([]);
  122 + }
  123 + try {
  124 + ProjectServer::useProject($info['project_id']);
61 $productModel = new Product(); 125 $productModel = new Product();
62 $data = [ 126 $data = [
63 'project_id' => $info['project_id'], 127 'project_id' => $info['project_id'],
64 'title' => $info['text']['title'], 128 'title' => $info['text']['title'],
65 - 'thumb'=>json_encode($info['text']['gallery'][0] ?? [],true),  
66 - 'gallery'=>json_encode($info['text']['gallery'] ?? [],true), 129 + 'thumb'=>json_encode($info['text']['image'][0] ?? [],true),
  130 + 'gallery'=>json_encode($info['text']['image'] ?? [],true),
67 'intro'=>$info['text']['remark'], 131 'intro'=>$info['text']['remark'],
68 - 'category_id'=>$info['text']['category_id'],  
69 - 'keyword_id'=>$info['text']['keyword_id'], 132 + 'category_id'=>$category_id ?? '',
  133 + 'keyword_id'=>$keyword_id ?? '',
70 'status'=>0, 134 'status'=>0,
71 ]; 135 ];
72 $id = $productModel->addReturnId($data); 136 $id = $productModel->addReturnId($data);
73 - RouteMap::setRoute($data['title'],RouteMap::SOURCE_PRODUCT,$id,$info['project_id']);  
74 - }elseif ($info['type'] == 2){  
75 - //博客  
76 - $blogModel = new Blog();  
77 - }else{  
78 - //新闻 137 + CategoryRelated::saveRelated($id, $info['text']['category_id'] ?? []);//分类关联
  138 + KeywordRelated::saveRelated($id,$info['text']['keyword_id'] ?? []);//关键字关联
  139 + $route = RouteMap::setRoute($data['title'],RouteMap::SOURCE_PRODUCT,$id,$info['project_id']);
  140 + $this->model->edit(['route'=>$route],['id'=>$id]);
  141 + DB::disconnect('custom_mysql');
  142 + }catch (\Exception $e){
  143 + $this->fail('保存失败,请联系管理员');
  144 + }
  145 + return $this->success();
  146 + }
  147 +
  148 + /**
  149 + * @remark :保存blog数据
  150 + * @name :saveBlogData
  151 + * @author :lyh
  152 + * @method :post
  153 + * @time :2025/9/25 16:26
  154 + */
  155 + public function saveBlogData($info)
  156 + {
  157 + if(isset($info['text']['category_id']) && !empty($info['text']['category_id'])) {
  158 + $category_id = ','.Arr::arrToSet($info['text']['category_id']).',';
  159 + }
  160 + if(isset($info['text']['image'])){
  161 + $info['text']['image'] = str_replace_url($info['text']['image'] ?? '');
  162 + }
  163 + $data = [
  164 + 'project_id' => $info['project_id'],
  165 + 'name' => $info['text']['title'],
  166 + 'image'=>$info['text']['image'],
  167 + 'text'=>$info['text']['remark'],
  168 + 'category_id'=>$category_id ?? '',
  169 + 'status'=>0,
  170 + ];
  171 + try {
  172 + ProjectServer::useProject($info['project_id']);
79 $newsModel = new News(); 173 $newsModel = new News();
  174 + $id = $newsModel->addReturnId($data);
  175 + $route = RouteMap::setRoute($data['name'],RouteMap::SOURCE_BLOG,$id,$info['project_id']);
  176 + $this->model->edit(['url'=>$route],['id'=>$id]);
  177 + DB::disconnect('custom_mysql');
  178 + }catch (\Exception $e){
  179 + $this->fail('保存失败,请联系管理员');
80 } 180 }
81 - DB::disconnect('custom_mysql'); 181 + return $this->success();
82 } 182 }
83 183
  184 + /**
  185 + * @remark :保存新闻数据
  186 + * @name :saveNewsData
  187 + * @author :lyh
  188 + * @method :post
  189 + * @time :2025/9/25 16:34
  190 + */
  191 + public function saveNewsData($info)
  192 + {
  193 + if(isset($info['text']['category_id']) && !empty($info['text']['category_id'])) {
  194 + $category_id = ','.Arr::arrToSet($info['text']['category_id']).',';
  195 + }
  196 + if(isset($info['text']['image'])){
  197 + $info['text']['image'] = str_replace_url($info['text']['image'] ?? '');
  198 + }
  199 + $data = [
  200 + 'project_id' => $info['project_id'],
  201 + 'name' => $info['text']['title'],
  202 + 'image'=>$info['text']['image'],
  203 + 'text'=>$info['text']['remark'],
  204 + 'category_id'=>$category_id ?? '',
  205 + 'status'=>0,
  206 + ];
  207 + try {
  208 + ProjectServer::useProject($info['project_id']);
  209 + $newsModel = new News();
  210 + $id = $newsModel->addReturnId($data);
  211 + $route = RouteMap::setRoute($data['name'],RouteMap::SOURCE_NEWS,$id,$info['project_id']);
  212 + $this->model->edit(['route'=>$route],['id'=>$id]);
  213 + DB::disconnect('custom_mysql');
  214 + }catch (\Exception $e){
  215 + $this->fail('保存失败,请联系管理员');
  216 + }
  217 + return $this->success();
  218 + }
84 } 219 }