From 1cda9be49d77c83bdab4cfea7e3558fd4064bdb1 Mon Sep 17 00:00:00 2001 From: seatonwan9 Date: 星期四, 28 八月 2025 02:03:11 +0800 Subject: [PATCH] 更新代码 --- src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java | 32 ++++++++++++++++++++++++-------- 1 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java b/src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java index f14987b..a5a63ee 100644 --- a/src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java +++ b/src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.webmanage.common.BusinessException; +import com.webmanage.emun.PriceTypeEnum; import com.webmanage.entity.ProductPricing; import com.webmanage.mapper.ProductPricingMapper; import com.webmanage.service.ProductPricingService; @@ -47,8 +48,17 @@ if (!StringUtils.hasText(productPricing.getPriceType())) { throw new BusinessException("浠锋牸璁剧疆涓嶈兘涓虹┖"); } - if (productPricing.getPrice() == null || productPricing.getPrice().doubleValue() < 0) { - throw new BusinessException("浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); + if (productPricing.getPriceType().indexOf(PriceTypeEnum.POINTS.getName()) > -1 + && productPricing.getPointsPrice() == null || + productPricing.getPriceType().indexOf(PriceTypeEnum.POINTS.getName()) > -1 + &&productPricing.getPointsPrice().doubleValue() < 0) { + throw new BusinessException("绉垎浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); + } + if (productPricing.getPriceType().indexOf(PriceTypeEnum.CURRENCY.getName()) > -1 + && productPricing.getCurrencyPrice()== null || + productPricing.getPriceType().indexOf(PriceTypeEnum.CURRENCY.getName()) > -1 + && productPricing.getCurrencyPrice().doubleValue() < 0){ + throw new BusinessException("璐у竵浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); } if (productPricing.getProductId() == null) { throw new BusinessException("浜у搧ID涓嶈兘涓虹┖"); @@ -96,8 +106,17 @@ if (!StringUtils.hasText(productPricing.getPriceType())) { throw new BusinessException("浠锋牸璁剧疆涓嶈兘涓虹┖"); } - if (productPricing.getPrice() == null || productPricing.getPrice().doubleValue() < 0) { - throw new BusinessException("浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); + if (productPricing.getPriceType().indexOf(PriceTypeEnum.POINTS.getName()) > -1 + && productPricing.getPointsPrice() == null || + productPricing.getPriceType().indexOf(PriceTypeEnum.POINTS.getName()) > -1 + &&productPricing.getPointsPrice().doubleValue() < 0) { + throw new BusinessException("绉垎浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); + } + if (productPricing.getPriceType().indexOf(PriceTypeEnum.CURRENCY.getName()) > -1 + && productPricing.getCurrencyPrice()== null || + productPricing.getPriceType().indexOf(PriceTypeEnum.CURRENCY.getName()) > -1 + && productPricing.getCurrencyPrice().doubleValue() < 0) { + throw new BusinessException("璐у竵浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); } boolean result = updateById(productPricing); @@ -143,11 +162,8 @@ } @Override - public List<ProductPricing> getPricingByProductId(Long productId) { + public List<ProductPricing> getPricingByProductId(String productId) { try { - if (productId == null) { - throw new BusinessException("浜у搧ID涓嶈兘涓虹┖"); - } return baseMapper.selectByProductId(productId); } catch (Exception e) { log.error("鏍规嵁浜у搧ID鏌ヨ瀹氫环澶辫触: ", e); -- Gitblit v1.8.0