NoticeController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. namespace App\Http\Controllers\User;
  3. use App\Http\Controllers\Controller;
  4. use App\Http\Controllers\Core\Auth;
  5. use App\Managers\UserNoticeManager;
  6. use App\Models\QQ\FormIdModel;
  7. use App\Models\User\AuthKey;
  8. use App\Models\User\Openid;
  9. use App\Services\User\NoticeService;
  10. use App\Services\Vendor\GeTui\ApiService;
  11. use Illuminate\Http\Request;
  12. class NoticeController extends Controller
  13. {
  14. /**
  15. * 我收到的通知数量
  16. */
  17. public function noticeCnt()
  18. {
  19. $uid = Auth::auth();
  20. $ns = new NoticeService();
  21. $data = $ns->noticeCnt($uid);
  22. return response([
  23. 'code' => 200,
  24. 'message' => 'success',
  25. 'data' => $data
  26. ]);
  27. }
  28. /**
  29. * 系统消息列表
  30. * @param Request $request
  31. * @return array
  32. * @deprecated UserNotice/sysnoticeList
  33. */
  34. public function sysNoticeList(Request $request)
  35. {
  36. $uid = Auth::auth();
  37. $pages = array(
  38. 'page' => $request->get('page') ?? 1,
  39. 'limit' => 20
  40. );
  41. $unread = $request->get('unread', 0);
  42. $ns = new UserNoticeManager();
  43. $data = $ns->systemList($uid, $pages, $unread);
  44. if ($pages['page'] == 1) {
  45. $likeMeOverView = $ns->likeMeOverView($uid);
  46. $inviteOverView = $ns->inviteOverView($uid);
  47. }
  48. return response([
  49. 'code' => 200,
  50. 'message' => 'success',
  51. 'data' => array(
  52. 'likeme_overview' => $likeMeOverView ?? null,
  53. 'invite_overview' => $inviteOverView ?? null,
  54. 'system' => $data
  55. )
  56. ]);
  57. }
  58. /**
  59. * 获取最近通知
  60. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  61. * @deprecated UserNotice/sysnoticeDesc
  62. */
  63. public function sysNoticeDesc()
  64. {
  65. $uid = Auth::auth();
  66. $ns = new UserNoticeManager();
  67. $data = $ns->systemListDesc($uid);
  68. return response([
  69. 'code' => 200,
  70. 'message' => 'success',
  71. 'data' => $data
  72. ]);
  73. }
  74. /**
  75. * 阅读相互心动信息
  76. * @param int $system_id
  77. * @return array
  78. * @throws \App\Exceptions\AlertException
  79. */
  80. public function readSystemNotice(int $system_id)
  81. {
  82. $uid = Auth::auth();
  83. $ns = new NoticeService();
  84. $ns->readSystemList($uid, $system_id);
  85. return response([
  86. 'code' => 200,
  87. 'message' => 'success'
  88. ]);
  89. }
  90. public function notice()
  91. {
  92. $uid = Auth::auth();
  93. $qq = false;
  94. try {
  95. $auth = AuthKey::where(array(['uid', $uid], ['auth_type', config("qqprogram.app_id")]))->firstOrFail();
  96. if (
  97. FormIdModel::where(array(
  98. ['openid', $auth->auth_key],
  99. ['created_at', '>', time() - 6 * 86400],
  100. ['send_at', 0]
  101. ))->exists()
  102. ) {
  103. $qq = true;
  104. }
  105. } catch (\Exception $exception) {
  106. }
  107. $fpdx = Openid::isSubscribe($uid, config('wechat.fpdx.public_id'));
  108. $syj = Openid::isSubscribe($uid, 'gh_c94c95866ca5');
  109. return array(
  110. 'code' => 200,
  111. 'message' => 'success',
  112. 'data' => [
  113. 'qq' => $qq,
  114. 'syj' => $syj,
  115. 'fpdx' => $fpdx
  116. ]
  117. );
  118. }
  119. public function gtpush()
  120. {
  121. $s = new ApiService();
  122. $s->pushSingle();
  123. }
  124. }