From 08ce88ac6f8f726531e1399975e563c1e33615b6 Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Mon, 26 May 2025 13:48:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E8=AF=BB=E5=89=94=E9=99=A4=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=B7=9F=E6=A0=87=E7=AD=BE=E5=85=B3=E8=81=94=E7=9A=84?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CourseRelearnController.java | 63 ++++++++++--------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/peanut/modules/common/controller/CourseRelearnController.java b/src/main/java/com/peanut/modules/common/controller/CourseRelearnController.java index 89af01ad..e7697697 100644 --- a/src/main/java/com/peanut/modules/common/controller/CourseRelearnController.java +++ b/src/main/java/com/peanut/modules/common/controller/CourseRelearnController.java @@ -129,37 +129,42 @@ public class CourseRelearnController { if (cc != null) { CourseEntity courseEntity = courseService.getById(cc.getCourseId()); if (courseEntity != null){ - MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); - wrapper.leftJoin(ShopProductCourseEntity.class,ShopProductCourseEntity::getProductId,ShopProduct::getProductId); - wrapper.selectAll(ShopProduct.class); - wrapper.eq(ShopProductCourseEntity::getCatalogueId,params.get("catalogueId")); - wrapper.eq(ShopProductCourseEntity::getDays,365); - wrapper.orderByAsc(ShopProduct::getPrice); - List shopProducts = shopProductService.list(wrapper); - if (shopProducts.size()>0) { - ShopProduct shopProduct = shopProducts.get(0); - ShopProduct sp1 = new ShopProduct(); - sp1.setProductId(shopProduct.getProductId()); - sp1.setProductName(shopProduct.getProductName().replace("一年","一月")); - sp1.setProductImages(shopProduct.getProductImages()); - BigDecimal sp1Price = shopProduct.getPrice().divide(new BigDecimal(12),0, RoundingMode.DOWN); - sp1.setPrice(sp1Price); + int mCount = courseToMedicalService.count(new LambdaQueryWrapper().eq(CourseToMedicine::getCourseId,courseEntity.getId())); + int sCount = courseToSociologyService.count(new LambdaQueryWrapper().eq(CourseToSociologyEntity::getCourseId,courseEntity.getId())); + int pCount = courseToPsycheService.count(new LambdaQueryWrapper().eq(CourseToPsyche::getCourseId,courseEntity.getId())); + if (mCount>0||sCount > 0||pCount > 0){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.leftJoin(ShopProductCourseEntity.class,ShopProductCourseEntity::getProductId,ShopProduct::getProductId); + wrapper.selectAll(ShopProduct.class); + wrapper.eq(ShopProductCourseEntity::getCatalogueId,params.get("catalogueId")); + wrapper.eq(ShopProductCourseEntity::getDays,365); + wrapper.orderByAsc(ShopProduct::getPrice); + List shopProducts = shopProductService.list(wrapper); + if (shopProducts.size()>0) { + ShopProduct shopProduct = shopProducts.get(0); + ShopProduct sp1 = new ShopProduct(); + sp1.setProductId(shopProduct.getProductId()); + sp1.setProductName(shopProduct.getProductName().replace("一年","一月")); + sp1.setProductImages(shopProduct.getProductImages()); + BigDecimal sp1Price = shopProduct.getPrice().divide(new BigDecimal(12),0, RoundingMode.DOWN); + sp1.setPrice(sp1Price); - ShopProduct sp2 = new ShopProduct(); - sp2.setProductId(shopProduct.getProductId()); - sp2.setProductName(shopProduct.getProductName().replace("一年","三月")); - sp2.setProductImages(shopProduct.getProductImages()); - BigDecimal sp2Price = shopProduct.getPrice().divide(new BigDecimal(4),0, RoundingMode.DOWN); - sp2Price = sp2Price.multiply(new BigDecimal(0.6)); - sp2Price = sp2Price.setScale(0, RoundingMode.DOWN); - sp2.setPrice(sp2Price); + ShopProduct sp2 = new ShopProduct(); + sp2.setProductId(shopProduct.getProductId()); + sp2.setProductName(shopProduct.getProductName().replace("一年","三月")); + sp2.setProductImages(shopProduct.getProductImages()); + BigDecimal sp2Price = shopProduct.getPrice().divide(new BigDecimal(4),0, RoundingMode.DOWN); + sp2Price = sp2Price.multiply(new BigDecimal(0.6)); + sp2Price = sp2Price.setScale(0, RoundingMode.DOWN); + sp2.setPrice(sp2Price); - List res = new ArrayList<>(); - res.add(sp1); - res.add(sp2); - return R.ok().put("productList",res); - }else { - return R.error("未找到一年期商品"); + List res = new ArrayList<>(); + res.add(sp1); + res.add(sp2); + return R.ok().put("productList",res); + }else { + return R.error("未找到一年期商品"); + } } } }