|
@@ -1,11 +1,27 @@
|
1
|
1
|
package com.huiju.estateagents.eContract.service.impl;
|
2
|
2
|
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
|
4
|
+import com.alibaba.fastjson.JSONObject;
|
|
5
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
6
|
+import com.fadada.sdk.client.FddClientBase;
|
|
7
|
+import com.fadada.sdk.client.authForfadada.FindCertInfo;
|
|
8
|
+import com.fadada.sdk.client.authForfadada.GetPersonVerifyUrl;
|
|
9
|
+import com.huiju.estateagents.common.CommConstant;
|
|
10
|
+import com.huiju.estateagents.config.FadadaProperties;
|
3
|
11
|
import com.huiju.estateagents.eContract.entity.TaContractUser;
|
4
|
12
|
import com.huiju.estateagents.eContract.mapper.TaContractUserMapper;
|
5
|
13
|
import com.huiju.estateagents.eContract.service.ITaContractUserService;
|
6
|
14
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
15
|
+import com.huiju.estateagents.entity.TaPerson;
|
|
16
|
+import com.huiju.estateagents.entity.TaRaiseRecord;
|
|
17
|
+import jodd.util.URLDecoder;
|
|
18
|
+import lombok.extern.slf4j.Slf4j;
|
|
19
|
+import org.apache.commons.codec.binary.Base64;
|
|
20
|
+import org.springframework.beans.factory.annotation.Autowired;
|
7
|
21
|
import org.springframework.stereotype.Service;
|
8
|
22
|
|
|
23
|
+import java.time.LocalDateTime;
|
|
24
|
+
|
9
|
25
|
/**
|
10
|
26
|
* <p>
|
11
|
27
|
* 电子合同注册用户表 服务实现类
|
|
@@ -14,7 +30,123 @@ import org.springframework.stereotype.Service;
|
14
|
30
|
* @author fxf
|
15
|
31
|
* @since 2020-03-26
|
16
|
32
|
*/
|
|
33
|
+@Slf4j
|
17
|
34
|
@Service
|
18
|
35
|
public class TaContractUserServiceImpl extends ServiceImpl<TaContractUserMapper, TaContractUser> implements ITaContractUserService {
|
19
|
36
|
|
|
37
|
+ @Autowired
|
|
38
|
+ private FadadaProperties fadadaProperties;
|
|
39
|
+
|
|
40
|
+ @Autowired
|
|
41
|
+ private TaContractUserMapper taContractUserMapper;
|
|
42
|
+ /**
|
|
43
|
+ * 小程序端首次签署合同的是要在法大大处创建账号
|
|
44
|
+ *
|
|
45
|
+ * @param person
|
|
46
|
+ * @param taRaiseRecord
|
|
47
|
+ * @return
|
|
48
|
+ */
|
|
49
|
+ @Override
|
|
50
|
+ public TaContractUser newFirstCustomerInfo(TaPerson person, TaRaiseRecord taRaiseRecord) throws Exception {
|
|
51
|
+ //首先判断是否注册过账号
|
|
52
|
+ QueryWrapper<TaContractUser> queryWrapper = new QueryWrapper<>();
|
|
53
|
+ queryWrapper.eq("mini_openid",person.getMiniOpenid());
|
|
54
|
+ TaContractUser taContractUser = taContractUserMapper.selectOne(queryWrapper);
|
|
55
|
+ if (null != taContractUser) {
|
|
56
|
+ taContractUser.setRaiseRecordId(taRaiseRecord.getRaiseRecordId());
|
|
57
|
+ return taContractUser;
|
|
58
|
+ }
|
|
59
|
+ //没有法大大账号的先注册
|
|
60
|
+ log.info("========法大大个人注册=======");
|
|
61
|
+ //在法大大注册个人用户
|
|
62
|
+ FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
|
|
63
|
+ //小程序id为注册账号
|
|
64
|
+ String open_id = person.getMiniappId();
|
|
65
|
+ //account_type 1是个人注册
|
|
66
|
+ String result =base.invokeregisterAccount(open_id,"1");
|
|
67
|
+ log.info("法大大注册信息{}", result);
|
|
68
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
69
|
+ if (jsonObject.getInteger("code") != 1){
|
|
70
|
+ throw new Exception(jsonObject.getString("msg"));
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ //插入个人用户数据
|
|
74
|
+ TaContractUser newContractUser = new TaContractUser();
|
|
75
|
+ newContractUser.setMiniOpenid(open_id);
|
|
76
|
+ newContractUser.setFadadaCode(jsonObject.getString("data"));
|
|
77
|
+ newContractUser.setPersonId(person.getPersonId());
|
|
78
|
+ newContractUser.setAuthStatus(CommConstant.CERTIFIED_STATUS_REGISTERED);
|
|
79
|
+ newContractUser.setCreateDate(LocalDateTime.now());
|
|
80
|
+ newContractUser.setOrgId(person.getOrgId());
|
|
81
|
+ newContractUser.setOrgId(CommConstant.STATUS_UNACCALIMED);
|
|
82
|
+
|
|
83
|
+ log.info("正在申请个人认证,客户编码是{}",jsonObject.getString("data"));
|
|
84
|
+ GetPersonVerifyUrl personverify = new GetPersonVerifyUrl(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
|
|
85
|
+ String customer_id = jsonObject.getString("data");
|
|
86
|
+ String verifyed_way = "0";
|
|
87
|
+ String page_modify = "1";
|
|
88
|
+ String notify_url = "https://www.baidu.com";
|
|
89
|
+ String return_url= "https://www.baidu.com"+"?raiseRecordId=" + taRaiseRecord.getRaiseRecordId();
|
|
90
|
+ String customer_ident_type = "0";
|
|
91
|
+ String personResult = personverify.invokePersonVerifyUrl(customer_id,verifyed_way,
|
|
92
|
+ page_modify,notify_url,return_url,null,customer_ident_type,
|
|
93
|
+ null,null,null,null,null);
|
|
94
|
+
|
|
95
|
+ String data = JSON.parseObject(personResult).getString("data");
|
|
96
|
+ if (null !=data){
|
|
97
|
+ String url = JSON.parseObject(data).getString("url");
|
|
98
|
+ url = decode(url);
|
|
99
|
+ newContractUser.setCertifiedAddress(url);
|
|
100
|
+ newContractUser.setCertifiedSerialNumber(JSON.parseObject(data).getString("transactionNo"));
|
|
101
|
+ }
|
|
102
|
+ newContractUser.setAuthStatus(CommConstant.CERTIFIED_STATUS_CERTIFICATION);
|
|
103
|
+ newContractUser.setRaiseRecordId(taRaiseRecord.getRaiseRecordId());
|
|
104
|
+ taContractUserMapper.insert(newContractUser);
|
|
105
|
+ return newContractUser;
|
|
106
|
+ }
|
|
107
|
+
|
|
108
|
+ /**
|
|
109
|
+ * 去法大大处更新客户的状态
|
|
110
|
+ *
|
|
111
|
+ * @param person
|
|
112
|
+ * @return
|
|
113
|
+ */
|
|
114
|
+ @Override
|
|
115
|
+ public TaContractUser getFirstCustomerInfo(TaPerson person) throws Exception {
|
|
116
|
+ //注册账号信息
|
|
117
|
+ QueryWrapper<TaContractUser> queryWrapper = new QueryWrapper<>();
|
|
118
|
+ queryWrapper.eq("mini_openid",person.getMiniOpenid());
|
|
119
|
+ TaContractUser taContractUser = taContractUserMapper.selectOne(queryWrapper);
|
|
120
|
+ log.info("个人正在从法大大获取最新数据,企业编号是 {}", taContractUser.getFadadaCode());
|
|
121
|
+ FindCertInfo personCertInfo = new FindCertInfo(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
|
|
122
|
+ String verified_serialno = taContractUser.getCertifiedSerialNumber();
|
|
123
|
+ String result = personCertInfo.invokeFindPersonCert(verified_serialno,
|
|
124
|
+ "1");
|
|
125
|
+ log.info("个人最新数据结果 {}",result);
|
|
126
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
127
|
+ if (jsonObject.getInteger("code") != 1){
|
|
128
|
+ throw new Exception(jsonObject.getString("msg"));
|
|
129
|
+ }
|
|
130
|
+ //更新数据
|
|
131
|
+ String data = jsonObject.getString("data");
|
|
132
|
+ if (null !=data){
|
|
133
|
+ JSONObject dataJson = JSONObject.parseObject(data);
|
|
134
|
+ //企业法人、代理人信息
|
|
135
|
+ JSONObject personJson = dataJson.getJSONObject("person");
|
|
136
|
+ if (null != personJson){
|
|
137
|
+ taContractUser.setStatus(personJson.getInteger("status"));
|
|
138
|
+ taContractUser.setTel(personJson.getString("mobile"));
|
|
139
|
+ taContractUser.setIdCard(personJson.getString("idCard"));
|
|
140
|
+ taContractUser.setReason(personJson.getString("auditFailReason"));
|
|
141
|
+ }
|
|
142
|
+ }
|
|
143
|
+ taContractUserMapper.updateById(taContractUser);
|
|
144
|
+ return taContractUser;
|
|
145
|
+ }
|
|
146
|
+
|
|
147
|
+ private String decode(String bizContent) {
|
|
148
|
+ bizContent = URLDecoder.decode(bizContent, "utf-8");
|
|
149
|
+ bizContent = new String(Base64.decodeBase64(bizContent.getBytes()));
|
|
150
|
+ return bizContent;
|
|
151
|
+ }
|
20
|
152
|
}
|