电子书vip价格新规则调整
This commit is contained in:
@@ -12,7 +12,7 @@ import java.util.Properties;
|
|||||||
public class MailUtil {
|
public class MailUtil {
|
||||||
|
|
||||||
private final static String mailName = "AmazingLimited@163.com";
|
private final static String mailName = "AmazingLimited@163.com";
|
||||||
private final static String mailToken = "ZMbHwKZF2Vr8V7xs";
|
private final static String mailToken = "DLTVBxdWpPdvvvFP";
|
||||||
|
|
||||||
public static R sendMail(String content,String receiveAddress){
|
public static R sendMail(String content,String receiveAddress){
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -259,12 +259,11 @@ public class BuyOrderController {
|
|||||||
@RequestMapping("/getVipDiscountAmount")
|
@RequestMapping("/getVipDiscountAmount")
|
||||||
public R getVipDiscountAmount(@RequestBody BuyOrder buyOrder){
|
public R getVipDiscountAmount(@RequestBody BuyOrder buyOrder){
|
||||||
BigDecimal b = new BigDecimal(0);
|
BigDecimal b = new BigDecimal(0);
|
||||||
if (userVipService.isVip()){
|
|
||||||
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
|
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
|
||||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||||
BigDecimal pvda = shopProductService.getVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId()));
|
BigDecimal pvda = shopProductService.getCourseOrBookVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId()));
|
||||||
b = b.add(pvda.multiply(new BigDecimal(buyOrderProduct.getQuantity())));
|
b = b.add(pvda.multiply(new BigDecimal(buyOrderProduct.getQuantity())));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return R.ok().put("discountAmount",b);
|
return R.ok().put("discountAmount",b);
|
||||||
}
|
}
|
||||||
@@ -277,7 +276,7 @@ public class BuyOrderController {
|
|||||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||||
ShopProduct shopProduct = shopProductService.getById(buyOrderProduct.getProductId());
|
ShopProduct shopProduct = shopProductService.getById(buyOrderProduct.getProductId());
|
||||||
if (userVipService.isVip()){
|
if (userVipService.isVip()){
|
||||||
BigDecimal pvda = shopProductService.getVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId()));
|
BigDecimal pvda = shopProductService.getCourseOrBookVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId()));
|
||||||
if (pvda.compareTo(BigDecimal.ZERO)>0){
|
if (pvda.compareTo(BigDecimal.ZERO)>0){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public interface ShopProductService extends IService<ShopProduct> {
|
|||||||
|
|
||||||
List<ShopProduct> appGetCategoryList(Integer catId);
|
List<ShopProduct> appGetCategoryList(Integer catId);
|
||||||
|
|
||||||
|
BigDecimal getCourseOrBookVipDiscountAmount(ShopProduct shopProduct);
|
||||||
|
|
||||||
BigDecimal getVipDiscountAmount(ShopProduct shopProduct);
|
BigDecimal getVipDiscountAmount(ShopProduct shopProduct);
|
||||||
|
|
||||||
BigDecimal getVipPrice(ShopProduct shopProduct);
|
BigDecimal getVipPrice(ShopProduct shopProduct);
|
||||||
@@ -36,8 +38,5 @@ public interface ShopProductService extends IService<ShopProduct> {
|
|||||||
PageUtils queryPageactivityprice(Map<String, Object> params);
|
PageUtils queryPageactivityprice(Map<String, Object> params);
|
||||||
|
|
||||||
List<ShopProduct> getProductListForBook(Integer bookId);
|
List<ShopProduct> getProductListForBook(Integer bookId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.peanut.modules.book.service.impl;
|
package com.peanut.modules.book.service.impl;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||||
import com.peanut.common.utils.ShiroUtils;
|
import com.peanut.common.utils.ShiroUtils;
|
||||||
|
import com.peanut.modules.common.dao.BookDao;
|
||||||
import com.peanut.modules.common.dao.ShopProductBookDao;
|
import com.peanut.modules.common.dao.ShopProductBookDao;
|
||||||
|
import com.peanut.modules.common.entity.BookEntity;
|
||||||
import com.peanut.modules.common.entity.ShopProductBookEntity;
|
import com.peanut.modules.common.entity.ShopProductBookEntity;
|
||||||
|
import com.peanut.modules.common.service.UserEbookVipService;
|
||||||
import com.peanut.modules.common.service.UserVipService;
|
import com.peanut.modules.common.service.UserVipService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -28,6 +32,10 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|||||||
private UserVipService userVipService;
|
private UserVipService userVipService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopProductBookDao shopProductBookDao;
|
private ShopProductBookDao shopProductBookDao;
|
||||||
|
@Autowired
|
||||||
|
private UserEbookVipService userEbookVipService;
|
||||||
|
@Autowired
|
||||||
|
private BookDao bookDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
@@ -55,7 +63,6 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|||||||
List<ShopProduct> list = this.getBaseMapper().appGetCategoryList(catId);
|
List<ShopProduct> list = this.getBaseMapper().appGetCategoryList(catId);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getVipDiscountAmount(ShopProduct shopProduct) {
|
public BigDecimal getVipDiscountAmount(ShopProduct shopProduct) {
|
||||||
BigDecimal p = new BigDecimal(0);
|
BigDecimal p = new BigDecimal(0);
|
||||||
@@ -75,6 +82,98 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public BigDecimal getCourseOrBookVipDiscountAmount(ShopProduct shopProduct) {
|
||||||
|
BigDecimal p = new BigDecimal(0);
|
||||||
|
// 书籍02 / 预售书03:按关联图书isVip处理
|
||||||
|
String goodsType = shopProduct.getGoodsType();
|
||||||
|
if ("02".equals(goodsType) || "03".equals(goodsType)) {
|
||||||
|
Integer bookIsVip = getRelatedBookIsVip(shopProduct.getProductId());
|
||||||
|
// isVip=1:电子书会员免费,课程会员打对应折扣
|
||||||
|
if (bookIsVip != null && bookIsVip == 1) {
|
||||||
|
BigDecimal vipPrice = BigDecimal.ZERO;
|
||||||
|
if (userEbookVipService.isBookVip()) {
|
||||||
|
vipPrice = BigDecimal.ZERO;
|
||||||
|
} else if (userVipService.isVip() && shopProduct.getIsVipPrice() == 1) {
|
||||||
|
if (userVipService.is4569SVip(ShiroUtils.getUId()) || userVipService.is78SVip(ShiroUtils.getUId())) {
|
||||||
|
vipPrice = shopProduct.getPrice().multiply(new BigDecimal(0.8));
|
||||||
|
} else {
|
||||||
|
vipPrice = shopProduct.getPrice().multiply(new BigDecimal(0.9));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
// vip折后价不低于活动价,直接返回0
|
||||||
|
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0)) > 0
|
||||||
|
&& vipPrice.compareTo(shopProduct.getActivityPrice()) >= 0) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
return shopProduct.getPrice().subtract(vipPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
// isVip=2:付费折扣
|
||||||
|
if (bookIsVip != null && bookIsVip == 2 && shopProduct.getIsVipPrice() == 1) {
|
||||||
|
BigDecimal courseVipPrice = BigDecimal.ZERO;
|
||||||
|
if (userVipService.isVip()) {
|
||||||
|
if (userVipService.is4569SVip(ShiroUtils.getUId()) || userVipService.is78SVip(ShiroUtils.getUId())) {
|
||||||
|
courseVipPrice = shopProduct.getPrice().multiply(new BigDecimal(0.8));
|
||||||
|
} else if (userVipService.isVip()) {
|
||||||
|
courseVipPrice = shopProduct.getPrice().multiply(new BigDecimal(0.9));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BigDecimal bookVipPrice = BigDecimal.ZERO;
|
||||||
|
if (userEbookVipService.isBookVip()) {
|
||||||
|
bookVipPrice = shopProduct.getPrice().multiply(new BigDecimal(0.8));
|
||||||
|
}
|
||||||
|
// 取非0且更小的vip价
|
||||||
|
BigDecimal vipPrice = BigDecimal.ZERO;
|
||||||
|
if (courseVipPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
vipPrice = courseVipPrice;
|
||||||
|
}
|
||||||
|
if (bookVipPrice.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
&& (vipPrice.compareTo(BigDecimal.ZERO) == 0 || bookVipPrice.compareTo(vipPrice) < 0)) {
|
||||||
|
vipPrice = bookVipPrice;
|
||||||
|
}
|
||||||
|
if (vipPrice.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
// vip折后价不低于活动价,直接返回0
|
||||||
|
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0)) > 0
|
||||||
|
&& vipPrice.compareTo(shopProduct.getActivityPrice()) >= 0) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
return shopProduct.getPrice().subtract(vipPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
|
||||||
|
if (userVipService.is4569SVip(ShiroUtils.getUId())||userVipService.is78SVip(ShiroUtils.getUId())){
|
||||||
|
p = shopProduct.getPrice().multiply(new BigDecimal(0.8));
|
||||||
|
}else if (userVipService.isVip()){
|
||||||
|
p = shopProduct.getPrice().multiply(new BigDecimal(0.9));
|
||||||
|
}
|
||||||
|
// vip折后价不低于活动价,直接返回0
|
||||||
|
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0))>0
|
||||||
|
&&p.compareTo(shopProduct.getActivityPrice())>=0){
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
return shopProduct.getPrice().subtract(p).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品关联图书获取isVip
|
||||||
|
*/
|
||||||
|
private Integer getRelatedBookIsVip(Integer productId) {
|
||||||
|
List<ShopProductBookEntity> productBooks = shopProductBookDao.selectList(new LambdaQueryWrapper<ShopProductBookEntity>()
|
||||||
|
.eq(ShopProductBookEntity::getProductId, productId)
|
||||||
|
.eq(ShopProductBookEntity::getDelFlag, 0)
|
||||||
|
.last("limit 1"));
|
||||||
|
if (productBooks == null || productBooks.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
BookEntity book = bookDao.selectById(productBooks.get(0).getBookId());
|
||||||
|
return book == null ? null : book.getIsVip();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getVipPrice(ShopProduct shopProduct) {
|
public BigDecimal getVipPrice(ShopProduct shopProduct) {
|
||||||
@@ -89,12 +188,11 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|||||||
// b = (activityPrice == null || activityPrice.equals(BigDecimal.ZERO)) ? shopProduct.getPrice() : activityPrice;
|
// b = (activityPrice == null || activityPrice.equals(BigDecimal.ZERO)) ? shopProduct.getPrice() : activityPrice;
|
||||||
// }
|
// }
|
||||||
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0))>0
|
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0))>0
|
||||||
&&b.compareTo(shopProduct.getActivityPrice())>0){
|
&&b.compareTo(shopProduct.getActivityPrice())>=0){
|
||||||
b = new BigDecimal(0);
|
b = new BigDecimal(0);
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils getNewBook(Map<String, Object> params) {
|
public PageUtils getNewBook(Map<String, Object> params) {
|
||||||
IPage<ShopProduct> page = this.page(
|
IPage<ShopProduct> page = this.page(
|
||||||
@@ -145,8 +243,86 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|||||||
wrapper.eq(ShopProductBookEntity::getBookId,bookId);
|
wrapper.eq(ShopProductBookEntity::getBookId,bookId);
|
||||||
wrapper.orderByAsc(ShopProduct::getPrice);
|
wrapper.orderByAsc(ShopProduct::getPrice);
|
||||||
List<ShopProduct> shopProducts = shopProductBookDao.selectJoinList(ShopProduct.class, wrapper);
|
List<ShopProduct> shopProducts = shopProductBookDao.selectJoinList(ShopProduct.class, wrapper);
|
||||||
|
BookEntity book = bookDao.selectById(bookId);
|
||||||
|
Integer isVip = book == null ? null : book.getIsVip();
|
||||||
|
boolean courseVip = userVipService.isVip();
|
||||||
|
boolean bookVip = userEbookVipService.isBookVip();
|
||||||
|
for (ShopProduct shopProduct : shopProducts) {
|
||||||
|
BigDecimal minPrice = BigDecimal.ZERO;
|
||||||
|
int discountType = 0;
|
||||||
|
BigDecimal price = shopProduct.getPrice();
|
||||||
|
if (price != null && price.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
minPrice = price;
|
||||||
|
}
|
||||||
|
BigDecimal activityPrice = shopProduct.getActivityPrice();
|
||||||
|
if (activityPrice != null && activityPrice.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
&& minPrice.compareTo(activityPrice) > 0) {
|
||||||
|
discountType = 1;
|
||||||
|
minPrice = activityPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
// isVip=1:电子书vip免费,课程vip打对应折扣
|
||||||
|
if (isVip != null && isVip == 1) {
|
||||||
|
if (bookVip) {
|
||||||
|
shopProduct.setVipPrice(BigDecimal.ZERO);
|
||||||
|
discountType = 2;
|
||||||
|
minPrice = BigDecimal.ZERO;
|
||||||
|
} else if (courseVip && shopProduct.getIsVipPrice() != null && shopProduct.getIsVipPrice() == 1) {
|
||||||
|
BigDecimal courseVipPrice = this.getVipPrice(shopProduct);
|
||||||
|
shopProduct.setVipPrice(courseVipPrice);
|
||||||
|
if (courseVipPrice.compareTo(BigDecimal.ZERO) > 0 && minPrice.compareTo(courseVipPrice) > 0) {
|
||||||
|
discountType = 2;
|
||||||
|
minPrice = courseVipPrice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// isVip=2:付费,电子书vip八折,课程vip打对应折扣
|
||||||
|
} else if (isVip != null && isVip == 2 && shopProduct.getIsVipPrice() != null && shopProduct.getIsVipPrice() == 1
|
||||||
|
&& minPrice.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
&& (courseVip || bookVip)) {
|
||||||
|
BigDecimal vipPrice = BigDecimal.ZERO;
|
||||||
|
BigDecimal courseVipPrice = BigDecimal.ZERO;
|
||||||
|
if (courseVip) {
|
||||||
|
courseVipPrice = this.getVipPrice(shopProduct);
|
||||||
|
}
|
||||||
|
BigDecimal bookVipPrice = BigDecimal.ZERO;
|
||||||
|
if (bookVip) {
|
||||||
|
bookVipPrice = userEbookVipService.getBookVipPrice(shopProduct);
|
||||||
|
}
|
||||||
|
if (courseVipPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
vipPrice = courseVipPrice;
|
||||||
|
shopProduct.setVipPrice(vipPrice);
|
||||||
|
}
|
||||||
|
if (bookVipPrice.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
&& (vipPrice.compareTo(BigDecimal.ZERO) == 0 || bookVipPrice.compareTo(vipPrice) < 0)) {
|
||||||
|
vipPrice = bookVipPrice;
|
||||||
|
shopProduct.setVipPrice(bookVipPrice);
|
||||||
|
}
|
||||||
|
// minPrice 更大才用 vip 替换,否则不替换
|
||||||
|
if (vipPrice.compareTo(BigDecimal.ZERO) > 0 && minPrice.compareTo(vipPrice) > 0) {
|
||||||
|
discountType = 2;
|
||||||
|
minPrice = vipPrice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shopProduct.setIsVip(isVip);
|
||||||
|
shopProduct.setDiscountType(discountType);
|
||||||
|
shopProduct.setMinPrice(minPrice);
|
||||||
|
}
|
||||||
return shopProducts;
|
return shopProducts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 课程vip原始折后价(不与活动价比较,由调用方与 minPrice 比较)
|
||||||
|
*/
|
||||||
|
private BigDecimal calcCourseVipRawPrice(ShopProduct shopProduct) {
|
||||||
|
if (shopProduct.getPrice() == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
if (userVipService.is4569SVip(ShiroUtils.getUId()) || userVipService.is78SVip(ShiroUtils.getUId())) {
|
||||||
|
return shopProduct.getPrice().multiply(new BigDecimal(0.8)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
if (userVipService.isVip()) {
|
||||||
|
return shopProduct.getPrice().multiply(new BigDecimal(0.9)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -80,6 +80,101 @@ public class HomeController {
|
|||||||
wrapper.like(BookEntity::getName,params.get("title"));
|
wrapper.like(BookEntity::getName,params.get("title"));
|
||||||
wrapper.orderByAsc(BookAbroadToLable::getSort);
|
wrapper.orderByAsc(BookAbroadToLable::getSort);
|
||||||
List<Map<String,Object>> list = toLableService.listMaps(wrapper);
|
List<Map<String,Object>> list = toLableService.listMaps(wrapper);
|
||||||
|
for (Map<String, Object> map : list) {
|
||||||
|
//查询最低价格
|
||||||
|
List<ShopProduct> shopProducts = shopProductService.list(new MPJLambdaWrapper<ShopProduct>()
|
||||||
|
.leftJoin(ShopProductBookEntity.class,ShopProductBookEntity::getProductId,ShopProduct::getProductId)
|
||||||
|
.selectAll(ShopProduct.class)
|
||||||
|
.eq(ShopProduct::getGoodsType,"02")
|
||||||
|
.eq(ShopProductBookEntity::getBookId,map.get("bookId")));
|
||||||
|
map.put("minPrice",0);
|
||||||
|
map.put("discountType",0);
|
||||||
|
List<Map<String,BigDecimal>> priceList = new ArrayList<>();
|
||||||
|
for (ShopProduct shopProduct : shopProducts) {
|
||||||
|
BigDecimal price = shopProduct.getPrice();
|
||||||
|
if (price.compareTo(BigDecimal.ZERO)>0){
|
||||||
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",BigDecimal.ZERO);
|
||||||
|
priceMap.put("price",price);
|
||||||
|
priceList.add(priceMap);
|
||||||
|
}
|
||||||
|
BigDecimal activityPrice = shopProduct.getActivityPrice();
|
||||||
|
if (activityPrice.compareTo(BigDecimal.ZERO)>0){
|
||||||
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",new BigDecimal(1));
|
||||||
|
priceMap.put("price",activityPrice);
|
||||||
|
priceList.add(priceMap);
|
||||||
|
}
|
||||||
|
BigDecimal vipPrice = BigDecimal.ZERO;
|
||||||
|
if(Integer.parseInt(map.get("isVip").toString())==0){
|
||||||
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",new BigDecimal(0));
|
||||||
|
priceMap.put("price",BigDecimal.ZERO);
|
||||||
|
priceList.add(priceMap);
|
||||||
|
}else if(Integer.parseInt(map.get("isVip").toString())==1 ){
|
||||||
|
boolean courseVip = userVipService.isVip();
|
||||||
|
boolean bookVip = userEbookVipService.isBookVip();
|
||||||
|
if(bookVip){
|
||||||
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",new BigDecimal(2));
|
||||||
|
priceMap.put("price",BigDecimal.ZERO);
|
||||||
|
priceList.add(priceMap);
|
||||||
|
}else if(courseVip){
|
||||||
|
BigDecimal courseVipPrice = shopProductService.getVipPrice(shopProduct);
|
||||||
|
if (courseVipPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",new BigDecimal(2));
|
||||||
|
priceMap.put("price",courseVipPrice);
|
||||||
|
priceList.add(priceMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if(Integer.parseInt(map.get("isVip").toString())==2 && shopProduct.getIsVipPrice()==1){
|
||||||
|
boolean courseVip = userVipService.isVip();
|
||||||
|
boolean bookVip = userEbookVipService.isBookVip();
|
||||||
|
BigDecimal courseVipPrice = BigDecimal.ZERO;
|
||||||
|
if(courseVip){
|
||||||
|
courseVipPrice = shopProductService.getVipPrice(shopProduct);
|
||||||
|
}
|
||||||
|
BigDecimal bookVipPrice = BigDecimal.ZERO;
|
||||||
|
if(bookVip){
|
||||||
|
bookVipPrice = userEbookVipService.getBookVipPrice(shopProduct);
|
||||||
|
}
|
||||||
|
if (courseVipPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
vipPrice = courseVipPrice;
|
||||||
|
}
|
||||||
|
if (bookVipPrice.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
&& (vipPrice.compareTo(BigDecimal.ZERO) == 0 || bookVipPrice.compareTo(vipPrice) < 0)) {
|
||||||
|
vipPrice = bookVipPrice;
|
||||||
|
}
|
||||||
|
// 非vip用户vipPrice为0,不加入比价,避免minPrice被写成0且discountType=2
|
||||||
|
if (vipPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",new BigDecimal(2));
|
||||||
|
priceMap.put("price",vipPrice);
|
||||||
|
priceList.add(priceMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (priceList.size()>0){
|
||||||
|
priceList=priceList.stream().sorted((b1,b2)->{
|
||||||
|
return b1.get("price").compareTo(b2.get("price"));
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
Map<String,BigDecimal> minPriceMap = priceList.get(0);
|
||||||
|
map.put("minPrice", minPriceMap.get("price"));
|
||||||
|
map.put("discountType", minPriceMap.get("discountType").intValue());
|
||||||
|
}
|
||||||
|
map.put("isBuy",false);
|
||||||
|
long count = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||||
|
.eq(UserEbookBuyEntity::getUserId,ShiroUtils.getUId())
|
||||||
|
.eq(UserEbookBuyEntity::getBookId,map.get("bookId")));
|
||||||
|
if (count > 0) {
|
||||||
|
map.put("isBuy",true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for (Map<String, Object> map : list) {
|
// for (Map<String, Object> map : list) {
|
||||||
// long readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
// long readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||||
// .eq(BookReadRateEntity::getBookId,map.get("bookId")));
|
// .eq(BookReadRateEntity::getBookId,map.get("bookId")));
|
||||||
@@ -263,29 +358,85 @@ public class HomeController {
|
|||||||
.eq(ShopProduct::getGoodsType,"02")
|
.eq(ShopProduct::getGoodsType,"02")
|
||||||
.eq(ShopProductBookEntity::getBookId,map.get("bookId")));
|
.eq(ShopProductBookEntity::getBookId,map.get("bookId")));
|
||||||
map.put("minPrice",0);
|
map.put("minPrice",0);
|
||||||
List<BigDecimal> priceList = new ArrayList<>();
|
map.put("discountType",0);
|
||||||
|
List<Map<String,BigDecimal>> priceList = new ArrayList<>();
|
||||||
for (ShopProduct shopProduct : shopProducts) {
|
for (ShopProduct shopProduct : shopProducts) {
|
||||||
BigDecimal price = shopProduct.getPrice();
|
BigDecimal price = shopProduct.getPrice();
|
||||||
if (price.compareTo(BigDecimal.ZERO)>0){
|
if (price.compareTo(BigDecimal.ZERO)>0){
|
||||||
priceList.add(price);
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",BigDecimal.ZERO);
|
||||||
|
priceMap.put("price",price);
|
||||||
|
priceList.add(priceMap);
|
||||||
}
|
}
|
||||||
BigDecimal activityPrice = shopProduct.getActivityPrice();
|
BigDecimal activityPrice = shopProduct.getActivityPrice();
|
||||||
if (activityPrice.compareTo(BigDecimal.ZERO)>0){
|
if (activityPrice.compareTo(BigDecimal.ZERO)>0){
|
||||||
priceList.add(activityPrice);
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",new BigDecimal(1));
|
||||||
|
priceMap.put("price",activityPrice);
|
||||||
|
priceList.add(priceMap);
|
||||||
}
|
}
|
||||||
BigDecimal vipPrice = BigDecimal.ZERO;
|
BigDecimal vipPrice = BigDecimal.ZERO;
|
||||||
if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
|
|
||||||
vipPrice = shopProductService.getVipPrice(shopProduct);
|
if(Integer.parseInt(map.get("isVip").toString())==0){
|
||||||
if (vipPrice.compareTo(BigDecimal.ZERO)>0){
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
priceList.add(vipPrice);
|
priceMap.put("discountType",new BigDecimal(0));
|
||||||
|
priceMap.put("price",BigDecimal.ZERO);
|
||||||
|
priceList.add(priceMap);
|
||||||
|
}else if(Integer.parseInt(map.get("isVip").toString())==1 ){
|
||||||
|
boolean courseVip = userVipService.isVip();
|
||||||
|
boolean bookVip = userEbookVipService.isBookVip();
|
||||||
|
if(bookVip){
|
||||||
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",new BigDecimal(2));
|
||||||
|
priceMap.put("price",BigDecimal.ZERO);
|
||||||
|
priceList.add(priceMap);
|
||||||
|
}else if(courseVip){
|
||||||
|
BigDecimal courseVipPrice = shopProductService.getVipPrice(shopProduct);
|
||||||
|
if (courseVipPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",new BigDecimal(2));
|
||||||
|
priceMap.put("price",courseVipPrice);
|
||||||
|
priceList.add(priceMap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}else if(Integer.parseInt(map.get("isVip").toString())==2 && shopProduct.getIsVipPrice()==1){
|
||||||
|
boolean courseVip = userVipService.isVip();
|
||||||
|
boolean bookVip = userEbookVipService.isBookVip();
|
||||||
|
if(courseVip||bookVip){
|
||||||
|
BigDecimal courseVipPrice = BigDecimal.ZERO;
|
||||||
|
if(courseVip){
|
||||||
|
courseVipPrice = shopProductService.getVipPrice(shopProduct);
|
||||||
|
}
|
||||||
|
BigDecimal bookVipPrice = BigDecimal.ZERO;
|
||||||
|
if(bookVip){
|
||||||
|
bookVipPrice = userEbookVipService.getBookVipPrice(shopProduct);
|
||||||
|
}
|
||||||
|
if (courseVipPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
vipPrice = courseVipPrice;
|
||||||
|
}
|
||||||
|
if (bookVipPrice.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
&& (vipPrice.compareTo(BigDecimal.ZERO) == 0 || bookVipPrice.compareTo(vipPrice) < 0)) {
|
||||||
|
vipPrice = bookVipPrice;
|
||||||
|
}
|
||||||
|
// 非vip用户vipPrice为0,不加入比价,避免minPrice被写成0且discountType=2
|
||||||
|
if (vipPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
Map<String,BigDecimal> priceMap = new HashMap<>();
|
||||||
|
priceMap.put("discountType",new BigDecimal(2));
|
||||||
|
priceMap.put("price",vipPrice);
|
||||||
|
priceList.add(priceMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (priceList.size()>0){
|
if (priceList.size()>0){
|
||||||
priceList=priceList.stream().sorted((b1,b2)->{
|
priceList=priceList.stream().sorted((b1,b2)->{
|
||||||
return b1.compareTo(b2);
|
return b1.get("price").compareTo(b2.get("price"));
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
map.put("minPrice",priceList.get(0));
|
Map<String,BigDecimal> minPriceMap = priceList.get(0);
|
||||||
|
map.put("minPrice", minPriceMap.get("price"));
|
||||||
|
map.put("discountType", minPriceMap.get("discountType").intValue());
|
||||||
}
|
}
|
||||||
map.put("isBuy",false);
|
map.put("isBuy",false);
|
||||||
long count = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
long count = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||||
|
|||||||
@@ -194,4 +194,13 @@ public class ShopProduct implements Serializable {
|
|||||||
//vip价格
|
//vip价格
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private BigDecimal vipPrice;
|
private BigDecimal vipPrice;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private BigDecimal minPrice;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private int discountType;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer isVip;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package com.peanut.modules.common.service;
|
package com.peanut.modules.common.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.peanut.modules.common.entity.ShopProduct;
|
||||||
import com.peanut.modules.common.entity.UserEbookVip;
|
import com.peanut.modules.common.entity.UserEbookVip;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public interface UserEbookVipService extends IService<UserEbookVip> {
|
public interface UserEbookVipService extends IService<UserEbookVip> {
|
||||||
|
BigDecimal getBookVipPrice(ShopProduct shopProduct);
|
||||||
|
|
||||||
|
Boolean isBookVip();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,33 @@
|
|||||||
package com.peanut.modules.common.service.impl;
|
package com.peanut.modules.common.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.peanut.common.utils.ShiroUtils;
|
||||||
import com.peanut.modules.common.dao.UserEbookVipDao;
|
import com.peanut.modules.common.dao.UserEbookVipDao;
|
||||||
|
import com.peanut.modules.common.entity.ShopProduct;
|
||||||
import com.peanut.modules.common.entity.UserEbookVip;
|
import com.peanut.modules.common.entity.UserEbookVip;
|
||||||
import com.peanut.modules.common.service.UserEbookVipService;
|
import com.peanut.modules.common.service.UserEbookVipService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service("commonUserEbookVipService")
|
@Service("commonUserEbookVipService")
|
||||||
public class UserEbookVipServiceImpl extends ServiceImpl<UserEbookVipDao, UserEbookVip> implements UserEbookVipService {
|
public class UserEbookVipServiceImpl extends ServiceImpl<UserEbookVipDao, UserEbookVip> implements UserEbookVipService {
|
||||||
|
@Override
|
||||||
|
public BigDecimal getBookVipPrice(ShopProduct shopProduct) {
|
||||||
|
return shopProduct.getPrice().multiply(new BigDecimal(0.8)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Boolean isBookVip() {
|
||||||
|
UserEbookVip vip = this.getOne(new LambdaQueryWrapper<UserEbookVip>()
|
||||||
|
.eq(UserEbookVip::getUserId, ShiroUtils.getUId())
|
||||||
|
.and(w -> w.isNull(UserEbookVip::getEndTime)
|
||||||
|
.or()
|
||||||
|
.gt(UserEbookVip::getEndTime, new Date()))
|
||||||
|
.last("limit 1"));
|
||||||
|
return vip != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,43 +187,77 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|||||||
.stream().map(UserCourseBuyEntity::getCourseId).collect(Collectors.toList());
|
.stream().map(UserCourseBuyEntity::getCourseId).collect(Collectors.toList());
|
||||||
if (list.size()>0&&buyList.size()>0){
|
if (list.size()>0&&buyList.size()>0){
|
||||||
wrapper.and(t->t.in(CourseToMedicine::getMedicalId,list).or().in(CourseToMedicine::getCourseId,buyList));
|
wrapper.and(t->t.in(CourseToMedicine::getMedicalId,list).or().in(CourseToMedicine::getCourseId,buyList));
|
||||||
}else if (list.size()>0){
|
|
||||||
wrapper.in(CourseToMedicine::getMedicalId,list);
|
|
||||||
}else if (buyList.size()>0){
|
|
||||||
wrapper.in(CourseToMedicine::getCourseId,buyList);
|
|
||||||
}
|
|
||||||
long page = Long.parseLong(param.get("page").toString());
|
|
||||||
int limit = Integer.parseInt(param.get("limit").toString());
|
|
||||||
Page<CourseEntity> courseEntityPage;
|
|
||||||
List<CourseEntity> courseEntities;
|
|
||||||
if (list.size()>0||buyList.size()>0){
|
|
||||||
if (StringUtils.isNotEmpty(param.get("medicalId").toString())){
|
|
||||||
wrapper.eq(CourseToMedicine::getMedicalId,param.get("medicalId"));
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(param.get("title").toString())){
|
|
||||||
wrapper.like(CourseEntity::getTitle,param.get("title"));
|
|
||||||
}
|
|
||||||
wrapper.distinct();
|
|
||||||
wrapper.selectAll(CourseEntity.class);
|
|
||||||
wrapper.orderByAsc(CourseEntity::getSort);
|
|
||||||
courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(page, limit), CourseEntity.class, wrapper);
|
|
||||||
courseEntities = courseEntityPage.getRecords();
|
|
||||||
}else {
|
}else {
|
||||||
courseEntityPage = new Page<>(page, limit);
|
if (list.size()>0){
|
||||||
courseEntities = new ArrayList<>();
|
wrapper.in(CourseToMedicine::getMedicalId,list);
|
||||||
}
|
}else if (buyList.size()>0){
|
||||||
if(courseEntities.size()<limit){
|
wrapper.in(CourseToMedicine::getCourseId,buyList);
|
||||||
Map<String, Object> sociologyParam = new HashMap<>(param);
|
|
||||||
if (list.size()==0&&buyList.size()==0){
|
|
||||||
//无医学课程,直接查国学分页
|
|
||||||
}else {
|
}else {
|
||||||
sociologyParam.put("page", 1);
|
return new Page<>();
|
||||||
sociologyParam.put("limit", limit - courseEntities.size());
|
|
||||||
sociologyParam.put("excludeIds", courseEntities.stream().map(CourseEntity::getId).collect(Collectors.toList()));
|
|
||||||
}
|
}
|
||||||
courseEntities.addAll(getUserSociologyCourse(sociologyParam));
|
|
||||||
courseEntityPage.setRecords(courseEntities);
|
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isNotEmpty(param.get("medicalId").toString())){
|
||||||
|
wrapper.eq(CourseToMedicine::getMedicalId,param.get("medicalId"));
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(param.get("title").toString())){
|
||||||
|
wrapper.like(CourseEntity::getTitle,param.get("title"));
|
||||||
|
}
|
||||||
|
wrapper.distinct();
|
||||||
|
wrapper.selectAll(CourseEntity.class);
|
||||||
|
wrapper.orderByAsc(CourseEntity::getSort);
|
||||||
|
Page<CourseEntity> courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(Long.parseLong(param.get("page").toString()), Long.parseLong(param.get("limit").toString())), CourseEntity.class, wrapper);
|
||||||
|
List<CourseEntity> courseEntities = courseEntityPage.getRecords();
|
||||||
|
System.out.println(courseEntities);
|
||||||
|
|
||||||
|
MPJLambdaWrapper<CourseEntity> wrapper2 = new MPJLambdaWrapper<>();
|
||||||
|
wrapper2.rightJoin(CourseToSociologyEntity.class,CourseToSociologyEntity::getCourseId,CourseEntity::getId);
|
||||||
|
//开通的会员下的课程
|
||||||
|
List list2 = new ArrayList<>();//通过顶级标签获取最下层标签
|
||||||
|
// if (userVipService.isMedicalVip(ShiroUtils.getUId())){
|
||||||
|
// userVipService.bottomLabel(1,list);
|
||||||
|
// }
|
||||||
|
// if (userVipService.isChineseWesternVip(ShiroUtils.getUId())){
|
||||||
|
// userVipService.bottomLabel(74,list);
|
||||||
|
// }
|
||||||
|
// if (userVipService.isAcupunctureVip(ShiroUtils.getUId())){
|
||||||
|
// userVipService.bottomLabel(2,list);
|
||||||
|
// }
|
||||||
|
// if (userVipService.istumorVip(ShiroUtils.getUId())){
|
||||||
|
// userVipService.bottomLabel(5,list);
|
||||||
|
// }
|
||||||
|
// if (userVipService.isPsycheVip(ShiroUtils.getUId())){
|
||||||
|
// userVipService.bottomLabel(4,list);
|
||||||
|
// }
|
||||||
|
System.out.println("==============9999"+buyList.size());
|
||||||
|
System.out.println(buyList);
|
||||||
|
if (list2.size()>0&&buyList.size()>0){
|
||||||
|
wrapper2.and(t->t.in(CourseToSociologyEntity::getSociologyId,list2).or().in(CourseToSociologyEntity::getCourseId,buyList));
|
||||||
|
}else {
|
||||||
|
if (list2.size()>0){
|
||||||
|
wrapper2.in(CourseToSociologyEntity::getSociologyId,list2);
|
||||||
|
}else if (buyList.size()>0){
|
||||||
|
wrapper2.in(CourseToSociologyEntity::getCourseId,buyList);
|
||||||
|
}else {
|
||||||
|
return new Page<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(param.get("medicalId").toString())){
|
||||||
|
wrapper2.eq(CourseToSociologyEntity::getSociologyId,param.get("medicalId"));
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(param.get("title").toString())){
|
||||||
|
wrapper2.like(CourseEntity::getTitle,param.get("title"));
|
||||||
|
}
|
||||||
|
wrapper2.distinct();
|
||||||
|
wrapper2.selectAll(CourseEntity.class);
|
||||||
|
wrapper2.orderByAsc(CourseEntity::getSort);
|
||||||
|
Page<CourseEntity> courseEntityPage2 = this.getBaseMapper().selectJoinPage(new Page<>(Long.parseLong(param.get("page").toString()), Long.parseLong(param.get("limit").toString())), CourseEntity.class, wrapper2);
|
||||||
|
List<CourseEntity> courseEntities2 = courseEntityPage2.getRecords();
|
||||||
|
if(courseEntities.size()>0){
|
||||||
|
courseEntities.addAll(courseEntities2);
|
||||||
|
}else{
|
||||||
|
courseEntities = courseEntities2;
|
||||||
|
}
|
||||||
|
|
||||||
for (CourseEntity co:courseEntities){
|
for (CourseEntity co:courseEntities){
|
||||||
int i = studyingDao.selectCount(new LambdaQueryWrapper<UserCourseStudying>()
|
int i = studyingDao.selectCount(new LambdaQueryWrapper<UserCourseStudying>()
|
||||||
.eq(UserCourseStudying::getCourseId,co.getId())
|
.eq(UserCourseStudying::getCourseId,co.getId())
|
||||||
@@ -262,49 +296,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|||||||
}
|
}
|
||||||
return courseEntityPage;
|
return courseEntityPage;
|
||||||
}
|
}
|
||||||
public List<CourseEntity> getUserSociologyCourse(Map<String, Object> param){
|
|
||||||
|
|
||||||
log.info("=======getUserSociologyCourse===in====",param);
|
|
||||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
|
||||||
wrapper.rightJoin(CourseToSociologyEntity.class,CourseToSociologyEntity::getCourseId,CourseEntity::getId);
|
|
||||||
//开通的会员下的课程
|
|
||||||
List list = new ArrayList<>();//通过顶级标签获取最下层标签
|
|
||||||
if (userVipService.isSociologyVip(ShiroUtils.getUId())){
|
|
||||||
userVipService.bottomLabel(7,list);
|
|
||||||
}
|
|
||||||
//购买的课程
|
|
||||||
List buyList = userCourseBuyDao.selectList(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
|
||||||
.eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId()))
|
|
||||||
.stream().map(UserCourseBuyEntity::getCourseId).collect(Collectors.toList());
|
|
||||||
if (list.size()>0&&buyList.size()>0){
|
|
||||||
wrapper.and(t->t.in(CourseToSociologyEntity::getSociologyId,list).or().in(CourseToSociologyEntity::getCourseId,buyList));
|
|
||||||
}else {
|
|
||||||
if (list.size()>0){
|
|
||||||
wrapper.in(CourseToSociologyEntity::getSociologyId,list);
|
|
||||||
}else if (buyList.size()>0){
|
|
||||||
wrapper.in(CourseToSociologyEntity::getCourseId,buyList);
|
|
||||||
}else {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(param.get("medicalId").toString())){
|
|
||||||
wrapper.eq(CourseToSociologyEntity::getSociologyId,param.get("medicalId"));
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(param.get("title").toString())){
|
|
||||||
wrapper.like(CourseEntity::getTitle,param.get("title"));
|
|
||||||
}
|
|
||||||
if (param.get("excludeIds") != null){
|
|
||||||
List excludeIds = (List) param.get("excludeIds");
|
|
||||||
if (excludeIds.size()>0){
|
|
||||||
wrapper.notIn(CourseEntity::getId,excludeIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.distinct();
|
|
||||||
wrapper.selectAll(CourseEntity.class);
|
|
||||||
wrapper.orderByAsc(CourseEntity::getSort);
|
|
||||||
Page<CourseEntity> courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(Long.parseLong(param.get("page").toString()), Long.parseLong(param.get("limit").toString())), CourseEntity.class, wrapper);
|
|
||||||
return courseEntityPage.getRecords();
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public List getCourseExpire(Map<String, Object> param) {
|
public List getCourseExpire(Map<String, Object> param) {
|
||||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user