fix: 商品列表返回会员价修改

This commit is contained in:
张松
2024-11-07 15:56:26 +08:00
parent 6f75f31e95
commit bc0bcf67a8

View File

@@ -21,6 +21,7 @@ import com.chaozhanggui.system.cashierservice.entity.vo.*;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpShopInfoMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpShopTableMapper;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
@@ -108,6 +109,8 @@ public class ProductService {
@Autowired
private StringRedisTemplate stringRedisTemplate;
private final TbFreeDineConfigService freeDineConfigService;
@Autowired
private MpShopInfoMapper mpShopInfoMapper;
public ProductService(ShopUtils shopUtils, TbFreeDineConfigService freeDineConfigService) {
this.shopUtils = shopUtils;
@@ -224,6 +227,7 @@ public class ProductService {
List<TbProduct> tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId));
concurrentMap.put("hots", handleDate(tbProducts,true,1,false));
List<TbProductGroup> groupList = tbProductGroupMapper.selectByShopId(shopId, id);
TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId);
if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) {
//热销
TbProductGroup hot = new TbProductGroup();
@@ -236,7 +240,7 @@ public class ProductService {
String in = g.getProductIds().substring(1, g.getProductIds().length() - 1);
if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) {
List<TbProduct> products = tbProductMapper.selectByIdInAndCheck(in);
g.setProducts(handleDate(products,false,g.getIsSale(),false));
g.setProducts(handleDate(products,false,g.getIsSale(),false, shopInfo));
} else {
g.setProducts(new ArrayList<>());
}
@@ -450,7 +454,8 @@ public class ProductService {
* @param check 是否校验可售
* @return
*/
public List<TbProduct> handleDate(List<TbProduct> products,boolean check,Integer isSale,boolean isVip){
public List<TbProduct> handleDate(List<TbProduct> products,boolean check,Integer isSale,boolean isVip, TbShopInfo shopInfo){
boolean isMemberPrice = shopInfo.getIsMemberPrice() != null && shopInfo.getIsMemberPrice() == 1;
if (!CollectionUtils.isEmpty(products)) {
products.parallelStream().forEach(it -> {
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
@@ -504,7 +509,7 @@ public class ProductService {
it.setLowPrice(lowerPrice);
// 会员价
if (lowMemberPrice == null) {
if (lowMemberPrice == null || !isMemberPrice) {
lowMemberPrice = BigDecimal.ZERO;
}
it.setLowMemberPrice(lowMemberPrice);