vip优惠商品添加用户是否vip判断

This commit is contained in:
wuchunlei
2025-03-14 13:09:23 +08:00
parent 7eb3e58a18
commit 16f8166877
12 changed files with 26 additions and 22 deletions

View File

@@ -388,7 +388,7 @@ public class BookLabelAndMarketController {
List<Map<String,Object>> list = toLabelService.listMaps(wrapper); List<Map<String,Object>> list = toLabelService.listMaps(wrapper);
for (Map<String,Object> map:list){ for (Map<String,Object> map:list){
ShopProduct shopProduct = shopProductService.getById(map.get("product_id").toString()); ShopProduct shopProduct = shopProductService.getById(map.get("product_id").toString());
if (shopProduct.getIsVipPrice()==1){ if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
map.put("vip_price",shopProductService.getVipPrice(shopProduct)); map.put("vip_price",shopProductService.getVipPrice(shopProduct));
} }
} }

View File

@@ -155,7 +155,7 @@ 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.noVip()){ 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.getVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId()));
@@ -172,7 +172,7 @@ public class BuyOrderController {
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList(); List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) { for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
ShopProduct shopProduct = shopProductService.getById(buyOrderProduct.getProductId()); ShopProduct shopProduct = shopProductService.getById(buyOrderProduct.getProductId());
if (!userVipService.noVip()){ if (userVipService.isVip()){
BigDecimal pvda = shopProductService.getVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId())); BigDecimal pvda = shopProductService.getVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId()));
if (pvda.compareTo(BigDecimal.ZERO)>0){ if (pvda.compareTo(BigDecimal.ZERO)>0){
continue; continue;
@@ -194,7 +194,7 @@ public class BuyOrderController {
wrapper.in(ShopProduct::getProductId,Arrays.asList(productIds)); wrapper.in(ShopProduct::getProductId,Arrays.asList(productIds));
List<ShopProduct> shopProductList = shopProductService.list(wrapper); List<ShopProduct> shopProductList = shopProductService.list(wrapper);
for (ShopProduct shopProduct:shopProductList){ for (ShopProduct shopProduct:shopProductList){
if (shopProduct.getIsVipPrice()==1){ if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct)); shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
} }
} }
@@ -294,7 +294,7 @@ public class BuyOrderController {
ShopProduct product = shopProductService.getById(productId); ShopProduct product = shopProductService.getById(productId);
BigDecimal price = getRealPrice(product); BigDecimal price = getRealPrice(product);
if (buyOrder.getVipDiscountAmount()!=null&&buyOrder.getVipDiscountAmount().compareTo(new BigDecimal(0))>0 if (buyOrder.getVipDiscountAmount()!=null&&buyOrder.getVipDiscountAmount().compareTo(new BigDecimal(0))>0
&&product.getIsVipPrice()==1){ &&userVipService.isVip()&&product.getIsVipPrice()==1){
price = shopProductService.getVipPrice(product); price = shopProductService.getVipPrice(product);
} }
if (!handleStock(buyOrderProduct, product)) { if (!handleStock(buyOrderProduct, product)) {

View File

@@ -280,7 +280,7 @@ public class ShopProductController {
} }
for (ShopProductBookEntity spbe : ss) { for (ShopProductBookEntity spbe : ss) {
ShopProduct ca_sp = shopProductService.getById(spbe.getProductId()); ShopProduct ca_sp = shopProductService.getById(spbe.getProductId());
if (!userVipService.noVip()&&ca_sp.getIsVipPrice()==1){ if (userVipService.isVip()&&ca_sp.getIsVipPrice()==1){
ca_sp.setVipPrice(shopProductService.getVipPrice(ca_sp)); ca_sp.setVipPrice(shopProductService.getVipPrice(ca_sp));
} }
frag.add(ca_sp); frag.add(ca_sp);
@@ -322,7 +322,7 @@ public class ShopProductController {
booklist.add(String.valueOf(bookId)); booklist.add(String.valueOf(bookId));
list.add(byId); list.add(byId);
} }
if (shopProduct.getIsVipPrice()==1){ if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct)); shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
} }
//添加获取标签逻辑 //添加获取标签逻辑

View File

