缴费接口开发一

This commit is contained in:
hejinbo
2023-09-11 18:17:17 +08:00
parent 67ccbbd4f7
commit aa351abd15
8 changed files with 101 additions and 111 deletions
@@ -1,8 +0,0 @@
package com.ruoyi.system.mapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CasePaymentMapper {
void queryPayList();
}
@@ -1,21 +0,0 @@
package com.ruoyi.system.service;
import com.ruoyi.dto.PayRequest;
public interface ICasePaymentService {
/**
* 案件缴费
* @param request
* @return
*/
String casePay(PayRequest request);
/**
* 查询缴费列表
*/
String queryPayList();
String getPaymentListByCaseId();
String payConfirm();
}
@@ -1,46 +0,0 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.ElegentPay;
import com.ruoyi.constant.Platform;
import com.ruoyi.constant.TradeType;
import com.ruoyi.dto.PayRequest;
import com.ruoyi.dto.PayResponse;
import com.ruoyi.system.mapper.CasePaymentMapper;
import com.ruoyi.system.service.ICasePaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CasePaymentServiceImpl implements ICasePaymentService {
private final ElegentPay elegentPay;
private final CasePaymentMapper paymentMapper;
@Autowired
public CasePaymentServiceImpl(ElegentPay elegentPay,CasePaymentMapper paymentMapper ){
this.elegentPay=elegentPay;
this.paymentMapper=paymentMapper;
}
@Override
public String casePay(PayRequest request) {
PayResponse payResponse = elegentPay.requestPay(request, TradeType.NATIVE, Platform.WX);
if (payResponse!=null){
return payResponse.getCode_url();
}
return null;
}
@Override
public String queryPayList() {
paymentMapper.queryPayList();
return null;
}
@Override
public String getPaymentListByCaseId() {
return null;
}
@Override
public String payConfirm() {
return null;
}
}
@@ -0,0 +1,20 @@
package com.ruoyi.wisdomarbitrate.domain.dto;
import lombok.Data;
/**
* 案件缴费传入参数
*/
@Data
public class CasePayDTO {
private int totalFee; //订单金额 单位:分
private String body;//商品描述
/**
* 交易类型 native(扫码) / jsapi(小程序) / app / h5
*/
private String tradeType;
/**
* 支付方式 wxpay(微信) alipay(支付宝)
*/
private String platform;
}
@@ -0,0 +1,15 @@
package com.ruoyi.wisdomarbitrate.service;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.dto.PayRequest;
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO;
public interface ICasePaymentService {
/**
* 案件缴费
*/
AjaxResult casePay(CasePayDTO casePayDTO);
AjaxResult confirmPayment(CaseApplication caseApplication);
}
@@ -0,0 +1,48 @@
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.dto.PayRequest;
import com.ruoyi.dto.PayResponse;
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
import com.ruoyi.wisdomarbitrate.service.ICasePaymentService;
import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CasePaymentServiceImpl implements ICasePaymentService {
private final ElegentPay elegentPay;
private final CaseApplicationMapper caseApplicationMapper;
@Autowired
public CasePaymentServiceImpl(ElegentPay elegentPay
, CaseApplicationMapper caseApplicationMapper) {
this.elegentPay = elegentPay;
this.caseApplicationMapper = caseApplicationMapper;
}
@Override
public AjaxResult casePay(CasePayDTO casePayDTO) {
PayRequest payRequest = new PayRequest();
payRequest.setBody(casePayDTO.getBody());
payRequest.setOrderSn(System.currentTimeMillis() + "");
payRequest.setTotalFee(casePayDTO.getTotalFee());
PayResponse response = elegentPay.requestPay(payRequest, casePayDTO.getTradeType(), casePayDTO.getPlatform());
return AjaxResult.success(response);
}
@Override
public AjaxResult confirmPayment(CaseApplication caseApplication) {
caseApplication.setCaseStatus(CaseApplicationConstants.EVIDENCE_CONFREMED);
int i = caseApplicationMapper.updataCaseApplication(caseApplication);
if (i > 0) {
return AjaxResult.success();
}
return AjaxResult.error("暂无需要确认的缴费清单");
}
}