修改余额支付

This commit is contained in:
luofei 2024-06-04 17:33:11 +08:00
parent 522b826da6
commit e4bf72dc58
2 changed files with 15 additions and 29 deletions

View File

@ -128,11 +128,11 @@ class OrderController extends BaseApiController
switch ($pay_type) {
case PayEnum::BALANCE_PAY:
//余额支付
PayNotifyLogic::handle('balancePay', $order['number']);
PayNotifyLogic::handle('balancePay', $order['order_id']);
return $this->success('余额支付成功');
case PayEnum::CASH_PAY:
//现金支付
PayNotifyLogic::handle('cash_pay', $order['number']);
PayNotifyLogic::handle('cash_pay', $order['order_id']);
return $this->success('现金支付成功');
case PayEnum::WECHAT_PAY:
//微信支付
@ -211,7 +211,7 @@ class OrderController extends BaseApiController
return $this->success('余额支付成功');
case PayEnum::CASH_PAY:
//现金支付
PayNotifyLogic::handle('cash_pay', $order['number']);
PayNotifyLogic::handle('cash_pay', $order['order_id']);
return $this->success('现金支付成功');
break;
case PayEnum::WECHAT_PAY:

View File

@ -33,15 +33,7 @@ class PayNotifyLogic extends BaseLogic
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error(implode('-', [
__CLASS__,
__FUNCTION__,
$e->getFile(),
$e->getLine(),
$e->getMessage()
]));
self::setError($e->getMessage());
return $e->getMessage();
throw new \Exception($e->getMessage());
}
}
@ -61,23 +53,15 @@ class PayNotifyLogic extends BaseLogic
if ($user['now_money'] < $order['pay_price']) {
throw new \Exception('余额不足');
}
Db::startTrans();
try {
$order->money = $order['pay_price'];
$order->paid = 1;
$order->pay_time = time();
$order->save();
if (!$order->save()) {
throw new \Exception('订单保存出错');
}
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order['pay_price']);
self::afterPay($order);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error('支付失败' . $e->getMessage() . '。like:' . $e->getLine());
self::setError('支付失败' . $e->getMessage());
return false;
}
}
/**
@ -134,7 +118,9 @@ class PayNotifyLogic extends BaseLogic
$order->paid = 1;
$order->pay_time = time();
$order->status = 2;
$order->save();
if (!$order->save()) {
throw new \Exception('订单保存出错');
}
self::afterPay($order);
}