From 534975b4bb20b426b50460707ecde755b7505c4c Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Sun, 12 Oct 2025 15:12:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E7=94=A8=E6=88=B7=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=AE=A2=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/controller/BuyOrderController.java | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java b/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java index 7e73998b..95a2fb11 100644 --- a/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java +++ b/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java @@ -664,28 +664,28 @@ public class BuyOrderController { @RequestMapping(value = "/cancelOrder", method = RequestMethod.GET) @Transactional public R appDelete(@RequestParam("orderSn") String orderSn) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("order_sn", orderSn); - BuyOrder buyOrder = buyOrderService.getOne(queryWrapper); - if (buyOrder == null) { - return R.error("订单不存在"); - } - //回滚优惠卷 - if (buyOrder.getCouponId()!=null&&buyOrder.getCouponId()!=0){ - buyOrder.setCouponId(null); - buyOrderService.updateById(buyOrder); - } - // 库存回滚 - QueryWrapper buyOrderProductQueryWrapper = new QueryWrapper<>(); - buyOrderProductQueryWrapper.eq("order_id", buyOrder.getOrderId()); - List buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper); - for (BuyOrderProduct buyOrderProduct : buyOrderProductList) { - Integer productId = buyOrderProduct.getProductId(); - ShopProduct product = shopProductService.getById(productId); - product.setProductStock(product.getProductStock() + buyOrderProduct.getQuantity()); - shopProductService.updateById(product); - } - buyOrderService.removeById(buyOrder.getOrderId()); +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq("order_sn", orderSn); +// BuyOrder buyOrder = buyOrderService.getOne(queryWrapper); +// if (buyOrder == null) { +// return R.error("订单不存在"); +// } +// //回滚优惠卷 +// if (buyOrder.getCouponId()!=null&&buyOrder.getCouponId()!=0){ +// buyOrder.setCouponId(null); +// buyOrderService.updateById(buyOrder); +// } +// // 库存回滚 +// QueryWrapper buyOrderProductQueryWrapper = new QueryWrapper<>(); +// buyOrderProductQueryWrapper.eq("order_id", buyOrder.getOrderId()); +// List buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper); +// for (BuyOrderProduct buyOrderProduct : buyOrderProductList) { +// Integer productId = buyOrderProduct.getProductId(); +// ShopProduct product = shopProductService.getById(productId); +// product.setProductStock(product.getProductStock() + buyOrderProduct.getQuantity()); +// shopProductService.updateById(product); +// } +// buyOrderService.removeById(buyOrder.getOrderId()); return R.ok(); } @@ -703,9 +703,9 @@ public class BuyOrderController { */ @RequestMapping("/delete") public R delete(@RequestBody List orderSnList) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.in("order_sn", orderSnList); - buyOrderService.remove(queryWrapper); +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.in("order_sn", orderSnList); +// buyOrderService.remove(queryWrapper); return R.ok(); } @@ -717,24 +717,24 @@ public class BuyOrderController { @Transactional public R appDelete(@RequestParam("orderId") Integer orderId) { //1. 判断订单状态 - BuyOrder buyOrder = buyOrderService.getById(orderId); - if (buyOrder != null) { - //回滚优惠卷 - if (buyOrder.getCouponId()!=null&&buyOrder.getCouponId()!=0){ - buyOrder.setCouponId(null); - buyOrderService.updateById(buyOrder); - } - // 库存回滚 - List buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper() - .eq("order_id", buyOrder.getOrderId())); - for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) { - Integer productId = buyOrderDetailEntity.getProductId(); - ShopProduct product = shopProductService.getById(productId); - product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity()); - shopProductService.updateById(product); - } - buyOrderService.removeById(orderId); - } +// BuyOrder buyOrder = buyOrderService.getById(orderId); +// if (buyOrder != null) { +// //回滚优惠卷 +// if (buyOrder.getCouponId()!=null&&buyOrder.getCouponId()!=0){ +// buyOrder.setCouponId(null); +// buyOrderService.updateById(buyOrder); +// } +// // 库存回滚 +// List buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper() +// .eq("order_id", buyOrder.getOrderId())); +// for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) { +// Integer productId = buyOrderDetailEntity.getProductId(); +// ShopProduct product = shopProductService.getById(productId); +// product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity()); +// shopProductService.updateById(product); +// } +// buyOrderService.removeById(orderId); +// } return R.ok(); }