修改vipprice,用户会员类型修改

This commit is contained in:
wuchunlei
2025-03-06 11:13:26 +08:00
parent 7921c8bfa9
commit 1fcde7e350
12 changed files with 148 additions and 86 deletions

View File

@@ -38,6 +38,8 @@ public class BookLabelAndMarketController {
private ShopProductService productService;
@Autowired
private UserVipService userVipService;
@Autowired
private ShopProductService shopProductService;
/**
* 图书标签树
@@ -385,19 +387,9 @@ public class BookLabelAndMarketController {
wrapper.orderByDesc(ShopProduct::getSumSales);
List<Map<String,Object>> list = toLabelService.listMaps(wrapper);
for (Map<String,Object> map:list){
//vip价格,不是vip或者活动价更低返回0
if (map.get("is_vip_price").toString().equals("1")){
BigDecimal b = new BigDecimal(0);
if (userVipService.is456SVip()||userVipService.is78SVip()){
b = ((BigDecimal) map.get("price")).multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP);
}else if (!userVipService.noVip()){
b = ((BigDecimal) map.get("price")).multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
if (((BigDecimal) map.get("activity_price")).compareTo(new BigDecimal(0))>0
&&b.compareTo(((BigDecimal) map.get("activity_price")))>0){
b = new BigDecimal(0);
}
map.put("vip_price",b);
ShopProduct shopProduct = shopProductService.getById(map.get("id").toString());
if (shopProduct.getIsVipPrice()==1){
map.put("vip_price",shopProductService.getVipPrice(shopProduct));
}
}
return R.ok().put("result", list);

View File

@@ -190,23 +190,12 @@ public class BuyOrderController {
public R getShopProductListByIds(@RequestBody Map<String,Object> params){
String[] productIds = params.get("productIds").toString().split(",");
LambdaQueryWrapper<ShopProduct> wrapper = new LambdaQueryWrapper();
wrapper.select(ShopProduct::getProductId,ShopProduct::getProductName,ShopProduct::getProductImages,ShopProduct::getPrice,ShopProduct::getActivityPrice,ShopProduct::getIsVipPrice);
wrapper.select(ShopProduct::getProductId,ShopProduct::getProductName,ShopProduct::getProductImages,ShopProduct::getPrice,ShopProduct::getActivityPrice,ShopProduct::getIsVipPrice,ShopProduct::getGoodsType);
wrapper.in(ShopProduct::getProductId,Arrays.asList(productIds));
List<ShopProduct> shopProductList = shopProductService.list(wrapper);
for (ShopProduct shopProduct:shopProductList){
//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);
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
}
}
return R.ok().put("shopProductList",shopProductList);

View File

@@ -322,19 +322,8 @@ public class ShopProductController {
booklist.add(String.valueOf(bookId));
list.add(byId);
}
//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);
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
}
//添加获取标签逻辑
List<ShopProductToLabelEntity> shopProductToLabelEntities = shopProductToLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductToLabelEntity>()

View File

@@ -464,7 +464,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
List<BuyOrderProduct> buyOrderProducts = buyOrderProductService.getBaseMapper().selectList(new LambdaQueryWrapper<BuyOrderProduct>()
.eq(BuyOrderProduct::getOrderId, b.getOrderId()));
for (BuyOrderProduct bb : buyOrderProducts){
bb.setProduct(shopProductService.getOne(new LambdaQueryWrapper<ShopProduct>().select(ShopProduct::getProductId,ShopProduct::getProductName,ShopProduct::getProductImages,ShopProduct::getPrice,ShopProduct::getActivityPrice,ShopProduct::getIsVipPrice)
bb.setProduct(shopProductService.getOne(new LambdaQueryWrapper<ShopProduct>().select(ShopProduct::getProductId,ShopProduct::getProductName,ShopProduct::getProductImages,ShopProduct::getPrice,ShopProduct::getActivityPrice,ShopProduct::getIsVipPrice,ShopProduct::getGoodsType)
.eq(ShopProduct::getProductId,bb.getProductId())));
UserRecord userRecord = userRecordDao.selectOne(new QueryWrapper<UserRecord>()
.eq("userid", ShiroUtils.getUId())

View File

@@ -82,19 +82,8 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
}
shopCartVo.setActivityPrice(price);
shopCartVo.setIsVipPrice(productEntity.getIsVipPrice());
//vip价格,不是vip或者活动价更低返回0
if (productEntity.getIsVipPrice()==1){
BigDecimal b = new BigDecimal(0);
if (userVipService.is456SVip()||userVipService.is78SVip()){
b = productEntity.getPrice().multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP);
}else if (!userVipService.noVip()){
b = productEntity.getPrice().multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
if (productEntity.getActivityPrice().compareTo(new BigDecimal(0))>0
&&b.compareTo(productEntity.getActivityPrice())>0){
b = new BigDecimal(0);
}
shopCartVo.setVipPrice(b);
shopCartVo.setVipPrice(shopProductService.getVipPrice(productEntity));
}
cartList.add(shopCartVo);
}

View File

@@ -93,6 +93,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
public PageUtils getNewBook(Map<String, Object> params) {
IPage<ShopProduct> page = this.page(
new Query<ShopProduct>().getPage(params),
new QueryWrapper<ShopProduct>().eq("is_new",1).orderByDesc("create_time")
);
return new PageUtils(page);

View File

@@ -2,7 +2,13 @@ package com.peanut.modules.common.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.book.service.BuyOrderProductService;
import com.peanut.modules.book.service.ShopProductService;
import com.peanut.modules.common.entity.BuyOrder;
import com.peanut.modules.common.entity.BuyOrderProduct;
import com.peanut.modules.common.entity.ShopProduct;
import com.peanut.modules.common.entity.TransactionDetailsEntity;
import com.peanut.modules.common.service.BuyOrderService;
import com.peanut.modules.common.service.TransactionDetailsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@@ -24,6 +30,12 @@ public class TransactionDetailsController {
@Autowired
private TransactionDetailsService transactionDetailsService;
@Autowired
private BuyOrderService buyOrderService;
@Autowired
private BuyOrderProductService buyOrderProductService;
@Autowired
private ShopProductService shopProductService;
/**
* 获取付款记录列表
@@ -37,6 +49,29 @@ public class TransactionDetailsController {
}
wrapper.orderByDesc(TransactionDetailsEntity::getCreateTime);
List<TransactionDetailsEntity> list = transactionDetailsService.list(wrapper);
for (TransactionDetailsEntity detail:list){
if ("购买商品".equals(detail.getOrderType())){
String productName = "";
String orderSn = detail.getRemark().substring(8);
BuyOrder buyOrder = buyOrderService.getOne(new LambdaQueryWrapper<BuyOrder>()
.eq(BuyOrder::getOrderSn,orderSn));
if (buyOrder!=null){
List<BuyOrderProduct> products = buyOrderProductService.list(new LambdaQueryWrapper<BuyOrderProduct>()
.eq(BuyOrderProduct::getOrderId,buyOrder.getOrderId()));
for (BuyOrderProduct buyOrderProduct : products) {
ShopProduct shopProduct = shopProductService.getById(buyOrderProduct.getProductId());
if (shopProduct != null){
if (StringUtils.isNotBlank(productName)){
productName += ";"+shopProduct.getProductName();
}else {
productName += shopProduct.getProductName();
}
}
}
}
detail.setProductName(productName);
}
}
return R.ok().put("transactionDetailsList",list);
}

View File

@@ -3,6 +3,7 @@ package com.peanut.modules.common.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.HttpContextUtil;
import com.peanut.common.utils.R;
import com.peanut.common.utils.ShiroUtils;
import com.peanut.config.Constants;
@@ -22,6 +23,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 javax.servlet.http.HttpServletRequest;
import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.util.*;
@@ -64,14 +67,38 @@ public class UserVipController {
List<UserVip> l4 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,4).orderByDesc(UserVip::getEndTime));
List<UserVip> l5 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,5).orderByDesc(UserVip::getEndTime));
List<UserVip> l6 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,6).orderByDesc(UserVip::getEndTime));
if (l4.size()>0&&l5.size()>0&&l6.size()>0&&l4.get(0).getState()==0&&l5.get(0).getState()==0&&l6.get(0).getState()==0){
if (l4.size()>0&&l5.size()>0&&l6.size()>0){
Date t4 = l4.get(0).getEndTime();
Date t5 = l5.get(0).getEndTime();
Date t6 = l6.get(0).getEndTime();
Map map = new HashMap();
map.put("type",1);
map.put("endTime",t4.getTime()<t5.getTime()?(t4.getTime()<t6.getTime()?t4:(t5.getTime()<t6.getTime()?t5:t6)):(t5.getTime()<t6.getTime()?t5:t6));
resList.add(map);
if (t4.getTime()==t5.getTime()&&t5.getTime()==t6.getTime()){
Map map = new HashMap();
map.put("type",1);
map.put("endTime",t4);
resList.add(map);
}else {
List<Map<String,Object>> tempList = new ArrayList();
Map map4 = new HashMap();
map4.put("type",4);
map4.put("endTime",t4);
tempList.add(map4);
Map map5 = new HashMap();
map5.put("type",5);
map5.put("endTime",t5);
tempList.add(map5);
Map map6 = new HashMap();
map6.put("type",6);
map6.put("endTime",t6);
tempList.add(map6);
tempList = tempList.stream().sorted((map1,map2)->{
return Long.compare(((Date)map1.get("endTime")).getTime(),((Date)map2.get("endTime")).getTime());
}).collect(Collectors.toList());
resList.addAll(tempList);
Map map1 = new HashMap();
map1.put("type",1);
map1.put("endTime",tempList.get(0).get("endTime"));
resList.add(map1);
}
}else {
if (l4.size()>0){
Map map = new HashMap();
@@ -90,17 +117,38 @@ public class UserVipController {
map.put("type",6);
map.put("endTime",l6.get(0).getEndTime());
resList.add(map);
}
}
List<UserVip> l7 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,7).orderByDesc(UserVip::getEndTime));
List<UserVip> l8 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,8).orderByDesc(UserVip::getEndTime));
if (l7.size()>0&&l8.size()>0&&l7.get(0).getState()==0&&l8.get(0).getState()==0){
if (l7.size()>0&&l8.size()>0){
Date t7 = l7.get(0).getEndTime();
Date t8 = l8.get(0).getEndTime();
Map map = new HashMap();
map.put("type",2);
map.put("endTime",t7.getTime()<t8.getTime()?t7:t8);
resList.add(map);
if (t7.getTime()==t8.getTime()){
Map map = new HashMap();
map.put("type",2);
map.put("endTime",t7);
resList.add(map);
}else {
List<Map<String,Object>> tempList = new ArrayList();
Map map7 = new HashMap();
map7.put("type",7);
map7.put("endTime",t7);
tempList.add(map7);
Map map8 = new HashMap();
map8.put("type",8);
map8.put("endTime",t8);
tempList.add(map8);
tempList = tempList.stream().sorted((map1,map2)->{
return Long.compare(((Date)map1.get("endTime")).getTime(),((Date)map2.get("endTime")).getTime());
}).collect(Collectors.toList());
resList.addAll(tempList);
Map map2 = new HashMap();
map2.put("type",2);
map2.put("endTime",tempList.get(0).get("endTime"));
resList.add(map2);
}
}else {
if (l7.size()>0){
Map map = new HashMap();
@@ -116,7 +164,7 @@ public class UserVipController {
}
}
resList = resList.stream().sorted((map1,map2)->{
return Long.compare(((Date)map2.get("endTime")).getTime(),((Date)map1.get("endTime")).getTime());
return Long.compare(((Date)map1.get("endTime")).getTime(),((Date)map2.get("endTime")).getTime());
}).collect(Collectors.toList());
return R.ok().put("list", resList);
}
@@ -126,10 +174,18 @@ public class UserVipController {
@RequestMapping("/getVipBuyConfigList")
public R getVipBuyConfigList() {
List<List> ll = new ArrayList<>();
ll.add(Arrays.asList(1));
ll.add(Arrays.asList(4,5,6));
ll.add(Arrays.asList(2));
ll.add(Arrays.asList(7,8));
//根部不同平台返回不同列表
HttpServletRequest request = HttpContextUtil.getHttpServletRequest();
String appType = request.getHeader("appType")==null?"":request.getHeader("appType");
if ("psyche".equals(appType)){
ll.add(Arrays.asList(8,7));
ll.add(Arrays.asList(2));
}else {
ll.add(Arrays.asList(1));
ll.add(Arrays.asList(4,5,6));
ll.add(Arrays.asList(2));
ll.add(Arrays.asList(7,8));
}
List<Map<String,Object>> resList = new ArrayList<>();
for (List l : ll) {
LambdaQueryWrapper<VipBuyConfigEntity> wrapper = new LambdaQueryWrapper();

View File

@@ -59,6 +59,8 @@ public class TransactionDetailsEntity implements Serializable {
private String tel;
private String note;
@TableField(exist = false)
private String productName;
}

View File

@@ -33,7 +33,7 @@ public class MedicalLabelAndMarketController {
@Autowired
private ShopProductService productService;
@Autowired
private UserVipService userVipService;
private com.peanut.modules.book.service.ShopProductService shopProductService;
/**
* 分类标签树
@@ -68,19 +68,8 @@ public class MedicalLabelAndMarketController {
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);
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
}
}
return R.ok().put("result", page);

View File

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.R;
import com.peanut.common.utils.ShiroUtils;
import com.peanut.modules.book.service.ShopProductService;
import com.peanut.modules.common.dao.*;
import com.peanut.modules.common.entity.*;
import com.peanut.modules.common.service.MyUserService;
@@ -27,9 +28,9 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
@Autowired
private UserVipService userVipService;
@Autowired
private CourseToSociologyDao courseToSociologyDao;
private ShopProductService shopProductService;
@Autowired
private CourseToMedicineDao courseToMedicineDao;
private CourseToSociologyDao courseToSociologyDao;
@Autowired
private CourseCatalogueDao courseCatalogueDao;
@Autowired
@@ -45,8 +46,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
@Autowired
private UserCourseStudyingDao studyingDao;
@Autowired
private MyUserDao userDao;
@Autowired
private ShopProductDao shopProductDao;
@Autowired
private UserVipDao userVipDao;
@@ -126,9 +125,14 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
if (StringUtils.isNotEmpty(course.getRelationProductIds())){
String[] ids = course.getRelationProductIds().split(",");
List<ShopProduct> shopProductList = shopProductDao.selectList(new LambdaQueryWrapper<ShopProduct>()
.select(ShopProduct::getProductId,ShopProduct::getProductImages,ShopProduct::getProductName,ShopProduct::getActivityPrice,ShopProduct::getPrice)
.select(ShopProduct::getProductId,ShopProduct::getProductImages,ShopProduct::getProductName,ShopProduct::getActivityPrice,ShopProduct::getPrice,ShopProduct::getIsVipPrice,ShopProduct::getGoodsType)
.in(ShopProduct::getProductId, ids)
.orderByAsc(ShopProduct::getSort));
for (ShopProduct shopProduct : shopProductList) {
if (!userVipService.noVip()&&shopProduct.getIsVipPrice()==1){
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
}
}
flag.put("shopProductList",shopProductList);
}
//目录信息

View File

@@ -9,6 +9,7 @@ import com.peanut.modules.common.dao.ShopProductBookDao;
import com.peanut.modules.common.dao.ShopProductCourseDao;
import com.peanut.modules.common.dao.ShopProductDao;
import com.peanut.modules.common.entity.*;
import com.peanut.modules.common.service.UserVipService;
import com.peanut.modules.common.to.ParamTo;
import com.peanut.modules.sociology.service.ShopProductService;
import lombok.extern.slf4j.Slf4j;
@@ -30,7 +31,9 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
@Autowired
private ShopProductBookDao shopProductBookDao;
@Autowired
private BookDao bookDao;
private UserVipService userVipService;
@Autowired
private com.peanut.modules.book.service.ShopProductService shopProductService;
@Override
public Page getMarketProductList(ParamTo param) {
@@ -58,6 +61,9 @@ 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.noVip()&&product.getIsVipPrice()==1){
product.setVipPrice(shopProductService.getVipPrice(product));
}
flag.put("detail",product);//基础信息
//查询包含的书
MPJLambdaWrapper<ShopProductBookEntity> shopProductBookEntityMPJLambdaWrapper = new MPJLambdaWrapper<>();
@@ -108,6 +114,16 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
List<ShopProduct> shopProducts = this.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProduct>().in(ShopProduct::getProductId, is));
flag.put("GLProducts",shopProducts);
}
if (flag.containsKey("GLProducts")){
List<ShopProduct> shopProducts = (List)flag.get("GLProducts");
if (shopProducts.size()>0){
for (ShopProduct shopProduct : shopProducts) {
if (!userVipService.noVip()&&shopProduct.getIsVipPrice()==1){
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
}
}
}
}
return flag;
}
}