Parcourir la source

Merge remote-tracking branch 'origin/release-201830-wangcz' into release-201830-wangcz

wangcz il y a 7 ans
Parent
commit
f4299baae7

+ 9 - 6
src/main/java/com/uas/platform/b2c/prod/commodity/model/Goods.java

@@ -1180,7 +1180,7 @@ public class Goods implements Serializable {
 			this.attach = product.getAttachment();
 		}
 		this.packaging = product.getPackaging();
-		this.minPackQty = product.getMinPackQty();
+		this.minPackQty = product.getMinPackQty() == null ? 1 : product.getMinPackQty();
         this.reserve = product.getErpReserve() == null ? 0 : product.getErpReserve();
 
     }
@@ -1376,11 +1376,13 @@ public class Goods implements Serializable {
 		if(CollectionUtils.isEmpty(this.prices)) {
 			this.prices = FastjsonUtils.fromJsonArray(this.qtyPrice, GoodsQtyPrice.class);
 		}
-		for (GoodsQtyPrice price : this.prices) {
-			price.setRMBPrice(NumberUtil.fractionNumCeil(price.getRMBPrice(), 6));
-			price.setRMBNTPrice(NumberUtil.fractionNumCeil(price.getRMBNTPrice(), 6));
-			price.setUSDPrice(NumberUtil.fractionNumCeil(price.getUSDPrice(), 6));
-			price.setUSDNTPrice(NumberUtil.fractionNumCeil(price.getUSDNTPrice(), 6));
+		if (!StringUtils.isEmpty(this.prices)) {
+			for (GoodsQtyPrice price : this.prices) {
+				price.setRMBPrice(NumberUtil.fractionNumCeil(price.getRMBPrice(), 6));
+				price.setRMBNTPrice(NumberUtil.fractionNumCeil(price.getRMBNTPrice(), 6));
+				price.setUSDPrice(NumberUtil.fractionNumCeil(price.getUSDPrice(), 6));
+				price.setUSDNTPrice(NumberUtil.fractionNumCeil(price.getUSDNTPrice(), 6));
+			}
 		}
 		// 更新分段价格JSON字符串
 		this.qtyPrice = FastjsonUtils.toJson(this.prices);
@@ -1712,6 +1714,7 @@ public class Goods implements Serializable {
         g.setMinPackQty(product.getMinPackQty());
         g.setPackaging(product.getPackaging());
 		g.setCostPrice(product.getPrice());
+		g.setBatchCode(product.getId().toString().trim());
 		return g;
 	}
 

+ 16 - 7
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java

@@ -317,9 +317,11 @@ public class GoodsServiceImpl implements GoodsService {
         }
 
         //验证分段价格的有效性。
-        ResultMap resultMap = validFragmentPrice(goods);
-        if (resultMap.getCode() != CodeType.OK.code()) {
-            return resultMap;
+        if (!CollectionUtils.isEmpty(goods.getPrices())) {
+            ResultMap resultMap = validFragmentPrice(goods);
+            if (resultMap.getCode() != CodeType.OK.code()) {
+                return resultMap;
+            }
         }
         if (goods.getProductid() == null) {
             throw new IllegalOperatorException("型号" + goods.getCode() + "品牌" + goods.getBrandNameEn() +"的物料库信息丢失");
@@ -1461,6 +1463,9 @@ public class GoodsServiceImpl implements GoodsService {
      * @return
      */
     private String analyzeQtyNumber(List<GoodsQtyPrice> qtyPriceList) {
+        if (CollectionUtils.isEmpty(qtyPriceList)) {
+            return "";
+        }
         StringBuilder builder = new StringBuilder();
         for (GoodsQtyPrice qtyPrice : qtyPriceList) {
             builder.append(SplitChar.SLASH);
@@ -1479,6 +1484,9 @@ public class GoodsServiceImpl implements GoodsService {
      * @return
      */
     private String analyzeQtyPrice(List<GoodsQtyPrice> qtyPriceList) {
+        if (CollectionUtils.isEmpty(qtyPriceList)) {
+            return "";
+        }
         StringBuilder builder = new StringBuilder();
         Double price = null;
         for (GoodsQtyPrice qtyPrice : qtyPriceList) {
@@ -1623,16 +1631,17 @@ public class GoodsServiceImpl implements GoodsService {
         if(nowGoods.getProductid() != null) {
             Product product = productDao.findOne(nowGoods.getProductid());
             if(product != null) {
-                if (!nowGoods.getSpec().equals(oldGoods.getSpec())) {
+                if (!StringUtilB2C.isEmpty(nowGoods.getSpec()) && !nowGoods.getSpec().equals(oldGoods.getSpec())) {
                     product.setSpec(oldGoods.getSpec());
                 }
-                if (!nowGoods.getPackaging().equals(oldGoods.getPackaging())) {
+                if (!StringUtilB2C.isEmpty(nowGoods.getPackaging()) && !nowGoods.getPackaging().equals(oldGoods.getPackaging())) {
                     product.setPackaging(oldGoods.getPackaging());
                 }
-                if (!nowGoods.getMinPackQty().equals(oldGoods.getMinPackQty())) {
+                if (!StringUtilB2C.isEmpty(nowGoods.getMinPackQty()) && !nowGoods.getMinPackQty().equals(oldGoods.getMinPackQty())) {
                     product.setMinPackQty(oldGoods.getMinPackQty());
                 }
-                if (!product.getErpReserve().equals(oldGoods.getReserve())) {
+                if (!StringUtilB2C.isEmpty(nowGoods.getReserve()) && !StringUtilB2C.isEmpty(product.getErpReserve())
+                        && !product.getErpReserve().equals(oldGoods.getReserve())) {
                     product.setErpReserve(oldGoods.getReserve());
                     InOutboundDetail inOutboundDetail = new InOutboundDetail(product);
                     Double qty = NumberUtil.sub(oldGoods.getReserve(), product.getErpReserve());

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

@@ -476,7 +476,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			Object sellObj = readWorkBookCell(row.getCell(ModifyConstant.SALE_METHOD), Cell.CELL_TYPE_STRING,
 					r, ModifyConstant.SALE_METHOD);
 			aBatch.setSaleMethod(StringUtilB2C.getStr(sellObj).trim());
-			StoreIn storeIn = getModifyStoreInfo(sellObj, self, consignment);
+			StoreIn storeIn = getModifyStoreInfo(sellObj, self, consignment, skuObj);
 			if (storeIn == null) {
 				aBatch.addErrmsg(ErrorInfoConstant.STORE_ERROR.getInfo());
 				aBatch.setErrmsg(aBatch.getErrmsg().substring(1));
@@ -497,12 +497,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
 				aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
 			} else {
-				// 导入成功的需要判断自定义标签是否重复
-//				if (CollectionUtils.isNotEmpty(batchList) && aBatch.getTag() != null) {
-//					if (validateTagInfo(aBatch, batchList)) {
-//						aBatch.setTag(null);
-//					}
-//				}
 				validateRepeatInExcel(batchList, aBatch, true);
 			}
 			batchList.add(aBatch);
@@ -554,7 +548,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		}
 		Goods newGoods = null;
 		List<GoodsHistory> goodsHistoryList = new ArrayList<>();
-		for (ReleaseProductByBatch aBatch : batchList) {
+			for (ReleaseProductByBatch aBatch : batchList) {
 			newGoods = null;
 			if (!RegexConstant.isNumber(aBatch.getBatchCode())) {
 				for (Goods goods : goodses) {
@@ -583,7 +577,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				ResultMap resultMap = goodsService.updateGoods(newGoods);
 				if (resultMap.isSuccess()) {
 					Goods goods1 = (Goods) resultMap.getData();
-					if (Status.REMOVED.value() == aBatch.getStatus() && Status.REMOVED.value() != goods1.getStatus()) {
+					if (aBatch.getStatus() != null && goods1.getStatus() != null
+							&& Status.REMOVED.value() == aBatch.getStatus() && Status.REMOVED.value() != goods1.getStatus()) {
 						ResultMap offMap = goodsService.offShelfGoodsByProvider(newGoods.getBatchCode(), null, false);
 						if (offMap.isSuccess()) {
 							result++;
@@ -609,9 +604,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 						aBatch.setKindName(product.getProdName());
 						aBatch.setCurrency(product.getCurrency());
 						aBatch.setProductNum(product.getProdNum());
-						InOutboundDetail inOutboundDetail = new InOutboundDetail(newProduct);
-						fillInProduct(product, aBatch, inOutboundDetail);
 						newProduct = product;
+						InOutboundDetail inOutboundDetail = new InOutboundDetail(newProduct);
+						fillInProduct(newProduct, aBatch, inOutboundDetail);
 						Set<InOutboundDetail> set = new HashSet<>();
 						set.add(inOutboundDetail);
 						if (CollectionUtils.isNotEmpty(set)) {
@@ -635,8 +630,17 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				} else {
 					Goods needGoods = new Goods();
 					needGoods.setProductInfo(newProduct);
+					needGoods.setMinBuyQty(aBatch.getMinBuyQty() == null ? needGoods.getMinPackQty() : aBatch.getMinBuyQty());
+					if (StringUtils.isEmpty(needGoods.getSelfSale())) {
+						needGoods.setSelfSale("2");
+					}
 					goodsService.setGoodsDefault(needGoods);
+					needGoods.setStatus();
 					goodsDao.save(needGoods);
+					GoodsHistory history = goodsHistoryService.converTGoodsHist(needGoods,
+							GoodsHistory.OperateType.Update.getPhrase(), false);
+					// 修改上下架状态并产生上下架历史
+					goodsHistoryService.save(history);
 				}
 			}
 
@@ -798,7 +802,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		}
 	}
 
-	private StoreIn getModifyStoreInfo(Object value, StoreIn self, StoreIn consignment) {
+	private StoreIn getModifyStoreInfo(Object value, StoreIn self, StoreIn consignment, Object bachCode) {
+		if (!StringUtils.isEmpty(bachCode)) {
+			if (RegexConstant.isNumber(bachCode.toString().trim())) {
+				return consignment;
+			}
+		}
 		List<String> sellList = Arrays.asList("自营", "寄售");
 		if (StringUtils.isEmpty(value) || !sellList.contains(StringUtilB2C.getStr(value))) {
 			return null;