Просмотр исходного кода

1:处理测试中提到的bug。(交期获取不到,自营的价格信息为空等问题。)

yujia 8 лет назад
Родитель
Сommit
e05d67dd50

+ 72 - 0
src/main/java/JSON.java

@@ -0,0 +1,72 @@
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class JSON {
+
+    private static String[] getKeyValue(String str) {
+        String field = str.substring(0, str.indexOf(":"));
+        if (field != null) {
+            if (field.startsWith("\"")) {
+                field = field.substring(1, field.length());
+            }
+            if (field.endsWith("\"")) {
+                field = field.substring(0, field.lastIndexOf("\""));
+            }
+        }
+        String value = str.substring(str.indexOf(":") + 1);
+        if (value != null) {
+            if ("null".equals(value)) {
+                value = null;
+            } else {
+                if (value.startsWith("\"")) {
+                    value = value.substring(1, value.length());
+                }
+                if (value.endsWith("\"")) {
+                    value = value.substring(0, value.lastIndexOf("\""));
+                }
+            }
+        }
+        return new String[] { field, value };
+    }
+
+    public static Map<String, String> parseObject(String jsonStr) {
+        Map<String, String> data = new HashMap<String, String>();
+        if (null != jsonStr) {
+            jsonStr = jsonStr.substring(jsonStr.indexOf("{") + 1, jsonStr.lastIndexOf("}"));
+            String[] strs = jsonStr.split(",\"");
+            for (String str : strs) {
+                if (str.indexOf(":") > 0) {
+                    String[] entry = getKeyValue(str);
+                    data.put(entry[0], entry[1]);
+                }
+            }
+        }
+        return data;
+    }
+
+    public static List<Map<String, String>> parseArray(String jsonStr) {
+        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
+        if (null != jsonStr) {
+            if (jsonStr.startsWith("[")) {
+                jsonStr = jsonStr.substring(1, jsonStr.length());
+            }
+            if (jsonStr.endsWith("]")) {
+                jsonStr = jsonStr.substring(0, jsonStr.lastIndexOf("]"));
+            }
+            if (jsonStr.indexOf("},") > -1) {
+                String[] js = jsonStr.split("},");
+                for (String j : js) {
+                    if (!j.endsWith("}"))
+                        j = j + "}";
+                    list.add(parseObject(j));
+                }
+            } else if (!(jsonStr.indexOf("{") == -1 || jsonStr.indexOf("}") == -1)) {
+                list.add(parseObject(jsonStr));
+            }
+        }
+        return list;
+    }
+
+}

+ 89 - 0
src/main/java/JsonPrice.java

