作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !3214
@@ -12,11 +12,18 @@ namespace App\Http\Controllers\Api\WorkOrder; @@ -12,11 +12,18 @@ namespace App\Http\Controllers\Api\WorkOrder;
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Api\BaseController; 13 use App\Http\Controllers\Api\BaseController;
14 use App\Models\Ticket\Project5Cate; 14 use App\Models\Ticket\Project5Cate;
  15 +use App\Models\Ticket\TicketUploadData;
15 use App\Models\WorkOrder\TicketProject; 16 use App\Models\WorkOrder\TicketProject;
  17 +use Illuminate\Http\Request;
16 use Illuminate\Support\Facades\Http; 18 use Illuminate\Support\Facades\Http;
17 19
18 class Ticket5UploadDataController extends BaseController 20 class Ticket5UploadDataController extends BaseController
19 { 21 {
  22 + public function __construct(Request $request)
  23 + {
  24 + parent::__construct($request);
  25 + $this->model = new TicketUploadData();
  26 + }
20 /** 27 /**
21 * @remark :获取对应项目的分类 28 * @remark :获取对应项目的分类
22 * @name :getProject5Cate 29 * @name :getProject5Cate
@@ -140,8 +147,8 @@ class Ticket5UploadDataController extends BaseController @@ -140,8 +147,8 @@ class Ticket5UploadDataController extends BaseController
140 'type' => 'required', 147 'type' => 'required',
141 'text' => 'required' 148 'text' => 'required'
142 ], [ 149 ], [
143 - 'post_od.required' => 'project_id不能为空',  
144 - 'type.required' => '上传类型不能为空', 150 + 'post_id.required' => 'project_id不能为空',
  151 + 'type.required' => '类型不能为空',
145 'text' => '数据详情不为空' 152 'text' => '数据详情不为空'
146 ]); 153 ]);
147 if(empty($this->param['text']['image'])){ 154 if(empty($this->param['text']['image'])){
@@ -152,7 +159,7 @@ class Ticket5UploadDataController extends BaseController @@ -152,7 +159,7 @@ class Ticket5UploadDataController extends BaseController
152 } 159 }
153 //验证当前数据是否已提交 160 //验证当前数据是否已提交
154 $this->param['text'] = json_encode($this->param['text'], true); 161 $this->param['text'] = json_encode($this->param['text'], true);
155 - $this->pushTicketByBots($this->param['post_id'],$this->param['type']); 162 + $this->pushTicketByBots($this->param['post_id'],$this->param['project_type']);
156 if(isset($this->param['id']) && !empty($this->param['id'])){ 163 if(isset($this->param['id']) && !empty($this->param['id'])){
157 //执行编辑 164 //执行编辑
158 $info = $this->model->read(['id'=>$this->param['id']]); 165 $info = $this->model->read(['id'=>$this->param['id']]);
@@ -163,8 +170,9 @@ class Ticket5UploadDataController extends BaseController @@ -163,8 +170,9 @@ class Ticket5UploadDataController extends BaseController
163 } 170 }
164 $this->response('success'); 171 $this->response('success');
165 }else{ 172 }else{
166 - $info = $this->model->read(['project_id' => $this->param['project_id'], 'type' => $this->param['type'], 'text' => $this->param['text'], 'status' => 0]); 173 + $info = $this->model->read(['post_id' => $this->param['post_id'],'project_type'=>$this->model::TYPE_FIVE ,'type' => $this->param['type'], 'text' => $this->param['text'], 'status' => 0]);
167 if ($info === false) { 174 if ($info === false) {
  175 + $this->param['project_type'] = $this->model::TYPE_FIVE ;
168 $id = $this->model->addReturnId($this->param); 176 $id = $this->model->addReturnId($this->param);
169 } else { 177 } else {
170 $id = $info['id']; 178 $id = $info['id'];
@@ -177,9 +185,9 @@ class Ticket5UploadDataController extends BaseController @@ -177,9 +185,9 @@ class Ticket5UploadDataController extends BaseController
177 /** 185 /**
178 * @remark :钉钉通知 186 * @remark :钉钉通知
179 * @name :pushTicketByBots 187 * @name :pushTicketByBots
180 - * @author :lyh  
181 * @method :post 188 * @method :post
182 * @time :2025/11/10 11:10 189 * @time :2025/11/10 11:10
  190 + * @author :lyh
183 */ 191 */
184 public function pushTicketByBots($post_id,$type = 1) 192 public function pushTicketByBots($post_id,$type = 1)
185 { 193 {
@@ -77,7 +77,7 @@ class TicketUploadDataController extends BaseController @@ -77,7 +77,7 @@ class TicketUploadDataController extends BaseController
77 { 77 {
78 $this->request->validate([ 78 $this->request->validate([
79 'status'=>'required', 79 'status'=>'required',
80 - 'id'=>'required' 80 + 'id'=>'required',
81 ],[ 81 ],[
82 'status.required' => '提交状态不能为空', 82 'status.required' => '提交状态不能为空',
83 'id.required' => '主键ID不能为空', 83 'id.required' => '主键ID不能为空',
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 9
10 namespace App\Http\Logic\Aside\Ticket; 10 namespace App\Http\Logic\Aside\Ticket;
11 11
  12 +use App\Enums\Common\Code;
12 use App\Helper\Arr; 13 use App\Helper\Arr;
13 use App\Http\Logic\Aside\BaseLogic; 14 use App\Http\Logic\Aside\BaseLogic;
14 use App\Models\Blog\Blog; 15 use App\Models\Blog\Blog;
@@ -23,8 +24,10 @@ use App\Models\Product\KeywordRelated; @@ -23,8 +24,10 @@ use App\Models\Product\KeywordRelated;
23 use App\Models\Product\Product; 24 use App\Models\Product\Product;
24 use App\Models\RouteMap\RouteMap; 25 use App\Models\RouteMap\RouteMap;
25 use App\Models\Ticket\TicketUploadData; 26 use App\Models\Ticket\TicketUploadData;
  27 +use App\Models\WorkOrder\TicketProject;
26 use App\Services\ProjectServer; 28 use App\Services\ProjectServer;
27 use Illuminate\Support\Facades\DB; 29 use Illuminate\Support\Facades\DB;
  30 +use Illuminate\Support\Facades\Http;
28 31
29 class TicketUploadDataLogic extends BaseLogic 32 class TicketUploadDataLogic extends BaseLogic
30 { 33 {
@@ -47,6 +50,9 @@ class TicketUploadDataLogic extends BaseLogic @@ -47,6 +50,9 @@ class TicketUploadDataLogic extends BaseLogic
47 $this->map['text'] = ['like','%'.$this->map['text'].'%']; 50 $this->map['text'] = ['like','%'.$this->map['text'].'%'];
48 } 51 }
49 ProjectServer::useProject($map['project_id']); 52 ProjectServer::useProject($map['project_id']);
  53 + if(empty($map['type'])){
  54 + $map['type'] = $this->model::TYPE_SIX;//6.0数据
  55 + }
50 $data = $this->model->lists($map,$page,$row,$order); 56 $data = $this->model->lists($map,$page,$row,$order);
51 if(!empty($data) && !empty($data['list'])){ 57 if(!empty($data) && !empty($data['list'])){
52 foreach ($data['list'] as &$v){ 58 foreach ($data['list'] as &$v){
@@ -154,22 +160,98 @@ class TicketUploadDataLogic extends BaseLogic @@ -154,22 +160,98 @@ class TicketUploadDataLogic extends BaseLogic
154 if($info === false){ 160 if($info === false){
155 $this->fail('当前数据不存在或已被删除'); 161 $this->fail('当前数据不存在或已被删除');
156 } 162 }
157 - //审核成功执行  
158 - if($this->param['status'] == 1){  
159 - ProjectServer::useProject($info['project_id']);  
160 - if($info['type'] == 1){  
161 - $this->saveProductData($info);  
162 - }elseif ($info['type'] == 2){  
163 - $this->saveBlogData($info);  
164 - }else{  
165 - $this->saveNewsData($info); 163 + if($info['project_type'] == $this->model::TYPE_SIX){//6.0数据
  164 + //审核成功执行
  165 + if($this->param['status'] == $this->model::STATUS_SUCCESS){
  166 + ProjectServer::useProject($info['project_id']);
  167 + if($info['type'] == $this->model::TYPE_PRODUCT){
  168 + $this->saveProductData($info);
  169 + }elseif ($info['type'] == $this->model::TYPE_BLOG){
  170 + $this->saveBlogData($info);
  171 + }else{
  172 + $this->saveNewsData($info);
  173 + }
  174 + DB::disconnect('custom_mysql');
  175 + }
  176 + }else{
  177 + if($this->param['status'] == $this->model::STATUS_SUCCESS){
  178 + $ticketProjectMdoel = new TicketProject();
  179 + $projectInfo = $ticketProjectMdoel->read(['post_id' => $info['post_id']]);
  180 + if($projectInfo === false){
  181 + $this->fail('当前项目不存在或数据未同步');
  182 + }
  183 + $projectInfo['website'] = 'https://devmark.globalso.com/';
  184 + $action = $this->model->saveAction($info['type']);
  185 + $url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
  186 + if(empty($action)){
  187 + $this->fail('未知请求,请联系管理员!');
  188 + }
  189 + if($info['type'] == $this->model::TYPE_PRODUCT){
  190 + $this->save5ProductData($info,$url);
  191 + }else{
  192 + $this->save5NewsData($info,$url);
  193 + }
166 } 194 }
167 - DB::disconnect('custom_mysql');  
168 } 195 }
169 $data = $this->model->edit(['status'=>$this->param['status'],'operator_id'=>$this->manager['id'],'remark'=>$this->param['remark'] ?? ''],['id'=>$this->param['id']]); 196 $data = $this->model->edit(['status'=>$this->param['status'],'operator_id'=>$this->manager['id'],'remark'=>$this->param['remark'] ?? ''],['id'=>$this->param['id']]);
170 return $this->success($data); 197 return $this->success($data);
171 } 198 }
172 199
  200 + /**
  201 + * @remark :保存5.0产品数据
  202 + * @name :save5ProductData
  203 + * @author :lyh
  204 + * @method :post
  205 + * @time :2025/11/10 14:18
  206 + */
  207 + public function save5ProductData($info,$url){
  208 + $response = Http::withHeaders([])->asForm()->post($url, [
  209 + 'title' => $info['text']['title'],
  210 + 'cate_id' => $info['text']['cate_id'] ?? '',
  211 + 'content'=>$info['text']['content'] ?? '',
  212 + 'short_description'=>$info['text']['short_description'] ?? '',
  213 + 'images'=>$info['text']['images'] ?? '',
  214 + ]);
  215 + if ($response->successful()) {
  216 + $result = $response->json(); // 获取 JSON 响应体
  217 + if ($result && $result['status'] == 200) {
  218 + return $this->success();
  219 + }
  220 + }
  221 + $this->fail('未知请求,请联系管理员!');
  222 + }
  223 +
  224 + /**
  225 + * @remark :保存新闻
  226 + * @name :save5NewsData
  227 + * @author :lyh
  228 + * @method :post
  229 + * @time :2025/11/10 14:43
  230 + */
  231 + public function save5NewsData($info,$url){
  232 + $response = Http::withHeaders([])->asForm()->post($url, [
  233 + 'title' => $info['text']['title'],
  234 + 'cate' => $info['text']['cate_id'] ?? '',
  235 + 'content'=>$info['text']['content'] ?? '',
  236 + 'images'=>$info['text']['images'] ?? '',
  237 + ]);
  238 + if ($response->successful()) {
  239 + $result = $response->json(); // 获取 JSON 响应体
  240 + if ($result && $result['status'] == 200) {
  241 + return $this->success();
  242 + }
  243 + }
  244 + $this->fail('未知请求,请联系管理员!');
  245 + }
  246 +
  247 +
  248 + /**
  249 + * @remark :设置排序
  250 + * @name :setProductSort
  251 + * @author :lyh
  252 + * @method :post
  253 + * @time :2025/11/10 14:11
  254 + */
173 public function setProductSort($mdoel){ 255 public function setProductSort($mdoel){
174 $info = $mdoel->orderBy('sort','desc')->first(); 256 $info = $mdoel->orderBy('sort','desc')->first();
175 if(empty($info)){ 257 if(empty($info)){
@@ -23,10 +23,29 @@ class TicketUploadData extends Base @@ -23,10 +23,29 @@ class TicketUploadData extends Base
23 { 23 {
24 protected $table = 'gl_tickets_upload_data'; 24 protected $table = 'gl_tickets_upload_data';
25 25
  26 + const TYPE_SIX = 2;//6.0
  27 + const TYPE_FIVE = 1;//5.0
  28 +
  29 + const STATUS_SUCCESS = 1;//审核成功
  30 +
  31 + const TYPE_PRODUCT = 1;//产品
  32 + const TYPE_BLOG = 2;//blog
  33 + const TYPE_NEWS = 3;//新闻
  34 +
26 public function getTextAttribute($value){ 35 public function getTextAttribute($value){
27 if(!empty($value)){ 36 if(!empty($value)){
28 $value = Arr::s2a($value); 37 $value = Arr::s2a($value);
29 } 38 }
30 return $value; 39 return $value;
31 } 40 }
  41 +
  42 +
  43 + public function saveAction($type)
  44 + {
  45 + $data = [
  46 + 1 => 'add_products',
  47 + 3 => 'add_news_api',
  48 + ];
  49 + return $data[$type] ?? '';
  50 + }
32 } 51 }