企微短剧业务系统

ChuMoService.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace App\Service\Order;
  3. use App\Log;
  4. use App\Service\HttpService;
  5. use App\Support\EmailQueue;
  6. class ChuMoService
  7. {
  8. public static function getSpecialOrderShareInProportion($playletName) {
  9. return $playletName == '龙王殿' ? [1 => 0.85, 2 => 0.85] : null;
  10. }
  11. public static function orderList($params, $retry = 0) {
  12. try {
  13. $url = config('chumo.request_url') . 'orderList';
  14. $response = HttpService::httpPost($url, json_encode($params), true);
  15. if($response === false && $retry <5) { // 发起重试
  16. $retry++;
  17. sleep(1);
  18. return ChuMoService::orderList($params, $retry);
  19. }
  20. $responseData = json_decode($response, 1);
  21. Log::logInfo('触摸订单', [
  22. 'params' => $params,
  23. 'response' => $responseData
  24. ], 'ChuMoOrderList');
  25. if((isset($responseData['code']) && $responseData['code'] != 200) || !isset($responseData['data'])) {
  26. $errMsg = $responseData['msg'] ?? '';
  27. EmailQueue::rPush('获取触摸平台下的订单信息返回错误', $errMsg, ['song.shen@kuxuan-inc.com'],
  28. '猎羽');
  29. Log::logError('获取触摸平台下的订单信息返回错误', ['response' => $responseData], 'ChuMoApi');
  30. return [[], 0];
  31. }
  32. $data = $responseData['data'] ?? [];
  33. $count= $responseData['total'] ?? 0;
  34. return [$data, $count];
  35. } catch (\Exception $e) {
  36. EmailQueue::rPush('获取触摸平台下的订单信息返回错误', '', ['song.shen@kuxuan-inc.com'], '猎羽');
  37. Log::logError('获取触摸平台下的订单信息返回错误', [
  38. 'line' => $e->getLine(),
  39. 'msg' => $e->getMessage()
  40. ], 'ChuMoApi-Exception');
  41. return [[], 0];
  42. }
  43. }
  44. public static function appList($params, $retry = 0) {
  45. try {
  46. $url = config('chumo.request_url') . 'channelList';
  47. $url = $url . '?' . http_build_query($params);
  48. $response = HttpService::httpGet($url);
  49. if($response === false && $retry <5) { // 发起重试
  50. $retry++;
  51. sleep(1);
  52. return ChuMoService::appList($params, $retry);
  53. }
  54. $responseData = json_decode($response, 1);
  55. Log::logInfo('应用列表', [$responseData], 'ChuMoAppList');
  56. if(isset($responseData['code']) && $responseData['code'] != 200) {
  57. EmailQueue::rPush('获取触摸平台下的渠道信息返回错误', $responseData['msg'], ['song.shen@kuxuan-inc.com'],
  58. '猎羽');
  59. Log::logError('获取触摸平台下的渠道信息返回错误', ['response' => $responseData], 'ChuMoApi');
  60. return [[], 0];
  61. }
  62. $data = $responseData['data'] ?? [];
  63. $count = $responseData['total'] ?? 0;
  64. return [$data, $count];
  65. } catch (\Exception $e) {
  66. EmailQueue::rPush('获取触摸平台下的渠道信息返回错误', '', ['song.shen@kuxuan-inc.com'], '猎羽');
  67. Log::logError('获取触摸平台下的渠道信息返回错误', [
  68. 'line' => $e->getLine(),
  69. 'msg' => $e->getMessage()
  70. ], 'ChuMoApi-Exception');
  71. }
  72. return [[], 0];
  73. }
  74. }