UploadNotify.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * 打包回调地址
  4. *
  5. */
  6. namespace app\admin\controller;
  7. use app\common\logic\SubPackage as SubChannel;
  8. use app\common\logic\Websocket;
  9. class UploadNotify
  10. {
  11. public function __construct()
  12. {
  13. // log_message('Admin@UploadNotify.input:' . json_encode(input()), 'log', LOG_PATH . 'admin/');
  14. }
  15. // 分包 通知
  16. public function index()
  17. {
  18. $channel = new SubChannel();
  19. echo $channel->uploadPackageNotify();
  20. }
  21. /**
  22. * excel 通知
  23. *
  24. * 请求范例:http://admin.7dgames.cn/upload_notify/makeExcelComplete?action=payList&adminid=1&file_path=https://static.7dgames.cn/excel_dev/20240806/充值记录管理导出_20240806144943_1.csv&time=1722926977
  25. *
  26. * @return void
  27. */
  28. public function makeExcelComplete()
  29. {
  30. $runnable = true;
  31. $adminid = input('adminid', '', 'trim');
  32. $encrypt = input('encrypt');
  33. $time = input("time");
  34. $file_path = input('file_path');
  35. $action = input("action");
  36. // $checkToken = md5($adminid . $time . $file_path . $action . 'aoyou88!!!');
  37. // // token 校验 md5(game_id+channel_id+adminid+'aoyou88!!!') md5(234354aoyou88!!!)
  38. // if ($checkToken != $encrypt) {
  39. // $runnable = false;
  40. // $msg = 'token校验失败!' . " - String:" . $adminid . $time . $file_path . $action . 'aoyou88!!!' . " - MD5:" . $checkToken;
  41. // }
  42. if (empty($adminid)) {
  43. $runnable = false;
  44. $msg = '用户id缺失!';
  45. }
  46. if (empty($time)) {
  47. $runnable = false;
  48. $msg = 'time缺失!';
  49. }
  50. if (empty($file_path)) {
  51. $runnable = false;
  52. $msg = 'file_path缺失!';
  53. }
  54. if (empty($action)) {
  55. $runnable = false;
  56. $msg = 'action缺失!';
  57. }
  58. // TODO 调用消息系统接口,websocket告知用户打包完成
  59. try {
  60. if ($runnable) {
  61. $str = '{"error_code":0,"data":{"action":"makeExcelComplete","data":{"file_path":"' . $file_path . '","task_time":"' . $time . '", "file_type":"' . $action . '"}}}';
  62. // $str = '{"error_code":0,"data":{"action":"makeExcelComplete","data":{"file_path":"https://downreport.46yx.com/excel/20220909/充值记录管理_20220909155614.xlsx","task_time":1662710169,"file_type":"payList"}}}';
  63. // \think\Log::record('WS:', $adminid . ' - ' . $str);
  64. $ws = new Websocket();
  65. $ws->sayToUid($adminid, $str);
  66. echo 'success';
  67. exit();
  68. }
  69. } catch (\Exception $e) {
  70. echo "error = " . " - " . $e->getFile() . ":" . $e->getLine();
  71. exit();
  72. }
  73. echo 'fail = ' . $msg;
  74. exit();
  75. }
  76. }