正在显示
4 个修改的文件
包含
88 行增加
和
16 行删除
| @@ -12,11 +12,18 @@ namespace App\Http\Controllers\Api\WorkOrder; | @@ -12,11 +12,18 @@ namespace App\Http\Controllers\Api\WorkOrder; | ||
| 12 | use App\Enums\Common\Code; | 12 | use App\Enums\Common\Code; |
| 13 | use App\Http\Controllers\Api\BaseController; | 13 | use App\Http\Controllers\Api\BaseController; |
| 14 | use App\Models\Ticket\Project5Cate; | 14 | use App\Models\Ticket\Project5Cate; |
| 15 | +use App\Models\Ticket\TicketUploadData; | ||
| 15 | use App\Models\WorkOrder\TicketProject; | 16 | use App\Models\WorkOrder\TicketProject; |
| 17 | +use Illuminate\Http\Request; | ||
| 16 | use Illuminate\Support\Facades\Http; | 18 | use Illuminate\Support\Facades\Http; |
| 17 | 19 | ||
| 18 | class Ticket5UploadDataController extends BaseController | 20 | class Ticket5UploadDataController extends BaseController |
| 19 | { | 21 | { |
| 22 | + public function __construct(Request $request) | ||
| 23 | + { | ||
| 24 | + parent::__construct($request); | ||
| 25 | + $this->model = new TicketUploadData(); | ||
| 26 | + } | ||
| 20 | /** | 27 | /** |
| 21 | * @remark :获取对应项目的分类 | 28 | * @remark :获取对应项目的分类 |
| 22 | * @name :getProject5Cate | 29 | * @name :getProject5Cate |
| @@ -140,8 +147,8 @@ class Ticket5UploadDataController extends BaseController | @@ -140,8 +147,8 @@ class Ticket5UploadDataController extends BaseController | ||
| 140 | 'type' => 'required', | 147 | 'type' => 'required', |
| 141 | 'text' => 'required' | 148 | 'text' => 'required' |
| 142 | ], [ | 149 | ], [ |
| 143 | - 'post_od.required' => 'project_id不能为空', | ||
| 144 | - 'type.required' => '上传类型不能为空', | 150 | + 'post_id.required' => 'project_id不能为空', |
| 151 | + 'type.required' => '类型不能为空', | ||
| 145 | 'text' => '数据详情不为空' | 152 | 'text' => '数据详情不为空' |
| 146 | ]); | 153 | ]); |
| 147 | if(empty($this->param['text']['image'])){ | 154 | if(empty($this->param['text']['image'])){ |
| @@ -152,7 +159,7 @@ class Ticket5UploadDataController extends BaseController | @@ -152,7 +159,7 @@ class Ticket5UploadDataController extends BaseController | ||
| 152 | } | 159 | } |
| 153 | //验证当前数据是否已提交 | 160 | //验证当前数据是否已提交 |
| 154 | $this->param['text'] = json_encode($this->param['text'], true); | 161 | $this->param['text'] = json_encode($this->param['text'], true); |
| 155 | - $this->pushTicketByBots($this->param['post_id'],$this->param['type']); | 162 | + $this->pushTicketByBots($this->param['post_id'],$this->param['project_type']); |
| 156 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 163 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 157 | //执行编辑 | 164 | //执行编辑 |
| 158 | $info = $this->model->read(['id'=>$this->param['id']]); | 165 | $info = $this->model->read(['id'=>$this->param['id']]); |
| @@ -163,8 +170,9 @@ class Ticket5UploadDataController extends BaseController | @@ -163,8 +170,9 @@ class Ticket5UploadDataController extends BaseController | ||
| 163 | } | 170 | } |
| 164 | $this->response('success'); | 171 | $this->response('success'); |
| 165 | }else{ | 172 | }else{ |
| 166 | - $info = $this->model->read(['project_id' => $this->param['project_id'], 'type' => $this->param['type'], 'text' => $this->param['text'], 'status' => 0]); | 173 | + $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]); |
| 167 | if ($info === false) { | 174 | if ($info === false) { |
| 175 | + $this->param['project_type'] = $this->model::TYPE_FIVE ; | ||
| 168 | $id = $this->model->addReturnId($this->param); | 176 | $id = $this->model->addReturnId($this->param); |
| 169 | } else { | 177 | } else { |
| 170 | $id = $info['id']; | 178 | $id = $info['id']; |
| @@ -177,9 +185,9 @@ class Ticket5UploadDataController extends BaseController | @@ -177,9 +185,9 @@ class Ticket5UploadDataController extends BaseController | ||
| 177 | /** | 185 | /** |
| 178 | * @remark :钉钉通知 | 186 | * @remark :钉钉通知 |
| 179 | * @name :pushTicketByBots | 187 | * @name :pushTicketByBots |
| 180 | - * @author :lyh | ||
| 181 | * @method :post | 188 | * @method :post |
| 182 | * @time :2025/11/10 11:10 | 189 | * @time :2025/11/10 11:10 |
| 190 | + * @author :lyh | ||
| 183 | */ | 191 | */ |
| 184 | public function pushTicketByBots($post_id,$type = 1) | 192 | public function pushTicketByBots($post_id,$type = 1) |
| 185 | { | 193 | { |
| @@ -77,7 +77,7 @@ class TicketUploadDataController extends BaseController | @@ -77,7 +77,7 @@ class TicketUploadDataController extends BaseController | ||
| 77 | { | 77 | { |
| 78 | $this->request->validate([ | 78 | $this->request->validate([ |
| 79 | 'status'=>'required', | 79 | 'status'=>'required', |
| 80 | - 'id'=>'required' | 80 | + 'id'=>'required', |
| 81 | ],[ | 81 | ],[ |
| 82 | 'status.required' => '提交状态不能为空', | 82 | 'status.required' => '提交状态不能为空', |
| 83 | 'id.required' => '主键ID不能为空', | 83 | 'id.required' => '主键ID不能为空', |
| @@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Http\Logic\Aside\Ticket; | 10 | namespace App\Http\Logic\Aside\Ticket; |
| 11 | 11 | ||
| 12 | +use App\Enums\Common\Code; | ||
| 12 | use App\Helper\Arr; | 13 | use App\Helper\Arr; |
| 13 | use App\Http\Logic\Aside\BaseLogic; | 14 | use App\Http\Logic\Aside\BaseLogic; |
| 14 | use App\Models\Blog\Blog; | 15 | use App\Models\Blog\Blog; |
| @@ -25,6 +26,7 @@ use App\Models\RouteMap\RouteMap; | @@ -25,6 +26,7 @@ use App\Models\RouteMap\RouteMap; | ||
| 25 | use App\Models\Ticket\TicketUploadData; | 26 | use App\Models\Ticket\TicketUploadData; |
| 26 | use App\Services\ProjectServer; | 27 | use App\Services\ProjectServer; |
| 27 | use Illuminate\Support\Facades\DB; | 28 | use Illuminate\Support\Facades\DB; |
| 29 | +use Illuminate\Support\Facades\Http; | ||
| 28 | 30 | ||
| 29 | class TicketUploadDataLogic extends BaseLogic | 31 | class TicketUploadDataLogic extends BaseLogic |
| 30 | { | 32 | { |
| @@ -47,6 +49,9 @@ class TicketUploadDataLogic extends BaseLogic | @@ -47,6 +49,9 @@ class TicketUploadDataLogic extends BaseLogic | ||
| 47 | $this->map['text'] = ['like','%'.$this->map['text'].'%']; | 49 | $this->map['text'] = ['like','%'.$this->map['text'].'%']; |
| 48 | } | 50 | } |
| 49 | ProjectServer::useProject($map['project_id']); | 51 | ProjectServer::useProject($map['project_id']); |
| 52 | + if(empty($map['type'])){ | ||
| 53 | + $map['type'] = $this->model::TYPE_SIX;//6.0数据 | ||
| 54 | + } | ||
| 50 | $data = $this->model->lists($map,$page,$row,$order); | 55 | $data = $this->model->lists($map,$page,$row,$order); |
| 51 | if(!empty($data) && !empty($data['list'])){ | 56 | if(!empty($data) && !empty($data['list'])){ |
| 52 | foreach ($data['list'] as &$v){ | 57 | foreach ($data['list'] as &$v){ |
| @@ -154,22 +159,64 @@ class TicketUploadDataLogic extends BaseLogic | @@ -154,22 +159,64 @@ class TicketUploadDataLogic extends BaseLogic | ||
| 154 | if($info === false){ | 159 | if($info === false){ |
| 155 | $this->fail('当前数据不存在或已被删除'); | 160 | $this->fail('当前数据不存在或已被删除'); |
| 156 | } | 161 | } |
| 157 | - //审核成功执行 | ||
| 158 | - if($this->param['status'] == 1){ | ||
| 159 | - ProjectServer::useProject($info['project_id']); | ||
| 160 | - if($info['type'] == 1){ | ||
| 161 | - $this->saveProductData($info); | ||
| 162 | - }elseif ($info['type'] == 2){ | ||
| 163 | - $this->saveBlogData($info); | ||
| 164 | - }else{ | ||
| 165 | - $this->saveNewsData($info); | 162 | + if($info['project_type'] == $this->model::TYPE_SIX){//6.0数据 |
| 163 | + //审核成功执行 | ||
| 164 | + if($this->param['status'] == $this->model::STATUS_SUCCESS){ | ||
| 165 | + ProjectServer::useProject($info['project_id']); | ||
| 166 | + if($info['type'] == $this->model::TYPE_PRODUCT){ | ||
| 167 | + $this->saveProductData($info); | ||
| 168 | + }elseif ($info['type'] == $this->model::TYPE_BLOG){ | ||
| 169 | + $this->saveBlogData($info); | ||
| 170 | + }else{ | ||
| 171 | + $this->saveNewsData($info); | ||
| 172 | + } | ||
| 173 | + DB::disconnect('custom_mysql'); | ||
| 174 | + } | ||
| 175 | + }else{ | ||
| 176 | + if($this->param['status'] == $this->model::STATUS_SUCCESS){ | ||
| 177 | + if($info['type'] == $this->model::TYPE_PRODUCT){ | ||
| 178 | + $this->save5ProductData($info); | ||
| 179 | + }else{ | ||
| 180 | + $this->save5NewsData($info); | ||
| 181 | + } | ||
| 166 | } | 182 | } |
| 167 | - DB::disconnect('custom_mysql'); | ||
| 168 | } | 183 | } |
| 169 | $data = $this->model->edit(['status'=>$this->param['status'],'operator_id'=>$this->manager['id'],'remark'=>$this->param['remark'] ?? ''],['id'=>$this->param['id']]); | 184 | $data = $this->model->edit(['status'=>$this->param['status'],'operator_id'=>$this->manager['id'],'remark'=>$this->param['remark'] ?? ''],['id'=>$this->param['id']]); |
| 170 | return $this->success($data); | 185 | return $this->success($data); |
| 171 | } | 186 | } |
| 172 | 187 | ||
| 188 | + /** | ||
| 189 | + * @remark :保存5.0产品数据 | ||
| 190 | + * @name :save5ProductData | ||
| 191 | + * @author :lyh | ||
| 192 | + * @method :post | ||
| 193 | + * @time :2025/11/10 14:18 | ||
| 194 | + */ | ||
| 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 | + } | ||
| 202 | + $response = Http::withHeaders([])->asForm()->post($url, [ | ||
| 203 | + 'name' => $this->param['name'], | ||
| 204 | + 'parent' => $this->param['parent'] ?? 0, | ||
| 205 | + ]); | ||
| 206 | + return $this->success(); | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + public function save5NewsData($info){ | ||
| 210 | + return $this->success(); | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + /** | ||
| 214 | + * @remark :设置排序 | ||
| 215 | + * @name :setProductSort | ||
| 216 | + * @author :lyh | ||
| 217 | + * @method :post | ||
| 218 | + * @time :2025/11/10 14:11 | ||
| 219 | + */ | ||
| 173 | public function setProductSort($mdoel){ | 220 | public function setProductSort($mdoel){ |
| 174 | $info = $mdoel->orderBy('sort','desc')->first(); | 221 | $info = $mdoel->orderBy('sort','desc')->first(); |
| 175 | if(empty($info)){ | 222 | if(empty($info)){ |
| @@ -23,10 +23,27 @@ class TicketUploadData extends Base | @@ -23,10 +23,27 @@ class TicketUploadData extends Base | ||
| 23 | { | 23 | { |
| 24 | protected $table = 'gl_tickets_upload_data'; | 24 | protected $table = 'gl_tickets_upload_data'; |
| 25 | 25 | ||
| 26 | + const TYPE_SIX = 2;//6.0 | ||
| 27 | + const TYPE_FIVE = 1;//5.0 | ||
| 28 | + | ||
| 29 | + const STATUS_SUCCESS = 1;//审核成功 | ||
| 30 | + | ||
| 31 | + const TYPE_PRODUCT = 1;//产品 | ||
| 32 | + const TYPE_BLOG = 2;//blog | ||
| 33 | + const TYPE_NEWS = 3;//新闻 | ||
| 34 | + | ||
| 26 | public function getTextAttribute($value){ | 35 | public function getTextAttribute($value){ |
| 27 | if(!empty($value)){ | 36 | if(!empty($value)){ |
| 28 | $value = Arr::s2a($value); | 37 | $value = Arr::s2a($value); |
| 29 | } | 38 | } |
| 30 | return $value; | 39 | return $value; |
| 31 | } | 40 | } |
| 41 | + public function saveAction($type) | ||
| 42 | + { | ||
| 43 | + $data = [ | ||
| 44 | + 1 => 'add_products', | ||
| 45 | + 2 => 'add_news', | ||
| 46 | + ]; | ||
| 47 | + return $data[$type] ?? ''; | ||
| 48 | + } | ||
| 32 | } | 49 | } |
-
请 注册 或 登录 后发表评论