瀏覽代碼

feat:乐团费用改造

Joburgess 4 年之前
父節點
當前提交
ea3f872a1f

+ 0 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsCategoryService.java

@@ -29,6 +29,4 @@ public interface GoodsCategoryService extends BaseService<Integer, GoodsCategory
      * @param goodsIds
      */
     void updateSubjectGoods(Long subjectGoodsMapperId, String goodsIds);
-
-    void goodsTest(List<Integer> goodsIds);
 }

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

@@ -118,6 +118,4 @@ public interface GoodsService extends BaseService<Integer, Goods> {
      * @return java.util.List<com.ym.mec.biz.dal.dto.GoodsSellDto>
      */
     List<GoodsSellDto> queryGoodsSellDtos(String goodsId);
-
-    void getGoodsTest(List<Integer> goodsIds);
 }

+ 0 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsCategoryServiceImpl.java

@@ -85,17 +85,4 @@ public class GoodsCategoryServiceImpl extends BaseServiceImpl<Integer, GoodsCate
 		subjectGoodsMapper.setUpdateTime(new Date());
 		subjectGoodsMapperDao.update(subjectGoodsMapper);
 	}
-
-	@Autowired
-	private GoodsService goodsService;
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public void goodsTest(List<Integer> goodsIds) {
-		goodsTest1(goodsIds);
-	}
-
-	public void goodsTest1(List<Integer> goodsIds) {
-		goodsService.subtractStock(goodsIds, AccountType.INTERNAL);
-	}
 }

+ 3 - 50
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
@@ -464,55 +465,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	}
 
 	@Override
-	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public void getGoodsTest(List<Integer> goodsIds) {
-		List<Goods> tempGoodsList = goodsDao.lockGoods(new ArrayList<>(goodsIds));
-		Map<Integer, Goods> idTempGoodsMap = tempGoodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
-		List<GoodsProcurement> goodsProcurements = new ArrayList<>();
-		for (Integer goodsId : goodsIds) {
-			Goods tempGoods = goodsDao.get(goodsId);
-			List<Goods> childGoods = new ArrayList<>();
-			if(StringUtils.isBlank(tempGoods.getComplementGoodsIdList())){
-				childGoods.add(tempGoods);
-			}else{
-				List<Integer> complementGoodsIds = Arrays.stream(tempGoods.getComplementGoodsIdList().split(",")).map(s -> Integer.valueOf(s)).collect(Collectors.toList());
-				childGoods = goodsDao.lockGoods(complementGoodsIds);
-			}
-			for (Goods goods : childGoods) {
-				GoodsProcurement goodsProcurement = null;
-				if(StockType.INTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.INTERNAL.equals(AccountType.INTERNAL))){
-					goodsProcurement = goodsProcurementDao.getWithStockSurplusProcurement(goods.getId());
-					goods.setStockCount(new AtomicInteger(goods.getStockCount()).decrementAndGet());
-					if(Objects.nonNull(goodsProcurement)){
-						goodsProcurement.setStockSoldNum(new AtomicInteger(goodsProcurement.getStockSoldNum()).incrementAndGet());
-					}
-				}else if(StockType.EXTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.EXTERNAL.equals(AccountType.EXTERNAL))){
-					goodsProcurement = goodsProcurementDao.getWithTaxStockSurplusProcurement(goods.getId());
-					goods.setTaxStockCount(new AtomicInteger(goods.getTaxStockCount()).decrementAndGet());
-					if(Objects.nonNull(goodsProcurement)){
-						goodsProcurement.setTaxStockSoldNum(new AtomicInteger(goodsProcurement.getTaxStockSoldNum()).incrementAndGet());
-					}
-				}
-
-				goods.setSellCount(new AtomicInteger(goods.getSellCount()).incrementAndGet());
-
-				goodsDao.update(goods);
-				if(Objects.nonNull(goodsProcurement)){
-					goodsProcurementDao.update(goodsProcurement);
-				}else{
-					goodsProcurement = new GoodsProcurement(goods.getId());
-				}
-				if(StringUtils.isNotBlank(tempGoods.getComplementGoodsIdList())){
-					goodsProcurement.setParentGoodsId(tempGoods.getId());
-				}
-
-				goodsProcurements.add(goodsProcurement);
-			}
-		}
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+	@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
 	public List<SellOrder> subtractStock(List<Integer> goodsIds, AccountType accountType) {
 		if(CollectionUtils.isEmpty(goodsIds)){
 			return Collections.emptyList();
@@ -522,7 +475,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		Map<Integer, Goods> idTempGoodsMap = tempGoodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
 		List<GoodsProcurement> goodsProcurements = new ArrayList<>();
 		for (Integer goodsId : goodsIds) {
-			Goods tempGoods = idTempGoodsMap.get(goodsId);
+			Goods tempGoods = goodsDao.get(goodsId);
 			List<Goods> childGoods = new ArrayList<>();
 			if(StringUtils.isBlank(tempGoods.getComplementGoodsIdList())){
 				childGoods.add(tempGoods);

+ 0 - 8
mec-web/src/main/java/com/ym/mec/web/controller/GoodsController.java

@@ -121,12 +121,4 @@ public class GoodsController extends BaseController {
     public Object findGoodsBySubId(Integer subjectId,String type){
         return succeed(goodsService.findGoodsBySubId(subjectId,type));
     }
-
-    @GetMapping("getGoodsTest")
-    public HttpResponseResult getGoodsTest(Integer goodsId){
-//        goodsService.getGoodsTest(Arrays.asList(goodsId));
-//        goodsService.subtractStock(Arrays.asList(goodsId), AccountType.INTERNAL);
-        goodsCategoryService.goodsTest(Arrays.asList(goodsId));
-        return succeed();
-    }
 }