傅行帆 5 år sedan
förälder
incheckning
a1f013d195

+ 17
- 4
src/main/java/com/huiju/estateagents/eContract/controller/TaCompanyController.java Visa fil

@@ -526,10 +526,23 @@ public class TaCompanyController extends BaseController {
526 526
                                   @RequestParam(value = "msg_digest",required = false) String msg_digest,
527 527
                                   HttpServletRequest request) {
528 528
         logger.info("企业认证回调函数参数:交易号 {},合同编号 {},签章结果代码 {},签章结果描述 ,{}, 下载地址{}, 查看地址 {},请求时间 {}, 摘要 {} ",transaction_id,contract_id,result_code,result_desc,download_url,viewpdf_url,timestamp,msg_digest);
529
-        TaContract taContract = iTaContractService.getById(contract_id);
530
-        taContract.setContractDownloadUrl(download_url);
531
-        taContract.setContractViewUrl(viewpdf_url);
532
-        iTaContractService.updateById(taContract);
529
+        Map<String, String[]> parameterMap = request.getParameterMap();
530
+        if ("3000".equals(result_code)){
531
+            TaContract taContract = iTaContractService.getById(parameterMap.get("contract_id")[0]);
532
+            taContract.setContractDownloadUrl(download_url);
533
+            taContract.setContractViewUrl(viewpdf_url);
534
+            taContract.setStatus(CommConstant.STATUS_NORMAL);
535
+            taContract.setReason(parameterMap.get("result_desc")[0]);
536
+            iTaContractService.updateById(taContract);
537
+        }else{
538
+            TaContract taContract = iTaContractService.getById(parameterMap.get("contract_id")[0]);
539
+            taContract.setContractDownloadUrl(download_url);
540
+            taContract.setContractViewUrl(viewpdf_url);
541
+            //签署失败
542
+            taContract.setStatus(2);
543
+            taContract.setReason(parameterMap.get("result_desc")[0]);
544
+            iTaContractService.updateById(taContract);
545
+        }
533 546
     }
534 547
 
535 548
     /**

+ 22
- 0
src/main/java/com/huiju/estateagents/eContract/controller/TaContractController.java Visa fil

@@ -297,4 +297,26 @@ public class TaContractController extends BaseController {
297 297
     }
298 298
 
299 299
 
300
+    /**
301
+     * 自动签署合同
302
+     */
303
+    @RequestMapping(value = "/wx/contract/check", method = RequestMethod.POST)
304
+    public ResponseBean checkContract(@RequestBody TaRaiseRecord taRaiseRecord, HttpServletRequest request) {
305
+        ResponseBean responseBean = new ResponseBean();
306
+        try {
307
+            String openid = getOpenId(request);
308
+            List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
309
+            if (null == taPersons || taPersons.size() != 1) {
310
+                return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
311
+            }
312
+            TaPerson person = taPersons.get(0);
313
+            TaContract taContract = iTaContractService.checkContract(taRaiseRecord, person);
314
+            responseBean.addSuccess(taContract);
315
+        } catch (Exception e) {
316
+            e.printStackTrace();
317
+            logger.error("taCompanyList -=- {}", e.toString());
318
+            responseBean.addError(e.getMessage());
319
+        }
320
+        return responseBean;
321
+    }
300 322
 }

+ 5
- 0
src/main/java/com/huiju/estateagents/eContract/entity/TaContract.java Visa fil

