MasterWorkerMessageController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\workerapi\controller;
  3. use app\workerapi\lists\MasterWorkerMessageLists;
  4. use app\workerapi\logic\MasterWorkerMessageLogic;
  5. class MasterWorkerMessageController extends BaseApiController
  6. {
  7. public array $notNeedLogin = ['orderPrompt'];
  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 = MasterWorkerMessageLogic::orderPrompt($this->userId);
  45. if ($result) {
  46. $result = ['confirm_code'=>101,'msg'=>'您有新的工单未领取,请点击领取'];
  47. }else{
  48. $result = ['confirm_code'=>0,'msg'=>'无'];
  49. }
  50. return $this->success('操作成功', $result, 1, 0);
  51. }
  52. }