商品的校验

This commit is contained in:
wangw 2024-11-29 15:09:24 +08:00
parent b1ba27aa1e
commit 2830d1d948
2 changed files with 21 additions and 16 deletions

View File

@ -61,12 +61,14 @@ public class TbShopSyncInfoController {
TbShopSyncInfoQueryCriteria criteria = new TbShopSyncInfoQueryCriteria();
criteria.setPointShopId(tbShopSyncInfo.getPointShopId());
TbShopSyncInfo tbShopSyncInfo1 = tbShopSyncInfoService.queryByShopId(criteria);
long between = DateUtil.between(new Date(), tbShopSyncInfo1.getSyncTime(), DateUnit.HOUR);
if(between > 24){
throw new RuntimeException("数据同步已超过一天 无法清除");
if(tbShopSyncInfo1 != null){
long between = DateUtil.between(new Date(), tbShopSyncInfo1.getSyncTime(), DateUnit.HOUR);
if(between > 24){
throw new RuntimeException("数据同步已超过一天 无法清除");
}
tbShopSyncInfoService.clear(tbShopSyncInfo);
}
tbShopSyncInfoService.clear(tbShopSyncInfo);
return new ResponseEntity<>(HttpStatus.CREATED);
return new ResponseEntity<>(HttpStatus.OK);
}

View File

@ -299,18 +299,21 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
Map<Integer, Integer> specs, Map<Integer, Integer> cateGorys) {
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
Map<Integer, Integer> proMap = new HashMap<>();
productRepository.findByShopId(sourceShopId.toString()).forEach(tbProduct -> {
Integer sourceSpecId = tbProduct.getId();
tbProduct.setId(null);
tbProduct.setShopId(pointShopId.toString());
tbProduct.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : "");
tbProduct.setSpecId(tbProduct.getSpecId() != null ? specs.get(tbProduct.getSpecId()) : null);
tbProduct.setUnitId(tbProduct.getUnitId() != null ? units.get(tbProduct.getUnitId()) : null);
tbProduct.setStockNumber(0);
List<TbProduct> products = productRepository.findByShopId(sourceShopId.toString());
if(CollectionUtil.isNotEmpty(products)){
products.forEach(tbProduct -> {
Integer sourceSpecId = tbProduct.getId();
tbProduct.setId(null);
tbProduct.setShopId(pointShopId.toString());
tbProduct.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : "");
tbProduct.setSpecId(tbProduct.getSpecId() != null ? specs.get(tbProduct.getSpecId()) : null);
tbProduct.setUnitId(tbProduct.getUnitId() != null ? units.get(tbProduct.getUnitId()) : null);
tbProduct.setStockNumber(0);
productRepository.save(tbProduct);
proMap.put(sourceSpecId, tbProduct.getId());
});
productRepository.save(tbProduct);
proMap.put(sourceSpecId, tbProduct.getId());
});
}
future.complete(proMap);
return future;
}