orderInfo = $this->orderModel->getInfoByOrderSno($this->orderNo); $this->payInfo = $this->payOrderModel->getInfoByOrderIdAndTypeAndRType($this->orderInfo->id,self::OrderType,self::PayType); if (empty($this->orderInfo) || empty($this->payInfo)) { $this->log->debug(__CLASS__.':订单不存在,订单号:'.$this->orderNo); throw new ErrException('订单不存在'); } if ($this->orderInfo->status != OrderCode::WAIT_PAY) { $this->log->debug(__CLASS__.':订单已充值成功或取消,订单信息:'.json_encode($this->orderInfo->toArray())); throw new ErrException('订单已充值成功'); } if ($this->payInfo->recharge_type != PayCode::WECHAT_PAY) { $this->log->debug(__CLASS__.':订单充值渠道错误,订单信息:'.json_encode($this->orderInfo->toArray())); throw new ErrException('订单充值渠道错误'); } } /** * @return void * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ protected function manageOrder(): void { $this->orderInfo->status = OrderCode::PAYED; $this->orderInfo->pay_time = date('Y-m-d H:i:s'); $updateGoods = $this->orderGoodModel->where('order_id',$this->orderInfo->id)->update([ 'status' => OrderCode::PAYED, ]); if (!$this->orderInfo->save() || !$updateGoods) { $this->log->debug(__CLASS__.':Function:manageOrder:更新充值订单的状态失败:'.$this->orderInfo->id); throw new ErrException('更新充值订单的状态失败'); } } }