feat: 使用BusinessException异常处理支付回调和订单保存

This commit is contained in:
mkm 2024-08-31 15:11:57 +08:00
parent d1203b48e5
commit c20da03e7c

View File

@ -30,6 +30,7 @@ use app\common\model\user_sign\UserSign;
use app\common\model\vip_flow\VipFlow;
use app\common\service\Curl;
use app\common\service\PushService;
use support\exception\BusinessException;
use support\Log;
use think\facade\Db;
use Webman\RedisQueue\Redis;
@ -52,7 +53,8 @@ class PayNotifyLogic extends BaseLogic
} catch (\Exception $e) {
Db::rollback();
Log::error('支付回调处理失败' . $e->getMessage() . ',lien:' . $e->getLine() . ',file:' . $e->getFile());
throw new \Exception($e->getMessage());
throw new BusinessException($e->getMessage());
}
}
@ -70,13 +72,13 @@ class PayNotifyLogic extends BaseLogic
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
$user = User::where('id', $order['uid'])->find();
if ($user['now_money'] < $order['pay_price']) {
throw new \Exception('余额不足');
throw new BusinessException('余额不足');
}
// $order->money = $order['pay_price'];
$order->paid = 1;
$order->pay_time = time();
if (!$order->save()) {
throw new \Exception('订单保存出错');
throw new BusinessException('订单保存出错');
}
if ($order['is_storage'] == 1) {
$order->status = 2;