From efc893767dadea440931b6e8c38c7600092406e7 Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Wed, 5 Mar 2025 09:17:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9vip=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ShopProductController.java | 2 +- .../MedicalLabelAndMarketController.java | 21 ++++++++++++ .../sys/controller/VisitorController.java | 32 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/peanut/modules/book/controller/ShopProductController.java b/src/main/java/com/peanut/modules/book/controller/ShopProductController.java index a907ac96..b1493ffa 100644 --- a/src/main/java/com/peanut/modules/book/controller/ShopProductController.java +++ b/src/main/java/com/peanut/modules/book/controller/ShopProductController.java @@ -280,7 +280,7 @@ public class ShopProductController { } for (ShopProductBookEntity spbe : ss) { ShopProduct ca_sp = shopProductService.getById(spbe.getProductId()); - if (ca_sp.getIsVipPrice()==1){ + if (!userVipService.noVip()&&ca_sp.getIsVipPrice()==1){ ca_sp.setVipPrice(shopProductService.getVipPrice(ca_sp)); } frag.add(ca_sp); diff --git a/src/main/java/com/peanut/modules/medical/controller/MedicalLabelAndMarketController.java b/src/main/java/com/peanut/modules/medical/controller/MedicalLabelAndMarketController.java index 8086275c..9d56fc39 100644 --- a/src/main/java/com/peanut/modules/medical/controller/MedicalLabelAndMarketController.java +++ b/src/main/java/com/peanut/modules/medical/controller/MedicalLabelAndMarketController.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.peanut.common.utils.R; import com.peanut.modules.common.entity.*; +import com.peanut.modules.common.service.UserVipService; import com.peanut.modules.medical.service.ShopProductMedicineLabelService; import com.peanut.modules.medical.service.ShopProductMedicineMarketService; import com.peanut.modules.medical.service.ShopProductService; @@ -12,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; + +import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -29,6 +32,8 @@ public class MedicalLabelAndMarketController { private ShopProductMedicineMarketService marketService; @Autowired private ShopProductService productService; + @Autowired + private UserVipService userVipService; /** * 分类标签树 @@ -62,6 +67,22 @@ public class MedicalLabelAndMarketController { wrapper.orderByAsc(ShopProductToMedicineMarket::getSort); Page page = productService.page(new Page<>( Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper); + for (ShopProduct shopProduct:page.getRecords()){ + //vip价格,不是vip或者活动价更低,返回0 + if (shopProduct.getIsVipPrice()==1){ + BigDecimal b = new BigDecimal(0); + if (userVipService.is456SVip()||userVipService.is78SVip()){ + b = shopProduct.getPrice().multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP); + }else if (!userVipService.noVip()){ + b = shopProduct.getPrice().multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP); + } + if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0))>0 + &&b.compareTo(shopProduct.getActivityPrice())>0){ + b = new BigDecimal(0); + } + shopProduct.setVipPrice(b); + } + } return R.ok().put("result", page); } diff --git a/src/main/java/com/peanut/modules/sys/controller/VisitorController.java b/src/main/java/com/peanut/modules/sys/controller/VisitorController.java index 367c84a8..6cc8f9ff 100644 --- a/src/main/java/com/peanut/modules/sys/controller/VisitorController.java +++ b/src/main/java/com/peanut/modules/sys/controller/VisitorController.java @@ -349,4 +349,36 @@ public class VisitorController { Long.parseLong(params.get("page").toString()), Long.parseLong(params.get("limit").toString())),wrapper); return R.ok().put("courseList",courseEntityPage); } + //获取标签下课程 + @RequestMapping("/getCourseByPsycheId") + public R getCourseByPsycheId(@RequestBody Map params){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); + wrapper.selectAll(CourseEntity.class); + wrapper.leftJoin(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId); + wrapper.eq(CourseToPsyche::getPsycheId,params.get("psycheId")); + List courseList = courseService.list(wrapper); + return R.ok().put("courseList",courseList); + } + //课程详情 + @RequestMapping("/getPsycheCourseInfo") + public R getPsycheCourseInfo(@RequestBody Map params){ + Map courseDetail = new HashMap<>(); + //基础信息 + CourseEntity course = courseService.getById(params.get("courseId").toString()); + courseDetail.put("course",course); + //目录信息 + List courseCatalogueEntities = courseCatalogueService.list(new LambdaQueryWrapper() + .eq(CourseCatalogueEntity::getCourseId, course.getId()).orderByAsc(CourseCatalogueEntity::getSort)); + courseDetail.put("catalogues",courseCatalogueEntities); + return R.ok().put("data",courseDetail); + } + //课程章节 + @RequestMapping("/getPsycheCourseCatalogueInfo") + public R getPsycheCourseCatalogueInfo(@RequestBody Map params){ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(CourseCatalogueChapterEntity::getCatalogueId,params.get("catalogueId")); + wrapper.orderByAsc(CourseCatalogueChapterEntity::getSort); + List list = courseCatalogueChapterService.list(wrapper); + return R.ok().put("list",list); + } }