mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-10-13 21:30:25 +00:00
feat 微信分账调试
This commit is contained in:
17
_doc/Task.md
17
_doc/Task.md
@@ -6,15 +6,20 @@
|
|||||||
## 3.0.0.bate3: 功能完善
|
## 3.0.0.bate3: 功能完善
|
||||||
- 优化:
|
- 优化:
|
||||||
- [ ] 增加首页驾驶舱功能
|
- [ ] 增加首页驾驶舱功能
|
||||||
- [ ] 分账功能
|
- [x] 分账界面功能
|
||||||
- [x] 分账接收方配置
|
- [x] 分账接收方配置
|
||||||
- [ ] 分账单管理
|
- [x] 分账单管理
|
||||||
- [ ] 分账接口开发
|
- [x] 接口开发 开启/完结/用不
|
||||||
|
- [ ] 分账接口开发
|
||||||
|
- [x] 支付宝
|
||||||
|
- [ ] 微信
|
||||||
|
- [ ] 分账扩展能力
|
||||||
|
- [ ] 自动分账
|
||||||
|
- [ ] 自动完成
|
||||||
|
- [ ] 自动同步状态
|
||||||
- [ ] 网关配套移动端开发
|
- [ ] 网关配套移动端开发
|
||||||
- [ ] 同步回调页
|
- [ ] 同步回调页
|
||||||
- [ ] 分账接收方和分账组优化
|
- [x] 分账接收方和分账组优化, 后台管理时, 编号自动生成
|
||||||
- [ ] 后台管理时, 编号自动生成
|
|
||||||
- [ ] 显示数据
|
|
||||||
- [x] 微信通道添加单独的认证跳转地址, 处理它的特殊情况
|
- [x] 微信通道添加单独的认证跳转地址, 处理它的特殊情况
|
||||||
- [x] 支付订单新增待支付状态
|
- [x] 支付订单新增待支付状态
|
||||||
## 3.0.0.beta2 收银台
|
## 3.0.0.beta2 收银台
|
||||||
|
@@ -142,7 +142,6 @@ public class AliPayAllocationService {
|
|||||||
var detail = detailMap.get(receiver.getTransIn());
|
var detail = detailMap.get(receiver.getTransIn());
|
||||||
if (Objects.nonNull(detail)) {
|
if (Objects.nonNull(detail)) {
|
||||||
detail.setResult(this.getDetailResultEnum(receiver.getState()).getCode());
|
detail.setResult(this.getDetailResultEnum(receiver.getState()).getCode());
|
||||||
detail.setErrorCode(receiver.getErrorCode());
|
|
||||||
detail.setErrorMsg(receiver.getErrorDesc());
|
detail.setErrorMsg(receiver.getErrorDesc());
|
||||||
// 如果是完成, 更新时间
|
// 如果是完成, 更新时间
|
||||||
if (AllocDetailResultEnum.SUCCESS.getCode().equals(detail.getResult())){
|
if (AllocDetailResultEnum.SUCCESS.getCode().equals(detail.getResult())){
|
||||||
|
@@ -2,8 +2,14 @@ package org.dromara.daxpay.channel.wechat.service.allocation;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.daxpay.channel.wechat.entity.config.WechatPayConfig;
|
||||||
|
import org.dromara.daxpay.service.bo.allocation.AllocStartResultBo;
|
||||||
|
import org.dromara.daxpay.service.entity.allocation.transaction.AllocDetail;
|
||||||
|
import org.dromara.daxpay.service.entity.allocation.transaction.AllocOrder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信分账V2版本接口
|
* 微信分账V2版本接口
|
||||||
* @author xxm
|
* @author xxm
|
||||||
@@ -13,4 +19,25 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class WeChatPayAllocationV2Service {
|
public class WeChatPayAllocationV2Service {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分账
|
||||||
|
*/
|
||||||
|
public AllocStartResultBo start(AllocOrder order, List<AllocDetail> details, WechatPayConfig config) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 完结
|
||||||
|
*/
|
||||||
|
public void finish(AllocOrder order, List<AllocDetail> details, WechatPayConfig config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步
|
||||||
|
*/
|
||||||
|
public void sync(AllocOrder order, List<AllocDetail> details, WechatPayConfig config) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package org.dromara.daxpay.channel.wechat.service.allocation;
|
package org.dromara.daxpay.channel.wechat.service.allocation;
|
||||||
|
|
||||||
|
import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingQueryV3Request;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingUnfreezeV3Request;
|
import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingUnfreezeV3Request;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingV3Request;
|
import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingV3Request;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingV3Result;
|
import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingV3Result;
|
||||||
@@ -36,7 +37,7 @@ public class WeChatPayAllocationV3Service {
|
|||||||
private final WechatPayConfigService wechatPayConfigService;
|
private final WechatPayConfigService wechatPayConfigService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发起分账
|
* 发起分账 使用分账号作为请求号4
|
||||||
*/
|
*/
|
||||||
public AllocStartResultBo start(AllocOrder allocOrder, List<AllocDetail> orderDetails, WechatPayConfig config){
|
public AllocStartResultBo start(AllocOrder allocOrder, List<AllocDetail> orderDetails, WechatPayConfig config){
|
||||||
|
|
||||||
@@ -44,9 +45,10 @@ public class WeChatPayAllocationV3Service {
|
|||||||
ProfitSharingService sharingService = wxPayService.getProfitSharingService();
|
ProfitSharingService sharingService = wxPayService.getProfitSharingService();
|
||||||
|
|
||||||
ProfitSharingV3Request request = new ProfitSharingV3Request();
|
ProfitSharingV3Request request = new ProfitSharingV3Request();
|
||||||
|
request.setAppid(config.getWxAppId());
|
||||||
request.setOutOrderNo(allocOrder.getAllocNo());
|
request.setOutOrderNo(allocOrder.getAllocNo());
|
||||||
request.setTransactionId(allocOrder.getOutOrderNo());
|
request.setTransactionId(allocOrder.getOutOrderNo());
|
||||||
request.setUnfreezeUnsplit(true);
|
request.setUnfreezeUnsplit(false);
|
||||||
|
|
||||||
// 分账接收方信息
|
// 分账接收方信息
|
||||||
var receivers = orderDetails.stream()
|
var receivers = orderDetails.stream()
|
||||||
@@ -67,7 +69,6 @@ public class WeChatPayAllocationV3Service {
|
|||||||
request.setReceivers(receivers);
|
request.setReceivers(receivers);
|
||||||
try {
|
try {
|
||||||
ProfitSharingV3Result result = sharingService.profitSharingV3(request);
|
ProfitSharingV3Result result = sharingService.profitSharingV3(request);
|
||||||
|
|
||||||
return new AllocStartResultBo().setOutAllocNo(result.getOrderId());
|
return new AllocStartResultBo().setOutAllocNo(result.getOrderId());
|
||||||
} catch (WxPayException e) {
|
} catch (WxPayException e) {
|
||||||
throw new OperationFailException("微信分账V3失败: "+e.getMessage());
|
throw new OperationFailException("微信分账V3失败: "+e.getMessage());
|
||||||
@@ -75,22 +76,40 @@ public class WeChatPayAllocationV3Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分账完结
|
* 分账完结 使用ID作为请求号
|
||||||
*/
|
*/
|
||||||
public void finish(AllocOrder allocOrder, List<AllocDetail> orderDetails, WechatPayConfig config){
|
public void finish(AllocOrder allocOrder, List<AllocDetail> details, WechatPayConfig config){
|
||||||
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(config);
|
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(config);
|
||||||
ProfitSharingService sharingService = wxPayService.getProfitSharingService();
|
ProfitSharingService sharingService = wxPayService.getProfitSharingService();
|
||||||
var request = new ProfitSharingUnfreezeV3Request();
|
var request = new ProfitSharingUnfreezeV3Request();
|
||||||
request.setOutOrderNo(allocOrder.getAllocNo());
|
request.setOutOrderNo(String.valueOf(allocOrder.getId()));
|
||||||
request.setTransactionId(allocOrder.getOutOrderNo());
|
request.setTransactionId(allocOrder.getOutOrderNo());
|
||||||
request.setDescription("分账完结");
|
request.setDescription("分账完结");
|
||||||
try {
|
try {
|
||||||
sharingService.profitSharingUnfreeze(request);
|
var result = sharingService.profitSharingUnfreeze(request);
|
||||||
} catch (WxPayException e) {
|
} catch (WxPayException e) {
|
||||||
throw new OperationFailException("微信分账V3失败: "+e.getMessage());
|
throw new OperationFailException("微信分账V3失败: "+e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步
|
||||||
|
*/
|
||||||
|
public void sync(AllocOrder allocOrder, List<AllocDetail> details, WechatPayConfig config){
|
||||||
|
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(config);
|
||||||
|
ProfitSharingService sharingService = wxPayService.getProfitSharingService();
|
||||||
|
ProfitSharingQueryV3Request request = new ProfitSharingQueryV3Request();
|
||||||
|
request.setOutOrderNo(allocOrder.getAllocNo());
|
||||||
|
// 根据订单状态判断
|
||||||
|
|
||||||
|
request.setTransactionId(allocOrder.getOutOrderNo());
|
||||||
|
try {
|
||||||
|
var result = sharingService.profitSharingQueryV3(request);
|
||||||
|
} catch (WxPayException e) {
|
||||||
|
throw new OperationFailException("微信分账订单查询V3失败: "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取分账接收方类型编码
|
* 获取分账接收方类型编码
|
||||||
*/
|
*/
|
||||||
@@ -103,4 +122,5 @@ public class WeChatPayAllocationV3Service {
|
|||||||
}
|
}
|
||||||
throw new ConfigErrorException("分账接收方类型错误");
|
throw new ConfigErrorException("分账接收方类型错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,11 @@ package org.dromara.daxpay.channel.wechat.strategy;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.daxpay.channel.wechat.code.WechatPayCode;
|
||||||
|
import org.dromara.daxpay.channel.wechat.entity.config.WechatPayConfig;
|
||||||
|
import org.dromara.daxpay.channel.wechat.service.allocation.WeChatPayAllocationV2Service;
|
||||||
|
import org.dromara.daxpay.channel.wechat.service.allocation.WeChatPayAllocationV3Service;
|
||||||
|
import org.dromara.daxpay.channel.wechat.service.config.WechatPayConfigService;
|
||||||
import org.dromara.daxpay.core.enums.ChannelEnum;
|
import org.dromara.daxpay.core.enums.ChannelEnum;
|
||||||
import org.dromara.daxpay.service.bo.allocation.AllocStartResultBo;
|
import org.dromara.daxpay.service.bo.allocation.AllocStartResultBo;
|
||||||
import org.dromara.daxpay.service.bo.allocation.AllocSyncResultBo;
|
import org.dromara.daxpay.service.bo.allocation.AllocSyncResultBo;
|
||||||
@@ -9,6 +14,8 @@ import org.dromara.daxpay.service.strategy.AbsAllocationStrategy;
|
|||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
|
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,7 +28,11 @@ import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROT
|
|||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class WechatAllocationStrategy extends AbsAllocationStrategy {
|
public class WechatAllocationStrategy extends AbsAllocationStrategy {
|
||||||
|
private final WeChatPayAllocationV3Service weChatPayAllocationV3Service;
|
||||||
|
private final WeChatPayAllocationV2Service weChatPayAllocationV2Service;
|
||||||
|
private final WechatPayConfigService wechatPayConfigService;
|
||||||
|
|
||||||
|
private WechatPayConfig config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分账通道
|
* 分账通道
|
||||||
@@ -31,20 +42,33 @@ public class WechatAllocationStrategy extends AbsAllocationStrategy {
|
|||||||
return ChannelEnum.WECHAT.getCode();
|
return ChannelEnum.WECHAT.getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doBeforeHandler(){
|
||||||
|
this.config = wechatPayConfigService.getAndCheckConfig();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始分账
|
* 开始分账
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AllocStartResultBo start() {
|
public AllocStartResultBo start() {
|
||||||
return null;
|
if (Objects.equals(config.getApiVersion(), WechatPayCode.API_V3)){
|
||||||
|
return weChatPayAllocationV3Service.start(getOrder(), getDetails(), this.config);
|
||||||
|
} else {
|
||||||
|
return weChatPayAllocationV2Service.start(getOrder(), getDetails(), this.config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* 完结
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void finish() {
|
public void finish() {
|
||||||
|
if (Objects.equals(config.getApiVersion(), WechatPayCode.API_V3)){
|
||||||
|
weChatPayAllocationV3Service.finish(getOrder(), this.getDetails(), this.config);
|
||||||
|
} else {
|
||||||
|
weChatPayAllocationV2Service.finish(getOrder(), this.getDetails(), this.config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,6 +76,13 @@ public class WechatAllocationStrategy extends AbsAllocationStrategy {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AllocSyncResultBo doSync() {
|
public AllocSyncResultBo doSync() {
|
||||||
|
if (Objects.equals(config.getApiVersion(), WechatPayCode.API_V3)){
|
||||||
|
weChatPayAllocationV3Service.finish(getOrder(), this.getDetails(), this.config);
|
||||||
|
|
||||||
|
weChatPayAllocationV3Service.sync(getOrder(), this.getDetails(), this.config);
|
||||||
|
} else {
|
||||||
|
weChatPayAllocationV2Service.sync(getOrder(), this.getDetails(), this.config);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,9 +26,15 @@ public class AllocConfig extends MchAppBaseEntity implements ToResult<AllocConfi
|
|||||||
/** 是否自动分账 */
|
/** 是否自动分账 */
|
||||||
private Boolean autoAlloc;
|
private Boolean autoAlloc;
|
||||||
|
|
||||||
|
/** 自动完结 */
|
||||||
|
private Boolean autoFinish;
|
||||||
|
|
||||||
/** 分账起始额 */
|
/** 分账起始额 */
|
||||||
private BigDecimal minAmount;
|
private BigDecimal minAmount;
|
||||||
|
|
||||||
|
/** 分账延迟时长(分钟) */
|
||||||
|
private Integer delayTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建对象
|
* 创建对象
|
||||||
|
@@ -24,10 +24,19 @@ public class AllocConfigParam {
|
|||||||
@Schema(description = "是否自动分账")
|
@Schema(description = "是否自动分账")
|
||||||
private Boolean autoAlloc;
|
private Boolean autoAlloc;
|
||||||
|
|
||||||
|
/** 自动完结 */
|
||||||
|
@Schema(description = "自动完结")
|
||||||
|
private Boolean autoFinish;
|
||||||
|
|
||||||
/** 分账起始额 */
|
/** 分账起始额 */
|
||||||
@Schema(description = "分账起始额")
|
@Schema(description = "分账起始额")
|
||||||
private BigDecimal minAmount;
|
private BigDecimal minAmount;
|
||||||
|
|
||||||
|
/** 分账延迟时长(分钟) */
|
||||||
|
@Schema(description = "分账延迟时长(分钟)")
|
||||||
|
private Integer delayTime;
|
||||||
|
|
||||||
|
/** 应用AppId */
|
||||||
@Schema(description = "应用AppId")
|
@Schema(description = "应用AppId")
|
||||||
private String appId;
|
private String appId;
|
||||||
|
|
||||||
|
@@ -24,4 +24,12 @@ public class AllocConfigResult extends MchAppResult {
|
|||||||
|
|
||||||
@Schema(description = "分账起始额")
|
@Schema(description = "分账起始额")
|
||||||
private BigDecimal minAmount;
|
private BigDecimal minAmount;
|
||||||
|
|
||||||
|
/** 自动完结 */
|
||||||
|
@Schema(description = "是否自动完结")
|
||||||
|
private Boolean autoFinish;
|
||||||
|
|
||||||
|
/** 分账延迟时长(分钟) */
|
||||||
|
@Schema(description = "分账延迟时长(分钟)")
|
||||||
|
private Integer delayTime;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user