更改退款接口

This commit is contained in:
terrfly 2021-06-18 10:20:03 +08:00
parent 9e8d51da02
commit 7b06548040
10 changed files with 56 additions and 39 deletions

View File

@ -287,8 +287,8 @@ CREATE TABLE `t_pay_order` (
`refund_amount` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '退款总金额,单位分',
`division_flag` TINYINT(6) DEFAULT 0 COMMENT '订单分账标志0-否 1-是',
`division_time` DATETIME COMMENT '预计分账发起时间',
`err_code` VARCHAR(64) DEFAULT NULL COMMENT '渠道支付错误码',
`err_msg` VARCHAR(128) DEFAULT NULL COMMENT '渠道支付错误描述',
`err_code` VARCHAR(128) DEFAULT NULL COMMENT '渠道支付错误码',
`err_msg` VARCHAR(256) DEFAULT NULL COMMENT '渠道支付错误描述',
`ext_param` VARCHAR(128) DEFAULT NULL COMMENT '商户扩展参数',
`notify_url` VARCHAR(128) NOT NULL default '' COMMENT '异步通知地址',
`return_url` VARCHAR(128) DEFAULT '' COMMENT '页面跳转地址',
@ -364,8 +364,8 @@ CREATE TABLE `t_refund_order` (
`client_ip` VARCHAR(32) DEFAULT NULL COMMENT '客户端IP',
`refund_reason` VARCHAR(256) NOT NULL COMMENT '退款原因',
`channel_order_no` VARCHAR(32) DEFAULT NULL COMMENT '渠道订单号',
`channel_err_code` VARCHAR(128) DEFAULT NULL COMMENT '渠道错误码',
`channel_err_msg` VARCHAR(128) DEFAULT NULL COMMENT '渠道错误描述',
`err_code` VARCHAR(128) DEFAULT NULL COMMENT '渠道错误码',
`err_msg` VARCHAR(256) DEFAULT NULL COMMENT '渠道错误描述',
`channel_extra` VARCHAR(512) DEFAULT NULL COMMENT '特定渠道发起时额外参数',
`notify_url` VARCHAR(128) DEFAULT NULL COMMENT '通知地址',
`ext_param` VARCHAR(64) DEFAULT NULL COMMENT '扩展参数',
@ -433,6 +433,7 @@ insert into t_sys_entitlement values('ENT_ORDER', '订单管理', 'transaction',
insert into t_sys_entitlement values('ENT_PAY_ORDER', '支付订单', 'account-book', '/pay', 'PayOrderListPage', 'ML', 0, 1, 'ENT_ORDER', '10', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_ORDER_LIST', '页面:订单列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_PAY_ORDER', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_PAY_ORDER_VIEW', '按钮:详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_PAY_ORDER', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_PAY_ORDER_REFUND', '按钮:订单退款', 'no-icon', '', '', 'PB', 0, 1, 'ENT_PAY_ORDER', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_REFUND_ORDER', '退款订单', 'exception', '/refund', 'RefundOrderListPage', 'ML', 0, 1, 'ENT_ORDER', '20', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_REFUND_LIST', '页面:退款订单列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_REFUND_ORDER', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_REFUND_ORDER_VIEW', '按钮:详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_REFUND_ORDER', '0', 'MGR', now(), now());

View File

@ -145,12 +145,12 @@ public class RefundOrder extends BaseModel {
/**
* 渠道错误码
*/
private String channelErrCode;
private String errCode;
/**
* 渠道错误描述
*/
private String channelErrMsg;
private String errMsg;
/**
* 特定渠道发起时额外参数

View File

@ -18,9 +18,11 @@ package com.jeequan.jeepay.mgr.ctrl.order;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.entity.PayOrder;
import com.jeequan.jeepay.core.entity.PayWay;
import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.PayOrderService;
@ -28,10 +30,7 @@ import com.jeequan.jeepay.service.impl.PayWayService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
@ -108,4 +107,33 @@ public class PayOrderController extends CommonCtrl {
return ApiRes.ok(payOrder);
}
/**
* 发起订单退款
* @author terrfly
* @site https://www.jeepay.vip
* @date 2021/6/17 16:38
*/
@MethodLog(remark = "发起订单退款")
@PreAuthorize("hasAuthority('ENT_PAY_ORDER_REFUND')")
@PostMapping("/refunds/{payOrderId}")
public ApiRes refund(@PathVariable("payOrderId") String payOrderId) {
Long refundAmount = getRequiredAmountL("refundAmount");
String refundReason = getValStringRequired("refundReason");
PayOrder payOrder = payOrderService.getById(payOrderId);
if (payOrder == null) return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
if(payOrder.getState() != PayOrder.STATE_SUCCESS){
throw new BizException("订单状态不正确");
}
if(payOrder.getRefundAmount() + refundAmount >= payOrder.getAmount()){
throw new BizException("退款金额超过订单可退款金额!");
}
throw new BizException("功能开发中, 暂时不支持后台退款请调起API接口发起退款。");
}
}

View File

@ -196,8 +196,8 @@ public class RefundOrderController extends ApiController {
refundOrder.setClientIp(StringUtils.defaultIfEmpty(rq.getClientIp(), getClientIp())); //客户端IP
refundOrder.setRefundReason(rq.getRefundReason()); //退款原因
refundOrder.setChannelOrderNo(null); //渠道订单号
refundOrder.setChannelErrCode(null); //渠道错误码
refundOrder.setChannelErrMsg(null); //渠道错误描述
refundOrder.setErrCode(null); //渠道错误码
refundOrder.setErrMsg(null); //渠道错误描述
refundOrder.setChannelExtra(rq.getChannelExtra()); //特定渠道发起时额外参数
refundOrder.setNotifyUrl(rq.getNotifyUrl()); //通知地址
refundOrder.setExtParam(rq.getExtParam()); //扩展参数
@ -254,8 +254,8 @@ public class RefundOrderController extends ApiController {
refundOrder.setState(orderState);
refundOrder.setChannelOrderNo(channelRetMsg.getChannelOrderId());
refundOrder.setChannelErrCode(channelRetMsg.getChannelErrCode());
refundOrder.setChannelErrMsg(channelRetMsg.getChannelErrMsg());
refundOrder.setErrCode(channelRetMsg.getChannelErrCode());
refundOrder.setErrMsg(channelRetMsg.getChannelErrMsg());
boolean isSuccess = refundOrderService.updateInit2Ing(refundOrder.getRefundOrderId());

View File

@ -40,6 +40,11 @@ public class QueryPayOrderRS extends AbstractRS {
*/
private String mchNo;
/**
* 商户应用ID
*/
private String appId;
/**
* 商户订单号
*/

View File

@ -58,9 +58,6 @@ public class RefundOrderRQ extends AbstractMchAppRQ {
/** 客户端IP地址 **/
private String clientIp;
/** 客户端设备信息 **/
private String device;
/** 异步通知地址 **/
private String notifyUrl;

View File

@ -33,12 +33,6 @@ public class RefundOrderRS extends AbstractRS {
/** 支付系统退款订单号 **/
private String refundOrderId;
/** 商户号 **/
private String mchNo;
/** 商户应用ID **/
private String appId;
/** 商户发起的退款订单号 **/
private String mchRefundNo;
@ -55,16 +49,10 @@ public class RefundOrderRS extends AbstractRS {
private String channelOrderNo;
/** 渠道返回错误代码 **/
private String channelErrCode;
private String errCode;
/** 渠道返回错误信息 **/
private String channelErrMsg;
/** 退款成功时间 **/
private Long successTime;
/** 创建时间 **/
private Long createdAt;
private String errMsg;
public static RefundOrderRS buildByRefundOrder(RefundOrder refundOrder){
@ -75,8 +63,6 @@ public class RefundOrderRS extends AbstractRS {
RefundOrderRS result = new RefundOrderRS();
BeanUtils.copyProperties(refundOrder, result);
result.setSuccessTime(refundOrder.getSuccessTime() == null ? null : refundOrder.getSuccessTime().getTime());
result.setCreatedAt(refundOrder.getCreatedAt() == null ? null : refundOrder.getCreatedAt().getTime());
return result;
}

View File

@ -159,8 +159,8 @@ public class PayMchNotifyService {
*/
public String createNotifyUrl(RefundOrder refundOrder, String appSecret) {
QueryRefundOrderRS queryPayOrderRS = QueryRefundOrderRS.buildByRefundOrder(refundOrder);
JSONObject jsonObject = (JSONObject)JSONObject.toJSON(queryPayOrderRS);
QueryRefundOrderRS queryRefundOrderRS = QueryRefundOrderRS.buildByRefundOrder(refundOrder);
JSONObject jsonObject = (JSONObject)JSONObject.toJSON(queryRefundOrderRS);
jsonObject.put("reqTime", System.currentTimeMillis()); //添加请求时间
// 报文签名

View File

@ -98,8 +98,8 @@ public class RefundOrderService extends ServiceImpl<RefundOrderMapper, RefundOrd
RefundOrder updateRecord = new RefundOrder();
updateRecord.setState(RefundOrder.STATE_FAIL);
updateRecord.setChannelErrCode(channelErrCode);
updateRecord.setChannelErrMsg(channelErrMsg);
updateRecord.setErrCode(channelErrCode);
updateRecord.setErrMsg(channelErrMsg);
updateRecord.setChannelOrderNo(channelOrderNo);
return update(updateRecord, new LambdaUpdateWrapper<RefundOrder>()

View File

@ -22,8 +22,8 @@
<result column="client_ip" property="clientIp" />
<result column="refund_reason" property="refundReason" />
<result column="channel_order_no" property="channelOrderNo" />
<result column="channel_err_code" property="channelErrCode" />
<result column="channel_err_msg" property="channelErrMsg" />
<result column="err_code" property="errCode" />
<result column="err_msg" property="errMsg" />
<result column="channel_extra" property="channelExtra" />
<result column="notify_url" property="notifyUrl" />
<result column="ext_param" property="extParam" />