修改vip价格

This commit is contained in:
wuchunlei
2025-03-05 09:17:41 +08:00
parent 3cfcfee825
commit efc893767d
3 changed files with 54 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.*;
import com.peanut.modules.common.service.UserVipService;
import com.peanut.modules.medical.service.ShopProductMedicineLabelService;
import com.peanut.modules.medical.service.ShopProductMedicineMarketService;
import com.peanut.modules.medical.service.ShopProductService;
@@ -12,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@@ -29,6 +32,8 @@ public class MedicalLabelAndMarketController {
private ShopProductMedicineMarketService marketService;
@Autowired
private ShopProductService productService;
@Autowired
private UserVipService userVipService;
/**
* 分类标签树
@@ -62,6 +67,22 @@ public class MedicalLabelAndMarketController {
wrapper.orderByAsc(ShopProductToMedicineMarket::getSort);
Page<ShopProduct> page = productService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
for (ShopProduct shopProduct:page.getRecords()){
//vip价格,不是vip或者活动价更低返回0
if (shopProduct.getIsVipPrice()==1){
BigDecimal b = new BigDecimal(0);
if (userVipService.is456SVip()||userVipService.is78SVip()){
b = shopProduct.getPrice().multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP);
}else if (!userVipService.noVip()){
b = shopProduct.getPrice().multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0))>0
&&b.compareTo(shopProduct.getActivityPrice())>0){
b = new BigDecimal(0);
}
shopProduct.setVipPrice(b);
}
}
return R.ok().put("result", page);
}