ReportCharge.php 2.0 KB

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