From ad5db85e540947e82c7a4d5612879b3b3ecdf459 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期五, 21 八月 2026 10:38:07 +0800
Subject: [PATCH] update

---
 backend/src/main/java/com/tourguide/common/huifu/biz/DouGongBasicDataBiz.java |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 108 insertions(+), 7 deletions(-)

diff --git a/backend/src/main/java/com/tourguide/common/huifu/biz/DouGongBasicDataBiz.java b/backend/src/main/java/com/tourguide/common/huifu/biz/DouGongBasicDataBiz.java
index eb2df3d..0518339 100644
--- a/backend/src/main/java/com/tourguide/common/huifu/biz/DouGongBasicDataBiz.java
+++ b/backend/src/main/java/com/tourguide/common/huifu/biz/DouGongBasicDataBiz.java
@@ -76,6 +76,19 @@
         log.info("个人用户基本信息开户返回参数:{}", response);
         return response;
     }
+
+    /** 企业用户基础资料进件。 */
+    public Map<String, Object> userBasicDataEnt(DouGongUserWithdrawalProfile userWithdrawal) throws Exception {
+        DouGongRequestSupport.initBasePay(huiFuProperties);
+        Map<String, Object> paramsInfo = enterpriseParams(userWithdrawal);
+        paramsInfo.put("req_seq_id", DouGongRequestSupport.generateForHuiFu());
+        paramsInfo.put("req_date", DouGongRequestSupport.todayForHuiFu());
+        log.info("企业用户基本信息开户请求参数:{}", paramsInfo);
+        Map<String, Object> response = BasePayRequest.requestBasePay(
+                "v2/user/basicdata/ent", paramsInfo, null, false);
+        log.info("企业用户基本信息开户返回参数:{}", response);
+        return response;
+    }
     /**
      * 个人用户基本信息修改
      * @return
@@ -113,6 +126,39 @@
         // 3. 发起API调用
         Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/basicdata/indv/modify", paramsInfo, null, false);
         log.info("个人用户基本信息修改返回参数:{}", response);
+        return response;
+    }
+
+    /** 企业用户基础资料修改,用于审核驳回后的重新提交。 */
+    public Map<String, Object> userBasicDataEntModify(DouGongUserWithdrawalProfile userWithdrawal) throws Exception {
+        DouGongRequestSupport.initBasePay(huiFuProperties);
+        Map<String, Object> paramsInfo = enterpriseParams(userWithdrawal);
+        paramsInfo.put("req_seq_id", DouGongRequestSupport.generateForHuiFu());
+        paramsInfo.put("req_date", DouGongRequestSupport.todayForHuiFu());
+        paramsInfo.put("huifu_id", userWithdrawal.getHuifuId());
+        log.info("企业用户基本信息修改请求参数:{}", paramsInfo);
+        Map<String, Object> response = BasePayRequest.requestBasePay(
+                "v2/user/basicdata/ent/modify", paramsInfo, null, false);
+        log.info("企业用户基本信息修改返回参数:{}", response);
+        return response;
+    }
+
+    /** 查询个人或企业用户的进件申请状态。 */
+    public Map<String, Object> userApplyQuery(DouGongUserWithdrawalProfile userWithdrawal,
+                                               String applyNo) throws Exception {
+        if (applyNo == null || applyNo.trim().isEmpty() || applyNo.trim().length() > 18) {
+            throw new IllegalArgumentException("斗拱进件状态查询申请单号不能为空且长度不能超过18个字符");
+        }
+        DouGongRequestSupport.initBasePay(huiFuProperties);
+        Map<String, Object> paramsInfo = new HashMap<>();
+        paramsInfo.put("huifu_id", userWithdrawal.getHuifuId());
+        paramsInfo.put("req_seq_id", DouGongRequestSupport.generateForHuiFu());
+        paramsInfo.put("req_date", DouGongRequestSupport.todayForHuiFu());
+        paramsInfo.put("apply_no", applyNo.trim());
+        log.info("用户进件申请状态查询请求参数:{}", paramsInfo);
+        Map<String, Object> response = BasePayRequest.requestBasePay(
+                "v2/user/apply/query", paramsInfo, null, false);
+        log.info("用户进件申请状态查询返回参数:{}", response);
         return response;
     }
     /**
@@ -266,13 +312,68 @@
         // 3. 发起API调用
         Map<String, Object> response = BasePayRequest.requestBasePay("v2/trade/acctpayment/balance/query", paramsInfo, null, false);
         log.info("账户余额信息查询返回参数:{}", response);
-        String string = response.get("acctInfo_list").toString();
-        JSONArray accountList = JSONArray.parseArray(string);
-        if (accountList != null && !accountList.isEmpty()) {
-            JSONObject acctInfo = accountList.getJSONObject(0);
-            log.info("账户余额信息查询返回余额:{}", acctInfo.getString("avail_bal"));
-            return acctInfo.getBigDecimal("avail_bal");
+        return availableBalance(response);
+    }
+
+    static BigDecimal availableBalance(Map<String, Object> response) {
+        if (response == null) return BigDecimal.ZERO;
+        Object accountData = response.get("acctInfo_list");
+        if (accountData == null) accountData = response.get("acct_info_list");
+        if (accountData == null) return BigDecimal.ZERO;
+        JSONArray accountList = accountData instanceof JSONArray
+                ? (JSONArray) accountData
+                : JSONArray.parseArray(accountData instanceof String
+                ? (String) accountData : JSONObject.toJSONString(accountData));
+        if (accountList == null || accountList.isEmpty()) return BigDecimal.ZERO;
+        JSONObject acctInfo = accountList.getJSONObject(0);
+        if (acctInfo == null || acctInfo.get("avail_bal") == null) return BigDecimal.ZERO;
+        BigDecimal balance = acctInfo.getBigDecimal("avail_bal");
+        return balance == null ? BigDecimal.ZERO : balance;
+    }
+
+    private Map<String, Object> enterpriseParams(DouGongUserWithdrawalProfile profile) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("reg_name", profile.getEnterpriseName());
+        params.put("license_code", profile.getCreditCode());
+        params.put("license_validity_type", validityType(profile.getLicenseValidityType()));
+        params.put("license_begin_date", compactDate(profile.getLicenseBeginDate()));
+        putFixedEndDate(params, "license_end_date", profile.getLicenseValidityType(), profile.getLicenseEndDate());
+        params.put("reg_prov_id", profile.getRegisteredProvinceCode());
+        params.put("reg_area_id", profile.getRegisteredCityCode());
+        params.put("reg_district_id", profile.getRegisteredDistrictCode());
+        params.put("reg_detail", profile.getRegisteredAddress());
+        params.put("legal_name", profile.getCertificateName());
+        params.put("legal_cert_type", "00");
+        params.put("legal_cert_no", profile.getCertificateCode());
+        String[] certificateDates = certificateDates(profile.getCertificateExpireTime());
+        params.put("legal_cert_validity_type", "长期".equals(certificateDates[1]) ? "1" : "0");
+        params.put("legal_cert_begin_date", compactDate(certificateDates[0]));
+        if (!"长期".equals(certificateDates[1])) {
+            params.put("legal_cert_end_date", compactDate(certificateDates[1]));
         }
-        return BigDecimal.ZERO;
+        params.put("legal_cert_nationality", "CHN");
+        params.put("contact_name", profile.getContactName());
+        params.put("contact_mobile", profile.getPhone());
+        return params;
+    }
+
+    private String validityType(String value) {
+        return "long_term".equals(value) ? "1" : "0";
+    }
+
+    private void putFixedEndDate(Map<String, Object> params, String key, String validityType, String value) {
+        if (!"long_term".equals(validityType) && value != null && !value.trim().isEmpty()) {
+            params.put(key, compactDate(value));
+        }
+    }
+
+    private String compactDate(String value) {
+        return value == null ? null : value.replace("-", "");
+    }
+
+    private String[] certificateDates(String value) {
+        String normalized = value == null ? "" : value.replace(",", ",");
+        String[] values = normalized.split(",", -1);
+        return values.length >= 2 ? values : new String[]{normalized, "长期"};
     }
 }

--
Gitblit v1.7.1