|
|
@@ -1,29 +1,41 @@
|
|
1
|
1
|
package com.ruoyi.wisdomarbitrate.service.impl;
|
|
2
|
2
|
|
|
3
|
|
-import com.ruoyi.CallBackService;
|
|
|
3
|
+
|
|
|
4
|
+
|
|
4
|
5
|
import com.ruoyi.ElegentPay;
|
|
5
|
6
|
import com.ruoyi.common.constant.CaseApplicationConstants;
|
|
6
|
7
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
7
|
|
-
|
|
|
8
|
+import com.ruoyi.common.utils.SmsUtils;
|
|
8
|
9
|
import com.ruoyi.dto.PayRequest;
|
|
9
|
10
|
import com.ruoyi.dto.PayResponse;
|
|
|
11
|
+import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate;
|
|
10
|
12
|
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
|
|
|
13
|
+import com.ruoyi.wisdomarbitrate.domain.CasePaymentRecord;
|
|
|
14
|
+import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO;
|
|
11
|
15
|
import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
|
|
|
16
|
+import com.ruoyi.wisdomarbitrate.mapper.CasePaymentRecordMapper;
|
|
12
|
17
|
import com.ruoyi.wisdomarbitrate.service.ICasePaymentService;
|
|
13
|
|
-import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO;
|
|
14
|
18
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
15
|
19
|
import org.springframework.stereotype.Service;
|
|
16
|
20
|
|
|
|
21
|
+import java.time.LocalDateTime;
|
|
|
22
|
+import java.util.Date;
|
|
|
23
|
+import java.util.List;
|
|
|
24
|
+
|
|
17
|
25
|
@Service
|
|
18
|
26
|
public class CasePaymentServiceImpl implements ICasePaymentService {
|
|
19
|
27
|
private final ElegentPay elegentPay;
|
|
20
|
28
|
private final CaseApplicationMapper caseApplicationMapper;
|
|
|
29
|
+ private final CasePaymentRecordMapper casePaymentRecordMapper;
|
|
|
30
|
+
|
|
21
|
31
|
|
|
22
|
32
|
@Autowired
|
|
23
|
33
|
public CasePaymentServiceImpl(ElegentPay elegentPay
|
|
24
|
|
- , CaseApplicationMapper caseApplicationMapper) {
|
|
|
34
|
+ , CaseApplicationMapper caseApplicationMapper
|
|
|
35
|
+ , CasePaymentRecordMapper casePaymentRecordMapper) {
|
|
25
|
36
|
this.elegentPay = elegentPay;
|
|
26
|
37
|
this.caseApplicationMapper = caseApplicationMapper;
|
|
|
38
|
+ this.casePaymentRecordMapper = casePaymentRecordMapper;
|
|
27
|
39
|
}
|
|
28
|
40
|
|
|
29
|
41
|
@Override
|
|
|
@@ -33,13 +45,65 @@ public class CasePaymentServiceImpl implements ICasePaymentService {
|
|
33
|
45
|
payRequest.setOrderSn(System.currentTimeMillis() + "");
|
|
34
|
46
|
payRequest.setTotalFee(casePayDTO.getTotalFee());
|
|
35
|
47
|
PayResponse response = elegentPay.requestPay(payRequest, casePayDTO.getTradeType(), casePayDTO.getPlatform());
|
|
|
48
|
+ if (response.getCode_url() == null) {
|
|
|
49
|
+ return AjaxResult.error();
|
|
|
50
|
+ }
|
|
|
51
|
+ //缴费记录表里新增数据
|
|
|
52
|
+ CasePaymentRecord casePaymentRecord = new CasePaymentRecord();
|
|
|
53
|
+ casePaymentRecord.setCaseId(casePayDTO.getCaseId());
|
|
|
54
|
+ casePaymentRecord.setOrderNumber(payRequest.getOrderSn());
|
|
|
55
|
+ casePaymentRecord.setPaymentStatus(0);
|
|
|
56
|
+ int count = casePaymentRecordMapper.saveRecord(casePaymentRecord);
|
|
|
57
|
+ if (count < 1) {
|
|
|
58
|
+ return AjaxResult.error("请检查参数是否有误");
|
|
|
59
|
+ }
|
|
36
|
60
|
return AjaxResult.success(response);
|
|
37
|
61
|
}
|
|
38
|
62
|
|
|
|
63
|
+
|
|
|
64
|
+ public AjaxResult callback(String orderSn) {
|
|
|
65
|
+ //查询记录
|
|
|
66
|
+ CasePaymentRecord casePaymentRecord = casePaymentRecordMapper.queryRecord(orderSn);
|
|
|
67
|
+ if (casePaymentRecord == null) {
|
|
|
68
|
+ return AjaxResult.error("未查询到相关记录");
|
|
|
69
|
+ }
|
|
|
70
|
+ Long caseId = casePaymentRecord.getCaseId();
|
|
|
71
|
+ //更改记录表里的支付状态和支付时间
|
|
|
72
|
+ casePaymentRecord.setPaymentStatus(1);
|
|
|
73
|
+ casePaymentRecord.setPaymentTime(new Date());
|
|
|
74
|
+ casePaymentRecordMapper.update(casePaymentRecord);
|
|
|
75
|
+ //根据案件id查询案件信息
|
|
|
76
|
+ CaseApplication caseApplication = new CaseApplication();
|
|
|
77
|
+ caseApplication.setId(caseId);
|
|
|
78
|
+ CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
|
|
|
79
|
+ caseApplication1.setCaseStatus(CaseApplicationConstants.PENDING_PAYMENT_CONFIRM);
|
|
|
80
|
+ //修改案件状态
|
|
|
81
|
+ caseApplicationMapper.submitCaseApplication(caseApplication);
|
|
|
82
|
+ //发送短信通知
|
|
|
83
|
+ SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
|
|
|
84
|
+ List<CaseAffiliate> caseAffiliates = caseApplication1.getCaseAffiliates();//获取案件关联人信息
|
|
|
85
|
+ if (caseAffiliates!=null&&caseAffiliates.size()>0){
|
|
|
86
|
+ for (CaseAffiliate caseAffiliate : caseAffiliates) {
|
|
|
87
|
+ request.setPhone(caseAffiliate.getContactTelphone());
|
|
|
88
|
+ //获取身份类型
|
|
|
89
|
+ int identityType = caseAffiliate.getIdentityType();
|
|
|
90
|
+ if (identityType==1){ //申请人
|
|
|
91
|
+ request.setTemplateId("申请人模板id"); //传入申请人模板id
|
|
|
92
|
+ // 这个值,要看你的模板中是否预留了占位符,如果没有则不需要设置
|
|
|
93
|
+ request.setTemplateParamSet(new String[]{"模板中的参数值,如果没有则为空"});
|
|
|
94
|
+ } else { //被申请人
|
|
|
95
|
+ request.setTemplateId("被申请人模板id");
|
|
|
96
|
+ request.setTemplateParamSet(new String[]{"模板中的参数值,如果没有则为空"});
|
|
|
97
|
+ }
|
|
|
98
|
+ }
|
|
|
99
|
+ }
|
|
|
100
|
+ SmsUtils.sendSms(request);
|
|
|
101
|
+ return AjaxResult.success();
|
|
|
102
|
+ }
|
|
39
|
103
|
@Override
|
|
40
|
104
|
public AjaxResult confirmPayment(CaseApplication caseApplication) {
|
|
41
|
105
|
caseApplication.setCaseStatus(CaseApplicationConstants.EVIDENCE_CONFREMED);
|
|
42
|
|
- int i = caseApplicationMapper.updataCaseApplication(caseApplication);
|
|
|
106
|
+ int i = caseApplicationMapper.submitCaseApplication(caseApplication);
|
|
43
|
107
|
if (i > 0) {
|
|
44
|
108
|
return AjaxResult.success();
|
|
45
|
109
|
}
|