修改退款审核、退款环节,记录操作人ID,通过请求token获取用户ID

This commit is contained in:
jkcdev 2025-05-20 14:41:58 +08:00
parent 579c5fc6bf
commit 657cee6dd8
4 changed files with 42 additions and 7 deletions

View File

@ -107,6 +107,12 @@
<artifactId>javax.servlet-api</artifactId>
<optional>true</optional>
</dependency>
<!-- Sa-Token 权限认证在线文档https://sa-token.cc -->
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-spring-boot3-starter</artifactId>
<version>${satoken.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -1,9 +1,13 @@
package com.cdzy.payment.controller;
import cn.dev33.satoken.stp.StpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.cdzy.common.enums.Code;
import com.cdzy.common.model.JsonResult;
import com.cdzy.payment.model.dto.*;
import com.cdzy.payment.service.WxPayService;
import com.ebike.feign.clients.StaffFeignClient;
import com.ebike.feign.model.rsp.StaffFeign;
import com.mybatisflex.core.paginate.Page;
import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.refund.model.Refund;
@ -26,7 +30,13 @@ public class EbikeWxPaymentController {
@Resource
private WxPayService wxPayService;
@Resource
private StaffFeignClient staffFeignClient;
/**
* 关闭订单
*
* @param orderId 骑行订单id
/**
* 微信支付下单
*
@ -84,7 +94,15 @@ public class EbikeWxPaymentController {
*/
@PostMapping("/refund")
public JsonResult<?> refund(@RequestBody ReqRefundDto refundDto) {
HandleNotifyResult r = wxPayService.refund(refundDto);
// 获取审核人信息
String tokenValue = StpUtil.getTokenValue();
String userId = null;
JsonResult<StaffFeign> result = staffFeignClient.getInfoByToken(tokenValue);
if (result.getCode() == Code.SUCCESS) {
StaffFeign staffFeign = result.getData();
userId = String.valueOf(staffFeign.getStaffId());
}
HandleNotifyResult r = wxPayService.refund(refundDto, userId);
return r.isSuccess()?JsonResult.success(true):JsonResult.failed(r.getMessage());
}
@ -96,7 +114,15 @@ public class EbikeWxPaymentController {
*/
@PostMapping("/reviewRefund")
public JsonResult<?> reviewRefund(@RequestBody ReqRefundProcessDto processDto) {
boolean r = wxPayService.refundReview(processDto);
// 获取审核人信息
String tokenValue = StpUtil.getTokenValue();
String userId = null;
JsonResult<StaffFeign> result = staffFeignClient.getInfoByToken(tokenValue);
if (result.getCode() == Code.SUCCESS) {
StaffFeign staffFeign = result.getData();
userId = String.valueOf(staffFeign.getStaffId());
}
boolean r = wxPayService.refundReview(processDto, userId);
return r?JsonResult.success(true):JsonResult.failed("审核失败");
}

View File

@ -81,17 +81,19 @@ public interface WxPayService {
* 审核退款申请
*
* @param processDto 退款审核信息
* @operator 操作人id
* @return 退款信息id
*/
Boolean refundReview(ReqRefundProcessDto processDto);
Boolean refundReview(ReqRefundProcessDto processDto, String operator);
/**
* 调用微信退款接口
*
* @param refundDto 退款请求
* @param operator 操作人id
* @return 退款信息id
*/
HandleNotifyResult refund(ReqRefundDto refundDto);
HandleNotifyResult refund(ReqRefundDto refundDto, String operator);
/**

View File

@ -373,13 +373,13 @@ public class WxPayServiceImpl implements WxPayService {
}
@Override
public Boolean refundReview(ReqRefundProcessDto processDto) {
public Boolean refundReview(ReqRefundProcessDto processDto, String operator) {
EbikeRefund ebikeRefund = ebikeRefundService.getById(processDto.getRefundId());
if (ebikeRefund == null) {
log.error("审核refundReview失败{} 退款申请不存在", processDto.getRefundId());
return false;
}
ebikeRefund.setReviewOperator(operator);
ebikeRefund.setProcessState(processDto.getOperate());
ebikeRefund.setProcessTime(LocalDateTime.now());
ebikeRefund.setRemark(processDto.getReason());
@ -396,7 +396,7 @@ public class WxPayServiceImpl implements WxPayService {
}
@Override
public HandleNotifyResult refund(ReqRefundDto refundDto) {
public HandleNotifyResult refund(ReqRefundDto refundDto, String operator) {
HandleNotifyResult result_ = new HandleNotifyResult();
result_.setSuccess(false);
// 首先验证密码
@ -451,6 +451,7 @@ public class WxPayServiceImpl implements WxPayService {
Refund result = wxRefundService.create(request);
// 更新退款信息
if (result != null) {
ebikeRefund.setRefundOperator(operator);
ebikeRefund.setOrderId(outTradeNo);
ebikeRefund.setTransactionId(transactionId);
ebikeRefund.setTotal(amount.getTotal());