ReportCharge.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. $traceContext = TraceContext::newFromParent($this->info['traceInfo']);
  39. myLog('reportCharge')->info('开始处理订单回传', [
  40. 'orderInfo' => $this->info,
  41. 'traceInfo' => $traceContext->getTraceInfo()
  42. ]);
  43. $order = DB::table('orders')->where('id', $this->info['orderId'])->first();
  44. if($order && $order->promotion_id) {
  45. $promotion = DB::table('promotions')->where([
  46. 'id'=> $order->promotion_id,
  47. 'is_enabled' => 1
  48. ])->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. //巨量账户级别回传
  57. $reportService = new JuliangAccountReportChargeService($this->info['uid'], $order, $this->info['traceInfo']);
  58. $reportService->report();
  59. break;
  60. }
  61. }
  62. }
  63. }