master:数据初始化,客户重复优惠增加过滤及校验;

pull/1121/head
liujiang 2025-11-06 14:16:27 +08:00
parent c71f1036b4
commit da4c8f4e58
8 changed files with 24 additions and 13 deletions

View File

@ -113,6 +113,10 @@ public class FhbController extends BaseController {
List<FhbCusDiscountVO.SMCDRecordVO> cacheList = ObjectUtils.defaultIfNull(redisCache
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId), new ArrayList<>());
CollectionUtils.addAll(cacheList, cusDiscountVO.getData().getRecords());
// 如果cacheList不为空则滤重
if (CollectionUtils.isNotEmpty(cacheList)) {
cacheList = cacheList.stream().distinct().collect(Collectors.toList());
}
// 存到redis中
redisCache.setCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId, cacheList, 5, TimeUnit.DAYS);
return R.ok();
@ -144,7 +148,7 @@ public class FhbController extends BaseController {
*/
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@GetMapping("/error/cus/price/{supplierId}")
public void getErrorCusDisc(HttpServletResponse response, @PathVariable Integer supplierId) throws UnsupportedEncodingException {
public void getErrorCusDisc(HttpServletResponse response, @PathVariable Integer supplierId) throws UnsupportedEncodingException {
// 先从redis中获取列表数据
List<FhbCusDiscountVO.SMCDRecordVO> cacheList = ObjectUtils.defaultIfNull(redisCache
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId), new ArrayList<>());

View File

@ -330,8 +330,9 @@ public class FhbOtherBizAfterController extends BaseController {
if (CollectionUtils.isEmpty(fhbCusDiscCacheList)) {
throw new ServiceException("fhb供应商客户优惠列表为空!" + supplierId, HttpStatus.ERROR);
}
// 增加一重保险客户优惠必须是大于0的
fhbCusDiscCacheList = fhbCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).collect(Collectors.toList());
// 增加一重保险客户优惠必须是大于0的且必须滤重
fhbCusDiscCacheList = fhbCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
List<FhbProdStockVO.SMPSRecordVO> fhbStockCacheList = redisCache
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_STOCK_KEY + supplierId);
if (CollectionUtils.isEmpty(fhbStockCacheList)) {

View File

@ -483,8 +483,9 @@ public class GtAndFhbBizController extends BaseController {
if (CollectionUtils.isEmpty(fhbCusDiscCacheList)) {
throw new ServiceException("fhb供应商客户优惠列表为空!" + initVO.getSupplierId(), HttpStatus.ERROR);
}
// 2025.10.16 增加一重保险客户优惠必须是大于0的
fhbCusDiscCacheList = fhbCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).collect(Collectors.toList());
// 2025.10.16 增加一重保险客户优惠必须是大于0的且必须滤重
fhbCusDiscCacheList = fhbCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
List<FhbProdStockVO.SMPSRecordVO> fhbStockCacheList = redisCache
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_STOCK_KEY + initVO.getSupplierId());
if (CollectionUtils.isEmpty(fhbStockCacheList)) {

View File

@ -393,8 +393,8 @@ public class GtAndTyBiz2Controller extends BaseController {
if (CollectionUtils.isEmpty(tyCusDiscCacheList)) {
throw new ServiceException("ty供应商客户优惠列表为空!" + initVO.getUserId(), HttpStatus.ERROR);
}
// 增加一重保险客户优惠必须大于0
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).collect(Collectors.toList());
// 增加一重保险客户优惠必须大于0;且必须滤重
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
// 从redis中获取已存在的商品库存数据
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + initVO.getUserId());

View File

@ -434,8 +434,8 @@ 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).collect(Collectors.toList());
// 增加一重保险客户优惠必须大于0;且必须滤重
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
// 从redis中获取已存在的商品库存数据
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + initVO.getUserId());

View File

@ -313,8 +313,8 @@ public class TYOtherBizAfterController extends BaseController {
if (CollectionUtils.isEmpty(tyCusDiscCacheList)) {
throw new ServiceException("ty供应商客户优惠列表为空!" + userId, HttpStatus.ERROR);
}
// 增加一重保险客户优惠必须大于0
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).collect(Collectors.toList());
// 增加一重保险客户优惠必须大于0;且必须滤重
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
// 从redis中获取已存在的商品库存数据
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + userId);

View File

@ -138,6 +138,7 @@ public class TyController extends BaseController {
@PostMapping("/cus/disc/cache")
public R<Integer> createCusDiscCache(@RequestParam(value = "userId") Long userId, @RequestParam("compareStr") String compareStr,
MultipartFile file) throws IOException {
// 导入的excel名只取客户名称
final String cusName = file.getOriginalFilename().replaceAll("\\..*$", "").replaceAll("[^\\u4e00-\\u9fa50-9]", "").trim();
ExcelUtil<TyCusDiscImportVO> util = new ExcelUtil<>(TyCusDiscImportVO.class);
List<TyCusDiscImportVO> tyProdVOList = util.importExcel(file.getInputStream());
@ -183,6 +184,10 @@ public class TyController extends BaseController {
});
// 加到总的客户优惠上
CollectionUtils.addAll(cacheList, importList);
// 如果客户优惠不为空,则滤重
if (CollectionUtils.isNotEmpty(cacheList)) {
cacheList = cacheList.stream().distinct().collect(Collectors.toList());
}
// TODO 过滤优惠大于0 是在比较插入数据的时候做的
// 存到redis中
redisCache.setCacheObject(CacheConstants.MIGRATION_TY_CUS_DISCOUNT_KEY + userId, cacheList);

View File

@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spcs.standard,
sp.prod_art_num,
spcs.price,
( SELECT discount FROM store_customer_product_discount WHERE store_cus_id = #{storeCusId} AND store_prod_color_id = spc.id AND del_flag = 0 ) AS discount
( SELECT DISTINCT discount FROM store_customer_product_discount WHERE store_cus_id = #{storeCusId} AND store_prod_color_id = spc.id AND del_flag = 0 ) AS discount
FROM
store_product_color_size spcs
JOIN store_product sp ON spcs.store_prod_id = sp.id
@ -55,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spcs.standard,
sp.prod_art_num,
spcs.price,
( SELECT discount FROM store_customer_product_discount WHERE store_cus_id = #{storeCusId} AND store_prod_color_id = spc.id AND del_flag = 0 ) AS discount
( SELECT DISTINCT discount FROM store_customer_product_discount WHERE store_cus_id = #{storeCusId} AND store_prod_color_id = spc.id AND del_flag = 0 ) AS discount
FROM
store_product_color_size spcs
JOIN store_product sp ON spcs.store_prod_id = sp.id