|
|
@@ -50,6 +50,7 @@ import com.uas.platform.b2c.trade.order.dao.ProofingDao;
|
|
|
import com.uas.platform.b2c.trade.order.dao.PurchaseDetailDao;
|
|
|
import com.uas.platform.b2c.trade.order.model.Order;
|
|
|
import com.uas.platform.b2c.trade.order.model.OrderDetail;
|
|
|
+import com.uas.platform.b2c.trade.order.model.PurchaseDetail;
|
|
|
import com.uas.platform.b2c.trade.order.model.TradeProofing;
|
|
|
import com.uas.platform.b2c.trade.order.service.OrderDetailService;
|
|
|
import com.uas.platform.b2c.trade.order.service.OrderService;
|
|
|
@@ -4243,4 +4244,63 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据销售单明细,获取物料信息
|
|
|
+ *
|
|
|
+ * @param detail 销售单明细
|
|
|
+ * @return Product
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Product getProductByPurchaseDetail(PurchaseDetail detail) {
|
|
|
+ if (detail == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Product product = productService.getProductByProductNumAndProductid(detail.getGoodsnumber(), detail.getProductid());
|
|
|
+ if (product != null) {
|
|
|
+ return product;
|
|
|
+ }
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(detail.getBatchCode())) {
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryDao.findNewByBatchCode(detail.getBatchCode());
|
|
|
+ if (goodsHistory != null) {
|
|
|
+ product = productService.getProductByProductNumAndProductid(goodsHistory.getProdNum(), goodsHistory.getProductid());
|
|
|
+ } else {
|
|
|
+ product = productService.getProductByEnuuAndCodeAndBrand(detail.getPurchase().getSellerenuu(), detail.getCmpCode(), detail.getBrName());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ product = productService.getProductByEnuuAndCodeAndBrand(detail.getPurchase().getSellerenuu(), detail.getCmpCode(), detail.getBrName());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (product != null) {
|
|
|
+ if (StringUtils.isEmpty(detail.getGoodsnumber())) {
|
|
|
+ detail.setGoodsnumber(product.getProdNum());
|
|
|
+ }
|
|
|
+ if (detail.getProductid() == null) {
|
|
|
+ detail.setProductid(product.getId());
|
|
|
+ }
|
|
|
+ List<Goods> goodsList = goodsDao.findByEnUUAndCodeAndBrandNameEn(detail.getPurchase().getSellerenuu(), detail.getCmpCode(), detail.getBrName());
|
|
|
+ List<Goods> goodses = new ArrayList<>();
|
|
|
+ List<GoodsHistory> goodsHistoryList = new ArrayList<>();
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
+ if (StringUtils.isEmpty(goods.getProdNum()) || goods.getProductid() == null) {
|
|
|
+ if (goods.getProductid() == null) {
|
|
|
+ product.setErpReserve(NumberUtil.add(product.getErpReserve(), goods.getReserve()));
|
|
|
+ }
|
|
|
+ goods.setProdNum(product.getProdNum());
|
|
|
+ goods.setProductid(product.getId());
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.Update.getPhrase(), Boolean.FALSE);
|
|
|
+ goodsHistoryList.add(goodsHistory);
|
|
|
+ goodses.add(goods);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(goodses)) {
|
|
|
+ goodsDao.save(goodses);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsHistoryList)) {
|
|
|
+ goodsHistoryService.save(goodsHistoryList);
|
|
|
+ }
|
|
|
+ product = productDao.save(product);
|
|
|
+ }
|
|
|
+ return product;
|
|
|
+ }
|
|
|
}
|