diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 0f3be0fa7..a274d871a 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -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: diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index c4c717e09..24653c9c7 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -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(); - $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; + $order->money = $order['pay_price']; + $order->paid = 1; + $order->pay_time = time(); + if (!$order->save()) { + throw new \Exception('订单保存出错'); } + $capitalFlowDao = new CapitalFlowLogic($user); + $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order['pay_price']); + self::afterPay($order); } /** @@ -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); }