【功能优化】完成转账回调接口
This commit is contained in:
@@ -44,7 +44,7 @@ public class BrokerageRecordController {
|
||||
@Operation(summary = "获得佣金记录")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('trade:brokerage-record:query')")
|
||||
public CommonResult<BrokerageRecordRespVO> getBrokerageRecord(@RequestParam("id") Integer id) {
|
||||
public CommonResult<BrokerageRecordRespVO> getBrokerageRecord(@RequestParam("id") Long id) {
|
||||
BrokerageRecordDO brokerageRecord = brokerageRecordService.getBrokerageRecord(id);
|
||||
return success(BrokerageRecordConvert.INSTANCE.convert(brokerageRecord));
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ public class BrokerageWithdrawController {
|
||||
@PutMapping("/approve")
|
||||
@Operation(summary = "通过申请")
|
||||
@PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')")
|
||||
public CommonResult<Boolean> approveBrokerageWithdraw(@RequestParam("id") Integer id) {
|
||||
public CommonResult<Boolean> approveBrokerageWithdraw(@RequestParam("id") Long id) {
|
||||
brokerageWithdrawService.auditBrokerageWithdraw(id, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, "", getClientIP());
|
||||
return success(true);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class BrokerageWithdrawController {
|
||||
@Operation(summary = "获得佣金提现")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')")
|
||||
public CommonResult<BrokerageWithdrawRespVO> getBrokerageWithdraw(@RequestParam("id") Integer id) {
|
||||
public CommonResult<BrokerageWithdrawRespVO> getBrokerageWithdraw(@RequestParam("id") Long id) {
|
||||
BrokerageWithdrawDO brokerageWithdraw = brokerageWithdrawService.getBrokerageWithdraw(id);
|
||||
return success(BrokerageWithdrawConvert.INSTANCE.convert(brokerageWithdraw));
|
||||
}
|
||||
@@ -87,6 +87,7 @@ public class BrokerageWithdrawController {
|
||||
// 目前业务逻辑,不需要做任何事情
|
||||
// 当然,退款会有小概率会失败的情况,可以监控失败状态,进行告警
|
||||
log.info("[updateAfterRefund][notifyReqDTO({})]", notifyReqDTO);
|
||||
brokerageWithdrawService.updateTransfer(Long.parseLong(notifyReqDTO.getMerchantTransferId()), notifyReqDTO.getPayTransferId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,7 @@ import java.time.LocalDateTime;
|
||||
public class BrokerageRecordRespVO extends BrokerageRecordBaseVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28896")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
@@ -14,7 +14,7 @@ public class BrokerageWithdrawRejectReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "审核驳回原因", example = "不对")
|
||||
@NotEmpty(message = "审核驳回原因不能为空")
|
||||
|
@@ -14,7 +14,7 @@ import java.time.LocalDateTime;
|
||||
public class BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
@@ -35,7 +35,7 @@ public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO
|
||||
.orderByAsc(BrokerageWithdrawDO::getStatus).orderByDesc(BrokerageWithdrawDO::getId));
|
||||
}
|
||||
|
||||
default int updateByIdAndStatus(Integer id, Integer status, BrokerageWithdrawDO updateObj) {
|
||||
default int updateByIdAndStatus(Long id, Integer status, BrokerageWithdrawDO updateObj) {
|
||||
return update(updateObj, new LambdaUpdateWrapper<BrokerageWithdrawDO>()
|
||||
.eq(BrokerageWithdrawDO::getId, id)
|
||||
.eq(BrokerageWithdrawDO::getStatus, status));
|
||||
|
@@ -32,7 +32,7 @@ public interface BrokerageRecordService {
|
||||
* @param id 编号
|
||||
* @return 佣金记录
|
||||
*/
|
||||
BrokerageRecordDO getBrokerageRecord(Integer id);
|
||||
BrokerageRecordDO getBrokerageRecord(Long id);
|
||||
|
||||
/**
|
||||
* 获得佣金记录分页
|
||||
|
@@ -64,7 +64,7 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
||||
private ProductSkuApi productSkuApi;
|
||||
|
||||
@Override
|
||||
public BrokerageRecordDO getBrokerageRecord(Integer id) {
|
||||
public BrokerageRecordDO getBrokerageRecord(Long id) {
|
||||
return brokerageRecordMapper.selectById(id);
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ public interface BrokerageWithdrawService {
|
||||
* @param status 审核状态
|
||||
* @param auditReason 驳回原因
|
||||
*/
|
||||
void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason, String userIp);
|
||||
void auditBrokerageWithdraw(Long id, BrokerageWithdrawStatusEnum status, String auditReason, String userIp);
|
||||
|
||||
/**
|
||||
* 获得佣金提现
|
||||
@@ -36,7 +36,7 @@ public interface BrokerageWithdrawService {
|
||||
* @param id 编号
|
||||
* @return 佣金提现
|
||||
*/
|
||||
BrokerageWithdrawDO getBrokerageWithdraw(Integer id);
|
||||
BrokerageWithdrawDO getBrokerageWithdraw(Long id);
|
||||
|
||||
/**
|
||||
* 获得佣金提现分页
|
||||
@@ -77,4 +77,10 @@ public interface BrokerageWithdrawService {
|
||||
return convertMap(getWithdrawSummaryListByUserId(userIds, status), BrokerageWithdrawSummaryRespBO::getUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param merchantTransferId 提现编号
|
||||
* @param payTransferId 转账订单编号
|
||||
*/
|
||||
void updateTransfer(Long merchantTransferId, Long payTransferId);
|
||||
}
|
||||
|
@@ -9,6 +9,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||
import cn.iocoder.yudao.module.pay.api.transfer.PayTransferApi;
|
||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
|
||||
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
|
||||
@@ -39,7 +41,6 @@ import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.trade.dal.redis.no.TradeNoRedisDAO.TRADE_ORDER_NO_PREFIX;
|
||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@@ -76,7 +77,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason, String userIp) {
|
||||
public void auditBrokerageWithdraw(Long id, BrokerageWithdrawStatusEnum status, String auditReason, String userIp) {
|
||||
// 1.1 校验存在
|
||||
BrokerageWithdrawDO withdraw = validateBrokerageWithdrawExists(id);
|
||||
|
||||
@@ -105,7 +106,6 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
||||
PayTransferCreateReqDTO payTransferCreateReqDTO = getPayTransferCreateReqDTO(userIp, withdraw, socialUser);
|
||||
payTransferApi.createTransfer(payTransferCreateReqDTO);
|
||||
}
|
||||
// TODO 疯狂:调用转账接口
|
||||
} else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) {
|
||||
templateCode = MessageTemplateConstants.SMS_BROKERAGE_WITHDRAW_AUDIT_REJECT;
|
||||
// 3.2 驳回时需要退还用户佣金
|
||||
@@ -116,13 +116,13 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
||||
}
|
||||
|
||||
// 4. 通知用户
|
||||
Map<String, Object> templateParams = MapUtil.<String, Object>builder()
|
||||
.put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime()))
|
||||
.put("price", MoneyUtils.fenToYuanStr(withdraw.getPrice()))
|
||||
.put("reason", auditReason)
|
||||
.build();
|
||||
notifyMessageSendApi.sendSingleMessageToMember(new NotifySendSingleToUserReqDTO()
|
||||
.setUserId(withdraw.getUserId()).setTemplateCode(templateCode).setTemplateParams(templateParams));
|
||||
// Map<String, Object> templateParams = MapUtil.<String, Object>builder()
|
||||
// .put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime()))
|
||||
// .put("price", MoneyUtils.fenToYuanStr(withdraw.getPrice()))
|
||||
// .put("reason", auditReason)
|
||||
// .build();
|
||||
// notifyMessageSendApi.sendSingleMessageToMember(new NotifySendSingleToUserReqDTO()
|
||||
// .setUserId(withdraw.getUserId()).setTemplateCode(templateCode).setTemplateParams(templateParams));
|
||||
}
|
||||
|
||||
private PayTransferCreateReqDTO getPayTransferCreateReqDTO(String userIp, BrokerageWithdrawDO withdraw, SocialUserRespDTO socialUser) {
|
||||
@@ -138,7 +138,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
||||
return payTransferCreateReqDTO;
|
||||
}
|
||||
|
||||
private BrokerageWithdrawDO validateBrokerageWithdrawExists(Integer id) {
|
||||
private BrokerageWithdrawDO validateBrokerageWithdrawExists(Long id) {
|
||||
BrokerageWithdrawDO withdraw = brokerageWithdrawMapper.selectById(id);
|
||||
if (withdraw == null) {
|
||||
throw exception(BROKERAGE_WITHDRAW_NOT_EXISTS);
|
||||
@@ -147,7 +147,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrokerageWithdrawDO getBrokerageWithdraw(Integer id) {
|
||||
public BrokerageWithdrawDO getBrokerageWithdraw(Long id) {
|
||||
return brokerageWithdrawMapper.selectById(id);
|
||||
}
|
||||
|
||||
@@ -186,6 +186,23 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
||||
return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, status.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTransfer(Long id, Long payTransferId) {
|
||||
BrokerageWithdrawDO withdraw = validateBrokerageWithdrawExists(id);
|
||||
PayTransferRespDTO transfer = payTransferApi.getTransfer(payTransferId);
|
||||
if(PayTransferStatusEnum.isSuccess(transfer.getStatus())){
|
||||
withdraw.setStatus(BrokerageWithdrawStatusEnum.WITHDRAW_SUCCESS.getStatus());
|
||||
}else if(PayTransferStatusEnum.isPendingStatus(transfer.getStatus())){
|
||||
withdraw.setStatus(BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.getStatus());
|
||||
}else{
|
||||
withdraw.setStatus(BrokerageWithdrawStatusEnum.WITHDRAW_FAIL.getStatus());
|
||||
// 3.2 驳回时需要退还用户佣金
|
||||
brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT,
|
||||
String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle());
|
||||
}
|
||||
brokerageWithdrawMapper.updateById(withdraw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算提现手续费
|
||||
*
|
||||
|
Reference in New Issue
Block a user