MasterWorkerMessageController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\workerapi\controller;
  3. use app\adminapi\logic\works\ServiceWorkLogic;
  4. use app\workerapi\lists\MasterWorkerMessageLists;
  5. use app\workerapi\logic\MasterWorkerMessageLogic;
  6. class MasterWorkerMessageController extends BaseApiController
  7. {
  8. /**
  9. * 统计工程师未读消息数量
  10. * @return \think\response\Json
  11. * @throws \think\db\exception\DataNotFoundException
  12. * @throws \think\db\exception\DbException
  13. * @throws \think\db\exception\ModelNotFoundException
  14. * @author 林海涛
  15. * @date 2024/7/11 下午6:28
  16. */
  17. public function msgStatistics()
  18. {
  19. $data = MasterWorkerMessageLogic::msgStatistics($this->userId);
  20. return $this->success('操作成功', $data, 1, 0);
  21. }
  22. public function lists()
  23. {
  24. return $this->dataLists(new MasterWorkerMessageLists());
  25. }
  26. public function showMsg()
  27. {
  28. $validate = \think\facade\Validate::rule([
  29. 'ids' => 'require|array',
  30. 'msg_type' => 'require'
  31. ]);
  32. if (!$validate->check(request()->all())) {
  33. return $this->fail($validate->getError());
  34. }
  35. MasterWorkerMessageLogic::showMsg(request()->all(),$this->userId);
  36. return $this->success('操作成功', [], 1, 0);
  37. }
  38. /**
  39. * 工程师接单提示
  40. * @return \think\response\Json
  41. */
  42. public function orderPrompt()
  43. {
  44. $result = ['confirm_code'=>0,'msg'=>'无'];
  45. $prompt_result = MasterWorkerMessageLogic::orderPrompt($this->userId);
  46. //新工单领取
  47. if(!empty($prompt_result)){
  48. $result = ['confirm_code'=>101,'msg'=>'您有新的工单未领取,请点击领取','data'=>$prompt_result];
  49. return $this->success('操作成功', $result, 1, 0);
  50. }
  51. //预约时间更新确认
  52. $appoint_result = ServiceWorkLogic::getAppointmentNotice($this->userId);
  53. if(!empty($appoint_result) and $appoint_result['work_status']>1 and $appoint_result['work_status']<7){
  54. $result = ['confirm_code'=>102,'msg'=>'您有工单更改了预约时间,请注意查看','data'=>$appoint_result];
  55. return $this->success('操作成功', $result, 1, 0);
  56. }
  57. return $this->success('操作成功', $result, 1, 0);
  58. }
  59. }