mirror of
https://github.com/jeequan/jeepay
synced 2024-11-17 23:08:03 +08:00
添加商户系统的退款功能权限配置项
This commit is contained in:
parent
1985162085
commit
ad189f7d7c
@ -636,6 +636,7 @@ insert into t_sys_entitlement values('ENT_ORDER', '订单中心', 'transaction',
|
||||
insert into t_sys_entitlement values('ENT_ORDER_LIST', '页面:订单列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_PAY_ORDER', '0', 'MCH', now(), now());
|
||||
insert into t_sys_entitlement values('ENT_PAY_ORDER_VIEW', '按钮:详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_PAY_ORDER', '0', 'MCH', now(), now());
|
||||
insert into t_sys_entitlement values('ENT_PAY_ORDER_SEARCH_PAY_WAY', '筛选项:支付方式', 'no-icon', '', '', 'PB', 0, 1, 'ENT_PAY_ORDER', '0', 'MCH', now(), now());
|
||||
insert into t_sys_entitlement values('ENT_PAY_ORDER_REFUND', '按钮:订单退款', 'no-icon', '', '', 'PB', 0, 1, 'ENT_PAY_ORDER', '0', 'MCH', now(), now());
|
||||
insert into t_sys_entitlement values('ENT_REFUND_ORDER', '退款记录', 'exception', '/refund', 'RefundOrderListPage', 'ML', 0, 1, 'ENT_ORDER', '20', 'MCH', now(), now());
|
||||
insert into t_sys_entitlement values('ENT_REFUND_LIST', '页面:退款订单列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_REFUND_ORDER', '0', 'MCH', now(), now());
|
||||
insert into t_sys_entitlement values('ENT_REFUND_ORDER_VIEW', '按钮:详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_REFUND_ORDER', '0', 'MCH', now(), now());
|
||||
|
@ -214,3 +214,9 @@ insert into t_sys_entitlement values('ENT_DIVISION_RECORD_VIEW', '按钮:详
|
||||
|
||||
## -- ++++ ++++
|
||||
|
||||
## -- ++++ [v1.7.0] ===> [v1.7.1] ++++
|
||||
-- 添加商户系统的退款功能权限配置项
|
||||
insert into t_sys_entitlement values('ENT_PAY_ORDER_REFUND', '按钮:订单退款', 'no-icon', '', '', 'PB', 0, 1, 'ENT_PAY_ORDER', '0', 'MCH', now(), now());
|
||||
|
||||
## -- ++++ ++++
|
||||
|
||||
|
@ -4,5 +4,5 @@
|
||||
/ /_/ // __/ __/ /_/ / /_/ / /_/ /
|
||||
\____/ \___/\___/ .___/\__,_/\__, /
|
||||
/_/ /____/
|
||||
:: Jeepay :: (v1.7.0.RELEASE)
|
||||
:: Jeepay :: (v1.7.1.RELEASE)
|
||||
适合互联网企业使用的开源支付系统 : https://www.jeequan.com
|
||||
|
@ -18,21 +18,29 @@ package com.jeequan.jeepay.mch.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.JeepayClient;
|
||||
import com.jeequan.jeepay.core.aop.MethodLog;
|
||||
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
|
||||
import com.jeequan.jeepay.core.entity.MchApp;
|
||||
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.core.utils.SeqKit;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
|
||||
import com.jeequan.jeepay.model.RefundOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.request.RefundOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.RefundOrderCreateResponse;
|
||||
import com.jeequan.jeepay.service.impl.MchAppService;
|
||||
import com.jeequan.jeepay.service.impl.PayOrderService;
|
||||
import com.jeequan.jeepay.service.impl.PayWayService;
|
||||
import com.jeequan.jeepay.service.impl.SysConfigService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -50,8 +58,9 @@ import java.util.Map;
|
||||
public class PayOrderController extends CommonCtrl {
|
||||
|
||||
@Autowired private PayOrderService payOrderService;
|
||||
|
||||
@Autowired private PayWayService payWayService;
|
||||
@Autowired private MchAppService mchAppService;
|
||||
@Autowired private SysConfigService sysConfigService;
|
||||
|
||||
/**
|
||||
* @Author: ZhuXiao
|
||||
@ -138,4 +147,60 @@ public class PayOrderController extends CommonCtrl {
|
||||
return ApiRes.ok(payOrder);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发起订单退款
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @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 || !payOrder.getMchNo().equals(getCurrentMchNo())) {
|
||||
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("退款金额超过订单可退款金额!");
|
||||
}
|
||||
|
||||
|
||||
RefundOrderCreateRequest request = new RefundOrderCreateRequest();
|
||||
RefundOrderCreateReqModel model = new RefundOrderCreateReqModel();
|
||||
request.setBizModel(model);
|
||||
|
||||
model.setMchNo(payOrder.getMchNo()); // 商户号
|
||||
model.setAppId(payOrder.getAppId());
|
||||
model.setPayOrderId(payOrderId);
|
||||
model.setMchRefundNo(SeqKit.genMhoOrderId());
|
||||
model.setRefundAmount(refundAmount);
|
||||
model.setRefundReason(refundReason);
|
||||
model.setCurrency("CNY");
|
||||
|
||||
MchApp mchApp = mchAppService.getById(payOrder.getAppId());
|
||||
|
||||
JeepayClient jeepayClient = new JeepayClient(sysConfigService.getDBApplicationConfig().getPaySiteUrl(), mchApp.getAppSecret());
|
||||
|
||||
try {
|
||||
RefundOrderCreateResponse response = jeepayClient.execute(request);
|
||||
if(response.getCode() != 0){
|
||||
throw new BizException(response.getMsg());
|
||||
}
|
||||
return ApiRes.ok(response.get());
|
||||
} catch (JeepayException e) {
|
||||
throw new BizException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
/ /_/ // __/ __/ /_/ / /_/ / /_/ /
|
||||
\____/ \___/\___/ .___/\__,_/\__, /
|
||||
/_/ /____/
|
||||
:: Jeepay :: (v1.7.0.RELEASE)
|
||||
:: Jeepay :: (v1.7.1.RELEASE)
|
||||
适合互联网企业使用的开源支付系统 : https://www.jeequan.com
|
||||
|
@ -4,5 +4,5 @@
|
||||
/ /_/ // __/ __/ /_/ / /_/ / /_/ /
|
||||
\____/ \___/\___/ .___/\__,_/\__, /
|
||||
/_/ /____/
|
||||
:: Jeepay :: (v1.7.0.RELEASE)
|
||||
:: Jeepay :: (v1.7.1.RELEASE)
|
||||
适合互联网企业使用的开源支付系统 : https://www.jeequan.com
|
||||
|
2
pom.xml
2
pom.xml
@ -36,7 +36,7 @@
|
||||
<!-- 配置属性声明, 支持自定义参数 -->
|
||||
<properties>
|
||||
|
||||
<isys.version>1.7.0</isys.version> <!-- 指定当前[项目]版本号 -->
|
||||
<isys.version>1.7.1</isys.version> <!-- 指定当前[项目]版本号 -->
|
||||
|
||||
<java.version>1.8</java.version> <!-- 指定java版本号 -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- 项目构建输出编码 -->
|
||||
|
Loading…
Reference in New Issue
Block a user