|
@@ -1,15 +1,21 @@
|
1
|
1
|
package com.huiju.estateagents.eContract.service.impl;
|
2
|
2
|
|
3
|
3
|
import com.alibaba.fastjson.JSONObject;
|
|
4
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
5
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
6
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
7
|
import com.fadada.sdk.client.FddClientBase;
|
|
8
|
+import com.fadada.sdk.client.request.ExtsignReq;
|
|
9
|
+import com.fadada.sdk.test.util.ConfigUtil;
|
|
10
|
+import com.fadada.sdk.util.http.HttpsUtil;
|
7
|
11
|
import com.huiju.estateagents.base.ResponseBean;
|
8
|
12
|
import com.huiju.estateagents.bo.request.ContractRecordRequestBO;
|
9
|
13
|
import com.huiju.estateagents.config.FadadaProperties;
|
10
|
14
|
import com.huiju.estateagents.eContract.entity.TaContract;
|
11
|
15
|
import com.huiju.estateagents.eContract.entity.TaContractBusiness;
|
|
16
|
+import com.huiju.estateagents.eContract.entity.TaContractUser;
|
12
|
17
|
import com.huiju.estateagents.eContract.mapper.TaContractMapper;
|
|
18
|
+import com.huiju.estateagents.eContract.mapper.TaContractUserMapper;
|
13
|
19
|
import com.huiju.estateagents.eContract.service.ITaContractService;
|
14
|
20
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
15
|
21
|
import com.huiju.estateagents.entity.TaPerson;
|
|
@@ -49,6 +55,10 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
|
49
|
55
|
@Autowired
|
50
|
56
|
private TaOrgMapper taOrgMapper;
|
51
|
57
|
|
|
58
|
+ @Autowired
|
|
59
|
+ private TaContractUserMapper taContractUserMapper;
|
|
60
|
+
|
|
61
|
+
|
52
|
62
|
@Override
|
53
|
63
|
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) {
|
54
|
64
|
|
|
@@ -80,7 +90,7 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
|
80
|
90
|
*/
|
81
|
91
|
@Override
|
82
|
92
|
@Transactional
|
83
|
|
- public TaContract autoContract(TaRaiseRecord taRaiseRecord, TaPerson person) {
|
|
93
|
+ public TaContract autoContract(TaRaiseRecord taRaiseRecord, TaPerson person) throws Exception {
|
84
|
94
|
taRaiseRecord = taRaiseRecordMapper.selectById(taRaiseRecord.getRaiseRecordId());
|
85
|
95
|
|
86
|
96
|
//根据raiseId获取合同的所有参数
|
|
@@ -97,10 +107,74 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
|
97
|
107
|
taContract.setInvoiceTargetId(taRaiseRecord.getRaiseRecordId());
|
98
|
108
|
taContract.setCompanyId(taContractBusiness.getCompanyId());
|
99
|
109
|
taContract.setCreateDate(LocalDateTime.now());
|
|
110
|
+ taContract.setStatus(0);
|
100
|
111
|
taContractMapper.insert(taContract);
|
101
|
112
|
|
|
113
|
+ //上传合同
|
102
|
114
|
FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
|
103
|
115
|
String result = base.invokeUploadDocs(taContract.getContractId().toString(), taContractBusiness.getContractTemplateName(), null, taContractBusiness.getContractTemplateAddress(), ".pdf");
|
104
|
|
- return null;
|
|
116
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
117
|
+ if (!jsonObject.getInteger("code").equals("1000")){
|
|
118
|
+ throw new Exception(jsonObject.getString("msg"));
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ //自动签署合同
|
|
122
|
+ String timeStamp = HttpsUtil.getTimeStamp();
|
|
123
|
+ String transaction_id = "TRAN_" + timeStamp;
|
|
124
|
+ ExtsignReq req = new ExtsignReq();
|
|
125
|
+ req.setCustomer_id(taContractBusiness.getFadadaCode());
|
|
126
|
+ req.setTransaction_id(transaction_id);
|
|
127
|
+ req.setContract_id(taContract.getContractId().toString());
|
|
128
|
+ req.setClient_role("1");
|
|
129
|
+ req.setSign_keyword(taContractBusiness.getSignatoryKeywords());
|
|
130
|
+ req.setKeyword_strategy(taContractBusiness.getSignatoryStrategy());
|
|
131
|
+ req.setDoc_title(taContractBusiness.getContractTemplateName());
|
|
132
|
+ String autoSignResult = base.invokeExtSignAuto(req);
|
|
133
|
+ JSONObject autoSignResultJson = JSONObject.parseObject(autoSignResult);
|
|
134
|
+ if (!autoSignResultJson.getInteger("code").equals("1000")){
|
|
135
|
+ throw new Exception(jsonObject.getString("msg"));
|
|
136
|
+ }
|
|
137
|
+
|
|
138
|
+ //反更新合同地址
|
|
139
|
+ taContract.setContractDownloadUrl(autoSignResultJson.getString("download_url"));
|
|
140
|
+ taContract.setContractViewUrl(autoSignResultJson.getString("viewpdf_url"));
|
|
141
|
+ taContract.setStatus(1);
|
|
142
|
+ taContractMapper.updateById(taContract);
|
|
143
|
+ return taContract;
|
|
144
|
+ }
|
|
145
|
+
|
|
146
|
+ /**
|
|
147
|
+ * 手动签署合同
|
|
148
|
+ *
|
|
149
|
+ * @param taContract
|
|
150
|
+ * @param person
|
|
151
|
+ * @return
|
|
152
|
+ */
|
|
153
|
+ @Override
|
|
154
|
+ public String manualContract(TaContract taContract, TaPerson person) {
|
|
155
|
+ //获取客户信息
|
|
156
|
+ QueryWrapper<TaContractUser> queryWrapper = new QueryWrapper<>();
|
|
157
|
+ queryWrapper.eq("mini_openid",person.getMiniOpenid());
|
|
158
|
+ TaContractUser taContractUser = taContractUserMapper.selectOne(queryWrapper);
|
|
159
|
+
|
|
160
|
+ //根据raiseId获取合同的所有参数
|
|
161
|
+ TaContractBusiness taContractBusiness = taContractMapper.selectContractInfoByRaiseId(taContract.getTargetId().toString());
|
|
162
|
+
|
|
163
|
+ //手动签署合同
|
|
164
|
+ String timeStamp = HttpsUtil.getTimeStamp();
|
|
165
|
+ String transaction_id = "TRAN_" + timeStamp;
|
|
166
|
+
|
|
167
|
+ FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
|
|
168
|
+ ExtsignReq req = new ExtsignReq();
|
|
169
|
+ req.setCustomer_id(taContractUser.getFadadaCode());
|
|
170
|
+ req.setTransaction_id(transaction_id);
|
|
171
|
+ req.setContract_id(taContract.getContractId().toString());
|
|
172
|
+ req.setSign_keyword(taContractBusiness.getCustomerKeywords());
|
|
173
|
+ req.setKeyword_strategy(taContractBusiness.getCustomerStrategy());
|
|
174
|
+ req.setDoc_title(taContractBusiness.getContractTemplateName());
|
|
175
|
+ req.setReturn_url("www.baidu.com");
|
|
176
|
+ req.setNotify_url("www.baidu.com");
|
|
177
|
+ String signUrl = base.invokeExtSign(req);
|
|
178
|
+ return signUrl;
|
105
|
179
|
}
|
106
|
180
|
}
|