复读剔除没有跟标签关联的课程
This commit is contained in:
@@ -129,37 +129,42 @@ public class CourseRelearnController {
|
||||
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);
|
||||
int mCount = courseToMedicalService.count(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getCourseId,courseEntity.getId()));
|
||||
int sCount = courseToSociologyService.count(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getCourseId,courseEntity.getId()));
|
||||
int pCount = courseToPsycheService.count(new LambdaQueryWrapper<CourseToPsyche>().eq(CourseToPsyche::getCourseId,courseEntity.getId()));
|
||||
if (mCount>0||sCount > 0||pCount > 0){
|
||||
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);
|
||||
|
||||
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<ShopProduct> res = new ArrayList<>();
|
||||
res.add(sp1);
|
||||
res.add(sp2);
|
||||
return R.ok().put("productList",res);
|
||||
}else {
|
||||
return R.error("未找到一年期商品");
|
||||
List<ShopProduct> res = new ArrayList<>();
|
||||
res.add(sp1);
|
||||
res.add(sp2);
|
||||
return R.ok().put("productList",res);
|
||||
}else {
|
||||
return R.error("未找到一年期商品");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user