作者 lyh

变更数据

... ... @@ -24,6 +24,7 @@ use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Models\Ticket\TicketUploadData;
use App\Models\WorkOrder\TicketProject;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
... ... @@ -174,10 +175,21 @@ class TicketUploadDataLogic extends BaseLogic
}
}else{
if($this->param['status'] == $this->model::STATUS_SUCCESS){
$ticketProjectMdoel = new TicketProject();
$projectInfo = $ticketProjectMdoel->read(['post_id' => $info['post_id']]);
if($projectInfo === false){
$this->fail('当前项目不存在或数据未同步');
}
$projectInfo['website'] = 'https://devmark.globalso.com/';
$action = $this->model->saveAction($info['type']);
$url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
if(empty($action)){
$this->fail('未知请求,请联系管理员!');
}
if($info['type'] == $this->model::TYPE_PRODUCT){
$this->save5ProductData($info);
$this->save5ProductData($info,$url);
}else{
$this->save5NewsData($info);
$this->save5NewsData($info,$url);
}
}
}
... ... @@ -192,24 +204,47 @@ class TicketUploadDataLogic extends BaseLogic
* @method :post
* @time :2025/11/10 14:18
*/
public function save5ProductData($info){
$projectInfo['website'] = 'https://devmark.globalso.com/';
$action = $this->model->saveAction($this->param['type']);
$url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
if(empty($action)){
$this->response('未知请求',Code::SYSTEM_ERROR);
}
public function save5ProductData($info,$url){
$response = Http::withHeaders([])->asForm()->post($url, [
'name' => $this->param['name'],
'parent' => $this->param['parent'] ?? 0,
'title' => $info['text']['title'],
'cate_id' => $info['text']['cate_id'] ?? '',
'content'=>$info['text']['content'] ?? '',
'short_description'=>$info['text']['short_description'] ?? '',
'images'=>$info['text']['images'] ?? '',
]);
return $this->success();
if ($response->successful()) {
$result = $response->json(); // 获取 JSON 响应体
if ($result && $result['status'] == 200) {
return $this->success();
}
}
$this->fail('未知请求,请联系管理员!');
}
public function save5NewsData($info){
return $this->success();
/**
* @remark :保存新闻
* @name :save5NewsData
* @author :lyh
* @method :post
* @time :2025/11/10 14:43
*/
public function save5NewsData($info,$url){
$response = Http::withHeaders([])->asForm()->post($url, [
'title' => $info['text']['title'],
'cate' => $info['text']['cate_id'] ?? '',
'content'=>$info['text']['content'] ?? '',
'images'=>$info['text']['images'] ?? '',
]);
if ($response->successful()) {
$result = $response->json(); // 获取 JSON 响应体
if ($result && $result['status'] == 200) {
return $this->success();
}
}
$this->fail('未知请求,请联系管理员!');
}
/**
* @remark :设置排序
* @name :setProductSort
... ...
... ... @@ -38,11 +38,13 @@ class TicketUploadData extends Base
}
return $value;
}
public function saveAction($type)
{
$data = [
1 => 'add_products',
2 => 'add_news',
3 => 'add_news_api',
];
return $data[$type] ?? '';
}
... ...