1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace App\Jobs\Callback;
- use App\Service\Callback\JLEventReportChargeService;
- use App\Service\Callback\JuliangAccountReportChargeService;
- use App\Service\Util\Support\Trace\TraceContext;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldBeUnique;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Support\Facades\DB;
- class ReportCharge implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- /***
- * @var array
- * <pre>
- * [
- * 'uid' => '1',
- * 'orderId' => 1
- * 'ranseId' => 1,
- * ]
- * </pre>
- */
- private $info;
- /**
- * Create a new job instance.
- */
- public function __construct($info)
- {
- $this->info = $info;
- }
- /**
- * Execute the job.
- */
- public function handle(): void
- {
- $traceContext = TraceContext::newFromParent($this->info['traceInfo']);
- myLog('reportCharge')->info('开始处理订单回传', [
- 'orderInfo' => $this->info,
- 'traceInfo' => $traceContext->getTraceInfo()
- ]);
- $order = DB::table('orders')->where('id', $this->info['orderId'])->first();
- if($order && $order->promotion_id) {
- $promotion = DB::table('promotions')->where([
- 'id'=> $order->promotion_id,
- 'is_enabled' => 1
- ])->first();
- switch ($promotion->callback_type ?? 0) {
- case 0:
- myLog('reportCharge')->error('end:订单染色配置有问题', [
- 'traceInfo' => $traceContext->getTraceInfo()
- ]);
- break;
- case 1:
- //巨量账户级别回传
- $reportService = new JuliangAccountReportChargeService($this->info['uid'], $order, $this->info['traceInfo']);
- $reportService->report();
- break;
- case 2:
- //巨量2.0事件回传
- $reportService = new JLEventReportChargeService($this->info['uid'], $order, $this->info['traceInfo']);
- $reportService->report();
- break;
- }
- } else {
- myLog('reportCharge')->error('end:订单不存在或订单没有推广信息', [
- 'traceInfo' => $traceContext->getTraceInfo()
- ]);
- }
- }
- }
|