Jelajahi Sumber

调整编辑物料的接口

yujia 7 tahun lalu
induk
melakukan
493ed61fdf

+ 1 - 6
src/main/java/com/uas/platform/b2c/common/account/service/impl/EnterpriseServiceImpl.java

@@ -25,7 +25,6 @@ import com.uas.sso.util.AccountUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -101,11 +100,7 @@ public class EnterpriseServiceImpl implements EnterpriseService{
 	 */
 	@Override
 	public ResultMap getCurrencyByRegisterAddress() {
-		User user = SystemSession.getUser();
-		if(user == null) {
-			return new ResultMap(CodeType.NO_INFO, "个人信息缺失,请确定是否登录");
-		}
-		Enterprise enterprise = user.getEnterprise();
+		Enterprise enterprise = SystemSession.getUser().getEnterprise();
 		if(enterprise == null) {
 			return new ResultMap(CodeType.NO_INFO, "企业信息缺失,请完善对应的信息");
 		}

+ 1 - 1
src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceFOrderServiceImpl.java

@@ -352,7 +352,7 @@ public class InvoiceFOrderServiceImpl implements InvoiceFOrderService {
 		if (org.apache.commons.lang.StringUtils.isEmpty(shipList)) {
 			return new ResultMap(CodeType.NO_INFO, "发货明细缺失");
 		}
-		List<Map<String, Object>> list = FlexJsonUtils.fromJsonArray(shipList, Map.class);
+		List<Map<String, Object>> list = FlexJsonUtils.fromJsonArray(shipList, HashMap.class);
 		if (CollectionUtils.isEmpty(list)) {
 			return new ResultMap(CodeType.NO_INFO, "发货明细缺失");
 		}

+ 1 - 1
src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceFPurchaseServiceImpl.java

@@ -663,7 +663,7 @@ public class InvoiceFPurchaseServiceImpl implements InvoiceFPurchaseService {
 		if (org.apache.commons.lang.StringUtils.isEmpty(shipStr)) {
 			return new ResultMap(CodeType.NO_INFO, "发货明细缺失");
 		}
-		List<Map<String, Object>> list = FlexJsonUtils.fromJsonArray(shipStr, Map.class);
+		List<Map<String, Object>> list = FlexJsonUtils.fromJsonArray(shipStr, HashMap.class);
 		InvoiceFPurchase invoiceFPurchase = createInvoiceFPurchase(purchase, list);
 		Integer sendType = Integer.parseInt(jObj.getString("sendType"));
 

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/controller/GoodsController.java

@@ -285,7 +285,7 @@ public class GoodsController {
 	 * @param updateStatus 是否跟新状态
      * @return result map
      */
-    @RequestMapping(method = RequestMethod.PUT)
+    @RequestMapping(value = "/update", method = RequestMethod.POST)
 	public ResultMap updateGoods(@RequestBody Goods goods, Boolean updateStatus) {
 		logger.log("商品批次", "更新已上架商品信息");
 		return goodsService.updateGoods(goods);

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

@@ -723,7 +723,7 @@ public class Goods implements Serializable {
 
 	public void setStatus() {
 		if (this.autoPublish) {
-			if (StringUtils.isEmpty(this.packaging) || StringUtils.isEmpty(this.produceDate) || (this.minBuyQty == null) || (this.minPackQty == null) || (this.b2cMinDelivery == null) || (this.b2cMaxDelivery == null) || StringUtils.isEmpty(this.qtyPrice)) {
+			if (StringUtils.isEmpty(this.packaging) || (this.minBuyQty == null) || (this.minPackQty == null) || (this.b2cMinDelivery == null) || (this.b2cMaxDelivery == null) || StringUtils.isEmpty(this.qtyPrice)) {
 				//做未上架处理
 				this.status = Status.NO_SHELVE.value();
 			} else {
@@ -731,7 +731,7 @@ public class Goods implements Serializable {
 				this.status = (NumberUtil.compare(this.getReserve(), this.getMinBuyQty()) > -1) ? Status.AVAILABLE.value() : Status.UNAVAILABLE.value();
 			}
 		} else {
-			this.status = Status.NO_SHELVE.value();
+			this.status = Status.REMOVED.value();
 		}
 	}
 
@@ -933,11 +933,11 @@ public class Goods implements Serializable {
 	}
 
 	public void setTaxRate() {
-		if (this.getCurrencyName().contains(StringConstant.RMB) && this.getRmbTaxRate() == null) {
-			this.setRmbTaxRate(0.17);
+		if (this.currencyName.contains(StringConstant.RMB) && this.rmbTaxRate == null) {
+			this.rmbTaxRate = 0.17;
 		}
-		if (this.getCurrencyName().contains(StringConstant.USD) && this.getUsdTaxRate() == null) {
-			this.setUsdTaxRate((double) 0);
+		if (this.currencyName.contains(StringConstant.USD) && this.usdTaxRate == null) {
+			this.usdTaxRate = (double) 0;
 		}
 	}
 
@@ -1758,6 +1758,20 @@ public class Goods implements Serializable {
 		return new ResultMap(CodeType.OK, "成功");
 	}
 
+	/**
+	 * 根据最小起订量 调整分段信息
+	 */
+	public void adjustFragmentPrice() {
+		if (!StringUtils.isEmpty(this.minBuyQty) && org.apache.commons.lang.StringUtils.isNotEmpty(this.qtyPrice)) {
+			List<GoodsQtyPrice> array = FastjsonUtils.fromJsonArray(this.qtyPrice, GoodsQtyPrice.class);
+			GoodsQtyPrice price = array.get(0);
+			if (NumberUtil.compare(price.getStart(), this.minBuyQty) > 0) {
+				price.setStart(this.minBuyQty);
+				this.qtyPrice = FastjsonUtils.toJson(array);
+			}
+		}
+	}
+
 	public String getSpec() {
 		return spec;
 	}
@@ -1942,4 +1956,30 @@ public class Goods implements Serializable {
 
 		return this;
 	}
+
+
+	public void setMinBuyQtyByMinPackQty(Double minBuyQty) {
+		if (StringUtils.isEmpty(minBuyQty)) {
+			this.minBuyQty = this.minPackQty;
+		} else {
+			if (minBuyQty <= 0) {
+				this.minBuyQty = this.minPackQty;
+			} else {
+				if (NumberUtil.compare(minBuyQty, DoubleConstant.maxMinPackageQty) > 0) {
+					minBuyQty = DoubleConstant.maxMinPackageQty;
+				}
+				this.minBuyQty = minBuyQty;
+				if ((this.breakUp != null) && !this.breakUp && this.minPackQty != null) {
+					double remainder = this.minBuyQty % this.minPackQty;
+					if (NumberUtil.compare(remainder, 0.0) != 0) {
+						if (Double.compare(this.minBuyQty, this.minPackQty) < 0) {
+							this.minBuyQty = this.minPackQty;
+						} else {
+							this.minBuyQty = (NumberUtil.sub(this.minBuyQty, remainder));
+						}
+					}
+				}
+			}
+		}
+	}
 }

+ 12 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/V_ProductPerson.java

@@ -280,6 +280,9 @@ public class V_ProductPerson implements Serializable{
     @Column(name = "pr_attach")
     private String attach;
 
+    @Transient
+    private Goods goods;
+
     @Transient
     private ProductAttachSubmit productAttachSubmit;
 
@@ -634,4 +637,13 @@ public class V_ProductPerson implements Serializable{
         this.attach = attach;
         return this;
     }
+
+    public Goods getGoods() {
+        return goods;
+    }
+
+    public V_ProductPerson setGoods(Goods goods) {
+        this.goods = goods;
+        return this;
+    }
 }

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

@@ -11,6 +11,7 @@ import com.uas.platform.b2c.advertise.ad.service.RecommendProductService;
 import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
 import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.common.account.service.EnterpriseService;
 import com.uas.platform.b2c.common.search.service.SearcherService;
 import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.constant.ShortConstant;
@@ -241,6 +242,9 @@ public class GoodsServiceImpl implements GoodsService {
     @Autowired
     private V_ProductPrivateService v_productPrivateService;
 
+    @Autowired
+    private EnterpriseService enterpriseService;
+
     private final Logger logger = Logger.getLogger(getClass());
 
     @Autowired
@@ -281,7 +285,7 @@ public class GoodsServiceImpl implements GoodsService {
         if (!goods.getBreakUp()) {
             if (goods.getMinPackQty() != null) {
                 if (goods.getMinBuyQty() % goods.getMinPackQty() != 0) {
-                    throw new IllegalOperatorException("最小起订量必须为最小包装量的整数倍");
+                    goods.setMinBuyQtyByMinPackQty(goods.getMinBuyQty());
                 }
             }
         }
@@ -538,6 +542,12 @@ public class GoodsServiceImpl implements GoodsService {
                     createNumberService.getTimeNumber("product$goods", 8));
             goods.setBatchCode(batchCode);
         }
+        ResultMap resultMap = enterpriseService.getCurrencyByRegisterAddress();
+        if (resultMap.getCode() == IntegerConstant.YES_INT.intValue()) {
+            goods.setCurrencyName(resultMap.getData().toString());
+        } else {
+            throw new IllegalOperatorException(resultMap.getMessage());
+        }
         goods.setCreatedDate(new Date());
         goods.setUpdateDate(goods.getCreatedDate());
         goods.setEnUU(SystemSession.getUser().getEnterprise().getUu());
@@ -1286,7 +1296,7 @@ public class GoodsServiceImpl implements GoodsService {
         }
         if (nowGoods == null) {
             //根据物料信息,生成在售产品
-            publish(goods, "NORMAL");
+            resultGoods = publish(goods, "NORMAL");
         } else {
             // 检查身份
             if (!nowGoods.getEnUU().equals(enUU)) {
@@ -1359,12 +1369,12 @@ public class GoodsServiceImpl implements GoodsService {
             ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_MIN_DELIVERY.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeMinDelivery), StringUtilB2C.valueOf(afterMinDelivery), ModifyInfo.TYPE_SALE);
             infoList.add(info);
         }
-        Integer beforeGoodsStatus = beforeGoods.getStatus();
-        Integer afterGoodsStatus = afterGoods.getStatus();
-        if (!beforeGoodsStatus.equals(afterGoodsStatus)) {
-            ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_GOODS_STATUS.getPhrase(), beforeGoods.getBatchCode(), Status.valueStringOf(beforeGoodsStatus), Status.valueStringOf(afterGoodsStatus), ModifyInfo.TYPE_SALE);
-            infoList.add(info);
-        }
+//        Integer beforeGoodsStatus = beforeGoods.getStatus();
+//        Integer afterGoodsStatus = afterGoods.getStatus();
+//        if (!beforeGoodsStatus.equals(afterGoodsStatus)) {
+//            ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_GOODS_STATUS.getPhrase(), beforeGoods.getBatchCode(), Status.valueStringOf(beforeGoodsStatus), Status.valueStringOf(afterGoodsStatus), ModifyInfo.TYPE_SALE);
+//            infoList.add(info);
+//        }
         Short beforeMaxDelivery = beforeGoods.getMaxDelivery();
         Short afterMaxDelivery = afterGoods.getMaxDelivery();
         if (!StringUtilB2C.equals(StringUtilB2C.valueOf(beforeMaxDelivery), StringUtilB2C.valueOf(afterMaxDelivery))) {
@@ -1556,10 +1566,11 @@ public class GoodsServiceImpl implements GoodsService {
     public Goods updateGoods(Goods nowGoods, Goods oldGoods) {
         nowGoods.setMaxDelivery(oldGoods.getMaxDelivery());
         nowGoods.setMinDelivery(oldGoods.getMinDelivery());
-        nowGoods.setTag(oldGoods.getTag());
+        nowGoods.setB2cMaxDelivery(null);
+        nowGoods.setB2cMinDelivery(null);
         //判断是否切换了销售方式
         Boolean isChangeSaleType = false;
-        String storeuuid = oldGoods.getStoreid();
+        String storeuuid = nowGoods.getStoreid();
         isChangeSaleType = setStoreName(nowGoods, oldGoods);
 
         if(nowGoods.getProductid() != null) {
@@ -1578,23 +1589,26 @@ public class GoodsServiceImpl implements GoodsService {
         }
 
         // 设置货到香港,货到大陆的延长时间
-        if (nowGoods.getMaxDelivery() != null) {
+        if (nowGoods.getMaxDelivery() != null || nowGoods.getMinDelivery() != null) {
             setB2CDelayTime(nowGoods);
         }
 
         nowGoods.setUpdateDate(new Date());
-        nowGoods.setMinBuyQty(oldGoods.getMinBuyQty());
         nowGoods.setBreakUp(oldGoods.getBreakUp());
+        nowGoods.setMinBuyQtyByMinPackQty(oldGoods.getMinBuyQty());
         nowGoods.setPerQty();
+        oldGoods.setCurrencyName(nowGoods.getCurrencyName());
         // 用含税单价同步未含税单价
         oldGoods.setWithOutTaxRMBPrice();
         oldGoods.setWithOutTaxUSDPrice();
         //保留六位有效数字
         oldGoods.setSixFraction();
         nowGoods.setQtyPrice(oldGoods.getQtyPrice());
+        nowGoods.adjustFragmentPrice();
         // 更新本批次最小最大价格信息
         nowGoods.setMaxAndMinPrice();
         nowGoods.setAutoPublish(oldGoods.getAutoPublish());
+        Integer oldStatus = nowGoods.getStatus();
         nowGoods.setStatus();
         ResultMap resultMap = checkGoods(nowGoods);
         if (resultMap.getCode() != CodeType.OK.code()) {
@@ -1604,13 +1618,13 @@ public class GoodsServiceImpl implements GoodsService {
                 OperateType.Update.getPhrase(), false);
         // 修改上下架状态并产生上下架历史
         goodsHistoryService.save(history);
-        if (!nowGoods.getStatus().equals(oldGoods.getStatus())) {
+        if (!nowGoods.getStatus().equals(oldStatus)) {
             GoodsHistory goodsHistory = null;
-            // 如果是下架
-            if (oldGoods.getStatus().equals(Status.REMOVED.value())) {
-                goodsHistory = goodsHistoryService.converTGoodsHist(nowGoods, OperateType.Down.getPhrase(), false);
-            } else if (oldGoods.getStatus().equals(Status.AVAILABLE.value())) {
+            //做上下架判断
+            if ((oldStatus.equals(Status.NO_SHELVE.value()) || oldStatus.equals(Status.REMOVED.value())) && (nowGoods.getStatus().equals(Status.AVAILABLE.value()) || nowGoods.getStatus().equals(Status.UNAVAILABLE.value()))) {
                 goodsHistory = goodsHistoryService.converTGoodsHist(nowGoods, OperateType.Publish.getPhrase(), false);
+            } else if ((nowGoods.getStatus().equals(Status.NO_SHELVE) || nowGoods.getStatus().equals(Status.REMOVED.value())) && (oldStatus.equals(Status.UNAVAILABLE.value()) || oldStatus.equals(Status.AVAILABLE.value()))) {
+                goodsHistory = goodsHistoryService.converTGoodsHist(nowGoods, OperateType.Down.getPhrase(), false);
             }
             if (null != goodsHistory) {
                 goodsHistoryService.save(goodsHistory);

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

@@ -320,7 +320,6 @@ public class ProductServiceImpl implements ProductService {
             LogicalExpression logicalExpression4 = PredicateUtils.or(expressions4);
             page.expression(logicalExpression4);
         }
-        long l = System.currentTimeMillis();
         Page<V_ProductPerson> productPage = v_productPersonDao.findAll(new Specification<V_ProductPerson>() {
             @Override
             public Predicate toPredicate(Root<V_ProductPerson> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
@@ -328,45 +327,46 @@ public class ProductServiceImpl implements ProductService {
                 return null;
             }
         }, page);
-        long l1 = System.currentTimeMillis();
-        System.err.println("l1 ------------- l" + (l1 - l));
         List<V_ProductPerson> productList = productPage.getContent();
         if (CollectionUtils.isNotEmpty(productList)) {
             List<Long> list = new ArrayList<>();
             for (V_ProductPerson product : productList) {
-                if ("ERP".equals(product.getSourceApp())) {
-                    ProductDetail productDetail = productDetailDao.findByProductId(product.getId());
-                    if (productDetail != null) {
+                list.add(product.getId());
+            }
+
+            List<ProductDetail> productDetails = productDetailDao.findByProductIds(list);
+            List<ProductAttachSubmit> productAttachSubmits = productAttachService.findByProductidsAndStatus(list, Status.UNAUDIT.value());
+            List<Goods> goodsList = goodsService.findByProductids(list);
+            Map<Long, List<ProductReplace>> batchGetProductReplace = batchGetProductReplace(list);
+
+            for (V_ProductPerson product : productList) {
+                // 设置ERP信息
+                for (ProductDetail productDetail : productDetails) {
+                    if ((productDetail.getProductId() != null) && (productDetail.getProductId().longValue() == product.getId().longValue())) {
                         product.setProductDetail(productDetail);
+                        break;
                     }
                 }
-                list.add(product.getId());
-            }
-            long l2 = System.currentTimeMillis();
-            System.err.println("l2 ------------- l1" + (l2 - l1));
-            if (CollectionUtils.isNotEmpty(list)) {
-                List<ProductAttachSubmit> submits = productAttachService.findByProductidsAndStatus(list, Status.UNAUDIT.value());
-                for (ProductAttachSubmit productAttachSubmit : submits) {
-                    for (V_ProductPerson product : productList) {
-                        if (product.getId().longValue() == productAttachSubmit.getProductId().longValue()) {
-                            product.setProductAttachSubmit(productAttachSubmit);
-                            break;
-                        }
+
+                // 设置规格书提交的信息
+                for (ProductAttachSubmit attachSubmit : productAttachSubmits) {
+                    if (product.getId().equals(attachSubmit.getProductId())) {
+                        product.setProductAttachSubmit(attachSubmit);
+                        break;
                     }
                 }
-                long l3 = System.currentTimeMillis();
-                System.err.println("l3 ------------- l2" + (l3 - l2));
-                Map<Long, List<ProductReplace>> batchGetProductReplace = batchGetProductReplace(list);
-                if ((batchGetProductReplace != null) && (batchGetProductReplace.size() != 0)) {
-                    for (V_ProductPerson product : productList) {
-                        List<ProductReplace> productReplaces = batchGetProductReplace.get(product.getId());
-                        if (CollectionUtils.isNotEmpty(productReplaces)) {
-                            product.setProductReplaceList(productReplaces);
-                        }
+
+                for (Goods goods : goodsList) {
+                    if (product.getId().equals(goods.getProductid())) {
+                        product.setGoods(goods);
+                        break;
                     }
                 }
-                long l4 = System.currentTimeMillis();
-                System.err.println("l4 ------------- l3" + (l4 - l3));
+
+                List<ProductReplace> productReplaces = batchGetProductReplace.get(product.getId());
+                if (CollectionUtils.isNotEmpty(productReplaces)) {
+                    product.setProductReplaceList(productReplaces);
+                }
             }
             return new PageImpl<V_ProductPerson>(productList, page, productPage.getTotalElements());
         } else {

+ 1 - 1
src/main/java/com/uas/platform/b2c/trade/order/service/impl/OrderDetailServiceImpl.java

@@ -518,7 +518,7 @@ public class OrderDetailServiceImpl implements OrderDetailService {
 			throw new IllegalOperatorException("传入的库存信息为空");
 		}
 		List<OrderDetail> orderDetailList = orderDetailDao.findByBatchCodeAndStatus(goods.getBatchCode(), Status.TOBECONFIRMED.value());
-		if(goods.getStatus().intValue() == Status.UNAVAILABLE.value() || goods.getStatus().intValue() == Status.REMOVED.value() || goods.getStatus().intValue() == Status.GOODS_DELETE.value()) {
+		if(goods.getStatus().intValue() == Status.UNAVAILABLE.value() || goods.getStatus().intValue() == Status.REMOVED.value() || goods.getStatus().intValue() == Status.GOODS_DELETE.value() || goods.getStatus().intValue() == Status.NO_SHELVE.value()) {
 			return deleteOrderDetailsByGoods(orderDetailList);
 		}else {
 			List<Order> orders = new ArrayList<>();

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

@@ -489,7 +489,6 @@ public class Cart {
 	 */
 	public void updateCartByGoods(Goods goods) {
 		this.img = goods.getImg();
-		this.pack = goods.getPackaging();
 		this.encapsulation = goods.getEncapsulation();
 		this.storeUuid = goods.getStoreid();
 		this.pack = goods.getPackaging();