傅行帆 пре 5 година
родитељ
комит
8aed6817df

+ 25
- 5
src/main/java/com/huiju/estateagents/eContract/service/impl/TaCompanySealUtil.java Прегледај датотеку

@@ -3,11 +3,15 @@ package com.huiju.estateagents.eContract.service.impl;
3 3
 import com.fadada.sdk.client.FddClientBase;
4 4
 import com.fadada.sdk.util.crypt.FddEncryptTool;
5 5
 import com.fadada.sdk.util.http.HttpsUtil;
6
+import com.huiju.estateagents.common.StringUtils;
6 7
 import com.huiju.estateagents.config.FadadaProperties;
8
+import com.huiju.estateagents.entity.TaMiniapp;
9
+import com.huiju.estateagents.mapper.TaMiniappMapper;
7 10
 import org.apache.http.message.BasicNameValuePair;
8 11
 import org.springframework.beans.factory.annotation.Autowired;
9 12
 import org.springframework.stereotype.Component;
10 13
 
14
+import java.io.File;
11 15
 import java.util.ArrayList;
12 16
 import java.util.HashMap;
13 17
 import java.util.Map;
@@ -18,8 +22,11 @@ public class TaCompanySealUtil {
18 22
     @Autowired
19 23
     private FadadaProperties fadadaProperties;
20 24
 
25
+    @Autowired
26
+    private TaMiniappMapper taMiniappMapper;
27
+
21 28
     public String addSignaTure(String customerId, String imgUrl) throws Exception {
22
-        FddClientBase base = new FddClientBase(fadadaProperties.getAppId(), fadadaProperties.getAppSecret(), fadadaProperties.getVersion(), fadadaProperties.getServeHost());
29
+        FddClientBase base = new FddClientBase(fadadaProperties.getAppId(), fadadaProperties.getAppSecret(), fadadaProperties.getVersion(), getFddServerHost(miniappId,fadadaProperties.getServeHost()));
23 30
         String base64Url = FddEncryptTool.ImageToBase64ByOnline(imgUrl);
24 31
         return base.invokeaddSignature(customerId, base64Url);
25 32
     }
@@ -44,7 +51,7 @@ public class TaCompanySealUtil {
44 51
             throw new RuntimeException(var7);
45 52
         }
46 53
 
47
-        return HttpsUtil.doPost(fadadaProperties.getServeHost() + "replace_signature.api", params);
54
+        return HttpsUtil.doPost(getFddServerHost(miniappId,fadadaProperties.getServeHost()) + "replace_signature.api", params);
48 55
     }
49 56
 
50 57
     public String delSignature(String customerId, String signatureId){
@@ -65,14 +72,14 @@ public class TaCompanySealUtil {
65 72
             throw new RuntimeException(var7);
66 73
         }
67 74
 
68
-        return HttpsUtil.doPost(fadadaProperties.getServeHost() + "remove_signature.api", params);
75
+        return HttpsUtil.doPost(getFddServerHost(miniappId,fadadaProperties.getServeHost()) + "remove_signature.api", params);
69 76
     }
70 77
 
71 78
     public String autoAuthCompanySeal(String transactionId, Integer authType, String contractId, String customerId, String companyId) throws Exception {
72 79
         String timeStamp = HttpsUtil.getTimeStamp();
73 80
         String sha1 = FddEncryptTool.sha1(fadadaProperties.getAppId() + FddEncryptTool.md5Digest(transactionId + timeStamp) + FddEncryptTool.sha1(fadadaProperties.getAppSecret() + customerId));
74 81
         String msgDigest = new String(FddEncryptTool.Base64Encode(sha1.getBytes()));
75
-        StringBuilder stringBuilder = new StringBuilder(fadadaProperties.getServeHost() + "before_authsign.api?");
82
+        StringBuilder stringBuilder = new StringBuilder(getFddServerHost(miniappId,fadadaProperties.getServeHost()) + "before_authsign.api?");
76 83
         stringBuilder.append("app_id="+fadadaProperties.getAppId()+"&");
77 84
         stringBuilder.append("customer_id="+customerId+"&");
78 85
         stringBuilder.append("timestamp="+timeStamp+"&");
@@ -104,6 +111,19 @@ public class TaCompanySealUtil {
104 111
             throw new RuntimeException(var7);
105 112
         }
106 113
 
107
-        return HttpsUtil.doPost(fadadaProperties.getServeHost() + "get_auth_status.api", params);
114
+        return HttpsUtil.doPost(getFddServerHost(miniappId,fadadaProperties.getServeHost()) + "get_auth_status.api", params);
115
+    }
116
+
117
+    /**
118
+     * 替换法大大服务器地址
119
+     * @return
120
+     */
121
+    private String getFddServerHost(String miniappId,String subUrl) {
122
+        TaMiniapp taMiniapp = taMiniappMapper.selectById(miniappId);
123
+        int index = subUrl.indexOf(File.separator);
124
+        int twoIndex = subUrl.indexOf(File.separator,index);
125
+        int threeIndex = subUrl.indexOf(File.separator,twoIndex);
126
+        String newUrl = StringUtils.isEmpty(taMiniapp.getFddServerHost()) ? subUrl : taMiniapp.getFddServerHost() + subUrl.substring(threeIndex);
127
+        return newUrl;
108 128
     }
