完善运营平台退款功能

This commit is contained in:
terrfly 2021-06-21 17:17:57 +08:00
parent 66921de215
commit 9772597867
4 changed files with 60 additions and 2 deletions

View File

@ -89,6 +89,12 @@
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<!-- 引入 jeepay-sdk-java -->
<dependency>
<groupId>com.jeequan</groupId>
<artifactId>jeepay-sdk-java</artifactId>
</dependency>
</dependencies>

View File

@ -15,18 +15,29 @@
*/
package com.jeequan.jeepay.mgr.ctrl.order;
import cn.hutool.core.lang.UUID;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
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.exception.JeepayException;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.model.RefundOrderCreateReqModel;
import com.jeequan.jeepay.model.RefundOrderCreateResModel;
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;
@ -49,6 +60,8 @@ public class PayOrderController extends CommonCtrl {
@Autowired private PayOrderService payOrderService;
@Autowired private PayWayService payWayService;
@Autowired private SysConfigService sysConfigService;
@Autowired private MchAppService mchAppService;
/**
* @author: pangxiaoyu
@ -129,11 +142,36 @@ public class PayOrderController extends CommonCtrl {
throw new BizException("订单状态不正确");
}
if(payOrder.getRefundAmount() + refundAmount >= payOrder.getAmount()){
if(payOrder.getRefundAmount() + refundAmount > payOrder.getAmount()){
throw new BizException("退款金额超过订单可退款金额!");
}
throw new BizException("功能开发中, 暂时不支持后台退款请调起API接口发起退款。");
RefundOrderCreateRequest request = new RefundOrderCreateRequest();
RefundOrderCreateReqModel model = new RefundOrderCreateReqModel();
request.setBizModel(model);
model.setMchNo(payOrder.getMchNo()); // 商户号
model.setAppId(payOrder.getAppId());
model.setPayOrderId(payOrderId);
model.setMchRefundNo(UUID.fastUUID().toString());
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());
}
}
}

View File

@ -89,6 +89,12 @@
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<!-- 引入 jeepay-sdk-java -->
<dependency>
<groupId>com.jeequan</groupId>
<artifactId>jeepay-sdk-java</artifactId>
</dependency>
</dependencies>
<!-- 作为可执行jar -->

View File

@ -37,6 +37,7 @@
<isys.version>1.1.0</isys.version> <!-- 指定当前[项目]版本号 -->
<!-- 其他工具包 -->
<jeepay.sdk.java.version>1.1.0</jeepay.sdk.java.version>
<fastjson.version>1.2.76</fastjson.version> <!-- fastjson -->
<mybatis.plus.starter.version>3.4.2</mybatis.plus.starter.version> <!-- mybatis plus -->
<hutool.util.version>5.6.6</hutool.util.version> <!-- hutool -->
@ -51,6 +52,13 @@
<dependencyManagement>
<dependencies>
<!-- jeepay sdk 支付工具包 -->
<dependency>
<groupId>com.jeequan</groupId>
<artifactId>jeepay-sdk-java</artifactId>
<version>${jeepay.sdk.java.version}</version>
</dependency>
<!-- alibaba FastJSON -->
<dependency>
<groupId>com.alibaba</groupId>