master:数据初始化,客户重复优惠增加过滤及校验;
parent
c71f1036b4
commit
da4c8f4e58
|
|
@ -113,6 +113,10 @@ public class FhbController extends BaseController {
|
||||||
List<FhbCusDiscountVO.SMCDRecordVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
List<FhbCusDiscountVO.SMCDRecordVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
||||||
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId), new ArrayList<>());
|
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId), new ArrayList<>());
|
||||||
CollectionUtils.addAll(cacheList, cusDiscountVO.getData().getRecords());
|
CollectionUtils.addAll(cacheList, cusDiscountVO.getData().getRecords());
|
||||||
|
// 如果cacheList不为空,则滤重
|
||||||
|
if (CollectionUtils.isNotEmpty(cacheList)) {
|
||||||
|
cacheList = cacheList.stream().distinct().collect(Collectors.toList());
|
||||||
|
}
|
||||||
// 存到redis中
|
// 存到redis中
|
||||||
redisCache.setCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId, cacheList, 5, TimeUnit.DAYS);
|
redisCache.setCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId, cacheList, 5, TimeUnit.DAYS);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|
@ -144,7 +148,7 @@ public class FhbController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||||
@GetMapping("/error/cus/price/{supplierId}")
|
@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中获取列表数据
|
// 先从redis中获取列表数据
|
||||||
List<FhbCusDiscountVO.SMCDRecordVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
List<FhbCusDiscountVO.SMCDRecordVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
||||||
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId), new ArrayList<>());
|
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId), new ArrayList<>());
|
||||||
|
|
|
||||||
|
|
@ -330,8 +330,9 @@ public class FhbOtherBizAfterController extends BaseController {
|
||||||
if (CollectionUtils.isEmpty(fhbCusDiscCacheList)) {
|
if (CollectionUtils.isEmpty(fhbCusDiscCacheList)) {
|
||||||
throw new ServiceException("fhb供应商客户优惠列表为空!" + supplierId, HttpStatus.ERROR);
|
throw new ServiceException("fhb供应商客户优惠列表为空!" + supplierId, HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
// 增加一重保险,客户优惠必须是大于0的
|
// 增加一重保险,客户优惠必须是大于0的;且必须滤重
|
||||||
fhbCusDiscCacheList = fhbCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).collect(Collectors.toList());
|
fhbCusDiscCacheList = fhbCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
List<FhbProdStockVO.SMPSRecordVO> fhbStockCacheList = redisCache
|
List<FhbProdStockVO.SMPSRecordVO> fhbStockCacheList = redisCache
|
||||||
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_STOCK_KEY + supplierId);
|
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_STOCK_KEY + supplierId);
|
||||||
if (CollectionUtils.isEmpty(fhbStockCacheList)) {
|
if (CollectionUtils.isEmpty(fhbStockCacheList)) {
|
||||||
|
|
|
||||||
|
|
@ -483,8 +483,9 @@ public class GtAndFhbBizController extends BaseController {
|
||||||
if (CollectionUtils.isEmpty(fhbCusDiscCacheList)) {
|
if (CollectionUtils.isEmpty(fhbCusDiscCacheList)) {
|
||||||
throw new ServiceException("fhb供应商客户优惠列表为空!" + initVO.getSupplierId(), HttpStatus.ERROR);
|
throw new ServiceException("fhb供应商客户优惠列表为空!" + initVO.getSupplierId(), HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
// 2025.10.16 增加一重保险,客户优惠必须是大于0的
|
// 2025.10.16 增加一重保险,客户优惠必须是大于0的;且必须滤重
|
||||||
fhbCusDiscCacheList = fhbCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).collect(Collectors.toList());
|
fhbCusDiscCacheList = fhbCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
List<FhbProdStockVO.SMPSRecordVO> fhbStockCacheList = redisCache
|
List<FhbProdStockVO.SMPSRecordVO> fhbStockCacheList = redisCache
|
||||||
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_STOCK_KEY + initVO.getSupplierId());
|
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_STOCK_KEY + initVO.getSupplierId());
|
||||||
if (CollectionUtils.isEmpty(fhbStockCacheList)) {
|
if (CollectionUtils.isEmpty(fhbStockCacheList)) {
|
||||||
|
|
|
||||||
|
|
@ -393,8 +393,8 @@ public class GtAndTyBiz2Controller extends BaseController {
|
||||||
if (CollectionUtils.isEmpty(tyCusDiscCacheList)) {
|
if (CollectionUtils.isEmpty(tyCusDiscCacheList)) {
|
||||||
throw new ServiceException("ty供应商客户优惠列表为空!" + initVO.getUserId(), HttpStatus.ERROR);
|
throw new ServiceException("ty供应商客户优惠列表为空!" + initVO.getUserId(), HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
// 增加一重保险,客户优惠必须大于0
|
// 增加一重保险,客户优惠必须大于0;且必须滤重
|
||||||
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).collect(Collectors.toList());
|
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
// 从redis中获取已存在的商品库存数据
|
// 从redis中获取已存在的商品库存数据
|
||||||
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + initVO.getUserId());
|
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + initVO.getUserId());
|
||||||
|
|
|
||||||
|
|
@ -434,8 +434,8 @@ public class GtAndTyBizController extends BaseController {
|
||||||
if (CollectionUtils.isEmpty(tyCusDiscCacheList)) {
|
if (CollectionUtils.isEmpty(tyCusDiscCacheList)) {
|
||||||
throw new ServiceException("ty供应商客户优惠列表为空!" + initVO.getUserId(), HttpStatus.ERROR);
|
throw new ServiceException("ty供应商客户优惠列表为空!" + initVO.getUserId(), HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
// 增加一重保险,客户优惠必须大于0
|
// 增加一重保险,客户优惠必须大于0;且必须滤重
|
||||||
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).collect(Collectors.toList());
|
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
// 从redis中获取已存在的商品库存数据
|
// 从redis中获取已存在的商品库存数据
|
||||||
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + initVO.getUserId());
|
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + initVO.getUserId());
|
||||||
|
|
|
||||||
|
|
@ -313,8 +313,8 @@ public class TYOtherBizAfterController extends BaseController {
|
||||||
if (CollectionUtils.isEmpty(tyCusDiscCacheList)) {
|
if (CollectionUtils.isEmpty(tyCusDiscCacheList)) {
|
||||||
throw new ServiceException("ty供应商客户优惠列表为空!" + userId, HttpStatus.ERROR);
|
throw new ServiceException("ty供应商客户优惠列表为空!" + userId, HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
// 增加一重保险,客户优惠必须大于0
|
// 增加一重保险,客户优惠必须大于0;且必须滤重
|
||||||
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).collect(Collectors.toList());
|
tyCusDiscCacheList = tyCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
// 从redis中获取已存在的商品库存数据
|
// 从redis中获取已存在的商品库存数据
|
||||||
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + userId);
|
List<TyProdStockVO> tyStockList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_PROD_STOCK_KEY + userId);
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,7 @@ public class TyController extends BaseController {
|
||||||
@PostMapping("/cus/disc/cache")
|
@PostMapping("/cus/disc/cache")
|
||||||
public R<Integer> createCusDiscCache(@RequestParam(value = "userId") Long userId, @RequestParam("compareStr") String compareStr,
|
public R<Integer> createCusDiscCache(@RequestParam(value = "userId") Long userId, @RequestParam("compareStr") String compareStr,
|
||||||
MultipartFile file) throws IOException {
|
MultipartFile file) throws IOException {
|
||||||
|
// 导入的excel名,只取客户名称
|
||||||
final String cusName = file.getOriginalFilename().replaceAll("\\..*$", "").replaceAll("[^\\u4e00-\\u9fa50-9]", "").trim();
|
final String cusName = file.getOriginalFilename().replaceAll("\\..*$", "").replaceAll("[^\\u4e00-\\u9fa50-9]", "").trim();
|
||||||
ExcelUtil<TyCusDiscImportVO> util = new ExcelUtil<>(TyCusDiscImportVO.class);
|
ExcelUtil<TyCusDiscImportVO> util = new ExcelUtil<>(TyCusDiscImportVO.class);
|
||||||
List<TyCusDiscImportVO> tyProdVOList = util.importExcel(file.getInputStream());
|
List<TyCusDiscImportVO> tyProdVOList = util.importExcel(file.getInputStream());
|
||||||
|
|
@ -183,6 +184,10 @@ public class TyController extends BaseController {
|
||||||
});
|
});
|
||||||
// 加到总的客户优惠上
|
// 加到总的客户优惠上
|
||||||
CollectionUtils.addAll(cacheList, importList);
|
CollectionUtils.addAll(cacheList, importList);
|
||||||
|
// 如果客户优惠不为空,则滤重
|
||||||
|
if (CollectionUtils.isNotEmpty(cacheList)) {
|
||||||
|
cacheList = cacheList.stream().distinct().collect(Collectors.toList());
|
||||||
|
}
|
||||||
// TODO 过滤优惠大于0 是在比较插入数据的时候做的
|
// TODO 过滤优惠大于0 是在比较插入数据的时候做的
|
||||||
// 存到redis中
|
// 存到redis中
|
||||||
redisCache.setCacheObject(CacheConstants.MIGRATION_TY_CUS_DISCOUNT_KEY + userId, cacheList);
|
redisCache.setCacheObject(CacheConstants.MIGRATION_TY_CUS_DISCOUNT_KEY + userId, cacheList);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
spcs.standard,
|
spcs.standard,
|
||||||
sp.prod_art_num,
|
sp.prod_art_num,
|
||||||
spcs.price,
|
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
|
FROM
|
||||||
store_product_color_size spcs
|
store_product_color_size spcs
|
||||||
JOIN store_product sp ON spcs.store_prod_id = sp.id
|
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,
|
spcs.standard,
|
||||||
sp.prod_art_num,
|
sp.prod_art_num,
|
||||||
spcs.price,
|
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
|
FROM
|
||||||
store_product_color_size spcs
|
store_product_color_size spcs
|
||||||
JOIN store_product sp ON spcs.store_prod_id = sp.id
|
JOIN store_product sp ON spcs.store_prod_id = sp.id
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue