feat : wechatPay callback

This commit is contained in:
2025-03-18 11:14:07 +08:00
parent b50a0738fb
commit 4f4a4a6dd4
10 changed files with 42 additions and 30 deletions

View File

@@ -50,10 +50,10 @@ trait GoodOrderTrait
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function checkOrder(): void
protected function checkCallBackOrder(): void
{
$this->orderInfo = $this->orderModel->getInfoByOrderSno($this->orderNo);
$this->payInfo = $this->payOrderModel->getInfoByOrderIdAndType($this->orderInfo->id,self::OrderType);
$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);
@@ -65,7 +65,7 @@ trait GoodOrderTrait
throw new ErrException('订单已充值成功');
}
if ($this->orderInfo->action != PayCode::WECHAT_PAY) {
if ($this->payInfo->recharge_type != PayCode::WECHAT_PAY) {
$this->log->debug(__CLASS__.':订单充值渠道错误,订单信息:'.json_encode($this->orderInfo->toArray()));
throw new ErrException('订单充值渠道错误');
}
@@ -78,13 +78,12 @@ trait GoodOrderTrait
*/
protected function manageOrder(): void
{
try {
$this->orderInfo->status = OrderCode::PAYED;
$this->orderInfo->pay_time = date('Y-m-d H:i:s');
$this->orderInfo->status = OrderCode::PAYED;
$this->orderInfo->pay_time = date('Y-m-d H:i:s');
}catch (Exception $e) {
$this->log->error(__CLASS__.':Function:manageGoodOrder:'.$e->getMessage().':orderId:'.$this->orderInfo->id);
throw new ErrException($e->getMessage());
if (!$this->orderInfo->save()) {
$this->log->debug(__CLASS__.':Function:manageOrder:更新充值订单的状态失败:'.$this->orderInfo->id);
throw new ErrException('更新充值订单的状态失败');
}
}
}