diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/controller/ZyOrdersController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/controller/ZyOrdersController.java index 5e2f7dd9..a8e3dd25 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/controller/ZyOrdersController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/controller/ZyOrdersController.java @@ -245,7 +245,41 @@ public class ZyOrdersController extends JeecgController ids = new ArrayList<>(); + ZyOrders zos = new ZyOrders(); + QueryWrapper queryWrapperzos = QueryGenerator.initQueryWrapper(zos, req.getParameterMap()); + queryWrapperzos.eq("order_id",zyOrders.getId()); + List listzos = zyOrdersService.list(queryWrapperzos); + if(listzos.size()>0){ + return Result.error("该订单已经拆分,不可以再次拆单!"); + }else{ + OrderGoods orderGoods = new OrderGoods(); + QueryWrapper queryWrapperog = QueryGenerator.initQueryWrapper(orderGoods, req.getParameterMap()); + queryWrapperog.eq("orders_id",zyOrders.getId()); + List listog = orderGoodsService.list(queryWrapperog); + if(listog.size()>0){ + for (int i = 0 ; i < listog.size() ; i++){ + ZyOrders zo = new ZyOrders(); + zo = zyOrders; + zo.setId(null); + zo.setOrdersNum(getOrdersNum()); + zo.setFreight(Double.parseDouble("0")); + zo.setIschild(1); + zo.setOrderId(zyOrders.getId()); + zo.setMoney(listog.get(i).getTotalPrice()); + zo.setPromotionPrice(listog.get(i).getPromotionPrice()); + zo.setActualPayment(listog.get(i).getPayTotalPrice()); + zo.setGoodsQuantity(1); + zyOrdersService.save(zo); + ids.add(zo.getId()); + OrderGoods og = new OrderGoods(); + og = listog.get(i); + og.setOrdersId(zo.getId()); + orderGoodsService.updateById(og); + } + } + } + return Result.OK(ids); }