Browse Source

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

wangcz 7 years ago
parent
commit
ab3e8e310f

+ 0 - 9
src/main/java/com/uas/platform/b2c/prod/commodity/constant/DoubleConstant.java

@@ -47,13 +47,4 @@ public class DoubleConstant {
      */
     public static final Double maxFluctuateRate = 2d;
 
-    /**
-     * 默认最小购买量
-     */
-    public static final Double defaultMinBuyQty = 1D;
-
-    /**
-     * 默认最小包装量
-     */
-    public static final Double defaultMinPackQty = 1D;
 }

+ 0 - 9
src/main/java/com/uas/platform/b2c/prod/commodity/constant/ShortConstant.java

@@ -17,13 +17,4 @@ public class ShortConstant {
      */
     public static final Short minDelivery = 1;
 
-    /**
-     * 默认最短交期
-     */
-    public static final Short defaultMinDelivery = 1;
-
-    /**
-     * 默认最长交期
-     */
-    public static final Short defaultMaxDelivery = 10;
 }

+ 21 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/Goods.java

@@ -9,6 +9,7 @@ import com.uas.platform.b2c.core.utils.StringUtilB2C;
 import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
 import com.uas.platform.b2c.prod.commodity.constant.IntegerConstant;
 import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
+import com.uas.platform.b2c.prod.commodity.type.ProductConstant;
 import com.uas.platform.b2c.prod.product.brand.modal.BrandInfo;
 import com.uas.platform.b2c.trade.presale.model.TradeDeliveryDelayTime;
 import com.uas.platform.b2c.trade.support.CodeType;
