|
...
|
...
|
@@ -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
|
|
...
|
...
|
@@ -46,23 +53,28 @@ class Ticket5UploadDataController extends BaseController |
|
|
|
$this->response('当前项目不存在或数据未同步',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
//todo::目前写死
|
|
|
|
$projectInfo['website'] = 'https://devmark.globalso.com/';
|
|
|
|
if($projectInfo['website'] != 'https://www.lstchocolatemachine.com/'){
|
|
|
|
$this->response('当前项目不允许操作',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
$action = $project5CateModel->getCateTypeAction($this->param['type']);
|
|
|
|
if(empty($action)){
|
|
|
|
$this->response('未知请求',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
$url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
|
|
|
|
$data = http_get($url);
|
|
|
|
if($data && $data['status'] == 200){
|
|
|
|
$resultData = $data['data'];
|
|
|
|
$saveData = [
|
|
|
|
'project_id' => $projectInfo['post_id'],
|
|
|
|
'domain' => $projectInfo['website'],
|
|
|
|
'text'=>json_encode($data['data']),
|
|
|
|
'type' => $this->param['type'],
|
|
|
|
];
|
|
|
|
$project5CateModel->addReturnId($saveData);
|
|
|
|
$this->response('success', Code::SUCCESS,$resultData);
|
|
|
|
$response = Http::withHeaders([])->asForm()->get($url);
|
|
|
|
if ($response->successful()) {
|
|
|
|
$result = $response->json(); // 获取 JSON 响应体
|
|
|
|
if ($result && $result['status'] == 200) {
|
|
|
|
$resultData = $result['data'];
|
|
|
|
$saveData = [
|
|
|
|
'project_id' => $projectInfo['post_id'],
|
|
|
|
'domain' => $projectInfo['website'],
|
|
|
|
'text'=>json_encode($result['data']),
|
|
|
|
'type' => $this->param['type'],
|
|
|
|
];
|
|
|
|
$project5CateModel->addReturnId($saveData);
|
|
|
|
$this->response('success', Code::SUCCESS,$resultData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->response('success',Code::SUCCESS,$url);
|
|
|
|
}
|
|
...
|
...
|
@@ -95,7 +107,9 @@ class Ticket5UploadDataController extends BaseController |
|
|
|
}
|
|
|
|
$project5CateModel = new Project5Cate();
|
|
|
|
//todo::目前写死,上线放开
|
|
|
|
$projectInfo['website'] = 'https://devmark.globalso.com/';
|
|
|
|
if($projectInfo['website'] != 'https://www.lstchocolatemachine.com/'){
|
|
|
|
$this->response('当前项目不允许操作',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
$action = $project5CateModel->saveCateTypeAction($this->param['type']);
|
|
|
|
$url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
|
|
|
|
if(empty($action)){
|
|
...
|
...
|
@@ -111,14 +125,17 @@ class Ticket5UploadDataController extends BaseController |
|
|
|
//todo::更新分类数据
|
|
|
|
$action1 = $project5CateModel->getCateTypeAction($this->param['type']);
|
|
|
|
$url1 = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action1;
|
|
|
|
$data = http_get($url1);
|
|
|
|
if($data && $data['status'] == 200){
|
|
|
|
$resultData = $data['data'];
|
|
|
|
$saveData = [
|
|
|
|
'text'=>json_encode($data['data']),
|
|
|
|
];
|
|
|
|
$project5CateModel->edit($saveData,['project_id' => $projectInfo['post_id'],'type'=>$this->param['type']]);
|
|
|
|
$this->response('success', Code::SUCCESS,$resultData);
|
|
|
|
$response = Http::withHeaders([])->asForm()->get($url1);
|
|
|
|
if ($response->successful()) {
|
|
|
|
$result = $response->json();
|
|
|
|
if($result && $result['status'] == 200){
|
|
|
|
$resultData = $result['data'];
|
|
|
|
$saveData = [
|
|
|
|
'text'=>json_encode($result['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
|
|
|
];
|
|
|
|
$project5CateModel->edit($saveData,['project_id' => $projectInfo['post_id'],'type'=>$this->param['type']]);
|
|
|
|
$this->response('success', Code::SUCCESS,$resultData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->response('success');
|
|
|
|
}
|
|
...
|
...
|
@@ -133,15 +150,15 @@ class Ticket5UploadDataController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2025/11/10 11:01
|
|
|
|
*/
|
|
|
|
public function save()
|
|
|
|
public function save5Data()
|
|
|
|
{
|
|
|
|
$this->request->validate([
|
|
|
|
'post_id' => 'required',
|
|
|
|
'type' => 'required',
|
|
|
|
'text' => 'required'
|
|
|
|
], [
|
|
|
|
'post_od.required' => 'project_id不能为空',
|
|
|
|
'type.required' => '上传类型不能为空',
|
|
|
|
'post_id.required' => 'post_id不能为空',
|
|
|
|
'type.required' => '类型不能为空',
|
|
|
|
'text' => '数据详情不为空'
|
|
|
|
]);
|
|
|
|
if(empty($this->param['text']['image'])){
|
|
...
|
...
|
@@ -152,7 +169,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 +180,10 @@ 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(['project_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 ;
|
|
|
|
$this->param['project_id'] = $this->param['post_id'];
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
} else {
|
|
|
|
$id = $info['id'];
|
|
...
|
...
|
@@ -177,16 +196,16 @@ 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)
|
|
|
|
{
|
|
|
|
$project = TicketProject::where('post_id', $post_id)->where('project_cate',$type)->where('is_del', 0)->first();
|
|
|
|
if (!$project){
|
|
|
|
return response()->json(['message' => '未找到对应的工单项目'], 404);
|
|
|
|
if ($project){
|
|
|
|
return $project->pushWechatGroupMsg("您好,用户已上传数据,请审核!");
|
|
|
|
}
|
|
|
|
return $project->pushWechatGroupMsg("您好,用户已上传数据,请审核!");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|