缴费及缴费确认接口开发
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.ruoyi.wisdomarbitrate.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class CasePaymentRecord extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 案件id
|
||||
*/
|
||||
private Long caseId;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String orderNumber;
|
||||
/**
|
||||
* 支付状态(0未支付,1已支付)
|
||||
*/
|
||||
private Integer paymentStatus;
|
||||
/**
|
||||
* 支付时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date paymentTime;
|
||||
}
|
||||
@@ -1,14 +1,25 @@
|
||||
package com.ruoyi.wisdomarbitrate.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 案件缴费传入参数
|
||||
*/
|
||||
@Data
|
||||
public class CasePayDTO {
|
||||
private int totalFee; //订单金额 单位:分
|
||||
private String body;//商品描述
|
||||
/**
|
||||
* 案件id
|
||||
*/
|
||||
private Long caseId;
|
||||
|
||||
/**
|
||||
* 订单金额 单位:分
|
||||
*/
|
||||
private int totalFee;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String body;
|
||||
/**
|
||||
* 交易类型 native(扫码) / jsapi(小程序) / app / h5
|
||||
*/
|
||||
@@ -17,4 +28,4 @@ public class CasePayDTO {
|
||||
* 支付方式 wxpay(微信) alipay(支付宝)
|
||||
*/
|
||||
private String platform;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.ruoyi.wisdomarbitrate.mapper;
|
||||
|
||||
import com.ruoyi.wisdomarbitrate.domain.CasePaymentRecord;
|
||||
|
||||
public interface CasePaymentRecordMapper {
|
||||
int saveRecord(CasePaymentRecord casePaymentRecord);
|
||||
|
||||
CasePaymentRecord queryRecord(String orderSn);
|
||||
|
||||
void update(CasePaymentRecord casePaymentRecord);
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.ruoyi.wisdomarbitrate.service.impl;
|
||||
|
||||
import com.ruoyi.CallBackService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 业务回调处理
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CallBackHandleServiceImpl implements CallBackService {
|
||||
@Autowired
|
||||
private CasePaymentServiceImpl casePaymentService;
|
||||
@Override
|
||||
public void successPay(String orderSn) {
|
||||
casePaymentService.callback(orderSn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failPay(String orderSn) {
|
||||
log.info("支付失败回调!"+orderSn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void successRefund(String orderSn) {
|
||||
log.info("退款成功回调!"+orderSn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failRefund(String orderSn) {
|
||||
log.info("退款失败回调!"+orderSn);
|
||||
}
|
||||
}
|
||||
+70
-6
@@ -1,29 +1,41 @@
|
||||
package com.ruoyi.wisdomarbitrate.service.impl;
|
||||
|
||||
import com.ruoyi.CallBackService;
|
||||
|
||||
|
||||
import com.ruoyi.ElegentPay;
|
||||
import com.ruoyi.common.constant.CaseApplicationConstants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
import com.ruoyi.common.utils.SmsUtils;
|
||||
import com.ruoyi.dto.PayRequest;
|
||||
import com.ruoyi.dto.PayResponse;
|
||||
import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate;
|
||||
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
|
||||
import com.ruoyi.wisdomarbitrate.service.ICasePaymentService;
|
||||
import com.ruoyi.wisdomarbitrate.domain.CasePaymentRecord;
|
||||
import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.CasePaymentRecordMapper;
|
||||
import com.ruoyi.wisdomarbitrate.service.ICasePaymentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CasePaymentServiceImpl implements ICasePaymentService {
|
||||
private final ElegentPay elegentPay;
|
||||
private final CaseApplicationMapper caseApplicationMapper;
|
||||
private final CasePaymentRecordMapper casePaymentRecordMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
public CasePaymentServiceImpl(ElegentPay elegentPay
|
||||
, CaseApplicationMapper caseApplicationMapper) {
|
||||
, CaseApplicationMapper caseApplicationMapper
|
||||
, CasePaymentRecordMapper casePaymentRecordMapper) {
|
||||
this.elegentPay = elegentPay;
|
||||
this.caseApplicationMapper = caseApplicationMapper;
|
||||
this.casePaymentRecordMapper = casePaymentRecordMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,13 +45,65 @@ public class CasePaymentServiceImpl implements ICasePaymentService {
|
||||
payRequest.setOrderSn(System.currentTimeMillis() + "");
|
||||
payRequest.setTotalFee(casePayDTO.getTotalFee());
|
||||
PayResponse response = elegentPay.requestPay(payRequest, casePayDTO.getTradeType(), casePayDTO.getPlatform());
|
||||
if (response.getCode_url() == null) {
|
||||
return AjaxResult.error();
|
||||
}
|
||||
//缴费记录表里新增数据
|
||||
CasePaymentRecord casePaymentRecord = new CasePaymentRecord();
|
||||
casePaymentRecord.setCaseId(casePayDTO.getCaseId());
|
||||
casePaymentRecord.setOrderNumber(payRequest.getOrderSn());
|
||||
casePaymentRecord.setPaymentStatus(0);
|
||||
int count = casePaymentRecordMapper.saveRecord(casePaymentRecord);
|
||||
if (count < 1) {
|
||||
return AjaxResult.error("请检查参数是否有误");
|
||||
}
|
||||
return AjaxResult.success(response);
|
||||
}
|
||||
|
||||
|
||||
public AjaxResult callback(String orderSn) {
|
||||
//查询记录
|
||||
CasePaymentRecord casePaymentRecord = casePaymentRecordMapper.queryRecord(orderSn);
|
||||
if (casePaymentRecord == null) {
|
||||
return AjaxResult.error("未查询到相关记录");
|
||||
}
|
||||
Long caseId = casePaymentRecord.getCaseId();
|
||||
//更改记录表里的支付状态和支付时间
|
||||
casePaymentRecord.setPaymentStatus(1);
|
||||
casePaymentRecord.setPaymentTime(new Date());
|
||||
casePaymentRecordMapper.update(casePaymentRecord);
|
||||
//根据案件id查询案件信息
|
||||
CaseApplication caseApplication = new CaseApplication();
|
||||
caseApplication.setId(caseId);
|
||||
CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
|
||||
caseApplication1.setCaseStatus(CaseApplicationConstants.PENDING_PAYMENT_CONFIRM);
|
||||
//修改案件状态
|
||||
caseApplicationMapper.submitCaseApplication(caseApplication);
|
||||
//发送短信通知
|
||||
SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
|
||||
List<CaseAffiliate> caseAffiliates = caseApplication1.getCaseAffiliates();//获取案件关联人信息
|
||||
if (caseAffiliates!=null&&caseAffiliates.size()>0){
|
||||
for (CaseAffiliate caseAffiliate : caseAffiliates) {
|
||||
request.setPhone(caseAffiliate.getContactTelphone());
|
||||
//获取身份类型
|
||||
int identityType = caseAffiliate.getIdentityType();
|
||||
if (identityType==1){ //申请人
|
||||
request.setTemplateId("申请人模板id"); //传入申请人模板id
|
||||
// 这个值,要看你的模板中是否预留了占位符,如果没有则不需要设置
|
||||
request.setTemplateParamSet(new String[]{"模板中的参数值,如果没有则为空"});
|
||||
} else { //被申请人
|
||||
request.setTemplateId("被申请人模板id");
|
||||
request.setTemplateParamSet(new String[]{"模板中的参数值,如果没有则为空"});
|
||||
}
|
||||
}
|
||||
}
|
||||
SmsUtils.sendSms(request);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
@Override
|
||||
public AjaxResult confirmPayment(CaseApplication caseApplication) {
|
||||
caseApplication.setCaseStatus(CaseApplicationConstants.EVIDENCE_CONFREMED);
|
||||
int i = caseApplicationMapper.updataCaseApplication(caseApplication);
|
||||
int i = caseApplicationMapper.submitCaseApplication(caseApplication);
|
||||
if (i > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.CasePaymentRecordMapper">
|
||||
<insert id="saveRecord">
|
||||
INSERT INTO case_payment_record (case_id, order_number, payment_status)
|
||||
VALUES (#{caseId}, #{orderNumber}, #{paymentStatus})
|
||||
</insert>
|
||||
<update id="update">
|
||||
update case_payment_record
|
||||
<set>
|
||||
<if test="caseId != null">case_id= #{caseId},</if>
|
||||
<if test="orderNumber != null and orderNumber != ''">order_number = #{orderNumber},</if>
|
||||
<if test="paymentTime != null ">payment_time = #{paymentTime},</if>
|
||||
<if test="paymentStatus != null ">payment_status = #{paymentStatus},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<select id="queryRecord" resultType="com.ruoyi.wisdomarbitrate.domain.CasePaymentRecord">
|
||||
select c.id ,c.case_id ,c.order_number ,c.payment_time ,c.create_time ,c.update_time ,c.payment_status
|
||||
from case_payment_record c
|
||||
<where>
|
||||
<if test="orderSn != null ">
|
||||
AND c.order_number = #{orderSn}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user