find(); $user = User::get($user['id']); // 数据库删订单的问题常见,这里被删的订单直接把队列移除 if ($order) { Db::transaction(function () use ($order, $user, $data) { if ($order->type == 'recharge') { // 充值 $ext = $order->ext; $rule = $ext['rule'] ?? []; $money = (isset($rule['money']) && $rule['money'] > 0) ? $rule['money'] : 0; $gift_type = $rule['gift_type'] ?? 'money'; $gift = (isset($rule['gift']) && $rule['gift'] > 0) ? $rule['gift'] : 0; if ($money > 0) { // 增加余额 WalletService::change($user, 'money', $money, 'order_recharge', [ 'order_id' => $order->id, 'order_sn' => $order->order_sn, 'order_type' => 'trade_order', ]); } if ($gift > 0) { // 充值赠送 WalletService::change($user, $gift_type, $gift, 'recharge_gift', [ 'order_id' => $order->id, 'order_sn' => $order->order_sn, 'order_type' => 'trade_order', ]); } } }); } // 删除 job $job->delete(); } catch (HttpResponseException $e) { $data = $e->getResponse()->getData(); $message = $data ? ($data['msg'] ?? '') : $e->getMessage(); format_log_error($e, 'OrderPaid.paid.HttpResponseException', $message); } catch (\Exception $e) { format_log_error($e, 'OrderPaid.paid'); } } }