@@ -765,7 +765,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
goodsResponseVo.setProductName(shopProduct.getProductName()); goodsResponseVo.setProductName(shopProduct.getProductName());
goodsResponseVo.setProductImage(shopProduct.getProductImages()); goodsResponseVo.setProductImage(shopProduct.getProductImages());
goodsResponseVo.setProductPrice(shopProduct.getPrice()); goodsResponseVo.setProductPrice(shopProduct.getPrice());
if (shopProduct.getIsVipPrice()==1){ if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
goodsResponseVo.setVipPrice(shopProductService.getVipPrice(shopProduct)); goodsResponseVo.setVipPrice(shopProductService.getVipPrice(shopProduct));
}else { }else {
goodsResponseVo.setVipPrice(BigDecimal.ZERO); goodsResponseVo.setVipPrice(BigDecimal.ZERO);

View File

@@ -82,7 +82,7 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
} }
shopCartVo.setActivityPrice(price); shopCartVo.setActivityPrice(price);
shopCartVo.setIsVipPrice(productEntity.getIsVipPrice()); shopCartVo.setIsVipPrice(productEntity.getIsVipPrice());
if (productEntity.getIsVipPrice()==1){ if (userVipService.isVip()&&productEntity.getIsVipPrice()==1){
shopCartVo.setVipPrice(shopProductService.getVipPrice(productEntity)); shopCartVo.setVipPrice(shopProductService.getVipPrice(productEntity));
} }
cartList.add(shopCartVo); cartList.add(shopCartVo);

View File

