seatonwan9
2025-08-19 79111317e126d0ee92b7125dc41d71bb4038bd21
产品定价
1个文件已添加
3个文件已修改
58 ■■■■ 已修改文件
src/main/java/com/webmanage/emun/PriceTypeEnum.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/entity/ProductPricing.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ProductPricingMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/emun/PriceTypeEnum.java
New file
@@ -0,0 +1,20 @@
package com.webmanage.emun;
/**
 * @ClassName PriceTypeEnum
 * @Description TODO
 * @Author wangxudong
 * @Date 2025/8/18 17:39
 * @Version 1.0
 **/
public enum PriceTypeEnum {
    POINTS("积分"),CURRENCY("货币"),AGREEMENT("协议"),FREE("免费");
    private String name;
    PriceTypeEnum(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
}
src/main/java/com/webmanage/entity/ProductPricing.java
@@ -70,10 +70,16 @@
    private String priceUnit;
    /**
     * 价格值
     * 货币价格值
     */
    @TableField("price")
    private BigDecimal price;
    @TableField("currency_price")
    private BigDecimal currencyPrice;
    /**
     * 积分价值
     */
    @TableField("points_price")
    private BigDecimal pointsPrice;
    /**
     * 启用状态
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,11 @@
            if (!StringUtils.hasText(productPricing.getPriceType())) {
                throw new BusinessException("价格设置不能为空");
            }
            if (productPricing.getPrice() == null || productPricing.getPrice().doubleValue() < 0) {
                throw new BusinessException("价格值不能为空且不能为负数");
            if (productPricing.getPointsPrice() == null || productPricing.getPointsPrice().doubleValue() < 0) {
                throw new BusinessException("积分价格值不能为空且不能为负数");
            }
            if (productPricing.getCurrencyPrice()== null || productPricing.getCurrencyPrice().doubleValue() < 0) {
                throw new BusinessException("货币价格值不能为空且不能为负数");
            }
            if (productPricing.getProductId() == null) {
                throw new BusinessException("产品ID不能为空");
@@ -96,8 +100,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);
src/main/resources/mapper/ProductPricingMapper.xml
@@ -12,7 +12,8 @@
        <result column="concurrent_nodes" property="concurrentNodes" jdbcType="VARCHAR"/>
        <result column="price_type" property="priceType" jdbcType="VARCHAR"/>
        <result column="price_unit" property="priceUnit" jdbcType="VARCHAR"/>
        <result column="price" property="price" jdbcType="NUMERIC"/>
        <result column="points_price" property="pointsPrice" jdbcType="DECIMAL"/>
        <result column="currency_price" property="currencyPrice" jdbcType="DECIMAL"/>
        <result column="is_active" property="isActive" jdbcType="BOOLEAN"/>
        <result column="product_id" property="productId" jdbcType="BIGINT"/>
        <result column="product_name" property="productName" jdbcType="VARCHAR"/>
@@ -29,7 +30,7 @@
    <!-- 基础字段 -->
    <sql id="Base_Column_List">
        id, suite_name, sales_form, customer_type, account_limit, concurrent_nodes, 
        price_type, price_unit, price, is_active, product_id, product_name, provider_id,
        price_type, price_unit, points_price,currency_price, is_active, product_id, product_name, provider_id,
        provider_name, description, created_at, updated_at, created_by, updated_by, deleted
    </sql>