Compare commits
3 Commits
83f467946d
...
b9d7f407fe
| Author | SHA1 | Date | |
|---|---|---|---|
| b9d7f407fe | |||
| 47133a6b0d | |||
| 66e10934c2 |
@@ -12,7 +12,7 @@ import java.util.Properties;
|
||||
public class MailUtil {
|
||||
|
||||
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){
|
||||
try {
|
||||
|
||||
@@ -259,12 +259,11 @@ public class BuyOrderController {
|
||||
@RequestMapping("/getVipDiscountAmount")
|
||||
public R getVipDiscountAmount(@RequestBody BuyOrder buyOrder){
|
||||
BigDecimal b = new BigDecimal(0);
|
||||
if (userVipService.isVip()){
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
BigDecimal pvda = shopProductService.getVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId()));
|
||||
b = b.add(pvda.multiply(new BigDecimal(buyOrderProduct.getQuantity())));
|
||||
}
|
||||
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
BigDecimal pvda = shopProductService.getCourseOrBookVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId()));
|
||||
b = b.add(pvda.multiply(new BigDecimal(buyOrderProduct.getQuantity())));
|
||||
}
|
||||
return R.ok().put("discountAmount",b);
|
||||
}
|
||||
@@ -277,7 +276,7 @@ public class BuyOrderController {
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
ShopProduct shopProduct = shopProductService.getById(buyOrderProduct.getProductId());
|
||||
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){
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ public interface ShopProductService extends IService<ShopProduct> {
|
||||
|
||||
List<ShopProduct> appGetCategoryList(Integer catId);
|
||||
|
||||
BigDecimal getCourseOrBookVipDiscountAmount(ShopProduct shopProduct);
|
||||
|
||||
BigDecimal getVipDiscountAmount(ShopProduct shopProduct);
|
||||
|
||||
BigDecimal getVipPrice(ShopProduct shopProduct);
|
||||
@@ -36,8 +38,5 @@ public interface ShopProductService extends IService<ShopProduct> {
|
||||
PageUtils queryPageactivityprice(Map<String, Object> params);
|
||||
|
||||
List<ShopProduct> getProductListForBook(Integer bookId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
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.entity.BookEntity;
|
||||
import com.peanut.modules.common.entity.ShopProductBookEntity;
|
||||
import com.peanut.modules.common.service.UserEbookVipService;
|
||||
import com.peanut.modules.common.service.UserVipService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -28,6 +32,10 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
private UserVipService userVipService;
|
||||
@Autowired
|
||||
private ShopProductBookDao shopProductBookDao;
|
||||
@Autowired
|
||||
private UserEbookVipService userEbookVipService;
|
||||
@Autowired
|
||||
private BookDao bookDao;
|
||||
|
||||
@Override
|
||||
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);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getVipDiscountAmount(ShopProduct shopProduct) {
|
||||
BigDecimal p = new BigDecimal(0);
|
||||
@@ -75,6 +82,98 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
}
|
||||
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
|
||||
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;
|
||||
// }
|
||||
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0))>0
|
||||
&&b.compareTo(shopProduct.getActivityPrice())>0){
|
||||
&&b.compareTo(shopProduct.getActivityPrice())>=0){
|
||||
b = new BigDecimal(0);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils getNewBook(Map<String, Object> params) {
|
||||
IPage<ShopProduct> page = this.page(
|
||||
@@ -145,8 +243,86 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
wrapper.eq(ShopProductBookEntity::getBookId,bookId);
|
||||
wrapper.orderByAsc(ShopProduct::getPrice);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 课程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.orderByAsc(BookAbroadToLable::getSort);
|
||||
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) {
|
||||
// long readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
// .eq(BookReadRateEntity::getBookId,map.get("bookId")));
|
||||
@@ -263,29 +358,85 @@ public class HomeController {
|
||||
.eq(ShopProduct::getGoodsType,"02")
|
||||
.eq(ShopProductBookEntity::getBookId,map.get("bookId")));
|
||||
map.put("minPrice",0);
|
||||
List<BigDecimal> priceList = new ArrayList<>();
|
||||
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){
|
||||
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();
|
||||
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;
|
||||
if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
|
||||
vipPrice = shopProductService.getVipPrice(shopProduct);
|
||||
if (vipPrice.compareTo(BigDecimal.ZERO)>0){
|
||||
priceList.add(vipPrice);
|
||||
|
||||
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();
|
||||
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){
|
||||
priceList=priceList.stream().sorted((b1,b2)->{
|
||||
return b1.compareTo(b2);
|
||||
return b1.get("price").compareTo(b2.get("price"));
|
||||
}).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);
|
||||
long count = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
|
||||
@@ -567,6 +567,7 @@ public class UserController {
|
||||
case 7: type = "国学vip";break;
|
||||
case 8: type = "心理学vip";break;
|
||||
case 9: type = "中西汇通vip";break;
|
||||
case 10: type = "妇幼生殖vip";break;
|
||||
}
|
||||
uvSb.append(type + "-开始时间" + DateUtil.format(uv.getStartTime(),"yyyy-MM-dd HH:mm:ss")
|
||||
+ "结束时间" + DateUtil.format(uv.getEndTime(),"yyyy-MM-dd HH:mm:ss") + "\n");
|
||||
|
||||
@@ -194,4 +194,13 @@ public class ShopProduct implements Serializable {
|
||||
//vip价格
|
||||
@TableField(exist = false)
|
||||
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;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.peanut.modules.common.entity.UserEbookVip;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public interface UserEbookVipService extends IService<UserEbookVip> {
|
||||
BigDecimal getBookVipPrice(ShopProduct shopProduct);
|
||||
|
||||
Boolean isBookVip();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,33 @@
|
||||
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.peanut.common.utils.ShiroUtils;
|
||||
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.service.UserEbookVipService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonUserEbookVipService")
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,6 +207,57 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
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){
|
||||
int i = studyingDao.selectCount(new LambdaQueryWrapper<UserCourseStudying>()
|
||||
.eq(UserCourseStudying::getCourseId,co.getId())
|
||||
|
||||
Reference in New Issue
Block a user