作者 李宇航

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

Lyh server



查看合并请求 !3214
... ... @@ -12,11 +12,18 @@ namespace App\Http\Controllers\Api\WorkOrder;
use App\Enums\Common\Code;
use App\Http\Controllers\Api\BaseController;
use App\Models\Ticket\Project5Cate;
use App\Models\Ticket\TicketUploadData;
use App\Models\WorkOrder\TicketProject;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
class Ticket5UploadDataController extends BaseController
{
public function __construct(Request $request)
{
parent::__construct($request);
$this->model = new TicketUploadData();
}
/**
* @remark :获取对应项目的分类
* @name :getProject5Cate
... ... @@ -140,8 +147,8 @@ class Ticket5UploadDataController extends BaseController
'type' => 'required',
'text' => 'required'
], [
'post_od.required' => 'project_id不能为空',
'type.required' => '上传类型不能为空',
'post_id.required' => 'project_id不能为空',
'type.required' => '类型不能为空',
'text' => '数据详情不为空'
]);
if(empty($this->param['text']['image'])){
... ... @@ -152,7 +159,7 @@ class Ticket5UploadDataController extends BaseController
}
//验证当前数据是否已提交
$this->param['text'] = json_encode($this->param['text'], true);
$this->pushTicketByBots($this->param['post_id'],$this->param['type']);
$this->pushTicketByBots($this->param['post_id'],$this->param['project_type']);
if(isset($this->param['id']) && !empty($this->param['id'])){
//执行编辑
$info = $this->model->read(['id'=>$this->param['id']]);
... ... @@ -163,8 +170,9 @@ class Ticket5UploadDataController extends BaseController
}
$this->response('success');
}else{
$info = $this->model->read(['project_id' => $this->param['project_id'], 'type' => $this->param['type'], 'text' => $this->param['text'], 'status' => 0]);
$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]);
if ($info === false) {
$this->param['project_type'] = $this->model::TYPE_FIVE ;
$id = $this->model->addReturnId($this->param);
} else {
$id = $info['id'];
... ... @@ -177,9 +185,9 @@ class Ticket5UploadDataController extends BaseController
/**
* @remark :钉钉通知
* @name :pushTicketByBots
* @author :lyh
* @method :post
* @time :2025/11/10 11:10
* @author :lyh
*/
public function pushTicketByBots($post_id,$type = 1)
{
... ...
... ... @@ -77,7 +77,7 @@ class TicketUploadDataController extends BaseController
{
$this->request->validate([
'status'=>'required',
'id'=>'required'
'id'=>'required',
],[
'status.required' => '提交状态不能为空',
'id.required' => '主键ID不能为空',
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Http\Logic\Aside\Ticket;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Blog\Blog;
... ... @@ -23,8 +24,10 @@ 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;
class TicketUploadDataLogic extends BaseLogic
{
... ... @@ -47,6 +50,9 @@ class TicketUploadDataLogic extends BaseLogic
$this->map['text'] = ['like','%'.$this->map['text'].'%'];
}
ProjectServer::useProject($map['project_id']);
if(empty($map['type'])){
$map['type'] = $this->model::TYPE_SIX;//6.0数据
}
$data = $this->model->lists($map,$page,$row,$order);
if(!empty($data) && !empty($data['list'])){
foreach ($data['list'] as &$v){
... ... @@ -154,22 +160,98 @@ class TicketUploadDataLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
if($info['project_type'] == $this->model::TYPE_SIX){//6.0数据
//审核成功执行
if($this->param['status'] == 1){
if($this->param['status'] == $this->model::STATUS_SUCCESS){
ProjectServer::useProject($info['project_id']);
if($info['type'] == 1){
if($info['type'] == $this->model::TYPE_PRODUCT){
$this->saveProductData($info);
}elseif ($info['type'] == 2){
}elseif ($info['type'] == $this->model::TYPE_BLOG){
$this->saveBlogData($info);
}else{
$this->saveNewsData($info);
}
DB::disconnect('custom_mysql');
}
}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,$url);
}else{
$this->save5NewsData($info,$url);
}
}
}
$data = $this->model->edit(['status'=>$this->param['status'],'operator_id'=>$this->manager['id'],'remark'=>$this->param['remark'] ?? ''],['id'=>$this->param['id']]);
return $this->success($data);
}
/**
* @remark :保存5.0产品数据
* @name :save5ProductData
* @author :lyh
* @method :post
* @time :2025/11/10 14:18
*/
public function save5ProductData($info,$url){
$response = Http::withHeaders([])->asForm()->post($url, [
'title' => $info['text']['title'],
'cate_id' => $info['text']['cate_id'] ?? '',
'content'=>$info['text']['content'] ?? '',
'short_description'=>$info['text']['short_description'] ?? '',
'images'=>$info['text']['images'] ?? '',
]);
if ($response->successful()) {
$result = $response->json(); // 获取 JSON 响应体
if ($result && $result['status'] == 200) {
return $this->success();
}
}
$this->fail('未知请求,请联系管理员!');
}
/**
* @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
* @author :lyh
* @method :post
* @time :2025/11/10 14:11
*/
public function setProductSort($mdoel){
$info = $mdoel->orderBy('sort','desc')->first();
if(empty($info)){
... ...
... ... @@ -23,10 +23,29 @@ class TicketUploadData extends Base
{
protected $table = 'gl_tickets_upload_data';
const TYPE_SIX = 2;//6.0
const TYPE_FIVE = 1;//5.0
const STATUS_SUCCESS = 1;//审核成功
const TYPE_PRODUCT = 1;//产品
const TYPE_BLOG = 2;//blog
const TYPE_NEWS = 3;//新闻
public function getTextAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
}
return $value;
}
public function saveAction($type)
{
$data = [
1 => 'add_products',
3 => 'add_news_api',
];
return $data[$type] ?? '';
}
}
... ...