Преглед изворни кода

@
fix: RuleService.toVO 兼容 conditionInfo 两种格式

- 扁平 Map: {"max_amount":"100",...} — RuleService.create 产出
- 数组: [{"rule_factor":"QUOTA_TOTAL","rule_value":"111"}] — 制度流程旧记录

新记录已改为扁平格式,旧记录不抛异常,从 QUOTA_TOTAL 提取 max_amount。
@

alphaH пре 8 часа
родитељ
комит
f51312a8a7

+ 19 - 13
java/src/main/java/com/payment/platform/module/payment/expense/rule/service/RuleService.java

@@ -168,7 +168,7 @@ public class RuleService {
             request.setBizModel(model);
 
             AlipayEbppInvoiceInstitutionExpenseruleCreateResponse response =
-                    alipayClientFactory.getClient((String) null).execute(request);
+                    alipayClientFactory.getClient(model.getEnterpriseId()).execute(request);
 
             if (!response.isSuccess()) {
                 throw new BusinessException(400, "创建使用规则失败: " +
@@ -219,7 +219,7 @@ public class RuleService {
             request.setBizModel(model);
 
             AlipayEbppInvoiceInstitutionExpenseruleModifyResponse response =
-                    alipayClientFactory.getClient((String) null).execute(request);
+                    alipayClientFactory.getClient(model.getEnterpriseId()).execute(request);
 
             if (!response.isSuccess()) {
                 throw new BusinessException(400, "修改使用规则失败: " +
@@ -265,7 +265,7 @@ public class RuleService {
             request.setBizModel(model);
 
             AlipayEbppInvoiceInstitutionExpenseruleDeleteResponse response =
-                    alipayClientFactory.getClient((String) null).execute(request);
+                    alipayClientFactory.getClient(model.getEnterpriseId()).execute(request);
 
             if (!response.isSuccess()) {
                 throw new BusinessException(400, "删除使用规则失败: " +
@@ -370,9 +370,10 @@ public class RuleService {
         vo.setUpdatedTime(e.getUpdatedTime());
         vo.setTenantId(e.getTenantId());
 
-        // 解析 conditionInfo JSON
+        // 解析 conditionInfo JSON(兼容两种格式)
         if (StrUtil.isNotBlank(e.getConditionInfo())) {
             try {
+                // 格式1: 扁平 Map {"max_amount":"100",...} — RuleService.create 产出
                 Map<String, Object> cond = objectMapper.readValue(e.getConditionInfo(), CONDITION_MAP_TYPE);
                 vo.setMaxAmount(getBigDecimal(cond, "max_amount"));
                 vo.setMaxDayAmount(getBigDecimal(cond, "max_day_amount"));
@@ -381,18 +382,23 @@ public class RuleService {
                 vo.setValidFrom(getString(cond, "valid_from"));
                 vo.setValidTo(getString(cond, "valid_to"));
                 vo.setMerchantPid(getString(cond, "merchant_pid"));
-
                 Object wd = cond.get("week_days");
-                if (wd instanceof List) {
-                    vo.setWeekDays(objectMapper.convertValue(wd, WEEK_DAYS_TYPE));
-                }
-
+                if (wd instanceof List) vo.setWeekDays(objectMapper.convertValue(wd, WEEK_DAYS_TYPE));
                 Object tr = cond.get("time_ranges");
-                if (tr instanceof List) {
-                    vo.setTimeRanges(objectMapper.convertValue(tr, TIME_RANGES_TYPE));
-                }
+                if (tr instanceof List) vo.setTimeRanges(objectMapper.convertValue(tr, TIME_RANGES_TYPE));
             } catch (Exception ex) {
-                throw new RuntimeException("反序列化规则条件失败", ex);
+                // 格式2: 数组 [{"rule_factor":"QUOTA_TOTAL","rule_value":"111"}] — 制度创建流程产出
+                try {
+                    List<Map<String, Object>> arr = objectMapper.readValue(e.getConditionInfo(),
+                            new com.fasterxml.jackson.core.type.TypeReference<List<Map<String, Object>>>() {});
+                    for (Map<String, Object> c : arr) {
+                        if ("QUOTA_TOTAL".equals(c.get("rule_factor"))) {
+                            vo.setMaxAmount(getBigDecimal(c, "rule_value"));
+                        }
+                    }
+                } catch (Exception ex2) {
+                    throw new RuntimeException("反序列化规则条件失败", ex2);
+                }
             }
         }