From 9b304fbffcd70283a92a307cdf9a2b59fa9347cc Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Mon, 26 May 2025 13:13:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E8=AF=BB=E5=89=94=E9=99=A4=E8=A2=AB?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=9A=84=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CourseRelearnController.java | 96 +++++++++++-------- 1 file changed, 57 insertions(+), 39 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 beb0f957..4c86aaaf 100644 --- a/src/main/java/com/peanut/modules/common/controller/CourseRelearnController.java +++ b/src/main/java/com/peanut/modules/common/controller/CourseRelearnController.java @@ -13,8 +13,10 @@ import com.peanut.modules.common.entity.*; import com.peanut.modules.common.service.BuyOrderService; import com.peanut.modules.common.service.JfTransactionDetailsService; import com.peanut.modules.common.service.MyUserService; +import com.peanut.modules.master.service.CourseCatalogueService; import com.peanut.modules.master.service.ShopProductService; import com.peanut.modules.master.service.UserCourseBuyService; +import com.peanut.modules.medical.service.CourseService; import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo; import com.peanut.modules.pay.weChatPay.service.WxpayService; import lombok.extern.slf4j.Slf4j; @@ -43,6 +45,10 @@ public class CourseRelearnController { @Autowired private UserCourseBuyService userCourseBuyService; @Autowired + private CourseService courseService; + @Autowired + private CourseCatalogueService courseCatalogueService; + @Autowired private ShopProductService shopProductService; @Autowired private BuyOrderService buyOrderService; @@ -84,15 +90,21 @@ public class CourseRelearnController { @RequestMapping("/courseCatalogueCanRelearn") public R courseCatalogueCanRelearn(@RequestBody Map params){ boolean flag = false; - List list = userCourseBuyService.list(new MPJLambdaWrapper() - .disableLogicDel()//查询出已删除数据 - .eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId()) - .eq(UserCourseBuyEntity::getCatalogueId,params.get("courseCatalogueId"))); - if (list.size() > 0) { - flag = true; - for (UserCourseBuyEntity userCourseBuyEntity : list) { - if (userCourseBuyEntity.getDelFlag()==0) { - flag = false; + CourseCatalogueEntity cc = courseCatalogueService.getById(params.get("courseCatalogueId").toString()); + if (cc != null) { + CourseEntity courseEntity = courseService.getById(cc.getCourseId()); + if (courseEntity != null) { + List list = userCourseBuyService.list(new MPJLambdaWrapper() + .disableLogicDel()//查询出已删除数据 + .eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId()) + .eq(UserCourseBuyEntity::getCatalogueId,params.get("courseCatalogueId"))); + if (list.size() > 0) { + flag = true; + for (UserCourseBuyEntity userCourseBuyEntity : list) { + if (userCourseBuyEntity.getDelFlag()==0) { + flag = false; + } + } } } } @@ -102,39 +114,45 @@ public class CourseRelearnController { //课程目录复读列表 @RequestMapping("/relearnShopProductList") public R relearnShopProductList(@RequestBody Map params) { + CourseCatalogueEntity cc = courseCatalogueService.getById(params.get("catalogueId").toString()); + 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); - 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("未找到一年期商品"); + } + } } + return R.ok().put("productList",new ArrayList<>()); } @RequestMapping("/relearnSave")