|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.platform.b2c.prod.commodity.service.impl;
|
|
package com.uas.platform.b2c.prod.commodity.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.uas.platform.b2c.common.account.model.User;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
import com.uas.platform.b2c.core.utils.StringUtilB2C;
|
|
import com.uas.platform.b2c.core.utils.StringUtilB2C;
|
|
@@ -179,6 +180,7 @@ public class CommodityInOutboundServiceImpl implements CommodityInOutboundServic
|
|
|
}
|
|
}
|
|
|
prids.add(inOutboundDetail.getProductId());
|
|
prids.add(inOutboundDetail.getProductId());
|
|
|
}
|
|
}
|
|
|
|
|
+ User user = SystemSession.getUser();
|
|
|
String inOutboundId = createNumberService.generateOrderNumber(com.uas.platform.b2c.core.constant.EncodingRulesConstant.INOUTBOUND_NUM, "trade$commodity_in_outbound", 8);
|
|
String inOutboundId = createNumberService.generateOrderNumber(com.uas.platform.b2c.core.constant.EncodingRulesConstant.INOUTBOUND_NUM, "trade$commodity_in_outbound", 8);
|
|
|
CommodityInOutbound inOutbound = new CommodityInOutbound(type);
|
|
CommodityInOutbound inOutbound = new CommodityInOutbound(type);
|
|
|
inOutbound.setInOutId(inOutboundId);
|
|
inOutbound.setInOutId(inOutboundId);
|
|
@@ -188,18 +190,26 @@ public class CommodityInOutboundServiceImpl implements CommodityInOutboundServic
|
|
|
List<Product> products = productService.findByProductId(prids);
|
|
List<Product> products = productService.findByProductId(prids);
|
|
|
for (InOutboundDetail inOutboundDetail : detaiList) {
|
|
for (InOutboundDetail inOutboundDetail : detaiList) {
|
|
|
for (Product product : products) {
|
|
for (Product product : products) {
|
|
|
|
|
+ if (user.getEnterprise().getUu().longValue() != product.getEnUU().longValue()) {
|
|
|
|
|
+ throw new IllegalOperatorException("型号:" + product.getPcmpcode() + ",品牌:" +product.getPbranden()+"不属于本公司,不能做出入库");
|
|
|
|
|
+ }
|
|
|
if (inOutboundDetail.getProductId().longValue() == product.getId().longValue()) {
|
|
if (inOutboundDetail.getProductId().longValue() == product.getId().longValue()) {
|
|
|
if (InOutBoundType.INBOUND.equals(type) || InOutBoundType.OTHER_INBOUND.equals(type) || InOutBoundType.PURCHASE_INBOUND.equals(type)) {
|
|
if (InOutBoundType.INBOUND.equals(type) || InOutBoundType.OTHER_INBOUND.equals(type) || InOutBoundType.PURCHASE_INBOUND.equals(type)) {
|
|
|
|
|
+ //只有入库会影响成本单价
|
|
|
|
|
+ if (NumberUtil.compare(inOutboundDetail.getPrice(), DoubleConstant.zero) > 0 && NumberUtil.compare(product.getPrice(), DoubleConstant.zero) > 0) {
|
|
|
|
|
+ product.setPrice(NumberUtil.div(NumberUtil.add(NumberUtil.mul(product.getPrice(), product.getErpReserve()), NumberUtil.mul(inOutboundDetail.getPrice(), inOutboundDetail.getQty())), NumberUtil.add(product.getErpReserve(), inOutboundDetail.getQty())));
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
product.setErpReserve(NumberUtil.add(product.getErpReserve(), inOutboundDetail.getQty()));
|
|
product.setErpReserve(NumberUtil.add(product.getErpReserve(), inOutboundDetail.getQty()));
|
|
|
} else {
|
|
} else {
|
|
|
//出库
|
|
//出库
|
|
|
if (NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) == 0) {
|
|
if (NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) == 0) {
|
|
|
- break;
|
|
|
|
|
|
|
+ throw new IllegalOperatorException("型号:" + product.getPcmpcode() + ",品牌:" +product.getPbranden()+"的物料为0,不能做出库");
|
|
|
} else if (NumberUtil.compare(product.getErpReserve(), inOutboundDetail.getQty()) > 0) {
|
|
} else if (NumberUtil.compare(product.getErpReserve(), inOutboundDetail.getQty()) > 0) {
|
|
|
product.setErpReserve(NumberUtil.sub(product.getErpReserve(), inOutboundDetail.getQty()));
|
|
product.setErpReserve(NumberUtil.sub(product.getErpReserve(), inOutboundDetail.getQty()));
|
|
|
} else {
|
|
} else {
|
|
|
- inOutboundDetail.setQty(product.getErpReserve());
|
|
|
|
|
- product.setErpReserve(DoubleConstant.zero);
|
|
|
|
|
|
|
+ throw new IllegalOperatorException("型号:" + product.getPcmpcode() + ",品牌:" +product.getPbranden()+"的物料库存数为"+product.getErpReserve() + "出库数是:"+inOutboundDetail.getQty()+"不能做出库");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|