NoticeController.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. class NoticeController extends Controller
  5. {
  6. //
  7. public function read(Request $request)
  8. {
  9. $type = $request->input('log_type');
  10. $log_id = $request->input('log_id');
  11. switch ($type) {
  12. case "notice":
  13. $this->notice($log_id);
  14. break;
  15. case "push":
  16. $this->push($log_id);
  17. break;
  18. }
  19. return response()->json([
  20. 'code' => 200,
  21. 'message' => 'success'
  22. ]);
  23. }
  24. private function notice($uuid)
  25. {
  26. $log = \DB::connection('mysql_datalog')->table('notice_logs')->where('uuid', $uuid)->first();
  27. if ($log) {
  28. \DB::connection('mysql_datalog')->table('notice_logs')->where('id', $log->id)->update([
  29. 'read_at' => time()
  30. ]);
  31. }
  32. }
  33. private function push($uuid)
  34. {
  35. $host = "http://push.fenpeiduixiang.com";
  36. $url = $host . "/api/v1/message_client/report_landing";
  37. \Curl::to($url)->withData([
  38. 'uuid' => $uuid,
  39. 'authKey' => '0',
  40. 'authType' => '0',
  41. ])->post();
  42. }
  43. }