🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
>[danger]//开启事务 ```` //开启事务 Db::startTrans(); try{ $status_u = Nintyuser::where('id',$uid)->update(['purse'=>$purse_user_end]); $status_f = Fitness::where('id',$fitness_id)->update(['purse'=>$purse_fitness_end]); $order_state = Order::where('order_id',$deal['order_id'])->update(['order_state' => 1]); if ($status_u != 1 || $status_f != 1 || $order_state !=1 ) { throw new PaymentException('抱歉,您的订单支付失败!'); } } catch (\Exception $e) { // 更新失败 回滚事务 Db::rollback(); //回滚事务 throw new PaymentException('抱歉,您的订单支付失败,请从新支付.'); } Db::commit();