|
@@ -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.MD5Utils;
|
13
|
14
|
import com.huiju.estateagents.common.StringUtils;
|
14
|
15
|
import com.huiju.estateagents.config.FadadaProperties;
|
15
|
16
|
import com.huiju.estateagents.eContract.entity.TaContract;
|
|
@@ -100,12 +101,29 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
|
100
|
101
|
public TaContract autoContract(TaRaiseRecord taRaiseRecord, TaPerson person) throws Exception {
|
101
|
102
|
taRaiseRecord = taRaiseRecordMapper.selectById(taRaiseRecord.getRaiseRecordId());
|
102
|
103
|
|
|
104
|
+
|
|
105
|
+
|
103
|
106
|
//根据raiseId获取合同的所有参数
|
104
|
107
|
TaContractBusiness taContractBusiness = taContractMapper.selectContractInfoByRaiseId(taRaiseRecord.getRaiseId());
|
105
|
108
|
if (null == taContractBusiness){
|
106
|
109
|
throw new Exception("无合同模板,请和置业顾问联系");
|
107
|
110
|
}
|
108
|
111
|
|
|
112
|
+ //检查是否签署过本合同
|
|
113
|
+ QueryWrapper<TaContract> queryWrapper = new QueryWrapper<>();
|
|
114
|
+ queryWrapper.eq("building_id",taRaiseRecord.getBuildingId());
|
|
115
|
+ queryWrapper.eq("org_id",taRaiseRecord.getOrgId());
|
|
116
|
+ queryWrapper.eq("target_type","raise");
|
|
117
|
+ queryWrapper.eq("target_id",Integer.valueOf(taRaiseRecord.getRaiseId()));
|
|
118
|
+ queryWrapper.eq("invoice_target_type","raise_record");
|
|
119
|
+ queryWrapper.eq("invoice_target_id",taRaiseRecord.getRaiseRecordId());
|
|
120
|
+ queryWrapper.eq("company_id",taContractBusiness.getCompanyId());
|
|
121
|
+ queryWrapper.eq("person_id",person.getPersonId());
|
|
122
|
+ TaContract oldContract = taContractMapper.selectOne(queryWrapper);
|
|
123
|
+ if (null != oldContract){
|
|
124
|
+ return oldContract;
|
|
125
|
+ }
|
|
126
|
+
|
109
|
127
|
//先入合同表
|
110
|
128
|
TaContract taContract = new TaContract();
|
111
|
129
|
taContract.setBuildingId(taRaiseRecord.getBuildingId());
|
|
@@ -118,10 +136,11 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
|
118
|
136
|
taContract.setCompanyId(taContractBusiness.getCompanyId());
|
119
|
137
|
taContract.setCreateDate(LocalDateTime.now());
|
120
|
138
|
taContract.setStatus(0);
|
|
139
|
+ taContract.setPersonId(person.getPersonId());
|
121
|
140
|
taContractMapper.insert(taContract);
|
122
|
141
|
|
123
|
142
|
//上传合同
|
124
|
|
- FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),getFddServerHost(person.getMiniappId(),fadadaProperties.getServeHost()));
|
|
143
|
+ FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
|
125
|
144
|
String result = base.invokeUploadDocs(taContract.getContractId().toString(), taContractBusiness.getContractTemplateName(), null, taContractBusiness.getContractTemplateAddress(), ".pdf");
|
126
|
145
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
127
|
146
|
if (!jsonObject.getString("code").equals("1000")){
|
|
@@ -148,7 +167,6 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
|
148
|
167
|
//反更新合同地址
|
149
|
168
|
taContract.setContractDownloadUrl(autoSignResultJson.getString("download_url"));
|
150
|
169
|
taContract.setContractViewUrl(autoSignResultJson.getString("viewpdf_url"));
|
151
|
|
- taContract.setStatus(1);
|
152
|
170
|
taContractMapper.updateById(taContract);
|
153
|
171
|
|
154
|
172
|
//企业名称
|
|
@@ -162,9 +180,9 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
|
162
|
180
|
*/
|
163
|
181
|
private String getFddServerHost(String miniappId,String subUrl) {
|
164
|
182
|
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);
|
|
183
|
+ int index = subUrl.indexOf("/");
|
|
184
|
+ int twoIndex = subUrl.indexOf("/",index+1);
|
|
185
|
+ int threeIndex = subUrl.indexOf("/",twoIndex+1);
|
168
|
186
|
String newUrl = StringUtils.isEmpty(taMiniapp.getFddServerHost()) ? subUrl : taMiniapp.getFddServerHost() + subUrl.substring(threeIndex);
|
169
|
187
|
return newUrl;
|
170
|
188
|
}
|
|
@@ -180,9 +198,12 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
|
180
|
198
|
public String manualContract(TaContract taContract, TaPerson person) throws Exception {
|
181
|
199
|
//获取客户信息
|
182
|
200
|
QueryWrapper<TaContractUser> queryWrapper = new QueryWrapper<>();
|
183
|
|
- queryWrapper.eq("mini_openid",person.getMiniOpenid());
|
|
201
|
+ queryWrapper.eq("mini_openid", MD5Utils.md5(person.getMiniOpenid()));
|
184
|
202
|
TaContractUser taContractUser = taContractUserMapper.selectOne(queryWrapper);
|
185
|
203
|
|
|
204
|
+ if (taContract.getStatus() == 1){
|
|
205
|
+ throw new Exception("已经成功签署,无需再次签署");
|
|
206
|
+ }
|
186
|
207
|
//根据raiseId获取合同的所有参数
|
187
|
208
|
TaContractBusiness taContractBusiness = taContractMapper.selectContractInfoByRaiseId(taContract.getTargetId().toString());
|
188
|
209
|
if (null == taContractBusiness){
|
|
@@ -193,7 +214,7 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
|
193
|
214
|
String timeStamp = HttpsUtil.getTimeStamp();
|
194
|
215
|
String transaction_id = "TRAN_" + timeStamp;
|
195
|
216
|
|
196
|
|
- FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),getFddServerHost(person.getMiniappId(),fadadaProperties.getServeHost()));
|
|
217
|
+ FddClientBase base = new FddClientBase(fadadaProperties.getAppId(),fadadaProperties.getAppSecret(),fadadaProperties.getVersion(),fadadaProperties.getServeHost());
|
197
|
218
|
ExtsignReq req = new ExtsignReq();
|
198
|
219
|
req.setCustomer_id(taContractUser.getFadadaCode());
|
199
|
220
|
req.setTransaction_id(transaction_id);
|
|
@@ -206,4 +227,35 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
|
206
|
227
|
String signUrl = base.invokeExtSign(req);
|
207
|
228
|
return signUrl;
|
208
|
229
|
}
|
|
230
|
+
|
|
231
|
+ /**
|
|
232
|
+ * 检查签署合同状态
|
|
233
|
+ *
|
|
234
|
+ * @param taRaiseRecord
|
|
235
|
+ * @param person
|
|
236
|
+ * @return
|
|
237
|
+ */
|
|
238
|
+ @Override
|
|
239
|
+ public TaContract checkContract(TaRaiseRecord taRaiseRecord, TaPerson person) throws Exception {
|
|
240
|
+ taRaiseRecord = taRaiseRecordMapper.selectById(taRaiseRecord.getRaiseRecordId());
|
|
241
|
+
|
|
242
|
+ //根据raiseId获取合同的所有参数
|
|
243
|
+ TaContractBusiness taContractBusiness = taContractMapper.selectContractInfoByRaiseId(taRaiseRecord.getRaiseId());
|
|
244
|
+ if (null == taContractBusiness){
|
|
245
|
+ throw new Exception("无合同模板,请和置业顾问联系");
|
|
246
|
+ }
|
|
247
|
+
|
|
248
|
+ //检查是否签署过本合同
|
|
249
|
+ QueryWrapper<TaContract> queryWrapper = new QueryWrapper<>();
|
|
250
|
+ queryWrapper.eq("building_id",taRaiseRecord.getBuildingId());
|
|
251
|
+ queryWrapper.eq("org_id",taRaiseRecord.getOrgId());
|
|
252
|
+ queryWrapper.eq("target_type","raise");
|
|
253
|
+ queryWrapper.eq("target_id",Integer.valueOf(taRaiseRecord.getRaiseId()));
|
|
254
|
+ queryWrapper.eq("invoice_target_type","raise_record");
|
|
255
|
+ queryWrapper.eq("invoice_target_id",taRaiseRecord.getRaiseRecordId());
|
|
256
|
+ queryWrapper.eq("company_id",taContractBusiness.getCompanyId());
|
|
257
|
+ queryWrapper.eq("person_id",person.getPersonId());
|
|
258
|
+ TaContract oldContract = taContractMapper.selectOne(queryWrapper);
|
|
259
|
+ return oldContract;
|
|
260
|
+ }
|
209
|
261
|
}
|