【代码评审】商城:分销提现时,支持余额自动添加,以及微信提现到余额里
This commit is contained in:
@@ -13,6 +13,7 @@ import jakarta.validation.constraints.NotNull;
|
||||
@Data
|
||||
public class PayTransferNotifyReqDTO {
|
||||
|
||||
// TODO 芋艿:要不要改成 orderId 待定;
|
||||
/**
|
||||
* 商户转账单号
|
||||
*/
|
||||
@@ -24,4 +25,5 @@ public class PayTransferNotifyReqDTO {
|
||||
*/
|
||||
@NotNull(message = "转账订单编号不能为空")
|
||||
private Long payTransferId;
|
||||
|
||||
}
|
||||
|
@@ -21,9 +21,11 @@ public interface PayTransferApi {
|
||||
Long createTransfer(@Valid PayTransferCreateReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 获取转账单详细
|
||||
* 获得转账单
|
||||
*
|
||||
* @param id 转账单编号
|
||||
* @return 转账单详细
|
||||
* @return 转账单
|
||||
*/
|
||||
PayTransferRespDTO getTransfer(Long id);
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.pay.api.transfer.dto;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@@ -12,7 +13,6 @@ public class PayTransferRespDTO {
|
||||
|
||||
/**
|
||||
* 转账单号
|
||||
*
|
||||
*/
|
||||
private String no;
|
||||
|
||||
@@ -24,9 +24,8 @@ public class PayTransferRespDTO {
|
||||
/**
|
||||
* 转账状态
|
||||
*
|
||||
* 枚举 {@link PayTransferStatusRespEnum}
|
||||
* 枚举 {@link PayTransferStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -10,16 +10,21 @@ import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletRespDTO;
|
||||
*/
|
||||
public interface PayWalletApi {
|
||||
|
||||
// TODO @luchi:1)改成 addWalletBalance;2)PayWalletCreateReqDto 搞成 userId、userType;3)bizType 使用 integer,不然后续挪到 cloud 不好弄,因为枚举不好序列化
|
||||
/**
|
||||
* 添加钱包
|
||||
*
|
||||
* @param reqDTO 创建请求
|
||||
*/
|
||||
void addWallet(PayWalletCreateReqDto reqDTO);
|
||||
|
||||
// TODO @luchi:不用去 getWalletByUserId 钱包,直接添加余额就好。里面内部去创建。如果删除掉的化,PayWalletRespDTO 也删除哈。
|
||||
/**
|
||||
* 根据用户id获取钱包信息
|
||||
* 根据用户编号,获取钱包信息
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 钱包信息
|
||||
*/
|
||||
PayWalletRespDTO getWalletByUserId(Long userId);
|
||||
|
||||
}
|
||||
|
@@ -1,15 +1,14 @@
|
||||
package cn.iocoder.yudao.module.pay.api.transfer;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.convert.transfer.PayTransferConvert;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO;
|
||||
import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 转账单 API 实现类
|
||||
*
|
||||
@@ -30,7 +29,7 @@ public class PayTransferApiImpl implements PayTransferApi {
|
||||
@Override
|
||||
public PayTransferRespDTO getTransfer(Long id) {
|
||||
PayTransferDO transfer = payTransferService.getTransfer(id);
|
||||
return PayTransferConvert.INSTANCE.convert3(transfer);
|
||||
return BeanUtils.toBean(transfer, PayTransferRespDTO.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package cn.iocoder.yudao.module.pay.api.wallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletCreateReqDto;
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -22,13 +22,12 @@ public class PayWalletApiImpl implements PayWalletApi {
|
||||
|
||||
@Override
|
||||
public void addWallet(PayWalletCreateReqDto reqDTO) {
|
||||
//添加钱包金额
|
||||
payWalletService.addWalletBalance(reqDTO.getWalletId(), reqDTO.getBizId(), reqDTO.getBizType(), reqDTO.getPrice());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayWalletRespDTO getWalletByUserId(Long userId) {
|
||||
PayWalletDO orCreateWallet = payWalletService.getOrCreateWallet(userId, UserTypeEnum.MEMBER.getValue());
|
||||
return PayWalletConvert.INSTANCE.convert03(orCreateWallet);
|
||||
return BeanUtils.toBean(orCreateWallet, PayWalletRespDTO.class);
|
||||
}
|
||||
}
|
||||
|
@@ -40,8 +40,7 @@ public class PayAppBaseVO {
|
||||
@URL(message = "退款结果的回调地址必须为 URL 格式")
|
||||
private String refundNotifyUrl;
|
||||
|
||||
@Schema(description = "转账结果的回调地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/refund-callback")
|
||||
@NotNull(message = "转账结果的回调地址不能为空")
|
||||
@Schema(description = "转账结果的回调地址", example = "http://127.0.0.1:48080/transfer-callback")
|
||||
@URL(message = "转账结果的回调地址必须为 URL 格式")
|
||||
private String transferNotifyUrl;
|
||||
|
||||
|
@@ -69,7 +69,7 @@ public class PayNotifyController {
|
||||
// 1. 校验支付渠道是否存在
|
||||
PayClient payClient = channelService.getPayClient(channelId);
|
||||
if (payClient == null) {
|
||||
log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId);
|
||||
log.error("[notifyOrder][渠道编号({}) 找不到对应的支付客户端]", channelId);
|
||||
throw exception(CHANNEL_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -83,13 +83,13 @@ public class PayNotifyController {
|
||||
@Operation(summary = "支付渠道的统一【退款】回调")
|
||||
@PermitAll
|
||||
public String notifyRefund(@PathVariable("channelId") Long channelId,
|
||||
@RequestParam(required = false) Map<String, String> params,
|
||||
@RequestBody(required = false) String body) {
|
||||
@RequestParam(required = false) Map<String, String> params,
|
||||
@RequestBody(required = false) String body) {
|
||||
log.info("[notifyRefund][channelId({}) 回调数据({}/{})]", channelId, params, body);
|
||||
// 1. 校验支付渠道是否存在
|
||||
PayClient payClient = channelService.getPayClient(channelId);
|
||||
if (payClient == null) {
|
||||
log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId);
|
||||
log.error("[notifyRefund][渠道编号({}) 找不到对应的支付客户端]", channelId);
|
||||
throw exception(CHANNEL_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -103,13 +103,13 @@ public class PayNotifyController {
|
||||
@Operation(summary = "支付渠道的统一【转账】回调")
|
||||
@PermitAll
|
||||
public String notifyTransfer(@PathVariable("channelId") Long channelId,
|
||||
@RequestParam(required = false) Map<String, String> params,
|
||||
@RequestBody(required = false) String body) {
|
||||
log.info("[notifyRefund][channelId({}) 回调数据({}/{})]", channelId, params, body);
|
||||
@RequestParam(required = false) Map<String, String> params,
|
||||
@RequestBody(required = false) String body) {
|
||||
log.info("[notifyTransfer][channelId({}) 回调数据({}/{})]", channelId, params, body);
|
||||
// 1. 校验支付渠道是否存在
|
||||
PayClient payClient = channelService.getPayClient(channelId);
|
||||
if (payClient == null) {
|
||||
log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId);
|
||||
log.error("[notifyTransfer][渠道编号({}) 找不到对应的支付客户端]", channelId);
|
||||
throw exception(CHANNEL_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.pay.convert.transfer;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
||||
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.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferCreateReqVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageItemRespVO;
|
||||
@@ -27,7 +26,6 @@ public interface PayTransferConvert {
|
||||
|
||||
PayTransferRespVO convert(PayTransferDO bean);
|
||||
|
||||
PayTransferRespDTO convert3(PayTransferDO bean);
|
||||
|
||||
PageResult<PayTransferPageItemRespVO> convertPage(PageResult<PayTransferDO> pageResult);
|
||||
|
||||
}
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package cn.iocoder.yudao.module.pay.convert.wallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletCreateReqDto;
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
@@ -20,6 +18,4 @@ public interface PayWalletConvert {
|
||||
|
||||
PageResult<PayWalletRespVO> convertPage(PageResult<PayWalletDO> page);
|
||||
|
||||
PayWalletRespDTO convert03(PayWalletDO orCreateWallet);
|
||||
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -24,10 +23,6 @@ public interface PayTransferMapper extends BaseMapperX<PayTransferDO> {
|
||||
PayTransferDO::getMerchantTransferId, merchantTransferId);
|
||||
}
|
||||
|
||||
default PayTransferDO selectByNo(String no){
|
||||
return selectOne(PayTransferDO::getNo, no);
|
||||
}
|
||||
|
||||
default PageResult<PayTransferDO> selectPage(PayTransferPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PayTransferDO>()
|
||||
.eqIfPresent(PayTransferDO::getNo, reqVO.getNo())
|
||||
@@ -42,15 +37,15 @@ public interface PayTransferMapper extends BaseMapperX<PayTransferDO> {
|
||||
.orderByDesc(PayTransferDO::getId));
|
||||
}
|
||||
|
||||
default List<PayTransferDO> selectListByStatus(Integer status){
|
||||
default List<PayTransferDO> selectListByStatus(Integer status) {
|
||||
return selectList(PayTransferDO::getStatus, status);
|
||||
}
|
||||
|
||||
default PayTransferDO selectByAppIdAndNo(Long appId, String no){
|
||||
return selectOne(new LambdaQueryWrapperX<PayTransferDO>()
|
||||
.eq(PayTransferDO::getAppId, appId)
|
||||
.eq(PayTransferDO::getNo, no));
|
||||
default PayTransferDO selectByAppIdAndNo(Long appId, String no) {
|
||||
return selectOne(PayTransferDO::getAppId, appId,
|
||||
PayTransferDO::getNo, no);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -114,7 +114,6 @@ public interface PayWalletMapper extends BaseMapperX<PayWalletDO> {
|
||||
return update(null, lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -78,4 +78,5 @@ public interface PayRefundService {
|
||||
* @return 同步到状态的退款数量,包括退款成功、退款失败
|
||||
*/
|
||||
int syncRefund();
|
||||
|
||||
}
|
||||
|
@@ -193,8 +193,6 @@ public class PayRefundServiceImpl implements PayRefundService {
|
||||
TenantUtils.execute(channel.getTenantId(), () -> getSelf().notifyRefund(channel, notify));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通知并更新订单的退款结果
|
||||
*
|
||||
|
@@ -63,4 +63,5 @@ public interface PayTransferService {
|
||||
* @param notify 通知
|
||||
*/
|
||||
void notifyTransfer(Long channelId, PayTransferRespDTO notify);
|
||||
|
||||
}
|
||||
|
@@ -29,7 +29,6 @@ import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Validator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
@@ -171,8 +170,7 @@ public class PayTransferServiceImpl implements PayTransferService {
|
||||
|
||||
private void notifyTransferInProgress(PayChannelDO channel, PayTransferRespDTO notify) {
|
||||
// 1.校验
|
||||
PayTransferDO transfer = transferMapper.selectByAppIdAndNo(
|
||||
channel.getAppId(), notify.getOutTransferNo());
|
||||
PayTransferDO transfer = transferMapper.selectByAppIdAndNo(channel.getAppId(), notify.getOutTransferNo());
|
||||
if (transfer == null) {
|
||||
throw exception(PAY_TRANSFER_NOT_FOUND);
|
||||
}
|
||||
@@ -195,8 +193,7 @@ public class PayTransferServiceImpl implements PayTransferService {
|
||||
|
||||
private void notifyTransferSuccess(PayChannelDO channel, PayTransferRespDTO notify) {
|
||||
// 1.校验
|
||||
PayTransferDO transfer = transferMapper.selectByAppIdAndNo(
|
||||
channel.getAppId(), notify.getOutTransferNo());
|
||||
PayTransferDO transfer = transferMapper.selectByAppIdAndNo(channel.getAppId(), notify.getOutTransferNo());
|
||||
if (transfer == null) {
|
||||
throw exception(PAY_TRANSFER_NOT_FOUND);
|
||||
}
|
||||
@@ -225,8 +222,7 @@ public class PayTransferServiceImpl implements PayTransferService {
|
||||
|
||||
private void notifyTransferClosed(PayChannelDO channel, PayTransferRespDTO notify) {
|
||||
// 1.校验
|
||||
PayTransferDO transfer = transferMapper.selectByAppIdAndNo(
|
||||
channel.getAppId(), notify.getOutTransferNo());
|
||||
PayTransferDO transfer = transferMapper.selectByAppIdAndNo(channel.getAppId(), notify.getOutTransferNo());
|
||||
if (transfer == null) {
|
||||
throw exception(PAY_TRANSFER_NOT_FOUND);
|
||||
}
|
||||
|
@@ -200,6 +200,7 @@ public class PayWalletServiceImpl implements PayWalletService {
|
||||
case UPDATE_BALANCE: // 更新余额
|
||||
walletMapper.updateWhenRecharge(payWallet.getId(), price);
|
||||
break;
|
||||
// TODO @luchi:1)不能使用 updateWhenRecharge,它是充值哈。应该增加余额就 ok 了。。ps:顺便帮我把 UPDATE_BALANCE 也改改哈;2)其实不用 WITHDRAW 枚举,复用 UPDATE_BALANCE 就好了。
|
||||
case WITHDRAW:
|
||||
walletMapper.updateWhenRecharge(payWallet.getId(), price);
|
||||
break;
|
||||
|
@@ -64,10 +64,6 @@
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-pay</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test 测试相关 -->
|
||||
<dependency>
|
||||
|
@@ -106,4 +106,5 @@ public interface PayClient {
|
||||
* @return 转账信息
|
||||
*/
|
||||
PayTransferRespDTO parseTransferNotify(Map<String, String> params, String body);
|
||||
|
||||
}
|
||||
|
@@ -84,4 +84,5 @@ public class PayTransferUnifiedReqDTO {
|
||||
@NotEmpty(message = "转账结果的回调地址不能为空")
|
||||
@URL(message = "转账结果的 notify 回调地址必须是 URL 格式")
|
||||
private String notifyUrl;
|
||||
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
// TODO @luchi:这个可以复用 wxjava 里的类么?
|
||||
@NoArgsConstructor
|
||||
public class WxPayTransferPartnerNotifyV3Result implements Serializable, WxPayBaseNotifyV3Result<WxPayTransferPartnerNotifyV3Result.TransferNotifyResult> {
|
||||
|
||||
|
@@ -325,6 +325,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa
|
||||
}
|
||||
}
|
||||
|
||||
// TODO @chihuo:这里是不是也要实现,支付宝的。
|
||||
@Override
|
||||
protected PayTransferRespDTO doParseTransferNotify(Map<String, String> params, String body) throws Throwable {
|
||||
throw new UnsupportedOperationException("未实现");
|
||||
|
@@ -18,21 +18,23 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.WxPayTransferPart
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum;
|
||||
import com.github.binarywang.wxpay.bean.notify.*;
|
||||
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyV3Result;
|
||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
|
||||
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result;
|
||||
import com.github.binarywang.wxpay.bean.request.*;
|
||||
import com.github.binarywang.wxpay.bean.result.*;
|
||||
import com.github.binarywang.wxpay.bean.transfer.TransferBatchesRequest;
|
||||
import com.github.binarywang.wxpay.bean.transfer.TransferBatchesResult;
|
||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.TransferService;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -356,17 +358,21 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
switch (config.getApiVersion()) {
|
||||
case API_VERSION_V3:
|
||||
return parseTransferNotifyV3(body);
|
||||
case API_VERSION_V2:
|
||||
throw new UnsupportedOperationException("V2 版本暂不支持,建议使用 V3 版本");
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
private PayTransferRespDTO parseTransferNotifyV3(String body) throws WxPayException {
|
||||
// 1. 解析回调
|
||||
// TODO @luchi:这个可以复用 wxjava 里的类么?
|
||||
WxPayTransferPartnerNotifyV3Result response = client.baseParseOrderNotifyV3Result(body, null, WxPayTransferPartnerNotifyV3Result.class, WxPayTransferPartnerNotifyV3Result.TransferNotifyResult.class);
|
||||
WxPayTransferPartnerNotifyV3Result.TransferNotifyResult result = response.getResult();
|
||||
// 2. 构建结果
|
||||
if (Objects.equals("FINISHED", result.getBatchStatus())) {
|
||||
if(result.getFailNum() <= 0){
|
||||
if (result.getFailNum() <= 0) {
|
||||
return PayTransferRespDTO.successOf(result.getBatchId(), parseDateV3(result.getUpdateTime()),
|
||||
result.getOutBatchNo(), response);
|
||||
}
|
||||
@@ -453,29 +459,33 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
|
||||
@Override
|
||||
protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) throws WxPayException {
|
||||
TransferService transferService = client.getTransferService();
|
||||
List<TransferBatchesRequest.TransferDetail> transferDetailList = new ArrayList<>();
|
||||
transferDetailList.add(TransferBatchesRequest.TransferDetail.newBuilder()
|
||||
.outDetailNo(reqDTO.getOutTransferNo())
|
||||
.transferAmount(reqDTO.getPrice())
|
||||
.transferRemark(reqDTO.getSubject())
|
||||
.openid(reqDTO.getOpenid())
|
||||
.build());
|
||||
// 1. 构建 TransferBatchesRequest 请求
|
||||
List<TransferBatchesRequest.TransferDetail> transferDetailList = Collections.singletonList(
|
||||
TransferBatchesRequest.TransferDetail.newBuilder()
|
||||
.outDetailNo(reqDTO.getOutTransferNo())
|
||||
.transferAmount(reqDTO.getPrice())
|
||||
.transferRemark(reqDTO.getSubject())
|
||||
.openid(reqDTO.getOpenid())
|
||||
.build());
|
||||
// TODO @luchi:能不能我们搞个 TransferBatchesRequestX extends TransferBatchesRequest,这样更简洁一点。
|
||||
TransferBatchesRequest transferBatches = TransferBatchesRequest.newBuilder()
|
||||
.appid(this.config.getAppId())
|
||||
.outBatchNo(reqDTO.getOutTransferNo())
|
||||
.batchName(reqDTO.getSubject())
|
||||
.batchRemark(reqDTO.getSubject())
|
||||
.totalAmount(reqDTO.getPrice())
|
||||
.totalNum(1)
|
||||
.transferDetailList(transferDetailList).build();
|
||||
transferBatches.setNotifyUrl(reqDTO.getNotifyUrl());
|
||||
TransferBatchesResult transferBatchesResult = transferService.transferBatches(transferBatches);
|
||||
.totalNum(transferDetailList.size())
|
||||
.transferDetailList(transferDetailList).build()
|
||||
.setNotifyUrl(reqDTO.getNotifyUrl());
|
||||
// 2.1 执行请求
|
||||
TransferBatchesResult transferBatchesResult = client.getTransferService().transferBatches(transferBatches);
|
||||
// 2.2 创建返回结果
|
||||
return PayTransferRespDTO.dealingOf(transferBatchesResult.getBatchId(), reqDTO.getOutTransferNo(), transferBatchesResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) {
|
||||
// TODO luchi:这个最好实现下。因为可能要主动轮询转账结果
|
||||
throw new UnsupportedOperationException("待实现");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user