feat:【MALL 商城】商城分佣提现,初步对接成功微信支付

This commit is contained in:
YunaiV
2025-05-11 08:12:42 +08:00
parent b91a30dd3e
commit 4d25e810e3
22 changed files with 162 additions and 225 deletions

View File

@@ -1,10 +1,13 @@
package cn.iocoder.yudao.module.pay.api.transfer;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig;
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO;
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO;
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO;
import cn.iocoder.yudao.module.pay.service.channel.PayChannelService;
import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -21,6 +24,8 @@ public class PayTransferApiImpl implements PayTransferApi {
@Resource
private PayTransferService payTransferService;
@Resource
private PayChannelService payChannelService;
@Override
public PayTransferCreateRespDTO createTransfer(PayTransferCreateReqDTO reqDTO) {
@@ -30,7 +35,15 @@ public class PayTransferApiImpl implements PayTransferApi {
@Override
public PayTransferRespDTO getTransfer(Long id) {
PayTransferDO transfer = payTransferService.getTransfer(id);
return BeanUtils.toBean(transfer, PayTransferRespDTO.class);
if (transfer == null) {
return null;
}
PayChannelDO channel = payChannelService.getChannel(transfer.getChannelId());
String mchId = null;
if (channel != null && channel.getConfig() instanceof WxPayClientConfig) {
mchId = ((WxPayClientConfig) channel.getConfig()).getMchId();
}
return BeanUtils.toBean(transfer, PayTransferRespDTO.class).setChannelMchId(mchId);
}
}

View File

@@ -80,12 +80,5 @@ public class PayDemoWithdrawDO extends BaseDO {
* 转账错误提示
*/
private String transferErrorMsg;
/**
* 渠道 package 信息
*
* 特殊:目前只有微信转账有这个东西!!!
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a>
*/
private String transferChannelPackageInfo;
}

View File

@@ -88,8 +88,7 @@ public class PayDemoTransferServiceImpl implements PayDemoWithdrawService {
// 2.2 更新转账单到 demo 示例提现单,并将状态更新为转账中
demoTransferMapper.updateByIdAndStatus(withdraw.getId(), withdraw.getStatus(),
new PayDemoWithdrawDO().setPayTransferId(transferRespDTO.getId())
.setTransferChannelPackageInfo(transferRespDTO.getChannelPackageInfo()));
new PayDemoWithdrawDO().setPayTransferId(transferRespDTO.getId()));
return transferRespDTO.getId();
}

View File

@@ -174,7 +174,7 @@ public class PayTransferServiceImpl implements PayTransferService {
int updateCounts = transferMapper.updateByIdAndStatus(transfer.getId(),
PayTransferStatusEnum.WAITING.getStatus(),
new PayTransferDO().setStatus(PayTransferStatusEnum.PROCESSING.getStatus())
.setChannelPackageInfo(transfer.getChannelPackageInfo()));
.setChannelPackageInfo(notify.getChannelPackageInfo()));
if (updateCounts == 0) {
throw exception(PAY_TRANSFER_NOTIFY_FAIL_STATUS_IS_NOT_WAITING);
}