注释用户删除订单功能

This commit is contained in:
wuchunlei
2025-10-12 15:12:26 +08:00
parent 41c47c89e8
commit 534975b4bb

View File

@@ -664,28 +664,28 @@ public class BuyOrderController {
@RequestMapping(value = "/cancelOrder", method = RequestMethod.GET) @RequestMapping(value = "/cancelOrder", method = RequestMethod.GET)
@Transactional @Transactional
public R appDelete(@RequestParam("orderSn") String orderSn) { public R appDelete(@RequestParam("orderSn") String orderSn) {
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>(); // QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_sn", orderSn); // queryWrapper.eq("order_sn", orderSn);
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper); // BuyOrder buyOrder = buyOrderService.getOne(queryWrapper);
if (buyOrder == null) { // if (buyOrder == null) {
return R.error("订单不存在"); // return R.error("订单不存在");
} // }
//回滚优惠卷 // //回滚优惠卷
if (buyOrder.getCouponId()!=null&&buyOrder.getCouponId()!=0){ // if (buyOrder.getCouponId()!=null&&buyOrder.getCouponId()!=0){
buyOrder.setCouponId(null); // buyOrder.setCouponId(null);
buyOrderService.updateById(buyOrder); // buyOrderService.updateById(buyOrder);
} // }
// 库存回滚 // // 库存回滚
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>(); // QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
buyOrderProductQueryWrapper.eq("order_id", buyOrder.getOrderId()); // buyOrderProductQueryWrapper.eq("order_id", buyOrder.getOrderId());
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper); // List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper);
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) { // for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
Integer productId = buyOrderProduct.getProductId(); // Integer productId = buyOrderProduct.getProductId();
ShopProduct product = shopProductService.getById(productId); // ShopProduct product = shopProductService.getById(productId);
product.setProductStock(product.getProductStock() + buyOrderProduct.getQuantity()); // product.setProductStock(product.getProductStock() + buyOrderProduct.getQuantity());
shopProductService.updateById(product); // shopProductService.updateById(product);
} // }
buyOrderService.removeById(buyOrder.getOrderId()); // buyOrderService.removeById(buyOrder.getOrderId());
return R.ok(); return R.ok();
} }
@@ -703,9 +703,9 @@ public class BuyOrderController {
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody List<String> orderSnList) { public R delete(@RequestBody List<String> orderSnList) {
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>(); // QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.in("order_sn", orderSnList); // queryWrapper.in("order_sn", orderSnList);
buyOrderService.remove(queryWrapper); // buyOrderService.remove(queryWrapper);
return R.ok(); return R.ok();
} }
@@ -717,24 +717,24 @@ public class BuyOrderController {
@Transactional @Transactional
public R appDelete(@RequestParam("orderId") Integer orderId) { public R appDelete(@RequestParam("orderId") Integer orderId) {
//1. 判断订单状态 //1. 判断订单状态
BuyOrder buyOrder = buyOrderService.getById(orderId); // BuyOrder buyOrder = buyOrderService.getById(orderId);
if (buyOrder != null) { // if (buyOrder != null) {
//回滚优惠卷 // //回滚优惠卷
if (buyOrder.getCouponId()!=null&&buyOrder.getCouponId()!=0){ // if (buyOrder.getCouponId()!=null&&buyOrder.getCouponId()!=0){
buyOrder.setCouponId(null); // buyOrder.setCouponId(null);
buyOrderService.updateById(buyOrder); // buyOrderService.updateById(buyOrder);
} // }
// 库存回滚 // // 库存回滚
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>() // List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
.eq("order_id", buyOrder.getOrderId())); // .eq("order_id", buyOrder.getOrderId()));
for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) { // for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) {
Integer productId = buyOrderDetailEntity.getProductId(); // Integer productId = buyOrderDetailEntity.getProductId();
ShopProduct product = shopProductService.getById(productId); // ShopProduct product = shopProductService.getById(productId);
product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity()); // product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity());
shopProductService.updateById(product); // shopProductService.updateById(product);
} // }
buyOrderService.removeById(orderId); // buyOrderService.removeById(orderId);
} // }
return R.ok(); return R.ok();
} }