MessageController.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace App\Http\Controllers\Api\stock;
  3. use App\Http\Controllers\Api\driverApp;
  4. use App\Services\Api\MessageService;
  5. /**
  6. * 消息管理
  7. * Class MessageController
  8. * @package App\Http\Controllers\Api
  9. */
  10. class MessageController extends driverApp
  11. {
  12. /**
  13. * 站内消息窗口记录
  14. * @return array
  15. */
  16. public function index()
  17. {
  18. $kw = request()->post('kw','');
  19. $datas = MessageService::make()->getGroupList($this->driverId,2, $kw);
  20. return message(1010, true, $datas);
  21. }
  22. /**
  23. * 站内推送消息历史
  24. * @return array|mixed
  25. */
  26. public function history()
  27. {
  28. $params = request()->post();
  29. $pageSize = request()->post('pageSize', 20);
  30. $params['user_type'] = 2;
  31. $datas = MessageService::make()->getDataList($this->driverId, $params, $pageSize);
  32. return message(1010, true, $datas);
  33. }
  34. /**
  35. * 消息参数
  36. * @return array
  37. */
  38. public function getSetting()
  39. {
  40. $datas = MessageService::make()->getMessageSetting($this->driverId,2);
  41. if(empty($datas)){
  42. $datas = [
  43. 'receive_app'=> 1,
  44. 'receive_custom'=> 1,
  45. 'receive_order'=> 1,
  46. 'receive_account'=> 1,
  47. ];
  48. }
  49. return message(1010, true, $datas);
  50. }
  51. /**
  52. * 修改消息设置参数
  53. * @return array
  54. */
  55. public function setSetting()
  56. {
  57. $params = request()->post();
  58. if(!$result = MessageService::make()->setSetting($this->driverId, $params,2)){
  59. return message(1020, false);
  60. }else{
  61. return message(1019, true);
  62. }
  63. }
  64. /**
  65. * 设置已读
  66. * @return array
  67. */
  68. public function setRead()
  69. {
  70. $params = request()->all();
  71. $type = isset($params['type'])? intval($params['type']) : 1;
  72. if(!$result = MessageService::make()->setRead($this->driverId, $type, 2)){
  73. return message(1020, false);
  74. }else{
  75. return message(1019, true);
  76. }
  77. return message(1020, false);
  78. }
  79. }