商品的校验
This commit is contained in:
parent
b1ba27aa1e
commit
2830d1d948
|
|
@ -61,12 +61,14 @@ public class TbShopSyncInfoController {
|
||||||
TbShopSyncInfoQueryCriteria criteria = new TbShopSyncInfoQueryCriteria();
|
TbShopSyncInfoQueryCriteria criteria = new TbShopSyncInfoQueryCriteria();
|
||||||
criteria.setPointShopId(tbShopSyncInfo.getPointShopId());
|
criteria.setPointShopId(tbShopSyncInfo.getPointShopId());
|
||||||
TbShopSyncInfo tbShopSyncInfo1 = tbShopSyncInfoService.queryByShopId(criteria);
|
TbShopSyncInfo tbShopSyncInfo1 = tbShopSyncInfoService.queryByShopId(criteria);
|
||||||
long between = DateUtil.between(new Date(), tbShopSyncInfo1.getSyncTime(), DateUnit.HOUR);
|
if(tbShopSyncInfo1 != null){
|
||||||
if(between > 24){
|
long between = DateUtil.between(new Date(), tbShopSyncInfo1.getSyncTime(), DateUnit.HOUR);
|
||||||
throw new RuntimeException("数据同步已超过一天 无法清除");
|
if(between > 24){
|
||||||
|
throw new RuntimeException("数据同步已超过一天 无法清除");
|
||||||
|
}
|
||||||
|
tbShopSyncInfoService.clear(tbShopSyncInfo);
|
||||||
}
|
}
|
||||||
tbShopSyncInfoService.clear(tbShopSyncInfo);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -299,18 +299,21 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
||||||
Map<Integer, Integer> specs, Map<Integer, Integer> cateGorys) {
|
Map<Integer, Integer> specs, Map<Integer, Integer> cateGorys) {
|
||||||
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
||||||
Map<Integer, Integer> proMap = new HashMap<>();
|
Map<Integer, Integer> proMap = new HashMap<>();
|
||||||
productRepository.findByShopId(sourceShopId.toString()).forEach(tbProduct -> {
|
List<TbProduct> products = productRepository.findByShopId(sourceShopId.toString());
|
||||||
Integer sourceSpecId = tbProduct.getId();
|
if(CollectionUtil.isNotEmpty(products)){
|
||||||
tbProduct.setId(null);
|
products.forEach(tbProduct -> {
|
||||||
tbProduct.setShopId(pointShopId.toString());
|
Integer sourceSpecId = tbProduct.getId();
|
||||||
tbProduct.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : "");
|
tbProduct.setId(null);
|
||||||
tbProduct.setSpecId(tbProduct.getSpecId() != null ? specs.get(tbProduct.getSpecId()) : null);
|
tbProduct.setShopId(pointShopId.toString());
|
||||||
tbProduct.setUnitId(tbProduct.getUnitId() != null ? units.get(tbProduct.getUnitId()) : null);
|
tbProduct.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : "");
|
||||||
tbProduct.setStockNumber(0);
|
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);
|
productRepository.save(tbProduct);
|
||||||
proMap.put(sourceSpecId, tbProduct.getId());
|
proMap.put(sourceSpecId, tbProduct.getId());
|
||||||
});
|
});
|
||||||
|
}
|
||||||
future.complete(proMap);
|
future.complete(proMap);
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue