修改VIP商品优惠
This commit is contained in:
@@ -765,11 +765,11 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
goodsResponseVo.setProductName(shopProduct.getProductName());
|
||||
goodsResponseVo.setProductImage(shopProduct.getProductImages());
|
||||
goodsResponseVo.setProductPrice(shopProduct.getPrice());
|
||||
// if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
|
||||
// goodsResponseVo.setVipPrice(shopProductService.getVipPrice(shopProduct));
|
||||
// }else {
|
||||
if (userVipService.isVip(userId)&&shopProduct.getIsVipPrice()==1){
|
||||
goodsResponseVo.setVipPrice(shopProductService.getVipPrice(shopProduct));
|
||||
}else {
|
||||
goodsResponseVo.setVipPrice(BigDecimal.ZERO);
|
||||
// }
|
||||
}
|
||||
goodsResponseVo.setQuantity(buyOrderProduct.getQuantity());
|
||||
goodsResponseVo.setProductId(shopProduct.getProductId());
|
||||
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
@@ -78,13 +78,14 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
b = shopProduct.getPrice().multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
}else if (userVipService.isVip()){
|
||||
b = shopProduct.getPrice().multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
}else {
|
||||
BigDecimal activityPrice = shopProduct.getActivityPrice();
|
||||
b = (activityPrice == null || activityPrice.equals(BigDecimal.ZERO)) ? shopProduct.getPrice() : activityPrice;
|
||||
}
|
||||
// else {
|
||||
// BigDecimal activityPrice = shopProduct.getActivityPrice();
|
||||
// b = (activityPrice == null || activityPrice.equals(BigDecimal.ZERO)) ? shopProduct.getPrice() : activityPrice;
|
||||
// }
|
||||
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0))>0
|
||||
&&b.compareTo(shopProduct.getActivityPrice())>0){
|
||||
b = shopProduct.getActivityPrice();
|
||||
b = new BigDecimal(0);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Set;
|
||||
public interface UserVipService extends IService<UserVip> {
|
||||
|
||||
boolean isVip();
|
||||
boolean isVip(int uid);
|
||||
boolean noMedicalVip();
|
||||
boolean isMedicalVip();
|
||||
boolean isChineseWesternVip();
|
||||
|
||||
@@ -42,6 +42,19 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVip(int uid) {
|
||||
if (uid >= 10000){
|
||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||
.eq(UserVip::getUserId, uid)
|
||||
.eq(UserVip::getState,0));
|
||||
if (userVipList.size() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean noMedicalVip() {
|
||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||
@@ -57,37 +70,37 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
|
||||
|
||||
@Override
|
||||
public boolean isMedicalVip() {
|
||||
return isVip(4);
|
||||
return isVipByType(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChineseWesternVip() {
|
||||
return isVip(9);
|
||||
return isVipByType(9);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcupunctureVip() {
|
||||
return isVip(5);
|
||||
return isVipByType(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean istumorVip() {
|
||||
return isVip(6);
|
||||
return isVipByType(6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSociologyVip() {
|
||||
return isVip(7);
|
||||
return isVipByType(7);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPsycheVip() {
|
||||
return isVip(8);
|
||||
return isVipByType(8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is4569SVip() {
|
||||
if (isVip(4)&&isVip(9)&&isVip(5)&&isVip(6)){
|
||||
if (isVipByType(4)&&isVipByType(9)&&isVipByType(5)&&isVipByType(6)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -95,22 +108,24 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
|
||||
|
||||
@Override
|
||||
public boolean is78SVip() {
|
||||
if (isVip(7)&&isVip(8)){
|
||||
if (isVipByType(7)&&isVipByType(8)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVip(int type) {
|
||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||
.eq(UserVip::getUserId, ShiroUtils.getUId())
|
||||
.eq(UserVip::getState,0)
|
||||
.eq(UserVip::getType,type));
|
||||
if (userVipList.size() > 0) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
public boolean isVipByType(int type) {
|
||||
int uid = ShiroUtils.getUId();
|
||||
if (uid >= 10000) {
|
||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||
.eq(UserVip::getUserId, uid)
|
||||
.eq(UserVip::getState,0)
|
||||
.eq(UserVip::getType,type));
|
||||
if (userVipList.size() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public UserVip ownCourseCatalogueByVip(MyUserEntity u,int courseId) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
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.ShopProductCourseDao;
|
||||
@@ -67,10 +68,11 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
public Map<String, Object> getProductDetail(Integer productId) {
|
||||
ShopProduct product = this.getById(productId);
|
||||
HashMap<String, Object> flag = new HashMap<>();
|
||||
// if (userVipService.isVip()&&product.getIsVipPrice()==1){
|
||||
// product.setVipPrice(shopProductService.getVipPrice(product));
|
||||
// }
|
||||
product.setVipPrice(BigDecimal.ZERO);
|
||||
if (userVipService.isVip(ShiroUtils.getUId())&&product.getIsVipPrice()==1){
|
||||
product.setVipPrice(shopProductService.getVipPrice(product));
|
||||
}else {
|
||||
product.setVipPrice(BigDecimal.ZERO);
|
||||
}
|
||||
flag.put("detail",product);//基础信息
|
||||
//查询包含的书
|
||||
MPJLambdaWrapper<ShopProductBookEntity> shopProductBookEntityMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
||||
@@ -126,9 +128,9 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
if (shopProducts.size()>0){
|
||||
for (ShopProduct shopProduct : shopProducts) {
|
||||
shopProduct.setVipPrice(BigDecimal.ZERO);
|
||||
// if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
|
||||
// shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
|
||||
// }
|
||||
if (userVipService.isVip(ShiroUtils.getUId())&&shopProduct.getIsVipPrice()==1){
|
||||
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user