|
@@ -297,25 +297,27 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
|
|
|
|
|
|
|
BigDecimal materialPrice = BigDecimal.ZERO;
|
|
BigDecimal materialPrice = BigDecimal.ZERO;
|
|
- List<Long> mIds;
|
|
+ List<ProductBomDetail> productBomDetailList = new ArrayList<>();
|
|
if (ObjectUtil.isNotEmpty(id)) {
|
|
if (ObjectUtil.isNotEmpty(id)) {
|
|
- mIds = productBomDetailService.listObject(ProductBomDetail::getProductId, q -> q
|
|
+ productBomDetailList = productBomDetailService.list(q -> q.eq(ProductBomDetail::getProductId, id));
|
|
- .eq(ProductBomDetail::getProductId, id)
|
|
|
|
- );
|
|
|
|
} else {
|
|
} else {
|
|
- mIds = Arrays.asList(productInfo.getRawMaterialId());
|
|
+ ProductBomDetail productBomDetail = new ProductBomDetail();
|
|
|
|
+ productBomDetail.setMaterialId(productInfo.getRawMaterialId());
|
|
|
|
+ productBomDetail.setType(1);
|
|
|
|
+ productBomDetail.setQuantity(BigDecimal.ONE);
|
|
|
|
+ productBomDetailList.add(productBomDetail);
|
|
}
|
|
}
|
|
|
|
|
|
- List<ProductInfo> list = this.list(q -> q.in(ProductInfo::getId, mIds));
|
|
+ for (ProductBomDetail productBomDetail : productBomDetailList) {
|
|
- for (ProductInfo materialInfo : list) {
|
|
+ ProductInfo materialInfo = this.getById(productBomDetail.getMaterialId());
|
|
if (ObjectUtil.equals(materialInfo.getClass(), 100)) {
|
|
if (ObjectUtil.equals(materialInfo.getClass(), 100)) {
|
|
-
|
|
+
|
|
BigDecimal multiply = length.multiply(width).multiply(materialInfo.getPrice());
|
|
BigDecimal multiply = length.multiply(width).multiply(materialInfo.getPrice());
|
|
materialPrice = materialPrice.add(multiply);
|
|
materialPrice = materialPrice.add(multiply);
|
|
} else {
|
|
} else {
|
|
-
|
|
+
|
|
- materialPrice = materialPrice.add(materialInfo.getPrice());
|
|
+ BigDecimal multiply = productBomDetail.getQuantity().multiply(materialInfo.getPrice());
|
|
-
|
|
+ materialPrice = materialPrice.add(multiply);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -333,31 +335,33 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.equals(productInfoDto.getDefinition(), 2)) {
|
|
if (ObjectUtil.equals(productInfoDto.getDefinition(), 2)) {
|
|
- List<Long> pIds = productBomDetailService.listObject(ProductBomDetail::getProductId, q -> q
|
|
+ List<ProductBomDetail> productBomDetailList = productBomDetailService.list(q -> q
|
|
.eq(ProductBomDetail::getMaterialId, productInfoDto.getId())
|
|
.eq(ProductBomDetail::getMaterialId, productInfoDto.getId())
|
|
);
|
|
);
|
|
|
|
|
|
- if (ObjectUtil.isNotEmpty(pIds)) {
|
|
+
|
|
- List<ProductInfo> productInfoList = this.listByIds(pIds);
|
|
+ ProductInfo materialInfo = this.getById(productInfoDto.getId());
|
|
- for (ProductInfo productInfo : productInfoList) {
|
|
+ BigDecimal oldPrice = materialInfo.getPrice();
|
|
- ProductInfo materialInfo = this.getById(productInfoDto.getId());
|
|
+ BigDecimal newPrice = productInfoDto.getPrice();
|
|
|
|
|
|
- BigDecimal oldPrice = materialInfo.getPrice();
|
|
+ for (ProductBomDetail productBomDetail : productBomDetailList) {
|
|
- BigDecimal newPrice = productInfoDto.getPrice();
|
|
+ ProductInfo productInfo = this.getById(productBomDetail.getProductId());
|
|
|
|
|
|
- if (ObjectUtil.equals(materialInfo.getClass(), 100)) {
|
|
+ if (ObjectUtil.equals(materialInfo.getClass(), 100)) {
|
|
- oldPrice = productInfo.getLength().multiply(productInfo.getWidth()).multiply(oldPrice);
|
|
+ oldPrice = productInfo.getLength().multiply(productInfo.getWidth()).multiply(oldPrice);
|
|
- newPrice = productInfo.getLength().multiply(productInfo.getWidth()).multiply(newPrice);
|
|
+ newPrice = productInfo.getLength().multiply(productInfo.getWidth()).multiply(newPrice);
|
|
- }
|
|
+ } else {
|
|
-
|
|
+ oldPrice = oldPrice.multiply(productBomDetail.getQuantity());
|
|
- BigDecimal subtract = newPrice.subtract(oldPrice);
|
|
+ newPrice = newPrice.multiply(productBomDetail.getQuantity());
|
|
- this.update(q -> q
|
|
|
|
- .in(ProductInfo::getId, productInfo.getId())
|
|
|
|
- .setSql("price = price + " + subtract)
|
|
|
|
- .set(BasePo::getUpdateTime, new Date())
|
|
|
|
- .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
|
- );
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ BigDecimal subtract = newPrice.subtract(oldPrice);
|
|
|
|
+ this.update(q -> q
|
|
|
|
+ .in(ProductInfo::getId, productInfo.getId())
|
|
|
|
+ .setSql("price = price + " + subtract)
|
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -449,20 +453,12 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
private void editFtpFile(ProductInfoDto productInfoDto) {
|
|
private void editFtpFile(ProductInfoDto productInfoDto) {
|
|
|
|
|
|
String prodImgTempPath = productInfoDto.getProdImgPath();
|
|
String prodImgTempPath = productInfoDto.getProdImgPath();
|
|
-
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(prodImgTempPath) && prodImgTempPath.startsWith("/temp")) {
|
|
if (ObjectUtil.isNotEmpty(prodImgTempPath) && prodImgTempPath.startsWith("/temp")) {
|
|
String prodImgPath = String.format("/product/prodImg/%s", productInfoDto.getId());
|
|
String prodImgPath = String.format("/product/prodImg/%s", productInfoDto.getId());
|
|
JSONObject prodImgJson = ftpFileService.moveFolder(prodImgTempPath, prodImgPath);
|
|
JSONObject prodImgJson = ftpFileService.moveFolder(prodImgTempPath, prodImgPath);
|
|
productInfoDto.setProdImgPath(prodImgJson.getString("path"));
|
|
productInfoDto.setProdImgPath(prodImgJson.getString("path"));
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|