复读剔除被删除的课程

This commit is contained in:
wuchunlei
2025-05-26 13:13:20 +08:00
parent d712983311
commit 9b304fbffc

View File

@@ -13,8 +13,10 @@ import com.peanut.modules.common.entity.*;
import com.peanut.modules.common.service.BuyOrderService; import com.peanut.modules.common.service.BuyOrderService;
import com.peanut.modules.common.service.JfTransactionDetailsService; import com.peanut.modules.common.service.JfTransactionDetailsService;
import com.peanut.modules.common.service.MyUserService; 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.ShopProductService;
import com.peanut.modules.master.service.UserCourseBuyService; 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.dto.WechatPaymentInfo;
import com.peanut.modules.pay.weChatPay.service.WxpayService; import com.peanut.modules.pay.weChatPay.service.WxpayService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -43,6 +45,10 @@ public class CourseRelearnController {
@Autowired @Autowired
private UserCourseBuyService userCourseBuyService; private UserCourseBuyService userCourseBuyService;
@Autowired @Autowired
private CourseService courseService;
@Autowired
private CourseCatalogueService courseCatalogueService;
@Autowired
private ShopProductService shopProductService; private ShopProductService shopProductService;
@Autowired @Autowired
private BuyOrderService buyOrderService; private BuyOrderService buyOrderService;
@@ -84,15 +90,21 @@ public class CourseRelearnController {
@RequestMapping("/courseCatalogueCanRelearn") @RequestMapping("/courseCatalogueCanRelearn")
public R courseCatalogueCanRelearn(@RequestBody Map<String,Object> params){ public R courseCatalogueCanRelearn(@RequestBody Map<String,Object> params){
boolean flag = false; boolean flag = false;
List<UserCourseBuyEntity> list = userCourseBuyService.list(new MPJLambdaWrapper<UserCourseBuyEntity>() CourseCatalogueEntity cc = courseCatalogueService.getById(params.get("courseCatalogueId").toString());
.disableLogicDel()//查询出已删除数据 if (cc != null) {
.eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId()) CourseEntity courseEntity = courseService.getById(cc.getCourseId());
.eq(UserCourseBuyEntity::getCatalogueId,params.get("courseCatalogueId"))); if (courseEntity != null) {
if (list.size() > 0) { List<UserCourseBuyEntity> list = userCourseBuyService.list(new MPJLambdaWrapper<UserCourseBuyEntity>()
flag = true; .disableLogicDel()//查询出已删除数据
for (UserCourseBuyEntity userCourseBuyEntity : list) { .eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId())
if (userCourseBuyEntity.getDelFlag()==0) { .eq(UserCourseBuyEntity::getCatalogueId,params.get("courseCatalogueId")));
flag = false; 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") @RequestMapping("/relearnShopProductList")
public R relearnShopProductList(@RequestBody Map<String,Object> params) { public R relearnShopProductList(@RequestBody Map<String,Object> params) {
CourseCatalogueEntity cc = courseCatalogueService.getById(params.get("catalogueId").toString());
if (cc != null) {
CourseEntity courseEntity = courseService.getById(cc.getCourseId());
if (courseEntity != null){
MPJLambdaWrapper<ShopProduct> 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<ShopProduct> 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<ShopProduct> wrapper = new MPJLambdaWrapper<>(); ShopProduct sp2 = new ShopProduct();
wrapper.leftJoin(ShopProductCourseEntity.class,ShopProductCourseEntity::getProductId,ShopProduct::getProductId); sp2.setProductId(shopProduct.getProductId());
wrapper.selectAll(ShopProduct.class); sp2.setProductName(shopProduct.getProductName().replace("一年","三月"));
wrapper.eq(ShopProductCourseEntity::getCatalogueId,params.get("catalogueId")); sp2.setProductImages(shopProduct.getProductImages());
wrapper.eq(ShopProductCourseEntity::getDays,365); BigDecimal sp2Price = shopProduct.getPrice().divide(new BigDecimal(4),0, RoundingMode.DOWN);
wrapper.orderByAsc(ShopProduct::getPrice); sp2Price = sp2Price.multiply(new BigDecimal(0.6));
List<ShopProduct> shopProducts = shopProductService.list(wrapper); sp2Price = sp2Price.setScale(0, RoundingMode.DOWN);
if (shopProducts.size()>0) { sp2.setPrice(sp2Price);
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(); List<ShopProduct> res = new ArrayList<>();
sp2.setProductId(shopProduct.getProductId()); res.add(sp1);
sp2.setProductName(shopProduct.getProductName().replace("一年","三月")); res.add(sp2);
sp2.setProductImages(shopProduct.getProductImages()); return R.ok().put("productList",res);
BigDecimal sp2Price = shopProduct.getPrice().divide(new BigDecimal(4),0, RoundingMode.DOWN); }else {
sp2Price = sp2Price.multiply(new BigDecimal(0.6)); return R.error("未找到一年期商品");
sp2Price = sp2Price.setScale(0, RoundingMode.DOWN); }
sp2.setPrice(sp2Price); }
List<ShopProduct> 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") @RequestMapping("/relearnSave")