@@ -147,6 +147,11 @@ public class TaContract implements Serializable {
147 147
      */
148 148
     private String personId;
149 149
 
150
+    /**
151
+     * 原因
152
+     */
153
+    private String reason;
154
+
150 155
     /**
151 156
      * 状态
152 157
      */

+ 8
- 0
src/main/java/com/huiju/estateagents/eContract/service/ITaContractService.java Visa fil

@@ -64,4 +64,12 @@ public interface ITaContractService extends IService<TaContract> {
64 64
      * @return
65 65
      */
66 66
     String manualContract(TaContract taContract, TaPerson person) throws Exception;
67
+
68
+    /**
69
+     * 检查签署合同状态
70
+     * @param taRaiseRecord
71
+     * @param person
72
+     * @return
73
+     */
74
+    TaContract checkContract(TaRaiseRecord taRaiseRecord, TaPerson person) throws Exception;
67 75
 }

+ 52
- 1
src/main/java/com/huiju/estateagents/eContract/service/impl/TaContractServiceImpl.java Visa fil

@@ -100,12 +100,29 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
100 100
     public TaContract autoContract(TaRaiseRecord taRaiseRecord, TaPerson person) throws Exception {
101 101
         taRaiseRecord = taRaiseRecordMapper.selectById(taRaiseRecord.getRaiseRecordId());
102 102
 
103
+
104
+
103 105
         //根据raiseId获取合同的所有参数
104 106
         TaContractBusiness taContractBusiness = taContractMapper.selectContractInfoByRaiseId(taRaiseRecord.getRaiseId());
105 107
         if (null == taContractBusiness){
106 108
             throw new Exception("无合同模板,请和置业顾问联系");
107 109
         }
108 110
 
111
+        //检查是否签署过本合同
112
+        QueryWrapper<TaContract> queryWrapper = new QueryWrapper<>();
113
+        queryWrapper.eq("building_id",taRaiseRecord.getBuildingId());
114
+        queryWrapper.eq("org_id",taRaiseRecord.getOrgId());
115
+        queryWrapper.eq("target_type","raise");
116
+        queryWrapper.eq("target_id",Integer.valueOf(taRaiseRecord.getRaiseId()));
117
+        queryWrapper.eq("invoice_target_type","raise_record");
118
+        queryWrapper.eq("invoice_target_id",taRaiseRecord.getRaiseRecordId());
119
+        queryWrapper.eq("company_id",taContractBusiness.getCompanyId());
120
+        queryWrapper.eq("person_id",person.getPersonId());
121
+        TaContract oldContract = taContractMapper.selectOne(queryWrapper);
122
+        if (null != oldContract){
123
+            return oldContract;
124
+        }
125
+
109 126
         //先入合同表
110 127
         TaContract taContract = new TaContract();
111 128
         taContract.setBuildingId(taRaiseRecord.getBuildingId());
@@ -118,6 +135,7 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
118 135
         taContract.setCompanyId(taContractBusiness.getCompanyId());
119 136
         taContract.setCreateDate(LocalDateTime.now());
120 137
         taContract.setStatus(0);
138
+        taContract.setPersonId(person.getPersonId());
121 139
         taContractMapper.insert(taContract);
122 140
 
123 141
         //上传合同
@@ -148,7 +166,6 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
148 166
         //反更新合同地址
149 167
         taContract.setContractDownloadUrl(autoSignResultJson.getString("download_url"));
150 168
         taContract.setContractViewUrl(autoSignResultJson.getString("viewpdf_url"));
151
-        taContract.setStatus(1);
152 169
         taContractMapper.updateById(taContract);
153 170
 
154 171
         //企业名称
@@ -183,6 +200,9 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
183 200
         queryWrapper.eq("mini_openid",person.getMiniOpenid());
184 201
         TaContractUser taContractUser = taContractUserMapper.selectOne(queryWrapper);
185 202
 
203
+        if (taContract.getStatus() == 1){
204
+            throw new Exception("已经成功签署,无需再次签署");
205
+        }
186 206
         //根据raiseId获取合同的所有参数
187 207
         TaContractBusiness taContractBusiness = taContractMapper.selectContractInfoByRaiseId(taContract.getTargetId().toString());
188 208
         if (null == taContractBusiness){
@@ -206,4 +226,35 @@ public class TaContractServiceImpl extends ServiceImpl<TaContractMapper, TaContr
206 226
         String signUrl = base.invokeExtSign(req);
207 227
         return signUrl;
208 228
     }
229
+
230
+    /**
231
+     * 检查签署合同状态
232
+     *
233
+     * @param taRaiseRecord
234
+     * @param person
235
+     * @return
236
+     */
237
+    @Override
238
+    public TaContract checkContract(TaRaiseRecord taRaiseRecord, TaPerson person) throws Exception {
239
+        taRaiseRecord = taRaiseRecordMapper.selectById(taRaiseRecord.getRaiseRecordId());
240
+
241
+        //根据raiseId获取合同的所有参数
242
+        TaContractBusiness taContractBusiness = taContractMapper.selectContractInfoByRaiseId(taRaiseRecord.getRaiseId());
243
+        if (null == taContractBusiness){
244
+            throw new Exception("无合同模板,请和置业顾问联系");
245
+        }
246
+
247
+        //检查是否签署过本合同
248
+        QueryWrapper<TaContract> queryWrapper = new QueryWrapper<>();
249
+        queryWrapper.eq("building_id",taRaiseRecord.getBuildingId());
250
+        queryWrapper.eq("org_id",taRaiseRecord.getOrgId());
251
+        queryWrapper.eq("target_type","raise");
252
+        queryWrapper.eq("target_id",Integer.valueOf(taRaiseRecord.getRaiseId()));
253
+        queryWrapper.eq("invoice_target_type","raise_record");
254
+        queryWrapper.eq("invoice_target_id",taRaiseRecord.getRaiseRecordId());
255
+        queryWrapper.eq("company_id",taContractBusiness.getCompanyId());
256
+        queryWrapper.eq("person_id",person.getPersonId());
257
+        TaContract oldContract = taContractMapper.selectOne(queryWrapper);
258
+        return oldContract;
259
+    }
209 260
 }

+ 1
- 1
src/main/java/com/huiju/estateagents/eContract/service/impl/TaContractUserServiceImpl.java Visa fil

@@ -98,7 +98,7 @@ public class TaContractUserServiceImpl extends ServiceImpl<TaContractUserMapper,
98 98
         String customer_ident_type = "0";
99 99
         String personResult = personverify.invokePersonVerifyUrl(customer_id,verifyed_way,
100 100
                 page_modify,notify_url,return_url,null,customer_ident_type,
101
-                null,null,null,"1",null);
101
+                null,null,null,"1","1");
102 102
 
103 103
         String data = JSON.parseObject(personResult).getString("data");
104 104
         if (null !=data){