缴费接口开发一
This commit is contained in:
+18
-27
@@ -1,9 +1,11 @@
|
|||||||
package com.ruoyi.web.controller.payment;
|
package com.ruoyi.web.controller.payment;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.dto.PayRequest;
|
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
|
||||||
import com.ruoyi.system.service.ICasePaymentService;
|
import com.ruoyi.wisdomarbitrate.service.ICasePaymentService;
|
||||||
|
import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,34 +19,23 @@ public class CasePaymentController {
|
|||||||
public CasePaymentController(ICasePaymentService paymentService){
|
public CasePaymentController(ICasePaymentService paymentService){
|
||||||
this.paymentService=paymentService;
|
this.paymentService=paymentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询缴费列表
|
|
||||||
*/
|
|
||||||
@GetMapping
|
|
||||||
public String queryPayList(){
|
|
||||||
return paymentService.queryPayList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据案件id查询缴费清单
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping
|
|
||||||
public String getPaymentListByCaseId(){
|
|
||||||
return paymentService.getPaymentListByCaseId();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 案件缴费
|
* 案件缴费
|
||||||
* @param request
|
* @param casePayDTO 缴费传入参数
|
||||||
* @return
|
* @return 统一响应结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/casePay")
|
@PostMapping("/casePay")
|
||||||
public String casePay(PayRequest request) {
|
public AjaxResult casePay(@Validated @RequestBody CasePayDTO casePayDTO) {
|
||||||
return paymentService.casePay(request);
|
return paymentService.casePay(casePayDTO);
|
||||||
}
|
}
|
||||||
@PutMapping
|
|
||||||
public String payConfirm(){
|
/**
|
||||||
return paymentService.payConfirm();
|
* 缴费确认
|
||||||
|
* @param caseApplication
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PutMapping("/confirm")
|
||||||
|
public AjaxResult confirmPayment(@Validated @RequestBody CaseApplication caseApplication) {
|
||||||
|
return paymentService.confirmPayment(caseApplication);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
+48
@@ -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("暂无需要确认的缴费清单");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<?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.system.mapper.CasePaymentMapper">
|
|
||||||
<select id="queryPayList">
|
|
||||||
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
Reference in New Issue
Block a user