|
|
@@ -11,6 +11,7 @@ import com.ruoyi.common.core.redis.RedisCache;
|
|
11
|
11
|
import com.ruoyi.common.enums.AnnexTypeEnum;
|
|
12
|
12
|
import com.ruoyi.common.enums.PaymentStatusEnum;
|
|
13
|
13
|
import com.ruoyi.common.enums.YesOrNoEnum;
|
|
|
14
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
14
|
15
|
import com.ruoyi.common.utils.SmsUtils;
|
|
15
|
16
|
import com.ruoyi.dto.PayRequest;
|
|
16
|
17
|
import com.ruoyi.dto.PayResponse;
|
|
|
@@ -19,15 +20,9 @@ import com.ruoyi.system.mapper.flow.MsCaseFlowMapper;
|
|
19
|
20
|
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CaseConfirmPayDTO;
|
|
20
|
21
|
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CasePayDTO;
|
|
21
|
22
|
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
|
|
22
|
|
-import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate;
|
|
23
|
|
-import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
|
|
24
|
|
-import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
|
|
25
|
|
-import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCasePaymentRecord;
|
|
|
23
|
+import com.ruoyi.wisdomarbitrate.domain.entity.mscase.*;
|
|
26
|
24
|
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.PaymentDetailVO;
|
|
27
|
|
-import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAffiliateMapper;
|
|
28
|
|
-import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseApplicationMapper;
|
|
29
|
|
-import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAttachMapper;
|
|
30
|
|
-import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCasePaymentRecordMapper;
|
|
|
25
|
+import com.ruoyi.wisdomarbitrate.mapper.mscase.*;
|
|
31
|
26
|
import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper;
|
|
32
|
27
|
import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService;
|
|
33
|
28
|
import com.ruoyi.wisdomarbitrate.service.mscase.MsCasePaymentService;
|
|
|
@@ -66,6 +61,8 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService {
|
|
66
|
61
|
MsCasePaymentService casePaymentService;
|
|
67
|
62
|
@Autowired
|
|
68
|
63
|
private RedisCache redisCache;
|
|
|
64
|
+ @Autowired
|
|
|
65
|
+ private MsCaseAuditMapper auditMapper;
|
|
69
|
66
|
|
|
70
|
67
|
|
|
71
|
68
|
@Override
|
|
|
@@ -273,101 +270,206 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService {
|
|
273
|
270
|
if (currentFlow == null) {
|
|
274
|
271
|
return AjaxResult.error("未找到当前流程节点");
|
|
275
|
272
|
}
|
|
|
273
|
+ MsCaseFlow flow =null;
|
|
|
274
|
+ // 如果同意,查找下一个流程节点,拒绝,查找上一个流程
|
|
|
275
|
+ if (dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) {
|
|
|
276
|
+ // 同意,根据流程id查找下一个流程节点
|
|
|
277
|
+ flow = caseFlowMapper.nextFlow(dto.getCaseFlowId());
|
|
|
278
|
+ if (flow == null) {
|
|
|
279
|
+ return AjaxResult.error("未找到下一个流程节点");
|
|
|
280
|
+ }
|
|
|
281
|
+ } else {
|
|
|
282
|
+ if (currentFlow.getBackFlowId() == null) {
|
|
|
283
|
+ return AjaxResult.error("未找到驳回流程");
|
|
|
284
|
+ }
|
|
|
285
|
+ // 拒绝,查找驳回流程
|
|
|
286
|
+ flow = caseFlowMapper.selectByPrimaryKey(currentFlow.getBackFlowId());
|
|
|
287
|
+ if (flow == null) {
|
|
|
288
|
+ return AjaxResult.error("未找到驳回流程");
|
|
|
289
|
+ }
|
|
276
|
290
|
|
|
277
|
|
- // 根据流程id查找下一个流程节点
|
|
278
|
|
- MsCaseFlow nextFlow = caseFlowMapper.nextFlow(dto.getCaseFlowId());
|
|
279
|
|
- if (nextFlow == null) {
|
|
280
|
|
- return AjaxResult.error("未找到下一个流程节点");
|
|
281
|
291
|
}
|
|
282
|
|
-
|
|
283
|
292
|
if (StrUtil.isNotEmpty(dto.getBatchNumber())) {
|
|
284
|
293
|
// 批量
|
|
285
|
294
|
List<MsCaseApplication> applicationList = applicationService.listByBatchNumber(dto.getBatchNumber(), dto.getCaseFlowId());
|
|
286
|
|
- if(CollectionUtil.isEmpty(applicationList)){
|
|
|
295
|
+ if (CollectionUtil.isEmpty(applicationList)) {
|
|
287
|
296
|
return AjaxResult.error("该批号下未找到案件");
|
|
288
|
297
|
}
|
|
289
|
298
|
for (MsCaseApplication application : applicationList) {
|
|
290
|
|
- casePaymentService.confirmPaid(currentFlow,nextFlow, application);
|
|
|
299
|
+ casePaymentService.confirmPaid(dto, currentFlow, flow, application);
|
|
291
|
300
|
}
|
|
292
|
|
- }else {
|
|
293
|
|
- MsCaseApplication caseApplication=new MsCaseApplication();
|
|
|
301
|
+ } else {
|
|
|
302
|
+ MsCaseApplication caseApplication = new MsCaseApplication();
|
|
294
|
303
|
caseApplication.setId(dto.getCaseId());
|
|
295
|
304
|
caseApplication.setLockStatus(YesOrNoEnum.YES.getCode());
|
|
296
|
|
- casePaymentService.confirmPaid(currentFlow,nextFlow,caseApplication );
|
|
|
305
|
+ casePaymentService.confirmPaid(dto, currentFlow, flow, caseApplication);
|
|
297
|
306
|
}
|
|
298
|
307
|
|
|
299
|
308
|
|
|
300
|
|
- return AjaxResult.success("确认缴费成功");
|
|
|
309
|
+
|
|
|
310
|
+ return AjaxResult.success();
|
|
301
|
311
|
}
|
|
302
|
312
|
|
|
303
|
313
|
/**
|
|
304
|
314
|
* 确认已缴费
|
|
305
|
|
- * @param nextFlow
|
|
|
315
|
+ * @param flow
|
|
306
|
316
|
* @param application
|
|
307
|
317
|
* @param
|
|
308
|
318
|
*/
|
|
309
|
319
|
@Transactional
|
|
310
|
|
- public void confirmPaid(MsCaseFlow currentFlow,MsCaseFlow nextFlow, MsCaseApplication application) {
|
|
|
320
|
+ public void confirmPaid(CaseConfirmPayDTO dto, MsCaseFlow currentFlow, MsCaseFlow flow, MsCaseApplication application) {
|
|
311
|
321
|
// 查询案件
|
|
312
|
322
|
MsCaseApplication caseAppllication = caseApplicationMapper.selectByPrimaryKey(application.getId());
|
|
313
|
|
- if(caseAppllication==null){
|
|
|
323
|
+ if (caseAppllication == null) {
|
|
314
|
324
|
throw new RuntimeException("未找到该案件");
|
|
315
|
325
|
}
|
|
316
|
326
|
//更改记录表里的支付状态和支付时间
|
|
317
|
327
|
MsCasePaymentRecord casePaymentRecord = new MsCasePaymentRecord();
|
|
318
|
|
- casePaymentRecord.setPaymentStatus(1);
|
|
|
328
|
+ if (dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) {
|
|
|
329
|
+ // 同意
|
|
|
330
|
+ casePaymentRecord.setPaymentStatus(1);
|
|
|
331
|
+ casePaymentRecord.setPaymentTime(new Date());
|
|
|
332
|
+ casePaymentRecord.setUpdateTime(new Date());
|
|
|
333
|
+ }else {
|
|
|
334
|
+ casePaymentRecord.setPaymentStatus(0);
|
|
|
335
|
+ }
|
|
319
|
336
|
casePaymentRecord.setCaseId(application.getId());
|
|
320
|
|
- casePaymentRecord.setPaymentTime(new Date());
|
|
321
|
|
- casePaymentRecord.setUpdateTime(new Date());
|
|
322
|
337
|
Example example = new Example(MsCasePaymentRecord.class);
|
|
323
|
338
|
example.createCriteria().andEqualTo("caseId", casePaymentRecord.getCaseId());
|
|
324
|
|
- casePaymentRecordMapper.updateByExampleSelective(casePaymentRecord,example);
|
|
|
339
|
+ casePaymentRecordMapper.updateByExampleSelective(casePaymentRecord, example);
|
|
325
|
340
|
// 更改案件流程id和案件状态
|
|
326
|
|
- application.setCaseFlowId(nextFlow.getId());
|
|
327
|
|
- application.setCaseStatusName(nextFlow.getCaseStatusName());
|
|
|
341
|
+ application.setCaseFlowId(flow.getId());
|
|
|
342
|
+ application.setCaseStatusName(flow.getCaseStatusName());
|
|
328
|
343
|
caseApplicationMapper.updateByPrimaryKeySelective(application);
|
|
329
|
|
- // 将该案件存放到redis,5日之内如果案件状态还是待受理状态,则发送不受理通知书并自动结束
|
|
330
|
|
- redisCache.setCacheObject(String.valueOf(application.getId()), application, Constants.CASE_ACCEPT_EXPIRATION, TimeUnit.DAYS);
|
|
331
|
|
-
|
|
|
344
|
+ if (dto.getApplicantConfirm() && dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) {
|
|
|
345
|
+ // 申请人确认缴费后将该案件存放到redis,5日之内如果案件状态还是待受理状态,则发送不受理通知书并自动结束
|
|
|
346
|
+ redisCache.setCacheObject(String.valueOf(application.getId()), application, Constants.CASE_ACCEPT_EXPIRATION, TimeUnit.DAYS);
|
|
|
347
|
+ }
|
|
332
|
348
|
// 新增日志
|
|
333
|
|
- CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),"确认已缴费");
|
|
334
|
|
-
|
|
|
349
|
+ if (dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) {
|
|
|
350
|
+ CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "确认已缴费");
|
|
|
351
|
+ }else {
|
|
|
352
|
+ CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "拒绝确认缴费,拒绝原因为:"+dto.getReason());
|
|
|
353
|
+ }
|
|
|
354
|
+ if (dto.getYesOrNo().equals(YesOrNoEnum.NO.getCode())) {
|
|
|
355
|
+ // 拒绝,新增审核记录
|
|
|
356
|
+ MsCaseAudit audit = new MsCaseAudit();
|
|
|
357
|
+ audit.setCaseNode(flow.getNodeId());
|
|
|
358
|
+ audit.setCaseStatusName(flow.getCaseStatusName());
|
|
|
359
|
+ audit.setCaseAppliId(dto.getCaseId());
|
|
|
360
|
+ audit.setYesOrNo(dto.getYesOrNo());
|
|
|
361
|
+ audit.setReason(dto.getReason());
|
|
|
362
|
+ audit.setCreateTime(new Date());
|
|
|
363
|
+ if (SecurityUtils.getLoginUser().getUser() != null) {
|
|
|
364
|
+ audit.setCreateBy(SecurityUtils.getUsername());
|
|
|
365
|
+ audit.setCreateNickName(SecurityUtils.getLoginUser().getUser().getNickName());
|
|
|
366
|
+ }
|
|
|
367
|
+ auditMapper.insert(audit);
|
|
|
368
|
+ }
|
|
335
|
369
|
// 查询申请人电话,如果是自然人,代理人不为空,则给代理人发短信,代理人为空,给申请人发短信
|
|
336
|
370
|
MsCaseAffiliate affiliate = caseAffiliateMapper.selectByPrimaryKey(application.getId());
|
|
337
|
|
- if(affiliate != null) {
|
|
338
|
|
- String phone="";
|
|
339
|
|
- String userName="";
|
|
340
|
|
- if(affiliate.getOrganizeFlag().equals(0)){
|
|
|
371
|
+ // 发送缴费通知
|
|
|
372
|
+ sendPaymentSms(dto,caseAppllication, affiliate,flow);
|
|
|
373
|
+
|
|
|
374
|
+
|
|
|
375
|
+ }
|
|
|
376
|
+ /**
|
|
|
377
|
+ * 被申请人确认已缴费
|
|
|
378
|
+ * @param dto
|
|
|
379
|
+ * @return
|
|
|
380
|
+ */
|
|
|
381
|
+ @Transactional
|
|
|
382
|
+ @Override
|
|
|
383
|
+ public AjaxResult resConfirmPaid(CaseConfirmPayDTO dto) {
|
|
|
384
|
+ dto.setApplicantConfirm(false);
|
|
|
385
|
+ confirmPaid(dto);
|
|
|
386
|
+ return AjaxResult.success();
|
|
|
387
|
+
|
|
|
388
|
+ }
|
|
|
389
|
+
|
|
|
390
|
+ /**
|
|
|
391
|
+ * 发送缴费短信
|
|
|
392
|
+ * @param dto
|
|
|
393
|
+ * @param caseAppllication
|
|
|
394
|
+ * @param affiliate
|
|
|
395
|
+ */
|
|
|
396
|
+ private void sendPaymentSms(CaseConfirmPayDTO dto, MsCaseApplication caseAppllication, MsCaseAffiliate affiliate,MsCaseFlow flow) {
|
|
|
397
|
+ if (affiliate != null) {
|
|
|
398
|
+ // 受理通知
|
|
|
399
|
+ String phone = "";
|
|
|
400
|
+ String userName = "";
|
|
|
401
|
+ // 缴费通知
|
|
|
402
|
+ String payPhone = "";
|
|
|
403
|
+ String payUserName = "";
|
|
|
404
|
+ if (affiliate.getOrganizeFlag().equals(0)) {
|
|
341
|
405
|
// 自然人
|
|
342
|
|
- if(StrUtil.isNotEmpty(affiliate.getContactTelphoneAgent())){
|
|
343
|
|
- phone=affiliate.getContactTelphoneAgent();
|
|
344
|
|
- userName=affiliate.getNameAgent();
|
|
345
|
|
- }else {
|
|
346
|
|
- phone=affiliate.getApplicationPhone();
|
|
347
|
|
- userName=affiliate.getApplicationName();
|
|
|
406
|
+ if (StrUtil.isNotEmpty(affiliate.getContactTelphoneAgent())) {
|
|
|
407
|
+ phone = affiliate.getContactTelphoneAgent();
|
|
|
408
|
+ userName = affiliate.getNameAgent();
|
|
|
409
|
+ } else {
|
|
|
410
|
+ phone = affiliate.getApplicationPhone();
|
|
|
411
|
+ userName = affiliate.getApplicationName();
|
|
348
|
412
|
}
|
|
349
|
413
|
|
|
350
|
|
- }else {
|
|
351
|
|
- phone=affiliate.getContactTelphoneAgent();
|
|
352
|
|
- userName=affiliate.getNameAgent();
|
|
|
414
|
+ } else {
|
|
|
415
|
+ phone = affiliate.getContactTelphoneAgent();
|
|
|
416
|
+ userName = affiliate.getNameAgent();
|
|
353
|
417
|
}
|
|
354
|
|
- if(StrUtil.isNotEmpty(phone)) {
|
|
355
|
|
- // 发送短信 2051914 调解缴费成功通知 尊敬的{1},您的调解申请费用已缴费成功。
|
|
356
|
|
- Boolean smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2051914", phone, new String[]{userName});
|
|
357
|
|
- // CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "申请人调解缴费成功通知短信,尊敬的" + userName + ",您的调解申请费用已缴费成功。");
|
|
358
|
|
-
|
|
|
418
|
+ if (StrUtil.isNotEmpty(phone)) {
|
|
|
419
|
+ payPhone=phone;
|
|
|
420
|
+ payUserName=userName;
|
|
|
421
|
+ if(!dto.getApplicantConfirm()) {
|
|
|
422
|
+ // 被申请人发送通知
|
|
|
423
|
+ payPhone=affiliate.getRespondentPhone();
|
|
|
424
|
+ payUserName=affiliate.getRespondentName();
|
|
|
425
|
+ }
|
|
|
426
|
+ Boolean smsFlag =true;
|
|
|
427
|
+ SmsSendRecord smsSendRecord=null;
|
|
|
428
|
+ // 申请人被申请人发送缴费成功短信 2051914 调解缴费成功通知 尊敬的{1},您的调解申请费用已缴费成功。
|
|
|
429
|
+ if (dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) {
|
|
|
430
|
+ smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2051914", payPhone, new String[]{payUserName});
|
|
|
431
|
+ smsSendRecord = new SmsSendRecord(caseAppllication.getId(), caseAppllication.getCaseNum(), payPhone, new Date(), "尊敬的" + payUserName + ",您的调解申请费用已缴费成功。");
|
|
|
432
|
+ } else {
|
|
|
433
|
+ smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2074402", payPhone, new String[]{payUserName, caseAppllication.getCaseNum(), dto.getReason()});
|
|
|
434
|
+ // 2074402 调解系统确认缴费不通过通知 尊敬的{1}用户,您的{2}案件,确认缴费未通过,理由为{3},请知晓,如非本人操作,请忽略本短信
|
|
|
435
|
+ smsSendRecord = new SmsSendRecord(caseAppllication.getId(), caseAppllication.getCaseNum(), payPhone, new Date(), "尊敬的" + payUserName + "用户,您的" + caseAppllication.getCaseNum() + "案件,确认缴费未通过,理由为" + dto.getReason() + ",请知晓,如非本人操作,请忽略本短信");
|
|
|
436
|
+ }
|
|
359
|
437
|
// 新增短信记录
|
|
360
|
|
- SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), caseAppllication.getCaseNum(), phone, new Date(), "尊敬的" + userName + ",您的调解申请费用已缴费成功。");
|
|
361
|
|
- if(smsFlag){
|
|
|
438
|
+ if (smsFlag) {
|
|
362
|
439
|
smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode());
|
|
363
|
|
- }else {
|
|
|
440
|
+ } else {
|
|
364
|
441
|
smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode());
|
|
365
|
442
|
}
|
|
366
|
443
|
smsRecordMapper.saveSmsSendRecord(smsSendRecord);
|
|
|
444
|
+ if(dto.getApplicantConfirm()&& dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) {
|
|
|
445
|
+ // 申请人发送受理短信
|
|
|
446
|
+ sendAcceptSms(dto, caseAppllication, userName, phone);
|
|
|
447
|
+ // 被申请人发送受理短信
|
|
|
448
|
+ sendAcceptSms(dto, caseAppllication, affiliate.getRespondentName(), affiliate.getRespondentPhone());
|
|
|
449
|
+ }
|
|
367
|
450
|
}
|
|
368
|
451
|
}
|
|
369
|
452
|
}
|
|
370
|
453
|
|
|
|
454
|
+ /**
|
|
|
455
|
+ * 发送受理短信
|
|
|
456
|
+ * @param dto
|
|
|
457
|
+ * @param caseAppllication
|
|
|
458
|
+ */
|
|
|
459
|
+ private void sendAcceptSms(CaseConfirmPayDTO dto, MsCaseApplication caseAppllication,String userName,String phone ) {
|
|
|
460
|
+ // 申请人被申请人发送受理通知书 2073601 尊敬的{1}用户,您的{2}案件,已成功受理,请知晓,如非本人操作,请忽略本短信。
|
|
|
461
|
+ Boolean smsFlag = SmsUtils.sendSms(caseAppllication.getId(), "2073601", phone, new String[]{userName, caseAppllication.getCaseNum()});
|
|
|
462
|
+ SmsSendRecord smsSendRecord = new SmsSendRecord(caseAppllication.getId(), caseAppllication.getCaseNum(), phone, new Date(), "尊敬的" + userName + "用户,您的" + caseAppllication.getCaseNum() + "案件,已成功受理,请知晓,如非本人操作,请忽略本短信。");
|
|
|
463
|
+ // 新增短信记录
|
|
|
464
|
+ if (smsFlag) {
|
|
|
465
|
+ smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode());
|
|
|
466
|
+ } else {
|
|
|
467
|
+ smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode());
|
|
|
468
|
+ }
|
|
|
469
|
+ smsRecordMapper.saveSmsSendRecord(smsSendRecord);
|
|
|
470
|
+
|
|
|
471
|
+ }
|
|
|
472
|
+
|
|
371
|
473
|
/**
|
|
372
|
474
|
* 确认缴费
|
|
373
|
475
|
*
|
|
|
@@ -380,7 +482,17 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService {
|
|
380
|
482
|
application.setPayType(dto.getPayType());
|
|
381
|
483
|
// 修改缴费附件
|
|
382
|
484
|
if (CollectionUtil.isNotEmpty(dto.getPayOrderList())) {
|
|
|
485
|
+
|
|
|
486
|
+
|
|
383
|
487
|
for (MsCaseAttach caseAttach : dto.getPayOrderList()) {
|
|
|
488
|
+ // 先删除之前的缴费
|
|
|
489
|
+ if(currentFlow.getButtonAuthFlag().equals("caseManagement:list:pay")){
|
|
|
490
|
+ // 申请人附件
|
|
|
491
|
+ caseAttachMapper.deleteCaseAttachByCasedIdAndType(application.getId(),AnnexTypeEnum.PAYMENT_RECEIPT.getCode());
|
|
|
492
|
+ }else {
|
|
|
493
|
+ // 被申请人缴费附件
|
|
|
494
|
+ caseAttachMapper.deleteCaseAttachByCasedIdAndType(application.getId(),AnnexTypeEnum.RES_PAYMENT_RECEIPT.getCode());
|
|
|
495
|
+ }
|
|
384
|
496
|
caseAttach.setCaseAppliId(application.getId());
|
|
385
|
497
|
caseAttachMapper.updateCaseAttach(caseAttach);
|
|
386
|
498
|
}
|