master:客户优惠去重;
parent
6155ebcccf
commit
9e98311ed4
|
|
@ -423,8 +423,21 @@ public class GtAndTyBiz222222Controller extends BaseController {
|
|||
if (CollectionUtils.isEmpty(tyCusDiscCacheList)) {
|
||||
throw new ServiceException("ty供应商客户优惠列表为空!" + initVO.getUserId(), HttpStatus.ERROR);
|
||||
}
|
||||
// 增加一重保险,客户优惠必须大于0;且必须滤重
|
||||
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
|
||||
Map<String, List<TyCusDiscImportVO>> distinctDiscMap = tyCusDiscCacheList.stream()
|
||||
// 第一重保险:客户优惠必须大于0;且必须滤重
|
||||
.filter(x -> x.getDiscount() > 0).distinct().collect(Collectors
|
||||
.groupingBy(x -> x.getCusName() + x.getProdArtNum() + ":" + x.getColorName()));
|
||||
List<TyCusDiscImportVO> tyCusDiscDistinctCacheList = new ArrayList<>();
|
||||
distinctDiscMap.forEach((k, multiDiscList) -> {
|
||||
// 存在这种错误数据,同一客户:相同颜色及货号 优惠相同 但初始价格及优惠价格不一样 比如:228 213;218 203 但优惠都是15。所以统一处理,取最大优惠
|
||||
if (multiDiscList.size() > 1) {
|
||||
// 获取最大优惠
|
||||
TyCusDiscImportVO maxDisc = multiDiscList.stream().max(Comparator.comparingInt(TyCusDiscImportVO::getDiscount)).get();
|
||||
tyCusDiscDistinctCacheList.add(maxDisc);
|
||||
} else {
|
||||
tyCusDiscDistinctCacheList.addAll(multiDiscList);
|
||||
}
|
||||
});
|
||||
|
||||
// 从redis中获取已存在的商品库存数据
|
||||
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + initVO.getUserId());
|
||||
|
|
@ -435,7 +448,7 @@ public class GtAndTyBiz222222Controller extends BaseController {
|
|||
Map<String, Map<String, TyProdStockVO>> tyProdStockMap = tyStockList.stream().collect(Collectors
|
||||
.groupingBy(TyProdStockVO::getProdArtNum, Collectors.toMap(TyProdStockVO::getColorName, x -> x)));
|
||||
// TY 货号颜色优惠对应关系
|
||||
Map<String, Map<String, List<TyCusDiscImportVO>>> tyCusDiscGroupMap = tyCusDiscCacheList.stream().collect(Collectors
|
||||
Map<String, Map<String, List<TyCusDiscImportVO>>> tyCusDiscGroupMap = tyCusDiscDistinctCacheList.stream().collect(Collectors
|
||||
.groupingBy(TyCusDiscImportVO::getProdArtNum, Collectors.groupingBy(TyCusDiscImportVO::getColorName)));
|
||||
// 步橘系统商品所有颜色maps
|
||||
Map<Long, Map<String, StoreProductColor>> prodColorGroupMap = prodColorList.stream().collect(Collectors
|
||||
|
|
|
|||
|
|
@ -464,8 +464,21 @@ public class GtAndTyBizController extends BaseController {
|
|||
if (CollectionUtils.isEmpty(tyCusDiscCacheList)) {
|
||||
throw new ServiceException("ty供应商客户优惠列表为空!" + initVO.getUserId(), HttpStatus.ERROR);
|
||||
}
|
||||
// 增加一重保险,客户优惠必须大于0;且必须滤重
|
||||
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
|
||||
Map<String, List<TyCusDiscImportVO>> distinctDiscMap = tyCusDiscCacheList.stream()
|
||||
// 第一重保险:客户优惠必须大于0;且必须滤重
|
||||
.filter(x -> x.getDiscount() > 0).distinct().collect(Collectors
|
||||
.groupingBy(x -> x.getCusName() + x.getProdArtNum() + ":" + x.getColorName()));
|
||||
List<TyCusDiscImportVO> tyCusDiscDistinctCacheList = new ArrayList<>();
|
||||
distinctDiscMap.forEach((k, multiDiscList) -> {
|
||||
// 存在这种错误数据,同一客户:相同颜色及货号 优惠相同 但初始价格及优惠价格不一样 比如:228 213;218 203 但优惠都是15。所以统一处理,取最大优惠
|
||||
if (multiDiscList.size() > 1) {
|
||||
// 获取最大优惠
|
||||
TyCusDiscImportVO maxDisc = multiDiscList.stream().max(Comparator.comparingInt(TyCusDiscImportVO::getDiscount)).get();
|
||||
tyCusDiscDistinctCacheList.add(maxDisc);
|
||||
} else {
|
||||
tyCusDiscDistinctCacheList.addAll(multiDiscList);
|
||||
}
|
||||
});
|
||||
|
||||
// 从redis中获取已存在的商品库存数据
|
||||
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + initVO.getUserId());
|
||||
|
|
@ -476,7 +489,7 @@ public class GtAndTyBizController extends BaseController {
|
|||
Map<String, Map<String, TyProdStockVO>> tyProdStockMap = tyStockList.stream().collect(Collectors
|
||||
.groupingBy(TyProdStockVO::getProdArtNum, Collectors.toMap(TyProdStockVO::getColorName, x -> x)));
|
||||
// TY 货号颜色优惠对应关系
|
||||
Map<String, Map<String, List<TyCusDiscImportVO>>> tyCusDiscGroupMap = tyCusDiscCacheList.stream().collect(Collectors
|
||||
Map<String, Map<String, List<TyCusDiscImportVO>>> tyCusDiscGroupMap = tyCusDiscDistinctCacheList.stream().collect(Collectors
|
||||
.groupingBy(TyCusDiscImportVO::getProdArtNum, Collectors.groupingBy(TyCusDiscImportVO::getColorName)));
|
||||
// 步橘系统商品所有颜色maps
|
||||
Map<Long, Map<String, StoreProductColor>> prodColorGroupMap = prodColorList.stream().collect(Collectors
|
||||
|
|
|
|||
|
|
@ -147,7 +147,6 @@ public class TyController extends BaseController {
|
|||
cacheList = Optional.ofNullable(cacheList).orElse(new ArrayList<>());
|
||||
// 前置校验
|
||||
this.cusDiscPrefixFilter(userId, cusName, cacheList);
|
||||
|
||||
// 获取GT所有下架的存货,将该部分存货排除
|
||||
// 先从redis中获取列表数据
|
||||
List<GtProdSkuVO> gtOffSaleList = ObjectUtils.defaultIfNull(redisCache
|
||||
|
|
@ -182,12 +181,21 @@ public class TyController extends BaseController {
|
|||
importList.add(x);
|
||||
}
|
||||
});
|
||||
// 如果同一货号 + 颜色 存在多个优惠,则只取其中之一
|
||||
Map<String, List<TyCusDiscImportVO>> distinctDiscMap = importList.stream().distinct().collect(Collectors.groupingBy(x -> x.getProdArtNum() + ":" + x.getColorName()));
|
||||
List<TyCusDiscImportVO> distinctDiscList = new ArrayList<>();
|
||||
distinctDiscMap.forEach((k, colorDiscList) -> {
|
||||
// 存在这种错误数据,同一客户:相同颜色及货号 优惠相同 但初始价格及优惠价格不一样 比如:228 213;218 203 但优惠都是15。所以统一处理,取最大优惠
|
||||
if (colorDiscList.size() > 1) {
|
||||
// 获取最大优惠
|
||||
TyCusDiscImportVO maxDisc = colorDiscList.stream().max(Comparator.comparingInt(TyCusDiscImportVO::getDiscount)).get();
|
||||
distinctDiscList.add(maxDisc);
|
||||
} else {
|
||||
distinctDiscList.addAll(colorDiscList);
|
||||
}
|
||||
});
|
||||
// 加到总的客户优惠上
|
||||
CollectionUtils.addAll(cacheList, importList);
|
||||
// 如果客户优惠不为空,则滤重
|
||||
if (CollectionUtils.isNotEmpty(cacheList)) {
|
||||
cacheList = cacheList.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
CollectionUtils.addAll(cacheList, distinctDiscList);
|
||||
// TODO 过滤优惠大于0 是在比较插入数据的时候做的
|
||||
// 存到redis中
|
||||
redisCache.setCacheObject(CacheConstants.MIGRATION_TY_CUS_DISCOUNT_KEY + userId, cacheList);
|
||||
|
|
|
|||
|
|
@ -3325,8 +3325,8 @@ CREATE TABLE `store_customer_product_discount`
|
|||
`store_id` bigint UNSIGNED NOT NULL COMMENT '档口ID',
|
||||
`store_prod_id` bigint UNSIGNED NOT NULL COMMENT '档口商品ID',
|
||||
`prod_art_num` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商品货号',
|
||||
`store_cus_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '档口客户名称',
|
||||
`store_cus_id` bigint UNSIGNED NOT NULL COMMENT '档口客户ID',
|
||||
`store_cus_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '档口客户名称',
|
||||
`store_prod_color_id` bigint UNSIGNED NOT NULL COMMENT '档口商品颜色ID',
|
||||
`discount` decimal(10, 2) UNSIGNED NOT NULL COMMENT '优惠金额',
|
||||
`version` bigint UNSIGNED NOT NULL COMMENT '版本号',
|
||||
|
|
|
|||
Loading…
Reference in New Issue