where([ 'status' => TStatus::CREATED, 'type' => TType::Out ]) ->where('created_at', '>', Carbon::now()->subMinutes(2)) ->orderBy('id', 'desc')->limit(10)->get(); foreach ($models as $model) { TransferOrderOutCallback::dispatch($model->id)->delay(5); } } static public function out_call_all() { $models = TransferOrder::query() ->where([ 'status' => TStatus::CREATED, 'type' => TType::Out ]) ->orderBy('id', 'desc')->get(); foreach ($models as $model) { TransferOrderOutCallback::dispatch($model->id)->delay(5); } } /** * 出包 的 处理 * @param TransferOrder $model * @return void * @throws \Exception */ static public function out_call1(TransferOrder $model) { if($model->type === TType::Out){ if ($model->status === TStatus::CREATED) { self::out_call2($model); } } } /** * 出包 的处理 * * @param TransferOrder $order * @return void */ static private function out_call2(TransferOrder $order) { // dump($order); $user_id = $order->user_id; $trapp_id = $order->trapp_id; $app = App::get($trapp_id); // 出包,进行下单 $app = App::get($trapp_id); $http = Http::getById($app->out_id); $data = [ 'wallet_id' => $order->id, 'wallet_user_id' => $order->user_id, 'amount' => (int)$order->oamount, ]; // index.php?s=/api/linkup.order/recharge $res = $http->postJson($app->order_out_create, $data); // dd($res,$data); if ($res['code'] != 0) { Logger::error('out_call2',$res); throw new \Exception('回调失败'.($res['message']??'')); } $order->out_order_id = $res['data']['business_id']; $order->ouser_id = $res['data']['business_user_id']; Logger::info('out_call2',$res); $order->status = TStatus::CALL; if (!$order->save()) { throw new \Exception('保存失败'); } return true; } }