@@ -1027,7 +1028,14 @@ public class Goods implements Serializable {
 	}
 
 	public void setMaxAndMinPrice() {
+		if (CollectionUtils.isEmpty(prices) && !StringUtilB2C.isEmpty(this.qtyPrice)) {
+			prices = FastjsonUtils.fromJsonArray(this.qtyPrice, GoodsQtyPrice.class);
+		}
 		if (!CollectionUtils.isEmpty(prices)) {
+			this.maxPriceRMB = prices.get(0).getRMBPrice();
+			this.minPriceRMB = this.maxPriceRMB;
+			this.maxPriceUSD = prices.get(0).getUSDPrice();
+			this.minPriceUSD = this.maxPriceUSD;
 			for (GoodsQtyPrice price : prices) {
 				if (NumberUtil.compare(this.minPriceRMB, price.getRMBPrice()) > 0) {
 					this.minPriceRMB = price.getRMBPrice();
@@ -1778,13 +1786,26 @@ public class Goods implements Serializable {
 		goods.setCode(product.getPcmpcode());
 		goods.setEncapsulation(product.getEncapsulation());
 		goods.setPackaging(product.getPackaging());
+		if (StringUtils.isEmpty(goods.getPackaging())) {
+			goods.setPackaging(ProductConstant.DEFAULT_PACKING);
+		}
 		goods.setProduceDate(product.getProduceDate());
 		goods.setUuid(product.getCmpUuId());
 		goods.setMinPackQty(product.getMinPackQty());
+		if (null == goods.getMinPackQty()) {
+		    goods.setMinPackQty(ProductConstant.DEFAULT_MIN_PACKQTY);
+        }
+        goods.setMinBuyQty(product.getMinOrder());
+        if (null == goods.getMinBuyQty()) {
+            goods.setMinBuyQty(ProductConstant.DEFAULT_MIN_BUYQTY);
+        }
 		goods.setEnUU(SystemSession.getUser().getEnterprise().getUu());
 		goods.setPublisherName(SystemSession.getUser().getUserName());
 		goods.setPublisherUU(SystemSession.getUser().getUserUU());
 		goods.setPublishPhone(SystemSession.getUser().getUserTel());
+		if (null == goods.getStatus()) {
+		    goods.setStatus(Status.NO_SHELVE.value());
+        }
 		return goods;
 	}
 

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -2965,7 +2965,7 @@ public class ProductServiceImpl implements ProductService {
         if (null != goods.getId()) {
             //如果现在是已上架,原先是未上架或者已下架,则做上架处理。否则做更新处理
             boolean publish = (Status.AVAILABLE.value() == goods.getStatus() || Status.UNAVAILABLE.value() == goods.getStatus()
-                    || Status.NO_SHELVE.value() == goods.getStatus()) && (Status.REMOVED.value() == goods.getOldStatus());
+                    || Status.NO_SHELVE.value() == goods.getStatus()) && (null == goods.getOldStatus() || Status.REMOVED.value() == goods.getOldStatus());
             if (publish) {
                 type = GoodsHistory.OperateType.Publish.getPhrase();
             } else {

+ 41 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/type/ProductConstant.java

@@ -41,4 +41,45 @@ public class ProductConstant {
      * 型号最长长度
      */
     public final static int MAX_CMPCODE_LENGTH = 100;
+
+    /**
+     * 默认包装方式(物料)
+     */
+    public static String DEFAULT_PACKING = "其他";
+
+    /**
+     * 默认最小购买量
+     */
+    public static final Double DEFAULT_MIN_BUYQTY = 1D;
+
+    /**
+     * 默认最小包装量
+     */
+    public static final Double DEFAULT_MIN_PACKQTY = 1D;
+
+    /**
+     * 是否可拆分(默认是)
+     */
+    public static final Boolean DEFAULT_BREAKUP = true;
+
+    /**
+     * 是否自动上架(默认是)
+     */
+    public static final Boolean DEFAULT_AUTO_PUBLISH = true;
+
+    /**
+     * 默认最短交期
+     */
+    public static final Short DEFAULT_MIN_DELIVERY = 1;
+
+    /**
+     * 默认最长交期
+     */
+    public static final Short DEFAULT_MAX_DELIVERY = 10;
+
+    /**
+     * 默认单位
+     */
+    public static final String DEFAULT_UNIT = "PCS";
+
 }

+ 28 - 20
src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseProductServiceImpl.java

@@ -9,7 +9,6 @@ import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.b2c.core.utils.StringUtilB2C;
 import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
 import com.uas.platform.b2c.prod.commodity.constant.ErrorInfoConstant;
-import com.uas.platform.b2c.prod.commodity.constant.ShortConstant;
 import com.uas.platform.b2c.prod.commodity.constant.UploadConstant;
 import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
 import com.uas.platform.b2c.prod.commodity.dao.GoodsHistoryDao;
@@ -21,6 +20,7 @@ import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
 import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
 import com.uas.platform.b2c.prod.commodity.service.ProductService;
 import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
+import com.uas.platform.b2c.prod.commodity.type.ProductConstant;
 import com.uas.platform.b2c.prod.commodity.util.SheetUtil;
 import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
 import com.uas.platform.b2c.trade.order.service.PurchaseProductService;
@@ -213,7 +213,7 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
         aProduct.setReleaseCode(ReleaseStatus.success.value());
         aProduct.setReleaseStatus(ReleaseStatus.success.getPhrase());
         aProduct.setRelbatchid(batch);
-        aProduct.setUnit("PCS");
+        aProduct.setUnit(ProductConstant.DEFAULT_UNIT);
         // 设置发布人信息
         aProduct.setPublisherName(SystemSession.getUser().getUserName());
         aProduct.setPublisherTel(SystemSession.getUser().getUserTel());
@@ -222,7 +222,13 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
             aProduct.setReserve(DoubleConstant.zero);
         }
         if (null == aProduct.getPackaging()) {
-            aProduct.setPackaging("其他");
+            aProduct.setPackaging(ProductConstant.DEFAULT_PACKING);
+        }
+        if (null == aProduct.getMinPackage()) {
+            aProduct.setMinPackage(ProductConstant.DEFAULT_MIN_PACKQTY);
+        }
+        if (null == aProduct.getMinBuyQty()) {
+            aProduct.setMinBuyQty(ProductConstant.DEFAULT_MIN_BUYQTY);
         }
     }
 
@@ -373,18 +379,13 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
         productService.saveByJdbcTemplate(batchList);
         List<com.uas.platform.b2c.prod.commodity.model.Product> productList = productService.findProductIdAndProdnumsByProdNums(productCodeList);
         List<ProductPrivate> privateList = new ArrayList<>();
-        String defaultPackaging = "其他";
-        Boolean defaultBreakUp = true;
-        Boolean defaultAutoPublish = true;
-        List<Goods> goodsList = new ArrayList<>();
-        List<GoodsHistory> historyList = new ArrayList<>();
+        List<Goods> finalGoodsList = new ArrayList<>();
         productList.forEach(product -> {
-            Goods goods = new Goods(defaultPackaging, defaultBreakUp, defaultAutoPublish, ShortConstant.defaultMaxDelivery,
-                    ShortConstant.defaultMinDelivery, DoubleConstant.defaultMinBuyQty, DoubleConstant.defaultMinPackQty, Status.NO_SHELVE.value());
+            Goods goods = new Goods(ProductConstant.DEFAULT_PACKING, ProductConstant.DEFAULT_BREAKUP, ProductConstant.DEFAULT_AUTO_PUBLISH,
+                    ProductConstant.DEFAULT_MAX_DELIVERY, ProductConstant.DEFAULT_MIN_DELIVERY, ProductConstant.DEFAULT_MIN_BUYQTY,
+                    ProductConstant.DEFAULT_MIN_PACKQTY, Status.NO_SHELVE.value());
             goods = productService.bindProductToGoods(goods, product);
-            goodsList.add(goods);
-            GoodsHistory goodsHistory = productService.assignmentGoodsHistory(goods);
-            historyList.add(goodsHistory);
+            finalGoodsList.add(goods);
             ProductPrivate productPrivate;
             List<ProductPrivate> privates = productPrivateDao.findByPrId(product.getId());
             if (CollectionUtils.isNotEmpty(privates)) {
@@ -401,14 +402,21 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
         });
 
         // 保存goods
-        if (CollectionUtils.isNotEmpty(goodsList)) {
-            goodsDao.save(goodsList);
+        if (CollectionUtils.isNotEmpty(finalGoodsList)) {
+            List<Goods> goodsList = goodsDao.save(finalGoodsList);
             USE_LOG.log("上架商品", "新增上架商品", "批量导入上架商品,数量 " + goodsList.size() + ", 批号 " + batchCode);
-        }
-        // 保存goodsHistory
-        if (CollectionUtils.isNotEmpty(historyList)) {
-            goodsHistoryDao.save(historyList);
-            USE_LOG.log("库存操作", "批量导入上架商品更新库存操作", "数量 " + historyList.size() + ", 批次号 " + batchCode);
+            List<GoodsHistory> historyList = new ArrayList<>();
+            goodsList.forEach(goods -> {
+                GoodsHistory goodsHistory = productService.assignmentGoodsHistory(goods);
+                goodsHistory.setB2cMaxDelivery(goods.getMaxDelivery());
+                goodsHistory.setB2cMinDelivery(goods.getMinDelivery());
+                historyList.add(goodsHistory);
+            });
+            // 保存goodsHistory
+            if (CollectionUtils.isNotEmpty(historyList)) {
+                goodsHistoryDao.save(historyList);
+                USE_LOG.log("库存操作", "批量导入上架商品更新库存操作", "数量 " + historyList.size() + ", 批次号 " + batchCode);
+            }
         }
         // 保存到私有库
         if (CollectionUtils.isNotEmpty(privateList)) {

+ 1 - 1
src/main/webapp/resources/js/admin/controllers/product/productManageCtrl.js

@@ -327,7 +327,7 @@ define(['app/app'], function(app) {
                 angular.forEach($scope.ids, function(val) {
                     idList.push(val.id)
                 })
-                url = '/trade/goods/background/downloadByIds?idStr=' + angular.toJson(idList)
+                url = '/trade/goods/background/downloadByIds?idStr=' + encodeURIComponent(angular.toJson(idList))
             } else {
                 // 拼装链接
                 url = "/trade/goods/background/download?page=" + $scope.pageParams.page + "&count=" + $scope.pageParams.count + "&sorting=" + encodeURIComponent(angular.toJson($scope.pageParams.sorting));

+ 1 - 1
src/main/webapp/resources/js/admin/controllers/product/saleProductManageCtrl.js

@@ -326,7 +326,7 @@ define(['app/app'], function(app) {
                 angular.forEach($scope.ids, function(val) {
                     idList.push(val.id)
                 })
-                url = '/trade/products/background/downloadByIds?idStr=' + angular.toJson(idList);
+                url = '/trade/products/background/downloadByIds?idStr=' + encodeURIComponent(angular.toJson(idList));
             } else {
                 // 拼装链接
                 url = "/trade/products/background/download?page=" + $scope.pageParams.page + "&count=" + $scope.pageParams.count + "&sorting=" + encodeURIComponent(angular.toJson($scope.pageParams.sorting));