Просмотр исходного кода

feat: MembershipService 支持 PREMIUM 等级

- canUseFeature() 新增 PREMIUM 分支,权益同 FAMILY
- createOrder() 新增 PREMIUM 定价分支,年起 ¥13,168/月起 ¥1,314
- applyMemberDiscount() 新增 PREMIUM 折扣支持,从 sys_config member_discount_premium 读取
Sisyphus 1 месяц назад
Родитель
Сommit
604bb24902

+ 29 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/MembershipService.java

@@ -157,6 +157,19 @@ public class MembershipService implements MembershipServiceInterface {
                     || "purchase_commission".equals(feature);
         }
 
+        // PREMIUM用户可用功能(同FAMILY全部权益)
+        if ("PREMIUM".equals(level)) {
+            return "free_activities".equals(feature)
+                    || "free_courses".equals(feature)
+                    || "full_price_purchase".equals(feature)
+                    || "referral_commission".equals(feature)
+                    || "discount_purchase".equals(feature)
+                    || "member_activities".equals(feature)
+                    || "create_family".equals(feature)
+                    || "invite_family".equals(feature)
+                    || "purchase_commission".equals(feature);
+        }
+
         // PROVIDER也有全部功能
         return true;
     }
@@ -240,6 +253,15 @@ public class MembershipService implements MembershipServiceInterface {
             }
             int fee = feeStr != null ? Integer.parseInt(feeStr) : 1314;
             amount = fee;
+        } else if ("PREMIUM".equals(levelCode)) {
+            // PREMIUM定价从sysConfig读取
+            if ("monthly".equals(effectivePeriod)) {
+                String feeStr = sysConfigService.getValue("member_fee_premium_monthly");
+                amount = feeStr != null ? Integer.parseInt(feeStr) : 131400;
+            } else {
+                String feeStr = sysConfigService.getValue("member_fee_premium");
+                amount = feeStr != null ? Integer.parseInt(feeStr) : 1316800;
+            }
         } else {
             // 按period从会员等级表定价
             if ("monthly".equals(effectivePeriod)) {
@@ -472,6 +494,13 @@ public class MembershipService implements MembershipServiceInterface {
                 return originalPrice * discountBps / 10000;
             }
         }
+        if ("PREMIUM".equals(level)) {
+            String discountStr = sysConfigService.getValue("member_discount_premium");
+            if (discountStr != null) {
+                int discountBps = Integer.parseInt(discountStr); // in bps
+                return originalPrice * discountBps / 10000;
+            }
+        }
         return originalPrice;
     }