Jelajahi Sumber

處理批量上架的問題

yuj 7 tahun lalu
induk
melakukan
ad47d08bb6

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/model/ReleaseProductByBatch.java

@@ -701,7 +701,7 @@ public class ReleaseProductByBatch implements Serializable {
 	public void setReserveByExcel(Object value) {
 		setReserveStr(StringUtilB2C.getStr(value));
 		if (StringUtils.isEmpty(value) || !RegexConstant.isNumber(value.toString())) {
-			setReserve(DoubleConstant.zero);
+			addErrmsg(ErrorInfoConstant.RESERVE_NUMBER_INFO.getInfo());
 		} else {
 			Double reserve = Double.valueOf(value.toString());
 			if (reserve % 1 != 0) {

+ 25 - 17
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -257,8 +257,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 						releaseProductByBatch.setReleaseCode(ReleaseStatus.lack_info.value());
 						releaseProductByBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
 					}
-					// 简单验证数据,防止空行保存的情况(品牌、类目、型号)
-					if (blankNum != 3) {
+					// 简单验证数据,防止空行保存的情况(品牌、类目、型号、庫存信息)
+					if (blankNum != 4) {
 						total++;
 						releaseProductByBatchs.add(releaseProductByBatch);
 					}
@@ -1210,6 +1210,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			Object reserveValue = readWorkBookCell(row.getCell(UploadConstant.RESERVE_NUMBER), Cell.CELL_TYPE_STRING,
 					rowNum, UploadConstant.RESERVE_NUMBER);
 			aProduct.setReserveByExcel(reserveValue);
+			if (StringUtils.isEmpty(reserveValue)) {
+				result += 1;
+			}
 
 			Object costPrice = readWorkBookCell(row.getCell(UploadConstant.COST_PRICE), Cell.CELL_TYPE_STRING,
 					rowNum, UploadConstant.COST_PRICE);
@@ -1341,7 +1344,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		}
 		aProduct.setFragmentPrice(StringUtilB2C.getStr(firstValue), 0);
 		if (StringUtils.isEmpty(firstValue)) {
-			aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
+			//aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
 		} else {
 			if (RegexConstant.isNumber(firstValue.toString())) {
 				Double cellPrice = Double.valueOf(firstValue.toString());
@@ -1353,7 +1356,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 					aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
 				}
 			} else {
-				aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
+				//aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
 			}
 
 		}
@@ -1431,7 +1434,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				Double price = Double.valueOf(priceValue.toString());
 				Double start = Double.valueOf(startValue.toString());
 				if (validatePrice(price) && validateStartNumber(start, aProduct.getMinBuyQty())) {
-					GoodsQtyPrice qtyPrice = getOneQtyPrice(Double.valueOf(startValue.toString()), DoubleConstant.maxMinPackageQty,
+					GoodsQtyPrice qtyPrice = getOneQtyPrice(Double.valueOf(startValue.toString()), DoubleConstant.maxReserve,
 							price, aProduct.getRmbTaxRate(), aProduct.getCurrency());
 					qtyPriceList.add(qtyPrice);
 					qtyPriceList.get(0).setEnd(Double.valueOf(startValue.toString()) - 1);
@@ -1472,7 +1475,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				Double start = Double.valueOf(startValue.toString());
 				Double lastEnd = qtyPriceList.get(qtyPriceList.size() - 1).getStart();
 				if (validatePrice(price) && validateStartNumber(start, lastEnd)) {
-					GoodsQtyPrice qtyPrice = getOneQtyPrice(start, DoubleConstant.maxMinPackageQty,
+					GoodsQtyPrice qtyPrice = getOneQtyPrice(start, DoubleConstant.maxReserve,
 							price, aProduct.getRmbTaxRate(), aProduct.getCurrency());
 					qtyPriceList.get(qtyPriceList.size() - 1).setEnd(start - 1);
 					qtyPriceList.add(qtyPrice);
@@ -1809,8 +1812,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
         if (StringUtils.isEmpty(batch)) {
             return "0";
         }
-		List<ReleaseProductByBatch> releaseProductByBatchList =
-				releaseProductByBatchDao.findByRelbatchid(batch);
+		List<ReleaseProductByBatch> releaseProductByBatchList = releaseProductByBatchDao.findByRelbatchid(batch);
 		if (CollectionUtils.isEmpty(releaseProductByBatchList)) {
 			return String.valueOf(IntegerConstant.NO_SHORT);
 		}
@@ -1877,6 +1879,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			List<ReleaseProductByBatch> insertGoods = new ArrayList<>();
 			Set<Long> prids = new HashSet<>();
 			List<Goods> updateGoods = new ArrayList<>();
+			List<GoodsHistory> goodsHistoryList = new ArrayList<>();
 			for (ReleaseProductByBatch releaseProductByBatch : list) {
 				if (releaseProductByBatch.getReleaseCode().intValue() == ReleaseStatus.success.value() || releaseProductByBatch.getReleaseCode().intValue() == ReleaseStatus.failure.value()) {
                     Boolean isExist = false;
@@ -1888,6 +1891,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
                                 isExist = true;
 								prids.add(releaseProductByBatch.getProductid());
                                 goods1.updateGoodsByReleaseProductByBatch(releaseProductByBatch, delayTime, ignoreImport);
+								goodsHistoryList.add(goodsHistoryService.converTGoodsHist(goods1, GoodsHistory.OperateType.Update.getPhrase(), false));
 								updateGoods.add(goods1);
                                 break;
 							}
@@ -1902,6 +1906,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				for (ReleaseProductByBatch releaseProductByBatch : insertGoods) {
 					goods = new Goods();
 					goods.setGoodsByReleaseProductByBatch(releaseProductByBatch, delayTime);
+					goodsHistoryList.add(goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false));
 					goodses.add(goods);
 				}
 			}
@@ -1911,6 +1916,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			if (CollectionUtils.isNotEmpty(updateGoods)) {
                 goodsDao.save(updateGoods);
             }
+            if (CollectionUtils.isNotEmpty(goodsHistoryList)) {
+				goodsHistoryService.save(goodsHistoryList);
+			}
 			return (goodses.size() + updateGoods.size());
 		} else {
 			return 0;
@@ -2124,15 +2132,15 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			public void run() {
 
 				//创建历史库存
-				List<Goods> goodses1 = goodsService.findByBatchId(batchid);
-				List<GoodsHistory> list = new ArrayList<>();
-				for (Goods goods : goodses1) {
-					GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false);
-					list.add(goodsHistory);
-				}
-				if (CollectionUtils.isNotEmpty(list)) {
-					goodsHistoryService.save(list);
-				}
+//				List<Goods> goodses1 = goodsService.findByBatchId(batchid);
+//				List<GoodsHistory> list = new ArrayList<>();
+//				for (Goods goods : goodses1) {
+//					GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false);
+//					list.add(goodsHistory);
+//				}
+//				if (CollectionUtils.isNotEmpty(list)) {
+//					goodsHistoryService.save(list);
+//				}
 				//创建物料的私有信息
 				productPrivateService.newProductPrivateIfNotExist(productIds);