|
|
|
@ -384,15 +384,15 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
purchase.setUpdateBy(user.getId()); |
|
|
|
// 入库时间,约定前台肯定传
|
|
|
|
final Date purchaseTime = purchase.getPurchaseTime(); |
|
|
|
if(purchaseTime == null){ |
|
|
|
if (purchaseTime == null) { |
|
|
|
// 如果前台没有传入库时间,就存当前时间,这里应该不会进入
|
|
|
|
purchase.setPurchaseTime(new Date()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 前台传的是不带时分秒的,如果是今天,那么使用当前时间,否则使用前台传的时间
|
|
|
|
if(DateUtil.isSameDay(new Date(),purchaseTime)){ |
|
|
|
if (DateUtil.isSameDay(new Date(), purchaseTime)) { |
|
|
|
purchase.setCreateTime(new Date()); |
|
|
|
purchase.setPurchaseTime(new Date()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 因为现在对账单或者是列表排序等都是根据creTime去排序和展示的,所以这里createTime 为入库时间,前台传,PurchaseTime为入库单创建时间
|
|
|
|
purchase.setCreateTime(purchaseTime); |
|
|
|
purchase.setPurchaseTime(new Date()); |
|
|
|
@ -596,7 +596,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
for (Stock stock : stockList) { |
|
|
|
|
|
|
|
final Product product = productMap.get(stock.getProductId()); |
|
|
|
if(!productMap.containsKey(stock.getProductId())){ |
|
|
|
if (!productMap.containsKey(stock.getProductId())) { |
|
|
|
// 如果没有商品信息那么就进行下一个循环,暂时不计算该商品的采购价及其他信息
|
|
|
|
continue; |
|
|
|
} |
|
|
|
@ -657,23 +657,23 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
stockPageQuery.setShopId(shopId); |
|
|
|
final List<Stock> records = stockMapper.getTailWarnProduct(stockPageQuery); |
|
|
|
// final List<Stock> records = result.getRecords();
|
|
|
|
final Map<String,StockProductVo> stringStockProductVoMap = new HashMap<>(); |
|
|
|
final Map<String, StockProductVo> stringStockProductVoMap = new HashMap<>(); |
|
|
|
for (Stock record : records) { |
|
|
|
final String productId = record.getProductId(); |
|
|
|
final Integer stockCount = record.getStockCount(); |
|
|
|
final Integer productStockCount = record.getStockCount() < 0?0:record.getStockCount(); |
|
|
|
final Integer productStockCount = record.getStockCount() < 0 ? 0 : record.getStockCount(); |
|
|
|
|
|
|
|
//存在,增加规格信息
|
|
|
|
final StockAttributeVo stockAttributeVo = new StockAttributeVo(); |
|
|
|
stockAttributeVo.setAttributeList(record.getAttributeList()); |
|
|
|
stockAttributeVo.setStockCount(stockCount); |
|
|
|
if(stringStockProductVoMap.containsKey(productId)){ |
|
|
|
if (stringStockProductVoMap.containsKey(productId)) { |
|
|
|
final Integer count = stringStockProductVoMap.get(productId).getStockCount(); |
|
|
|
// 计算商品的总库存
|
|
|
|
stringStockProductVoMap.get(productId).setStockCount(count+productStockCount); |
|
|
|
stringStockProductVoMap.get(productId).setStockCount(count + productStockCount); |
|
|
|
// 增加规格信息
|
|
|
|
stringStockProductVoMap.get(productId).getStockAttributeVoList().add(stockAttributeVo); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 不存在,先增加商品信息
|
|
|
|
final StockProductVo stockProductVo = new StockProductVo(); |
|
|
|
stockProductVo.setProductName(record.getProductName()); |
|
|
|
@ -686,7 +686,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
final List<StockAttributeVo> stockAttributeVoList = new ArrayList<>(); |
|
|
|
stockAttributeVoList.add(stockAttributeVo); |
|
|
|
stockProductVo.setStockAttributeVoList(stockAttributeVoList); |
|
|
|
stringStockProductVoMap.put(productId,stockProductVo); |
|
|
|
stringStockProductVoMap.put(productId, stockProductVo); |
|
|
|
} |
|
|
|
} |
|
|
|
final List<StockProductVo> stockProductVos = new ArrayList<>(stringStockProductVoMap.values()); |
|
|
|
@ -708,18 +708,18 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
purchase.setShopId(shopId); |
|
|
|
// 入库时间,约定前台肯定传
|
|
|
|
Date purchaseTime = purchase.getPurchaseTime(); |
|
|
|
log.debug("入库时间前台传的是==="+DateUtil.COMMON_FULL.getDateText(purchaseTime)); |
|
|
|
if(purchaseTime == null){ |
|
|
|
log.debug("入库时间前台传的是===" + DateUtil.COMMON_FULL.getDateText(purchaseTime)); |
|
|
|
if (purchaseTime == null) { |
|
|
|
// 如果前台没有传入库时间,就存当前时间,这里应该不会进入
|
|
|
|
purchase.setPurchaseTime(new Date()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 前台传的是不带时分秒的,如果是今天,那么使用当前时间,否则使用前台传的时间
|
|
|
|
log.debug("是否是同一天==="+DateUtil.COMMON_FULL.getDateText(purchaseTime)+"===="+DateUtil.COMMON_FULL.getDateText(new Date())+"====="+DateUtil.isSameDay(new Date(),purchaseTime)); |
|
|
|
if(DateUtil.isSameDay(new Date(),purchaseTime)){ |
|
|
|
log.debug("是否是同一天===" + DateUtil.COMMON_FULL.getDateText(purchaseTime) + "====" + DateUtil.COMMON_FULL.getDateText(new Date()) + "=====" + DateUtil.isSameDay(new Date(), purchaseTime)); |
|
|
|
if (DateUtil.isSameDay(new Date(), purchaseTime)) { |
|
|
|
purchase.setCreateTime(new Date()); |
|
|
|
purchase.setPurchaseTime(new Date()); |
|
|
|
purchaseTime = new Date(); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 因为现在对账单或者是列表排序等都是根据creTime去排序和展示的,所以这里createTime 为入库时间,前台传,PurchaseTime为入库单创建时间
|
|
|
|
purchase.setCreateTime(purchaseTime); |
|
|
|
purchase.setPurchaseTime(new Date()); |
|
|
|
@ -729,10 +729,10 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
// 语音入库没有入库id
|
|
|
|
String purchaseId = purchase.getId(); |
|
|
|
boolean insertFlag = true; |
|
|
|
if (StringUtils.isEmpty(purchaseId)){ |
|
|
|
if (StringUtils.isEmpty(purchaseId)) { |
|
|
|
purchaseId = SnowFlakeUtil.nextId().toString(); |
|
|
|
purchase.setId(purchaseId); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
insertFlag = false; |
|
|
|
} |
|
|
|
|
|
|
|
@ -758,7 +758,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
productCategoryVo.setShopId("spfl"); |
|
|
|
// 需要新增的
|
|
|
|
final Map<String, List<String>> attributeValueMap = new HashMap<>(); |
|
|
|
if(StringUtils.isEmpty(productId)){ |
|
|
|
if (StringUtils.isEmpty(productId)) { |
|
|
|
// 新增商品
|
|
|
|
final Product product = new Product(); |
|
|
|
product.setCreateBy(user.getId()); |
|
|
|
@ -792,7 +792,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
// 填充前台传过来的数据
|
|
|
|
purchaseDetail.setProductId(product.getId()); |
|
|
|
// 新增商品图片子图
|
|
|
|
if(purchaseDetail.getProductPictures() != null ){ |
|
|
|
if (purchaseDetail.getProductPictures() != null) { |
|
|
|
for (ProductPicture productPicture : purchaseDetail.getProductPictures()) { |
|
|
|
productPicture.setProductId(product.getId()); |
|
|
|
} |
|
|
|
@ -856,14 +856,14 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
// productCategoryService.batchSaveCategoryOfShop(productCategoryVo);
|
|
|
|
product.setAttrId(s); |
|
|
|
|
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 旧商品,更新批发价和零售价
|
|
|
|
productIdList.add(productId); |
|
|
|
} |
|
|
|
} |
|
|
|
// todo 在这里批量新增一下,下边的查询能查询到么?
|
|
|
|
productService.saveBatch(addProductList); |
|
|
|
if(!addProductPictureList.isEmpty()){ |
|
|
|
if (!addProductPictureList.isEmpty()) { |
|
|
|
productPictureService.batchSaveProductPicture(addProductPictureList); |
|
|
|
} |
|
|
|
|
|
|
|
@ -876,7 +876,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
} |
|
|
|
// 获取需要新增的规格及属性集合
|
|
|
|
// 获取需要新增的规格信息
|
|
|
|
final Map<String,Map<String,List<String>>> stringListMap = new HashMap<>(); |
|
|
|
final Map<String, Map<String, List<String>>> stringListMap = new HashMap<>(); |
|
|
|
for (PurchaseDetail purchaseDetail : purchaseDetails) { |
|
|
|
// 获取商品信息
|
|
|
|
final Product product = productMap.get(purchaseDetail.getProductId()); |
|
|
|
@ -884,7 +884,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
purchaseDetail.setShopId(shopId); |
|
|
|
purchaseDetail.setPurchaseId(purchaseId); |
|
|
|
// 设置一些商品信息
|
|
|
|
purchaseDetail.setProductName(product.getProductName()); |
|
|
|
// purchaseDetail.setProductName(product.getProductName());
|
|
|
|
purchaseDetail.setUnit(product.getUnit()); |
|
|
|
purchaseDetail.setCategoryId(product.getCategoryId()); |
|
|
|
purchaseDetail.setAttrId(product.getAttrId()); |
|
|
|
@ -960,6 +960,8 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
product.setWholesalePrice(purchaseDetail.getWholesalePrice()); |
|
|
|
// 更新商品的图片
|
|
|
|
product.setProductPicture(purchaseDetail.getProductPicture()); |
|
|
|
// 更新商品的名称
|
|
|
|
product.setProductName(purchaseDetail.getProductName()); |
|
|
|
updateProductList.add(product); |
|
|
|
|
|
|
|
// 先计算平均采购价、再更新库存数,否则会有问题。
|
|
|
|
@ -1056,24 +1058,24 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
} else { |
|
|
|
// 暂不支持其他规格
|
|
|
|
} |
|
|
|
if(stringListMap.containsKey(attrId)){ |
|
|
|
if (stringListMap.containsKey(attrId)) { |
|
|
|
final Map<String, List<String>> stringListMap1 = stringListMap.get(attrId); |
|
|
|
if(stringListMap1.containsKey(key)){ |
|
|
|
if (stringListMap1.containsKey(key)) { |
|
|
|
final List<String> stringList = stringListMap1.get(key); |
|
|
|
if(!stringList.contains(value)){ |
|
|
|
if (!stringList.contains(value)) { |
|
|
|
stringList.add(value); |
|
|
|
} |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
final List<String> stringList = new ArrayList<>(); |
|
|
|
stringList.add(value); |
|
|
|
stringListMap1.put(key, stringList); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
final Map<String,List<String>> attributeListMap = new HashMap<>(); |
|
|
|
} else { |
|
|
|
final Map<String, List<String>> attributeListMap = new HashMap<>(); |
|
|
|
final List<String> stringList = new ArrayList<>(); |
|
|
|
stringList.add(value); |
|
|
|
attributeListMap.put(key,stringList); |
|
|
|
stringListMap.put(attrId,attributeListMap); |
|
|
|
attributeListMap.put(key, stringList); |
|
|
|
stringListMap.put(attrId, attributeListMap); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1111,9 +1113,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
} |
|
|
|
} |
|
|
|
productCategoryVo.setProductAttributeOfAddVos(productAttributeOfAddVos); |
|
|
|
productCategoryService.batchSaveCategoryAndAttributeOfAi(productCategoryAiVos); |
|
|
|
productCategoryService.batchSaveCategoryAndAttributeOfAi(productCategoryAiVos); |
|
|
|
// 更新店铺分类库
|
|
|
|
productCategoryService.batchSaveCategoryOfShop(productCategoryVo); |
|
|
|
productCategoryService.batchSaveCategoryOfShop(productCategoryVo); |
|
|
|
|
|
|
|
// 更新那些未入库就进行销售销售详情、库存履历、库存表的采购价
|
|
|
|
saleDetailService.putInUpdatePurchasePrice(purchaseDetails); |
|
|
|
@ -1121,13 +1123,13 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
//3.登记采购单主表和采购单明细表
|
|
|
|
// log.debug("保存前的入库时间==="+DateUtil.COMMON_FULL.getDateText(purchase.getCreateTime())+"===="+DateUtil.COMMON_FULL.getDateText(purchase.getPurchaseTime()));
|
|
|
|
final boolean saveOrUpdateFlag; |
|
|
|
if(insertFlag){ |
|
|
|
if (insertFlag) { |
|
|
|
saveOrUpdateFlag = purchaseService.insert(purchase); |
|
|
|
// 不知道为什么保存不上creTime,这里再更新下两个时间
|
|
|
|
purchase.setCreateTime(purchaseTime); |
|
|
|
purchase.setPurchaseTime(new Date()); |
|
|
|
purchaseService.updateById(purchase); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
saveOrUpdateFlag = purchaseService.updateById(purchase); |
|
|
|
} |
|
|
|
if (saveOrUpdateFlag) { |
|
|
|
@ -1162,7 +1164,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
|
|
|
|
@Override |
|
|
|
public Stock getByProductIdAndAttributeList(String productId, String attributeList) { |
|
|
|
return stockMapper.getByProductIdAndAttributeList(productId,attributeList); |
|
|
|
return stockMapper.getByProductIdAndAttributeList(productId, attributeList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -1186,4 +1188,16 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements |
|
|
|
public List<Stock> getDefaultStockCount(List<String> productIdList) { |
|
|
|
return stockMapper.getDefaultStockCount(productIdList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除库存(真删除) |
|
|
|
* |
|
|
|
* @param id |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/8/8 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void deleteStockById(String id) { |
|
|
|
stockMapper.deleteById(id); |
|
|
|
} |
|
|
|
} |
|
|
|
|