109 129
 }

+ 3
- 3
src/main/java/com/huiju/estateagents/eContract/service/impl/TaCompanyServiceImpl.java Прегледај датотеку

@@ -64,7 +64,7 @@ public class TaCompanyServiceImpl extends ServiceImpl<TaCompanyMapper, TaCompany
64 64
     public TaCompany newFirstCompanyInfo() throws Exception {
65 65
         log.info("========法大大企业注册=======");
66 66
         //在法大大注册企业用户
67
-        FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
67
+        FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fddServerHost);
68 68
         String open_id = "CJ_" + HttpsUtil.getTimeStamp();
69 69
         String account_type = CommConstant.ACCOUNT_TYPE_COMPANY;
70 70
         String result =base.invokeregisterAccount(open_id,account_type);
@@ -103,7 +103,7 @@ public class TaCompanyServiceImpl extends ServiceImpl<TaCompanyMapper, TaCompany
103 103
         }
104 104
         log.info("正在申请企业认证,客户编码是{}",taCompany.getFadadaCode());
105 105
         //和法大大申请认证页面
106
-        GetCompanyVerifyUrl comverify = new GetCompanyVerifyUrl(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
106
+        GetCompanyVerifyUrl comverify = new GetCompanyVerifyUrl(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fddServerHost);
107 107
         //客户编号必填
108 108
         String customer_id = taCompany.getFadadaCode();
109 109
         /**
@@ -152,7 +152,7 @@ public class TaCompanyServiceImpl extends ServiceImpl<TaCompanyMapper, TaCompany
152 152
     public TaCompany updateCompanyInfoByFdd(Integer id) throws Exception {
153 153
         TaCompany taCompany = taCompanyMapper.selectById(id);
154 154
         log.info("企业正在从法大大获取最新数据,企业编号是 {}", taCompany.getFadadaCode());
155
-        FindCertInfo personCertInfo = new FindCertInfo(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
155
+        FindCertInfo personCertInfo = new FindCertInfo(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fddServerHost);
156 156
         String verified_serialno = taCompany.getCertifiedSerialNumber();
157 157
         String result = personCertInfo.invokeFindPersonCert(verified_serialno, CommConstant.ACCOUNT_TYPE_COMPANY);
158 158
         log.info("企业最新数据结果 {}",result);

+ 22
- 2
src/main/java/com/huiju/estateagents/eContract/service/impl/TaContractServiceImpl.java Прегледај датотеку

@@ -10,6 +10,7 @@ import com.fadada.sdk.test.util.ConfigUtil;
10 10
 import com.fadada.sdk.util.http.HttpsUtil;
11 11
 import com.huiju.estateagents.base.ResponseBean;
12 12
 import com.huiju.estateagents.bo.request.ContractRecordRequestBO;
13
+import com.huiju.estateagents.common.StringUtils;
13 14
 import com.huiju.estateagents.config.FadadaProperties;
14 15
 import com.huiju.estateagents.eContract.entity.TaContract;
15 16
 import com.huiju.estateagents.eContract.entity.TaContractBusiness;
@@ -18,8 +19,10 @@ import com.huiju.estateagents.eContract.mapper.TaContractMapper;
18 19
 import com.huiju.estateagents.eContract.mapper.TaContractUserMapper;
19 20
 import com.huiju.estateagents.eContract.service.ITaContractService;
20 21
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
22
+import com.huiju.estateagents.entity.TaMiniapp;
21 23
 import com.huiju.estateagents.entity.TaPerson;
22 24
 import com.huiju.estateagents.entity.TaRaiseRecord;
25
+import com.huiju.estateagents.mapper.TaMiniappMapper;
23 26
 import com.huiju.estateagents.mapper.TaOrgMapper;
24 27
 import com.huiju.estateagents.mapper.TaRaiseRecordMapper;
25 28
 import lombok.extern.slf4j.Slf4j;
@@ -27,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
27 30
 import org.springframework.stereotype.Service;
28 31
 import org.springframework.transaction.annotation.Transactional;
29 32
 
33
+import java.io.File;
30 34
 import java.time.LocalDate;
31 35
 import java.time.LocalDateTime;
32 36
 import java.util.Map;
@@ -58,6 +62,9 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
58 62
     @Autowired
59 63
     private TaContractUserMapper taContractUserMapper;
60 64
 
65
+    @Autowired
66
+    private TaMiniappMapper taMiniappMapper;
67
+
61 68
 
62 69
     @Override
63 70
     public ResponseBean listContractForAdmin(Integer pageNum, Integer pageSize, String contractName, Boolean archives, String signatoryName, Integer signatoryStatus, String customerName, Integer customerStatus, LocalDate archivesStartDate, LocalDate archivesEndDate, Integer orgId) {
@@ -114,7 +121,7 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
114 121
         taContractMapper.insert(taContract);
115 122
 
116 123
         //上传合同
117
-        FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
124
+        FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),getFddServerHost(person.getMiniappId(),fadadaProperties.getServeHost()));
118 125
         String result = base.invokeUploadDocs(taContract.getContractId().toString(), taContractBusiness.getContractTemplateName(), null, taContractBusiness.getContractTemplateAddress(), ".pdf");
119 126
         JSONObject jsonObject = JSONObject.parseObject(result);
120 127
         if (!jsonObject.getInteger("code").equals("1000")){
@@ -149,6 +156,19 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
149 156
         return taContract;
150 157
     }
151 158
 
159
+    /**
160
+     * 替换法大大服务器地址
161
+     * @return
162
+     */
163
+    private String getFddServerHost(String miniappId,String subUrl) {
164
+        TaMiniapp taMiniapp = taMiniappMapper.selectById(miniappId);
165
+        int index = subUrl.indexOf(File.separator);
166
+        int twoIndex = subUrl.indexOf(File.separator,index);
167
+        int threeIndex = subUrl.indexOf(File.separator,twoIndex);
168
+        String newUrl = StringUtils.isEmpty(taMiniapp.getFddServerHost()) ? subUrl : taMiniapp.getFddServerHost() + subUrl.substring(threeIndex);
169
+        return newUrl;
170
+    }
171
+
152 172
     /**
153 173
      * 手动签署合同
154 174
      *
@@ -173,7 +193,7 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
173 193
         String timeStamp = HttpsUtil.getTimeStamp();
174 194
         String transaction_id = "TRAN_" + timeStamp;
175 195
 
176
-        FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
196
+        FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),getFddServerHost(person.getMiniappId(),fadadaProperties.getServeHost()));
177 197
         ExtsignReq req = new ExtsignReq();
178 198
         req.setCustomer_id(taContractUser.getFadadaCode());
179 199
         req.setTransaction_id(transaction_id);

+ 27
- 6
src/main/java/com/huiju/estateagents/eContract/service/impl/TaContractUserServiceImpl.java Прегледај датотеку

@@ -7,19 +7,23 @@ import com.fadada.sdk.client.FddClientBase;
7 7
 import com.fadada.sdk.client.authForfadada.FindCertInfo;
8 8
 import com.fadada.sdk.client.authForfadada.GetPersonVerifyUrl;
9 9
 import com.huiju.estateagents.common.CommConstant;
10
+import com.huiju.estateagents.common.StringUtils;
10 11
 import com.huiju.estateagents.config.FadadaProperties;
11 12
 import com.huiju.estateagents.eContract.entity.TaContractUser;
12 13
 import com.huiju.estateagents.eContract.mapper.TaContractUserMapper;
13 14
 import com.huiju.estateagents.eContract.service.ITaContractUserService;
14 15
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
16
+import com.huiju.estateagents.entity.TaMiniapp;
15 17
 import com.huiju.estateagents.entity.TaPerson;
16 18
 import com.huiju.estateagents.entity.TaRaiseRecord;
19
+import com.huiju.estateagents.mapper.TaMiniappMapper;
17 20
 import jodd.util.URLDecoder;
18 21
 import lombok.extern.slf4j.Slf4j;
19 22
 import org.apache.commons.codec.binary.Base64;
20 23
 import org.springframework.beans.factory.annotation.Autowired;
21 24
 import org.springframework.stereotype.Service;
22 25
 
26
+import java.io.File;
23 27
 import java.time.LocalDateTime;
24 28
 
25 29
 /**
@@ -39,6 +43,9 @@ public class TaContractUserServiceImpl extends ServiceImpl<TaContractUserMapper,
39 43
 
40 44
     @Autowired
41 45
     private TaContractUserMapper taContractUserMapper;
46
+
47
+    @Autowired
48
+    private TaMiniappMapper taMiniappMapper;
42 49
     /**
43 50
      * 小程序端首次签署合同的是要在法大大处创建账号
44 51
      *
@@ -59,7 +66,7 @@ public class TaContractUserServiceImpl extends ServiceImpl<TaContractUserMapper,
59 66
         //没有法大大账号的先注册
60 67
         log.info("========法大大个人注册=======");
61 68
         //在法大大注册个人用户
62
-        FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
69
+        FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),getFddServerHost(person.getMiniappId(),fadadaProperties.getServeHost()));
63 70
         //小程序open——id为注册账号
64 71
         String open_id = person.getMiniOpenid();
65 72
         //account_type 1是个人注册
@@ -81,22 +88,23 @@ public class TaContractUserServiceImpl extends ServiceImpl<TaContractUserMapper,
81 88
         newContractUser.setOrgId(CommConstant.STATUS_UNACCALIMED);
82 89
 
83 90
         log.info("正在申请个人认证,客户编码是{}",jsonObject.getString("data"));
84
-        GetPersonVerifyUrl personverify = new GetPersonVerifyUrl(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
91
+        GetPersonVerifyUrl personverify = new GetPersonVerifyUrl(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),getFddServerHost(person.getMiniappId(),fadadaProperties.getServeHost()));
85 92
         String customer_id = jsonObject.getString("data");
86
-        String verifyed_way = "1";//三要素补充方案
93
+        //0:三要素标准方案; 1:三要素补充方案;
94
+        String verifyed_way = "0";
87 95
         String page_modify = "1";
88 96
         String notify_url = fadadaProperties.getCompanyNotify();
89 97
         String return_url= "/onlineSelling/pages/raiseMoney/Certification?id=" + taRaiseRecord.getRaiseRecordId();
90 98
         String customer_ident_type = "0";
91 99
         String personResult = personverify.invokePersonVerifyUrl(customer_id,verifyed_way,
92 100
                 page_modify,notify_url,return_url,null,customer_ident_type,
93
-                null,null,null,null,null);
101
+                null,null,null,"1",null);
94 102
 
95 103
         String data = JSON.parseObject(personResult).getString("data");
96 104
         if (null !=data){
97 105
             String url = JSON.parseObject(data).getString("url");
98 106
             url = decode(url);
99
-            newContractUser.setCertifiedAddress(url);
107
+            newContractUser.setCertifiedAddress(getFddServerHost(person.getMiniappId(),url));
100 108
             newContractUser.setCertifiedSerialNumber(JSON.parseObject(data).getString("transactionNo"));
101 109
         }
102 110
         newContractUser.setStatus(0);
@@ -106,6 +114,19 @@ public class TaContractUserServiceImpl extends ServiceImpl<TaContractUserMapper,
106 114
         return newContractUser;
107 115
     }
108 116
 
117
+    /**
118
+     * 替换法大大服务器地址
119
+     * @return
120
+     */
121
+    private String getFddServerHost(String miniappId,String subUrl) {
122
+        TaMiniapp taMiniapp = taMiniappMapper.selectById(miniappId);
123
+        int index = subUrl.indexOf(File.separator);
124
+        int twoIndex = subUrl.indexOf(File.separator,index);
125
+        int threeIndex = subUrl.indexOf(File.separator,twoIndex);
126
+        String newUrl = StringUtils.isEmpty(taMiniapp.getFddServerHost()) ? subUrl : taMiniapp.getFddServerHost() + subUrl.substring(threeIndex);
127
+        return newUrl;
128
+    }
129
+
109 130
     /**
110 131
      * 去法大大处更新客户的状态
111 132
      *
@@ -119,7 +140,7 @@ public class TaContractUserServiceImpl extends ServiceImpl<TaContractUserMapper,
119 140
         queryWrapper.eq("mini_openid",person.getMiniOpenid());
120 141
         TaContractUser taContractUser = taContractUserMapper.selectOne(queryWrapper);
121 142
         log.info("个人正在从法大大获取最新数据,企业编号是 {}", taContractUser.getFadadaCode());
122
-        FindCertInfo personCertInfo = new FindCertInfo(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
143
+        FindCertInfo personCertInfo = new FindCertInfo(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),getFddServerHost(person.getMiniappId(),fadadaProperties.getServeHost()));
123 144
         String verified_serialno = taContractUser.getCertifiedSerialNumber();
124 145
         String result = personCertInfo.invokeFindPersonCert(verified_serialno,
125 146
                 "1");