作者 lyh

变更数据

@@ -24,6 +24,7 @@ use App\Models\Product\KeywordRelated; @@ -24,6 +24,7 @@ use App\Models\Product\KeywordRelated;
24 use App\Models\Product\Product; 24 use App\Models\Product\Product;
25 use App\Models\RouteMap\RouteMap; 25 use App\Models\RouteMap\RouteMap;
26 use App\Models\Ticket\TicketUploadData; 26 use App\Models\Ticket\TicketUploadData;
  27 +use App\Models\WorkOrder\TicketProject;
27 use App\Services\ProjectServer; 28 use App\Services\ProjectServer;
28 use Illuminate\Support\Facades\DB; 29 use Illuminate\Support\Facades\DB;
29 use Illuminate\Support\Facades\Http; 30 use Illuminate\Support\Facades\Http;
@@ -174,10 +175,21 @@ class TicketUploadDataLogic extends BaseLogic @@ -174,10 +175,21 @@ class TicketUploadDataLogic extends BaseLogic
174 } 175 }
175 }else{ 176 }else{
176 if($this->param['status'] == $this->model::STATUS_SUCCESS){ 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 + }
177 if($info['type'] == $this->model::TYPE_PRODUCT){ 189 if($info['type'] == $this->model::TYPE_PRODUCT){
178 - $this->save5ProductData($info); 190 + $this->save5ProductData($info,$url);
179 }else{ 191 }else{
180 - $this->save5NewsData($info); 192 + $this->save5NewsData($info,$url);
181 } 193 }
182 } 194 }
183 } 195 }
@@ -192,23 +204,46 @@ class TicketUploadDataLogic extends BaseLogic @@ -192,23 +204,46 @@ class TicketUploadDataLogic extends BaseLogic
192 * @method :post 204 * @method :post
193 * @time :2025/11/10 14:18 205 * @time :2025/11/10 14:18
194 */ 206 */
195 - public function save5ProductData($info){  
196 - $projectInfo['website'] = 'https://devmark.globalso.com/';  
197 - $action = $this->model->saveAction($this->param['type']);  
198 - $url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;  
199 - if(empty($action)){  
200 - $this->response('未知请求',Code::SYSTEM_ERROR);  
201 - } 207 + public function save5ProductData($info,$url){
202 $response = Http::withHeaders([])->asForm()->post($url, [ 208 $response = Http::withHeaders([])->asForm()->post($url, [
203 - 'name' => $this->param['name'],  
204 - 'parent' => $this->param['parent'] ?? 0, 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'] ?? '',
205 ]); 214 ]);
  215 + if ($response->successful()) {
  216 + $result = $response->json(); // 获取 JSON 响应体
  217 + if ($result && $result['status'] == 200) {
206 return $this->success(); 218 return $this->success();
207 } 219 }
  220 + }
  221 + $this->fail('未知请求,请联系管理员!');
  222 + }
208 223
209 - public function save5NewsData($info){ 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) {
210 return $this->success(); 241 return $this->success();
211 } 242 }
  243 + }
  244 + $this->fail('未知请求,请联系管理员!');
  245 + }
  246 +
212 247
213 /** 248 /**
214 * @remark :设置排序 249 * @remark :设置排序
@@ -38,11 +38,13 @@ class TicketUploadData extends Base @@ -38,11 +38,13 @@ class TicketUploadData extends Base
38 } 38 }
39 return $value; 39 return $value;
40 } 40 }
  41 +
  42 +
41 public function saveAction($type) 43 public function saveAction($type)
42 { 44 {
43 $data = [ 45 $data = [
44 1 => 'add_products', 46 1 => 'add_products',
45 - 2 => 'add_news', 47 + 3 => 'add_news_api',
46 ]; 48 ];
47 return $data[$type] ?? ''; 49 return $data[$type] ?? '';
48 } 50 }