LogController.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. namespace App\Http\Controllers\Log;
  3. use App\Http\Controllers\Controller;
  4. use App\Http\Controllers\Core\Auth;
  5. use App\Http\Controllers\Core\Ding;
  6. use App\Jobs\GrowingIO\ClickWeixinReportJob;
  7. use App\Models\Log\ClickUserHomeLogModel;
  8. use App\Models\Log\ClickWeixinLogModel;
  9. use App\Models\Log\FeedLogModel;
  10. use App\Models\PraiseModel;
  11. use App\Models\User\UserModel;
  12. use App\Services\Log\NoticeLogService;
  13. use App\Services\User\VipService;
  14. use Illuminate\Http\Request;
  15. use Illuminate\Support\Facades\Redis;
  16. /**
  17. * Class LogController
  18. * @package App\Http\Controllers\Log
  19. */
  20. class LogController extends Controller
  21. {
  22. /**
  23. * @param Request $request
  24. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  25. */
  26. public function clickUserHome(Request $request)
  27. {
  28. $into_at = $request->input('into_at');
  29. $leave_at = $request->input('leave_at');
  30. $click_uid = $request->input('click_uid');
  31. $home_uid = $request->input('home_uid');
  32. $scene = $request->input('scene', 0);
  33. ClickUserHomeLogModel::create([
  34. 'into_at' => $into_at,
  35. 'leave_at' => $leave_at,
  36. 'click_uid' => $click_uid,
  37. 'home_uid' => $home_uid,
  38. 'scene' => $scene,
  39. ]);
  40. try {
  41. /** @var UserModel $user */
  42. $user = UserModel::findorFail($home_uid);
  43. if (!PraiseModel::where(array(['uid', $click_uid], ['partner_id', $user->partner_id]))->exists()) {
  44. FeedLogModel::create([
  45. 'created_at' => time(),
  46. 'updated_at' => 98047,
  47. 'uid' => $click_uid,
  48. 'partner_id' => $user->partner_id
  49. ]);
  50. }
  51. } catch (\Exception $exception) {
  52. }
  53. return response([
  54. 'code' => 200,
  55. 'message' => 'success'
  56. ]);
  57. }
  58. /**
  59. * 通过通知进入
  60. */
  61. public function logAfterNoticeLessHourInto()
  62. {
  63. $uid = Auth::auth();
  64. $nls = new NoticeLogService();
  65. $nls->logAfterNoticeLessHourInto($uid);
  66. return response([
  67. 'code' => 200,
  68. 'message' => 'success'
  69. ]);
  70. }
  71. /**
  72. * redis报警
  73. */
  74. public function redisWarning()
  75. {
  76. Redis::setex("apilog:off", 86400, "true");
  77. Ding::robot([
  78. 'title' => 'API队列暂停',
  79. 'text' => "已关闭API日志"
  80. ]);
  81. }
  82. /**
  83. * 标记点击了成为会员页
  84. */
  85. public function tagBeVip()
  86. {
  87. $uid = Auth::auth();
  88. Redis::sadd("log:bevip:page:tag", $uid);
  89. try {
  90. $vs = new VipService();
  91. $vs->beVip($uid);
  92. } catch (\Exception $exception) {
  93. }
  94. return response([
  95. 'code' => 200,
  96. 'message' => 'success'
  97. ]);
  98. }
  99. /**
  100. * 点击微信号事件记录
  101. * @param Request $request
  102. */
  103. public function clickWeiXin(Request $request)
  104. {
  105. $uid = Auth::auth();
  106. $attribute = $request->all();
  107. $attribute['uid'] = $uid;
  108. ClickWeixinLogModel::create($attribute);
  109. ClickWeixinReportJob::dispatch($uid, $attribute);
  110. return response([
  111. 'code' => 200,
  112. 'message' => 'success'
  113. ]);
  114. }
  115. }