@@ -54,10 +54,10 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
@Override @Override
public BigDecimal getVipDiscountAmount(ShopProduct shopProduct) { public BigDecimal getVipDiscountAmount(ShopProduct shopProduct) {
BigDecimal p = new BigDecimal(0); BigDecimal p = new BigDecimal(0);
if (shopProduct.getIsVipPrice()==1){ if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
if (userVipService.is4569SVip()||userVipService.is78SVip()){ if (userVipService.is4569SVip()||userVipService.is78SVip()){
p = shopProduct.getPrice().multiply(new BigDecimal(0.8)); p = shopProduct.getPrice().multiply(new BigDecimal(0.8));
}else if (!userVipService.noVip()){ }else if (userVipService.isVip()){
p = shopProduct.getPrice().multiply(new BigDecimal(0.9)); p = shopProduct.getPrice().multiply(new BigDecimal(0.9));
} }
//如果有折扣价比折扣价低就返回vip折扣金额 //如果有折扣价比折扣价低就返回vip折扣金额
@@ -76,7 +76,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
BigDecimal b = new BigDecimal(0); BigDecimal b = new BigDecimal(0);
if (userVipService.is4569SVip()||userVipService.is78SVip()){ if (userVipService.is4569SVip()||userVipService.is78SVip()){
b = shopProduct.getPrice().multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP); b = shopProduct.getPrice().multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP);
}else if (!userVipService.noVip()){ }else if (userVipService.isVip()){
b = shopProduct.getPrice().multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP); b = shopProduct.getPrice().multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP);
}else { }else {
BigDecimal activityPrice = shopProduct.getActivityPrice(); BigDecimal activityPrice = shopProduct.getActivityPrice();

View File

@@ -9,7 +9,7 @@ import java.util.Set;
public interface UserVipService extends IService<UserVip> { public interface UserVipService extends IService<UserVip> {
boolean noVip(); boolean isVip();
boolean noMedicalVip(); boolean noMedicalVip();
boolean isMedicalVip(); boolean isMedicalVip();
boolean isChineseWesternVip(); boolean isChineseWesternVip();

View File

@@ -31,14 +31,14 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
private VipBuyConfigDao vipBuyConfigDao; private VipBuyConfigDao vipBuyConfigDao;
@Override @Override
public boolean noVip() { public boolean isVip() {
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>() List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
.eq(UserVip::getUserId, ShiroUtils.getUId()) .eq(UserVip::getUserId, ShiroUtils.getUId())
.eq(UserVip::getState,0)); .eq(UserVip::getState,0));
if (userVipList.size() > 0) { if (userVipList.size() > 0) {
return false;
}else {
return true; return true;
}else {
return false;
} }
} }

View File

@@ -34,6 +34,8 @@ public class MedicalLabelAndMarketController {
private ShopProductService productService; private ShopProductService productService;
@Autowired @Autowired
private com.peanut.modules.book.service.ShopProductService shopProductService; private com.peanut.modules.book.service.ShopProductService shopProductService;
@Autowired
private UserVipService userVipService;
/** /**
* 分类标签树 * 分类标签树
@@ -68,7 +70,7 @@ public class MedicalLabelAndMarketController {
Page<ShopProduct> page = productService.page(new Page<>( Page<ShopProduct> page = productService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper); Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
for (ShopProduct shopProduct:page.getRecords()){ for (ShopProduct shopProduct:page.getRecords()){
if (shopProduct.getIsVipPrice()==1){ if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct)); shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
} }
} }

View File

@@ -37,6 +37,8 @@ public class PsycheHomeController {
private ShopProductService shopProductService; private ShopProductService shopProductService;
@Autowired @Autowired
private com.peanut.modules.book.service.ShopProductService spService; private com.peanut.modules.book.service.ShopProductService spService;
@Autowired
private UserVipService userVipService;
//获取标签列表 //获取标签列表
@RequestMapping("/getPsycheLabels") @RequestMapping("/getPsycheLabels")
@@ -83,7 +85,7 @@ public class PsycheHomeController {
Page<ShopProduct> shopProductPage = shopProductService.page(new Page<>( Page<ShopProduct> shopProductPage = shopProductService.page(new Page<>(
Long.parseLong(params.get("page").toString()), Long.parseLong(params.get("limit").toString())),wrapper); Long.parseLong(params.get("page").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
for (ShopProduct shopProduct:shopProductPage.getRecords()){ for (ShopProduct shopProduct:shopProductPage.getRecords()){
if (shopProduct.getIsVipPrice()==1){ if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
shopProduct.setVipPrice(spService.getVipPrice(shopProduct)); shopProduct.setVipPrice(spService.getVipPrice(shopProduct));
} }
} }

View File

@@ -129,7 +129,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
.in(ShopProduct::getProductId, ids) .in(ShopProduct::getProductId, ids)
.orderByAsc(ShopProduct::getSort)); .orderByAsc(ShopProduct::getSort));
for (ShopProduct shopProduct : shopProductList) { for (ShopProduct shopProduct : shopProductList) {
if (!userVipService.noVip()&&shopProduct.getIsVipPrice()==1){ if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct)); shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
} }
} }

View File

@@ -44,7 +44,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
wrapper.orderByAsc(ShopProductToSociologyMarket::getSort); wrapper.orderByAsc(ShopProductToSociologyMarket::getSort);
Page<ShopProduct> shopProductPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()), ShopProduct.class, wrapper); Page<ShopProduct> shopProductPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()), ShopProduct.class, wrapper);
for (ShopProduct shopProduct:shopProductPage.getRecords()){ for (ShopProduct shopProduct:shopProductPage.getRecords()){
if (shopProduct.getIsVipPrice()==1){ if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct)); shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
} }
} }
@@ -66,7 +66,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
public Map<String, Object> getProductDetail(Integer productId) { public Map<String, Object> getProductDetail(Integer productId) {
ShopProduct product = this.getById(productId); ShopProduct product = this.getById(productId);
HashMap<String, Object> flag = new HashMap<>(); HashMap<String, Object> flag = new HashMap<>();
if (product.getIsVipPrice()==1){ if (userVipService.isVip()&&product.getIsVipPrice()==1){
product.setVipPrice(shopProductService.getVipPrice(product)); product.setVipPrice(shopProductService.getVipPrice(product));
} }
flag.put("detail",product);//基础信息 flag.put("detail",product);//基础信息
@@ -123,7 +123,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
List<ShopProduct> shopProducts = (List)flag.get("GLProducts"); List<ShopProduct> shopProducts = (List)flag.get("GLProducts");
if (shopProducts.size()>0){ if (shopProducts.size()>0){
for (ShopProduct shopProduct : shopProducts) { for (ShopProduct shopProduct : shopProducts) {
if (!userVipService.noVip()&&shopProduct.getIsVipPrice()==1){ if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct)); shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
} }
} }