|
...
|
...
|
@@ -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
|
|
|
|
{
|
|
...
|
...
|
@@ -43,18 +46,24 @@ class TicketUploadDataLogic extends BaseLogic |
|
|
|
* @time :2025/9/25 14:17
|
|
|
|
*/
|
|
|
|
public function getDataList($map = [],$page = 1,$row = 20,$order = 'id'){
|
|
|
|
if(isset($this->map['text']) && !empty($this->map['text'])){
|
|
|
|
$this->map['text'] = ['like','%'.$this->map['text'].'%'];
|
|
|
|
if(isset($map['text']) && !empty($map['text'])){
|
|
|
|
$map['text'] = ['like','%'.$map['text'].'%'];
|
|
|
|
}
|
|
|
|
if(!isset($map['project_type']) || empty($map['project_type'])){
|
|
|
|
$map['project_type'] = $this->model::TYPE_SIX;
|
|
|
|
}
|
|
|
|
ProjectServer::useProject($map['project_id']);
|
|
|
|
$data = $this->model->lists($map,$page,$row,$order);
|
|
|
|
if(!empty($data) && !empty($data['list'])){
|
|
|
|
foreach ($data['list'] as &$v){
|
|
|
|
$v = $this->getHandleFileImage($v);
|
|
|
|
$v['text']['cate_name'] = $this->cateText($v['type'],$v['text']['category_id'] ?? []);
|
|
|
|
if($map['project_type'] == $this->model::TYPE_SIX){
|
|
|
|
ProjectServer::useProject($map['project_id']);
|
|
|
|
if(!empty($data) && !empty($data['list'])){
|
|
|
|
foreach ($data['list'] as &$v){
|
|
|
|
$v = $this->getHandleFileImage($v);
|
|
|
|
$v['text']['cate_name'] = $this->cateText($v['type'],$v['text']['category_id'] ?? []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -133,10 +142,12 @@ class TicketUploadDataLogic extends BaseLogic |
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前数据不存在或已被删除');
|
|
|
|
}
|
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
$info['text']['cate_name'] = $this->cateText($info['type'],$info['text']['category_id'] ?? [],$info['text']['keyword_id'] ?? [],true);
|
|
|
|
$info = $this->getHandleFileImage($info);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
if($info['project_type'] == $this->model::TYPE_SIX){
|
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
$info['text']['cate_name'] = $this->cateText($info['type'],$info['text']['category_id'] ?? [],$info['text']['keyword_id'] ?? [],true);
|
|
|
|
$info = $this->getHandleFileImage($info);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
return $this->success($info);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -154,22 +165,100 @@ class TicketUploadDataLogic extends BaseLogic |
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前数据不存在或已被删除');
|
|
|
|
}
|
|
|
|
//审核成功执行
|
|
|
|
if($this->param['status'] == 1){
|
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
if($info['type'] == 1){
|
|
|
|
$this->saveProductData($info);
|
|
|
|
}elseif ($info['type'] == 2){
|
|
|
|
$this->saveBlogData($info);
|
|
|
|
}else{
|
|
|
|
$this->saveNewsData($info);
|
|
|
|
if($info['project_type'] == $this->model::TYPE_SIX){//6.0数据
|
|
|
|
//审核成功执行
|
|
|
|
if($this->param['status'] == $this->model::STATUS_SUCCESS){
|
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
if($info['type'] == $this->model::TYPE_PRODUCT){
|
|
|
|
$this->saveProductData($info);
|
|
|
|
}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['project_id']]);
|
|
|
|
if($projectInfo === false){
|
|
|
|
$this->fail('当前项目不存在或数据未同步');
|
|
|
|
}
|
|
|
|
if(isset($projectInfo['split']) && $projectInfo['split'] == 1){
|
|
|
|
$projectInfo['website'] = $projectInfo['test_website'] ?? '';
|
|
|
|
}
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
$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' => isset($info['text']['cate']) ? implode(',', $info['text']['cate']) : '',
|
|
|
|
'content'=>$info['text']['content'] ?? '',
|
|
|
|
'short_description'=>$info['text']['short_description'] ?? '',
|
|
|
|
'images'=>$info['text']['image'] ?? '',
|
|
|
|
]);
|
|
|
|
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'] ?? 'ceshi123',
|
|
|
|
'cate' => isset($info['text']['cate']) ? implode(',', $info['text']['cate']) : '',
|
|
|
|
'content'=>$info['text']['content'] ?? '',
|
|
|
|
'image'=>$info['text']['image'] ?? '',
|
|
|
|
]);
|
|
|
|
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)){
|
|
...
|
...
|
@@ -308,4 +397,17 @@ class TicketUploadDataLogic extends BaseLogic |
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除
|
|
|
|
* @name :delData
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/11/14 11:04
|
|
|
|
*/
|
|
|
|
public function delData()
|
|
|
|
{
|
|
|
|
$this->model->del(['id'=>['in',$this->param['id']]]);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|