@@ -0,0 +1,89 @@
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class JsonPrice {
+
+    public static Double getPriceByQty(String priceJson, Double qty, String priceProperty) {
+        List<Map<String, String>> array = JSON.parseArray(priceJson);
+        Double start = 0.0d;
+        Double end = 0.0d;
+        try {
+            for (Map<String, String> map : array) {
+                start = Double.parseDouble(map.get("start"));
+                end = Double.parseDouble(map.get("end"));
+                if (Double.compare(start, qty) < 1 && Double.compare(end, qty) > -1) {
+                    String price = map.get(priceProperty);
+                    return (null == price || price.length() == 0) ? null : Double.parseDouble(price);
+                }
+            }
+            return null;
+        }catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static Double getInfoByProperty(String priceJson, Integer index, String property) {
+        List<Map<String, String>> array = JSON.parseArray(priceJson);
+        if(array.size() <= index) {
+            return null;
+        }else {
+            Map<String, String> map = array.get(index);
+            Set<String> properties = map.keySet();
+            for (String proper : properties) {
+                if(proper.equals(property)) {
+                    try {
+                        return Double.parseDouble(map.get(proper));
+                    }catch (Exception e) {
+                        return null;
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+
+    public static Double getMinPrice(String priceJson, String priceProperty) {
+        List<Map<String, String>> array = JSON.parseArray(priceJson);
+        Double minPrice = Double.MAX_VALUE;
+        for (Map<String, String> map : array) {
+            try {
+                String price = map.get(priceProperty);
+                Double mprice = (null == price || price.length() == 0) ? null : Double.parseDouble(price);
+                if (Double.compare(minPrice, mprice) > 0) {
+                    minPrice = mprice;
+                }
+                if(Double.compare(Double.MAX_VALUE, minPrice) == 0) {
+                    return null;
+                }else {
+                    return minPrice;
+                }
+            }catch (Exception e) {
+                return null;
+            }
+        }
+        return null;
+    }
+
+    public static Double getMaxPrice(String priceJson, String priceProperty) {
+        List<Map<String, String>> array = JSON.parseArray(priceJson);
+        Double maxPrice = Double.MIN_VALUE;
+        try {
+            for (Map<String, String> map : array) {
+                String price = map.get(priceProperty);
+                Double mprice = (null == price || price.length() == 0) ? null : Double.parseDouble(price);
+                if (Double.compare(maxPrice, mprice) < 1) {
+                    maxPrice = mprice;
+                }
+            }
+            if (Double.compare(Double.MIN_VALUE, maxPrice) == 0) {
+                return null;
+            } else {
+                return maxPrice;
+            }
+        }catch (Exception e) {
+            return null;
+        }
+    }
+} 

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

@@ -1378,8 +1378,8 @@ public class GoodsServiceImpl implements GoodsService {
 				if (CollectionUtils.isEmpty(delayTime1)) {
 					throw new IllegalOperatorException("请联系商城,您供应商交货延长时间 国外发往国外没设置。");
 				}
-				goods.setB2cDeliveryHKMaxTime((short) (delayTime1.get(0).getMaxTime() + goods.getSelfDeliveryHKMaxTime()));
-				goods.setB2cDeliveryHKMinTime((short) (delayTime1.get(0).getMinTime() + goods.getSelfDeliveryHKMinTime()));
+				goods.setB2cDeliveryHKMaxTime((short) (delayTime1.get(0).getMaxTime() + Short.valueOf(goods.getSelfDeliveryHKMaxTime() == null ? 0 : goods.getSelfDeliveryHKMaxTime())));
+				goods.setB2cDeliveryHKMinTime((short) (delayTime1.get(0).getMinTime() + Short.valueOf(goods.getSelfDeliveryHKMinTime() == null  ? 0 : goods.getSelfDeliveryHKMinTime())));
 				goods.setB2cMaxDelivery((short) (delayTime1.get(0).getMinTime() + Short.valueOf(goods.getMaxDelivery() == null ? 0 : goods.getMaxDelivery())));
 				goods.setB2cMinDelivery((short) (delayTime1.get(0).getMinTime() + Short.valueOf(goods.getMinDelivery() == null ? 0 : goods.getMinDelivery())));
 			}

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

@@ -173,7 +173,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 						reserve = Double.valueOf(reserveCellValue.toString());
 						int compareTo = reserve.compareTo(DoubleConstant.maxReserve);
 						if(compareTo > 0) {
-							releaseProductByBatch.addErrmsg("6:发布数量大于了我们设置的最大值99999999");
+							releaseProductByBatch.addErrmsg("6:发布数量大于了我们设置的最大值" + DoubleConstant.maxReserve);
 						}else if(NumberUtil.compare(reserve, DoubleConstant.zero) < 1) {
 							releaseProductByBatch.addErrmsg("6:发布数量必须大于0");
 						}
@@ -282,7 +282,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 					// 最小包单价
 					Object priceMinPackQtyCellValue = readWorkBookCell(row.getCell(9), Cell.CELL_TYPE_STRING, r, 9);
 					releaseProductByBatch.setMinPackPriceStr(String.valueOf(priceMinPackQtyCellValue));
-					if ((priceMinPackQtyCellValue != null)&&(isNumber(priceMinPackQtyCellValue.toString()))) {
+					if ((priceMinPackQtyCellValue != null)&&(isNumber(priceMinPackQtyCellValue.toString())) && (NumberUtil.compare(Double.valueOf(priceMinPackQtyCellValue.toString()), 0.0d) > 0)) {
 						Double price = Double.valueOf(priceMinPackQtyCellValue.toString());
 						price = fractionNumCeil(price, 6);
 						if(Currency.USD.equals(currency)) {
@@ -291,7 +291,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 							releaseProductByBatch.setRmbMinPackPrice(price);
 						}
 					}else {
-						releaseProductByBatch.addErrmsg("10:最小包单价信息为空");
+						releaseProductByBatch.addErrmsg("10:最小包单价信息必须是大于0的数字");
 					}
 
 					Object deliveryMinCellValue = readWorkBookCell(row.getCell(10), Cell.CELL_TYPE_STRING, r, 10);
@@ -493,7 +493,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		if((min != null) || (max != null)) {
 			min  = min == null ? max : min;
 			max  = max == null ? min : max;
-			if(min.shortValue() > ShortConstant.maxDelivery || min.shortValue() < 0 || max.shortValue() > Short.MAX_VALUE || max.shortValue() < 0){
+			if(min.shortValue() > ShortConstant.maxDelivery.shortValue() || min.shortValue() < 0 || max.shortValue() > ShortConstant.maxDelivery.shortValue() || max.shortValue() < 0){
 				releaseProductByBatch.addErrmsg("11-12:交期的信息必须为正整数并且小于" + ShortConstant.maxDelivery);
 			}else {
 				if(min.shortValue() > max.shortValue()) {
@@ -640,7 +640,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 
 		Object priceCellValue = readWorkBookCell(cellPrice, Cell.CELL_TYPE_STRING, r, num + 1);
 		releaseProductByBatch.setFragmentPrice(String.valueOf(priceCellValue), i);
-		if ((endQtyCellValue != null)&&(isNumber(endQtyCellValue.toString()))) {
+		if ((endQtyCellValue != null)&&(isNumber(endQtyCellValue.toString())) && (NumberUtil.compare(Double.valueOf(endQtyCellValue.toString()), 0.0d) > 0)) {
 			Double end = Double.valueOf(endQtyCellValue.toString());
 			GoodsQtyPrice qtyPrice = new GoodsQtyPrice();
 			// 分段结束值 与最小库存比较

+ 4 - 1
src/main/java/com/uas/platform/b2c/trade/order/model/OrderDetail.java

@@ -861,7 +861,10 @@ public class OrderDetail extends Document implements Serializable{
 			if(NumberUtil.compare(remind, 0.0) != 0) {
 				this.number = goods.getMinBuyQty();
 			}
-//			double times = NumberUtil.div(this.number, this.minPackQty)
+			if(NumberUtil.compare(this.number, goods.getMinBuyQty()) < 0) {
+				this.number = goods.getMinBuyQty();
+//			double times = NumberUtil.div(this.number, this.minPackQty
+			}
 //			double qty1 = NumberUtil.mul(times, goods.getMinPackQty());
 //			if(NumberUtil.compare(qty1, goods.getMinBuyQty()) <= 0) {
 //				this.number = goods.getMinBuyQty();

+ 3 - 0
src/main/java/com/uas/platform/b2c/trade/presale/model/Cart.java

@@ -315,6 +315,9 @@ public class Cart {
 			if(NumberUtil.compare(remaind, 0.0) != 0) {
 				this.number = goods.getMinBuyQty();
 			}
+			if(NumberUtil.compare(this.number, goods.getMinBuyQty()) < 0) {
+				this.number = goods.getMinBuyQty();
+			}
 //			double times = NumberUtil.div(this.number, this.minPackQty);
 //			double qty1 = NumberUtil.mul(times, goods.getMinPackQty());
 //			if(NumberUtil.compare(qty1, goods.getMinBuyQty()) <= 0) {

+ 1 - 1
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_upload_ctrl.js

@@ -172,7 +172,7 @@ define([ 'app/app' ], function(app) {
 				url: 'release/product/release/excel',
 				file: file,
 				method: 'POST',
-				params : {selfSale : $scope.batch.sellType == 'self' ? true : false}
+				params : {selfSale : $scope.batch.sellType == 'self' ? true : false, currency : $scope.batch.currency}
 			}).success(function(data) {
 				$scope.selectFile(' ');
 				$scope.batch.myFiles = [];

+ 9 - 11
src/main/webapp/resources/view/vendor/modal/releaseProductByBatchTip.html

@@ -17,19 +17,17 @@
 	<div class="modal-header"><h4>批量发布库存说明</h4></div>
 	<div class="modal-body col-xs-12">
 		<p class="col-xs-12">
-			<div class="col-xs-12">1:红色必选项</div>
-			<div class="col-xs-12">品牌英文名、产品型号、库存类型、库存数量、产品生产日期</div>
+			<div class="col-xs-12">1.标题红色为必填项,黑色为选填项</div>
+			<div class="col-xs-12">2.最小包装数量不填时默认为1</div>
+			<div class="col-xs-12">3.最小起订量不填时默认等于最小包装数量</div>
+			<div class="col-xs-12">4.不可拆卖时,最小起订量应为最小保障数量的倍数</div>
+			<div class="col-xs-12">5.价格分段不填写时默认存在一个分段,分段数量为1-999999999,价格为单价</div>
 		</p>
 		<p class="col-xs-12">
-			<div class="col-xs-12">2:二选一必填项</div>
-			<div class="col-xs-12">a.RMB和USD最小包单价可以选填一种:</div>
-			<div class="col-xs-12">b.大陆交期和香港交期可以选填一种:</div>
-			<div class="col-xs-12">c.根据自身实际情况,可同时选择两种币别销售</div>
-		</p>
-		<p class="col-xs-12">
-			<div class="col-xs-12">3:日期格式</div>
-			<div class="col-xs-12">a.以准确数字做交期天数,如直接填写"5"</div>
-			<div class="col-xs-12">b.以"~"做连接符写出区间段,如"3~5"</div>
+			<div class="col-xs-12">6.日期:</div>
+			<div class="col-xs-12" style="margin-left: 20px;">a.以准确的数字做交期</div>
+			<div class="col-xs-12" style="margin-left: 20px;">b.最小和最大交期一样时默认为准确交期</div>
+			<div class="col-xs-12" style="margin-left: 20px;">c.仅填写最小或最大交期时默认为准确交期</div>
 		</p>
 	</div>
 	<div class="modal-footer col-xs-12">