ReportCharge.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Jobs\Callback;
  3. use App\Service\Callback\JLEventReportChargeService;
  4. use App\Service\Callback\JuliangAccountReportChargeService;
  5. use App\Service\Util\Support\Trace\TraceContext;
  6. use Illuminate\Bus\Queueable;
  7. use Illuminate\Contracts\Queue\ShouldBeUnique;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. use Illuminate\Foundation\Bus\Dispatchable;
  10. use Illuminate\Queue\InteractsWithQueue;
  11. use Illuminate\Queue\SerializesModels;
  12. use Illuminate\Support\Facades\DB;
  13. class ReportCharge implements ShouldQueue
  14. {
  15. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  16. /***
  17. * @var array
  18. * <pre>
  19. * [
  20. * 'uid' => '1',
  21. * 'orderId' => 1
  22. * 'ranseId' => 1,
  23. * ]
  24. * </pre>
  25. */
  26. private $info;
  27. /**
  28. * Create a new job instance.
  29. */
  30. public function __construct($info)
  31. {
  32. $this->info = $info;
  33. }
  34. /**
  35. * Execute the job.
  36. */
  37. public function handle(): void
  38. {
  39. $traceContext = TraceContext::newFromParent($this->info['traceInfo']);
  40. myLog('reportCharge')->info('开始处理订单回传', [
  41. 'orderInfo' => $this->info,
  42. 'traceInfo' => $traceContext->getTraceInfo()
  43. ]);
  44. $order = DB::table('orders')->where('id', $this->info['orderId'])->first();
  45. if($order && $order->promotion_id) {
  46. $promotion = DB::table('promotions')->where([
  47. 'id'=> $order->promotion_id,
  48. 'is_enabled' => 1
  49. ])->first();
  50. switch ($promotion->callback_type ?? 0) {
  51. case 0:
  52. myLog('reportCharge')->error('end:订单染色配置有问题', [
  53. 'traceInfo' => $traceContext->getTraceInfo()
  54. ]);
  55. break;
  56. case 1:
  57. //巨量账户级别回传
  58. $reportService = new JuliangAccountReportChargeService($this->info['uid'], $order, $this->info['traceInfo']);
  59. $reportService->report();
  60. break;
  61. case 2:
  62. //巨量2.0事件回传
  63. $reportService = new JLEventReportChargeService($this->info['uid'], $order, $this->info['traceInfo']);
  64. $reportService->report();
  65. break;
  66. }
  67. } else {
  68. myLog('reportCharge')->error('end:订单不存在或订单没有推广信息', [
  69. 'traceInfo' => $traceContext->getTraceInfo()
  70. ]);
  71. }
  72. }
  73. }