From 79111317e126d0ee92b7125dc41d71bb4038bd21 Mon Sep 17 00:00:00 2001
From: seatonwan9
Date: 星期二, 19 八月 2025 01:35:50 +0800
Subject: [PATCH] 产品定价

---
 src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java |   21 +++++++++++++++++----
 src/main/java/com/webmanage/entity/ProductPricing.java                  |   12 +++++++++---
 src/main/resources/mapper/ProductPricingMapper.xml                      |    5 +++--
 src/main/java/com/webmanage/emun/PriceTypeEnum.java                     |   20 ++++++++++++++++++++
 4 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/webmanage/emun/PriceTypeEnum.java b/src/main/java/com/webmanage/emun/PriceTypeEnum.java
new file mode 100644
index 0000000..5a5c607
--- /dev/null
+++ b/src/main/java/com/webmanage/emun/PriceTypeEnum.java
@@ -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;
+    }
+}
diff --git a/src/main/java/com/webmanage/entity/ProductPricing.java b/src/main/java/com/webmanage/entity/ProductPricing.java
index 7c61271..fee2c84 100644
--- a/src/main/java/com/webmanage/entity/ProductPricing.java
+++ b/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;
 
     /**
      * 鍚敤鐘舵��
diff --git a/src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java b/src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java
index f14987b..25076bf 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,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);
diff --git a/src/main/resources/mapper/ProductPricingMapper.xml b/src/main/resources/mapper/ProductPricingMapper.xml
index a9966a7..1d5398f 100644
--- a/src/main/resources/mapper/ProductPricingMapper.xml
+++ b/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>
 

--
Gitblit v1.8.0