| | |
| | | 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; |
| | |
| | | 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不能为空"); |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | @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); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ProductPricing> getPricingByCondition(String suiteName, String salesForm, |
| | | public List<ProductPricing> getPricingByCondition(String productId, String suiteName, String salesForm, |
| | | String customerType, String priceType, Boolean isActive) { |
| | | try { |
| | | QueryWrapper<ProductPricing> queryWrapper = new QueryWrapper<>(); |
| | | |
| | | |
| | | if (StringUtils.hasText(productId)) { |
| | | queryWrapper.like("product_id", productId); |
| | | } |
| | | |
| | | if (StringUtils.hasText(suiteName)) { |
| | | queryWrapper.like("suite_name", suiteName); |
| | | } |