Selaa lähdekoodia

Merge remote-tracking branch 'origin/Joburgess' into Joburgess

周箭河 5 vuotta sitten
vanhempi
commit
846a9be0ef

+ 8 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/GoodsProcurement.java

@@ -49,7 +49,14 @@ public class GoodsProcurement {
 	
 	/**  */
 	private java.util.Date updateTime;
-	
+
+	public GoodsProcurement() {
+	}
+
+	public GoodsProcurement(Integer goodsId) {
+		this.goodsId = goodsId;
+	}
+
 	public void setId(Long id){
 		this.id = id;
 	}

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.dto.GoodsBatchNoDto;
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.GoodsProcurement;
 import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.common.service.BaseService;
 
@@ -85,7 +86,7 @@ public interface GoodsService extends BaseService<Integer, Goods> {
      * @param accountType: 收款账户类型
      * @return java.lang.String
      */
-    List<GoodsBatchNoDto> subtractStock(List<Integer> goodsIds, AccountType accountType);
+    List<GoodsProcurement> subtractStock(List<Integer> goodsIds, AccountType accountType);
 
     /**
      * @describe 增加商品库存

+ 6 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -305,7 +305,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public List<GoodsBatchNoDto> subtractStock(List<Integer> goodsIds, AccountType accountType) {
+	public List<GoodsProcurement> subtractStock(List<Integer> goodsIds, AccountType accountType) {
 		if(CollectionUtils.isEmpty(goodsIds)){
 			return Collections.emptyList();
 		}
@@ -329,7 +329,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		goodsDao.batchUpdate(tempGoodsList);
 		List<Goods> singleGoodsList = goodsDao.getGoodies(singleGoodsIds);
 		Map<Integer, Goods> idSingleGoodsMap = singleGoodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
-		List<GoodsBatchNoDto> goodsBatchNoDtos = new ArrayList<>();
+		List<GoodsProcurement> goodsBatchNoDtos = new ArrayList<>();
 		for (Integer singleGoodsId : singleGoodsIds) {
 			Goods goods = idSingleGoodsMap.get(singleGoodsId);
 			GoodsProcurement goodsProcurement = null;
@@ -351,10 +351,10 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 
 			goodsDao.update(goods);
 			if(Objects.nonNull(goodsProcurement)){
-				goodsBatchNoDtos.add(new GoodsBatchNoDto(goods.getId(), goodsProcurement.getBatchNo()));
+				goodsBatchNoDtos.add(goodsProcurement);
 				goodsProcurementDao.update(goodsProcurement);
 			}else{
-				goodsBatchNoDtos.add(new GoodsBatchNoDto(goods.getId(), goodsProcurement.getBatchNo()));
+				goodsBatchNoDtos.add(new GoodsProcurement(goods.getId()));
 			}
 		}
 
@@ -362,9 +362,10 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void increaseStock(List<GoodsBatchNoDto> goodsBatchNoDtos, List<Integer> goodsIdsList, AccountType accountType) {
 		Set<Integer> goodsIds = goodsBatchNoDtos.stream().map(GoodsBatchNoDto::getGoodsId).collect(Collectors.toSet());
-		List<Goods> goodsList = goodsDao.getGoodies(new ArrayList<>(goodsIds));
+		List<Goods> goodsList = goodsDao.lockGoods(new ArrayList<>(goodsIds));
 		Map<Integer, Goods> idGoodsMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
 		for (GoodsBatchNoDto goodsBatchNoDto : goodsBatchNoDtos) {
 			Goods goods = idGoodsMap.get(goodsBatchNoDto.getGoodsId());