mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-03 11:06:46 +00:00
feat 分账SDK接口开发和前端联调
This commit is contained in:
@@ -42,6 +42,13 @@ public class AllocationGroupController {
|
||||
return Res.ok(allocationGroupService.findById(id));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "编码是否存在")
|
||||
@GetMapping("/existsByGroupNo")
|
||||
public ResResult<Boolean> existsByGroupNo(String groupNo){
|
||||
return Res.ok(allocationGroupService.existsByGroupNo(groupNo));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询分账接收方信息")
|
||||
@GetMapping("/findReceiversByGroups")
|
||||
public ResResult<List<AllocationGroupReceiverResult>> findReceiversByGroups(Long groupId){
|
||||
|
@@ -61,13 +61,18 @@ public class AllocationOrderController {
|
||||
return Res.ok(allocationOrderService.findById(id));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "查询明细详情")
|
||||
@GetMapping("/detail/findById")
|
||||
public ResResult<AllocationOrderDetailDto> findDetailById(Long id){
|
||||
return Res.ok(allocationOrderService.findDetailById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询扩展信息")
|
||||
@GetMapping("/extra/findById")
|
||||
public ResResult<AllocationOrderDto> findExtraById(Long id){
|
||||
return Res.ok(allocationOrderService.findExtraById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取可以分账的通道")
|
||||
@GetMapping("/findChannels")
|
||||
public ResResult<List<LabelValue>> findChannels(){
|
||||
|
@@ -42,6 +42,12 @@ public class AllocationReceiverController {
|
||||
return Res.ok(receiverService.findById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "编码是否存在")
|
||||
@GetMapping("/existsByReceiverNo")
|
||||
public ResResult<Boolean> existsByReceiverNo(String receiverNo){
|
||||
return Res.ok(receiverService.existsByReceiverNo(receiverNo));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取可以分账的通道")
|
||||
@GetMapping("/findChannels")
|
||||
public ResResult<List<LabelValue>> findChannels(){
|
||||
|
@@ -8,7 +8,7 @@ import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.daxpay.single.param.payment.allocation.AllocationParam;
|
||||
import cn.daxpay.single.param.payment.pay.PayCloseParam;
|
||||
import cn.daxpay.single.param.payment.pay.PaySyncParam;
|
||||
import cn.daxpay.single.result.pay.SyncResult;
|
||||
import cn.daxpay.single.result.sync.PaySyncResult;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||
import cn.daxpay.single.service.core.order.pay.service.PayOrderExtraService;
|
||||
import cn.daxpay.single.service.core.order.pay.service.PayOrderQueryService;
|
||||
@@ -81,7 +81,7 @@ public class PayOrderController {
|
||||
|
||||
@Operation(summary = "同步支付状态")
|
||||
@PostMapping("/syncByOrderNo")
|
||||
public ResResult<SyncResult> syncById(String orderNo){
|
||||
public ResResult<PaySyncResult> syncById(String orderNo){
|
||||
PaySyncParam param = new PaySyncParam();
|
||||
param.setOrderNo(orderNo);
|
||||
return Res.ok(paySyncService.sync(param));
|
||||
|
@@ -6,7 +6,8 @@ import cn.bootx.platform.common.core.rest.ResResult;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.daxpay.single.code.PaymentApiCode;
|
||||
import cn.daxpay.single.param.payment.refund.RefundSyncParam;
|
||||
import cn.daxpay.single.result.pay.SyncResult;
|
||||
import cn.daxpay.single.result.sync.PaySyncResult;
|
||||
import cn.daxpay.single.result.sync.RefundSyncResult;
|
||||
import cn.daxpay.single.service.annotation.PlatformInitContext;
|
||||
import cn.daxpay.single.service.core.order.refund.service.RefundOrderQueryService;
|
||||
import cn.daxpay.single.service.core.order.refund.service.RefundOrderService;
|
||||
@@ -83,7 +84,7 @@ public class RefundOrderController {
|
||||
|
||||
@Operation(summary = "退款同步")
|
||||
@PostMapping("/syncByRefundNo")
|
||||
public ResResult<SyncResult> syncByRefundNo(String refundNo){
|
||||
public ResResult<RefundSyncResult> syncByRefundNo(String refundNo){
|
||||
RefundSyncParam refundSyncParam = new RefundSyncParam();
|
||||
refundSyncParam.setRefundNo(refundNo);
|
||||
return Res.ok(refundSyncService.sync(refundSyncParam));
|
||||
|
@@ -45,7 +45,4 @@ public interface PaymentApiCode {
|
||||
/** 删除分账方 */
|
||||
String ALLOCATION_RECEIVER_REMOVE = "allocationReceiverRemove";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -45,6 +45,10 @@ public class AllocationParam extends PaymentCommonParam {
|
||||
@Schema(description = "分账接收方列表")
|
||||
private List<AllocReceiverParam> receivers;
|
||||
|
||||
/** 是否不启用异步通知 */
|
||||
@Schema(description = "是否不启用异步通知")
|
||||
private Boolean notNotify;
|
||||
|
||||
/** 回调通知地址 */
|
||||
@Schema(description = "回调通知地址")
|
||||
private String notifyUrl;
|
||||
|
@@ -0,0 +1,19 @@
|
||||
package cn.daxpay.single.param.payment.transfer;
|
||||
|
||||
import cn.daxpay.single.param.PaymentCommonParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 转正订单查询参数
|
||||
* @author xxm
|
||||
* @since 2024/5/27
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "转正订单查询参数")
|
||||
public class QueryTransferParam extends PaymentCommonParam {
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package cn.daxpay.single.result.allocation;
|
||||
package cn.daxpay.single.result.order;
|
||||
|
||||
import cn.daxpay.single.code.AllocDetailResultEnum;
|
||||
import cn.daxpay.single.code.AllocReceiverTypeEnum;
|
@@ -1,4 +1,4 @@
|
||||
package cn.daxpay.single.result.allocation;
|
||||
package cn.daxpay.single.result.order;
|
||||
|
||||
import cn.daxpay.single.code.AllocOrderResultEnum;
|
||||
import cn.daxpay.single.code.AllocOrderStatusEnum;
|
@@ -1,4 +1,4 @@
|
||||
package cn.daxpay.single.result.allocation;
|
||||
package cn.daxpay.single.result.sync;
|
||||
|
||||
import cn.daxpay.single.result.PaymentCommonResult;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -15,5 +15,5 @@ import lombok.experimental.Accessors;
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "分账同步接口")
|
||||
public class AllocationSyncResult extends PaymentCommonResult {
|
||||
public class AllocSyncResult extends PaymentCommonResult {
|
||||
}
|
@@ -1,8 +1,7 @@
|
||||
package cn.daxpay.single.result.pay;
|
||||
package cn.daxpay.single.result.sync;
|
||||
|
||||
import cn.daxpay.single.code.AllocOrderStatusEnum;
|
||||
import cn.daxpay.single.code.RefundSyncStatusEnum;
|
||||
import cn.daxpay.single.code.PaySyncStatusEnum;
|
||||
import cn.daxpay.single.code.RefundSyncStatusEnum;
|
||||
import cn.daxpay.single.result.PaymentCommonResult;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@@ -12,23 +11,22 @@ import lombok.experimental.Accessors;
|
||||
import static cn.daxpay.single.code.PaySyncStatusEnum.FAIL;
|
||||
|
||||
/**
|
||||
* 各种单据同步结果
|
||||
* 支付同步结果
|
||||
* @author xxm
|
||||
* @since 2023/12/27
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "同步结果")
|
||||
public class SyncResult extends PaymentCommonResult {
|
||||
@Schema(title = "支付同步结果")
|
||||
public class PaySyncResult extends PaymentCommonResult {
|
||||
|
||||
/**
|
||||
* 支付网关同步状态
|
||||
* @see PaySyncStatusEnum
|
||||
* @see RefundSyncStatusEnum
|
||||
* @see AllocOrderStatusEnum
|
||||
*/
|
||||
@Schema(description = "支付网关同步状态")
|
||||
@Schema(description = "同步状态")
|
||||
private String status = FAIL.getCode();
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package cn.daxpay.single.result.sync;
|
||||
|
||||
import cn.daxpay.single.code.PaySyncStatusEnum;
|
||||
import cn.daxpay.single.code.RefundSyncStatusEnum;
|
||||
import cn.daxpay.single.result.PaymentCommonResult;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import static cn.daxpay.single.code.PaySyncStatusEnum.FAIL;
|
||||
|
||||
/**
|
||||
* 退款同步结果
|
||||
* @author xxm
|
||||
* @since 2023/12/27
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "支付同步结果")
|
||||
public class RefundSyncResult extends PaymentCommonResult {
|
||||
|
||||
/**
|
||||
* 支付网关同步状态
|
||||
* @see PaySyncStatusEnum
|
||||
* @see RefundSyncStatusEnum
|
||||
*/
|
||||
@Schema(description = "同步状态")
|
||||
private String status = FAIL.getCode();
|
||||
|
||||
}
|
@@ -53,7 +53,6 @@ public class UniAllocationController {
|
||||
return DaxRes.ok(allocationService.finish(param));
|
||||
}
|
||||
|
||||
|
||||
@PaymentSign
|
||||
@PlatformInitContext(PaymentApiCode.ALLOCATION_RECEIVER_ADD)
|
||||
@Operation(summary = "添加分账接收方接口")
|
||||
@@ -70,4 +69,5 @@ public class UniAllocationController {
|
||||
return DaxRes.ok(receiverService.remove(param));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -15,8 +15,6 @@ import cn.daxpay.single.service.annotation.PlatformInitContext;
|
||||
import cn.daxpay.single.service.core.payment.close.service.PayCloseService;
|
||||
import cn.daxpay.single.service.core.payment.pay.service.PayService;
|
||||
import cn.daxpay.single.service.core.payment.refund.service.RefundService;
|
||||
import cn.daxpay.single.service.core.payment.sync.service.PaySyncService;
|
||||
import cn.daxpay.single.service.core.payment.sync.service.RefundSyncService;
|
||||
import cn.daxpay.single.util.DaxRes;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -39,9 +37,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class UniPayController {
|
||||
private final PayService payService;
|
||||
private final RefundService refundService;
|
||||
private final PaySyncService paySyncService;
|
||||
private final PayCloseService payCloseService;
|
||||
private final RefundSyncService refundSyncService;
|
||||
|
||||
@PaymentSign
|
||||
@PlatformInitContext(PaymentApiCode.PAY)
|
||||
@@ -67,7 +63,6 @@ public class UniPayController {
|
||||
return DaxRes.ok(refundService.refund(param));
|
||||
}
|
||||
|
||||
|
||||
@PaymentSign
|
||||
@PlatformInitContext(PaymentApiCode.TRANSFER)
|
||||
@Operation(summary = "统一转账接口")
|
||||
@@ -76,5 +71,4 @@ public class UniPayController {
|
||||
return DaxRes.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -5,8 +5,9 @@ import cn.daxpay.single.param.payment.allocation.AllocSyncParam;
|
||||
import cn.daxpay.single.param.payment.pay.PaySyncParam;
|
||||
import cn.daxpay.single.param.payment.refund.RefundSyncParam;
|
||||
import cn.daxpay.single.result.DaxResult;
|
||||
import cn.daxpay.single.result.allocation.AllocationSyncResult;
|
||||
import cn.daxpay.single.result.pay.SyncResult;
|
||||
import cn.daxpay.single.result.sync.AllocSyncResult;
|
||||
import cn.daxpay.single.result.sync.PaySyncResult;
|
||||
import cn.daxpay.single.result.sync.RefundSyncResult;
|
||||
import cn.daxpay.single.service.annotation.PaymentSign;
|
||||
import cn.daxpay.single.service.annotation.PlatformInitContext;
|
||||
import cn.daxpay.single.service.core.payment.allocation.service.AllocationSyncService;
|
||||
@@ -28,7 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@Tag(name = "")
|
||||
@RestController
|
||||
@RequestMapping("/unipay/sync/")
|
||||
@RequestMapping("/unipay/sync")
|
||||
@RequiredArgsConstructor
|
||||
public class UniPaySyncController {
|
||||
|
||||
@@ -40,7 +41,7 @@ public class UniPaySyncController {
|
||||
@PlatformInitContext(PaymentApiCode.SYNC_PAY)
|
||||
@Operation(summary = "支付同步接口")
|
||||
@PostMapping("/pay")
|
||||
public DaxResult<SyncResult> syncPay(@RequestBody PaySyncParam param){
|
||||
public DaxResult<PaySyncResult> pay(@RequestBody PaySyncParam param){
|
||||
return DaxRes.ok(paySyncService.sync(param));
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ public class UniPaySyncController {
|
||||
@PlatformInitContext(PaymentApiCode.SYNC_REFUND)
|
||||
@Operation(summary = "退款同步接口")
|
||||
@PostMapping("/refund")
|
||||
public DaxResult<SyncResult> syncRefund(@RequestBody RefundSyncParam param){
|
||||
public DaxResult<RefundSyncResult> refund(@RequestBody RefundSyncParam param){
|
||||
return DaxRes.ok(refundSyncService.sync(param));
|
||||
}
|
||||
|
||||
@@ -56,8 +57,17 @@ public class UniPaySyncController {
|
||||
@PaymentSign
|
||||
@PlatformInitContext(PaymentApiCode.SYNC_ALLOCATION)
|
||||
@Operation(summary = "分账同步接口")
|
||||
@PostMapping("/sync")
|
||||
public DaxResult<AllocationSyncResult> sync(@RequestBody AllocSyncParam param){
|
||||
@PostMapping("/allocation")
|
||||
public DaxResult<AllocSyncResult> allocation(@RequestBody AllocSyncParam param){
|
||||
return DaxRes.ok(allocationSyncService.sync(param));
|
||||
}
|
||||
|
||||
@PaymentSign
|
||||
@PlatformInitContext(PaymentApiCode.SYNC_TRANSFER)
|
||||
@Operation(summary = "转账同步接口")
|
||||
@PostMapping("/transfer")
|
||||
public DaxResult<Void> transfer(@RequestBody AllocSyncParam param){
|
||||
allocationSyncService.sync(param);
|
||||
return DaxRes.ok();
|
||||
}
|
||||
}
|
||||
|
@@ -6,13 +6,14 @@ import cn.daxpay.single.param.payment.allocation.QueryAllocOrderParam;
|
||||
import cn.daxpay.single.param.payment.allocation.QueryAllocReceiverParam;
|
||||
import cn.daxpay.single.param.payment.pay.QueryPayParam;
|
||||
import cn.daxpay.single.param.payment.refund.QueryRefundParam;
|
||||
import cn.daxpay.single.param.payment.transfer.QueryTransferParam;
|
||||
import cn.daxpay.single.result.DaxResult;
|
||||
import cn.daxpay.single.result.allocation.AllocOrderResult;
|
||||
import cn.daxpay.single.result.order.AllocOrderResult;
|
||||
import cn.daxpay.single.result.allocation.AllocReceiversResult;
|
||||
import cn.daxpay.single.result.order.PayOrderResult;
|
||||
import cn.daxpay.single.result.order.RefundOrderResult;
|
||||
import cn.daxpay.single.service.annotation.PlatformInitContext;
|
||||
import cn.daxpay.single.service.annotation.PaymentSign;
|
||||
import cn.daxpay.single.service.annotation.PlatformInitContext;
|
||||
import cn.daxpay.single.service.core.order.pay.service.PayOrderQueryService;
|
||||
import cn.daxpay.single.service.core.order.refund.service.RefundOrderQueryService;
|
||||
import cn.daxpay.single.service.core.payment.allocation.service.AllocationReceiverService;
|
||||
@@ -67,6 +68,14 @@ public class UniQueryController {
|
||||
return DaxRes.ok(allocationService.queryAllocationOrder(param));
|
||||
}
|
||||
|
||||
@PaymentSign
|
||||
@PlatformInitContext(PaymentApiCode.QUERY_TRANSFER_ORDER)
|
||||
@Operation(summary = "转账订单查询接口")
|
||||
@PostMapping("/transferOrder")
|
||||
public DaxResult<Void> transferOrder(@RequestBody QueryTransferParam param){
|
||||
return DaxRes.ok();
|
||||
}
|
||||
|
||||
@PaymentSign
|
||||
@PlatformInitContext(PaymentApiCode.QUERY_ALLOCATION_RECEIVER)
|
||||
@Operation(summary = "分账接收方查询接口")
|
||||
|
@@ -1,16 +1,14 @@
|
||||
package cn.daxpay.single.gateway.controller;
|
||||
|
||||
import cn.daxpay.single.code.PaymentApiCode;
|
||||
import cn.daxpay.single.param.payment.pay.PayParam;
|
||||
import cn.daxpay.single.result.DaxResult;
|
||||
import cn.daxpay.single.service.annotation.PlatformInitContext;
|
||||
import cn.daxpay.single.service.annotation.PaymentSign;
|
||||
import cn.daxpay.single.service.annotation.PlatformInitContext;
|
||||
import cn.daxpay.single.util.DaxRes;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -29,7 +27,7 @@ public class UniReconcileController {
|
||||
@PlatformInitContext(PaymentApiCode.PAY)
|
||||
@Operation(summary = "下载指定日期的资金流水")
|
||||
@PostMapping("/pay")
|
||||
public DaxResult<?> down(@RequestBody PayParam payParam){
|
||||
public DaxResult<?> down(){
|
||||
return DaxRes.ok();
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,7 @@ import cn.daxpay.single.service.code.AliPayCode;
|
||||
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocRemoteSyncResult;
|
||||
import cn.daxpay.single.util.PayUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -106,7 +106,7 @@ public class AliPayAllocationService {
|
||||
* 分账状态同步
|
||||
*/
|
||||
@SneakyThrows
|
||||
public AllocSyncResult sync(AllocationOrder allocationOrder, List<AllocationOrderDetail> allocationOrderDetails){
|
||||
public AllocRemoteSyncResult sync(AllocationOrder allocationOrder, List<AllocationOrderDetail> allocationOrderDetails){
|
||||
AlipayTradeOrderSettleQueryModel model = new AlipayTradeOrderSettleQueryModel();
|
||||
model.setTradeNo(allocationOrder.getOutOrderNo());
|
||||
model.setOutRequestNo(allocationOrder.getOrderNo());
|
||||
@@ -134,7 +134,7 @@ public class AliPayAllocationService {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new AllocSyncResult().setSyncInfo(JSONUtil.toJsonStr(response));
|
||||
return new AllocRemoteSyncResult().setSyncInfo(JSONUtil.toJsonStr(response));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,7 +3,7 @@ package cn.daxpay.single.service.core.channel.alipay.service;
|
||||
import cn.bootx.platform.common.spring.exception.RetryableException;
|
||||
import cn.daxpay.single.code.PaySyncStatusEnum;
|
||||
import cn.daxpay.single.service.code.AliPayCode;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PaySyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
@@ -70,7 +70,7 @@ public class AliPayCloseService {
|
||||
* 关闭失败后, 获取支付网关的状态, 如果是关闭返回true, 其他情况抛出异常
|
||||
*/
|
||||
private boolean syncStatus(PayOrder payOrder){
|
||||
PaySyncResult gatewaySyncResult = aliPaySyncService.syncPayStatus(payOrder);
|
||||
PayRemoteSyncResult gatewaySyncResult = aliPaySyncService.syncPayStatus(payOrder);
|
||||
// 已经关闭
|
||||
if (Objects.equals(gatewaySyncResult.getSyncStatus(), PaySyncStatusEnum.CLOSED)){
|
||||
return true;
|
||||
|
@@ -6,8 +6,8 @@ import cn.daxpay.single.code.PaySyncStatusEnum;
|
||||
import cn.daxpay.single.service.code.AliPayCode;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PaySyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundRemoteSyncResult;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.domain.AlipayTradeFastpayRefundQueryModel;
|
||||
@@ -43,8 +43,8 @@ public class AliPaySyncService {
|
||||
* 4 查询不到
|
||||
* 5 查询失败
|
||||
*/
|
||||
public PaySyncResult syncPayStatus(PayOrder payOrder) {
|
||||
PaySyncResult syncResult = new PaySyncResult().setSyncStatus(PaySyncStatusEnum.FAIL);
|
||||
public PayRemoteSyncResult syncPayStatus(PayOrder payOrder) {
|
||||
PayRemoteSyncResult syncResult = new PayRemoteSyncResult().setSyncStatus(PaySyncStatusEnum.FAIL);
|
||||
// 查询
|
||||
try {
|
||||
AlipayTradeQueryModel queryModel = new AlipayTradeQueryModel();
|
||||
@@ -96,8 +96,8 @@ public class AliPaySyncService {
|
||||
* 退款同步查询
|
||||
* 注意: 支付宝退款没有网关订单号, 网关订单号是支付单的
|
||||
*/
|
||||
public RefundSyncResult syncRefundStatus(RefundOrder refundOrder) {
|
||||
RefundSyncResult syncResult = new RefundSyncResult().setSyncStatus(RefundSyncStatusEnum.FAIL);
|
||||
public RefundRemoteSyncResult syncRefundStatus(RefundOrder refundOrder) {
|
||||
RefundRemoteSyncResult syncResult = new RefundRemoteSyncResult().setSyncStatus(RefundSyncStatusEnum.FAIL);
|
||||
try {
|
||||
AlipayTradeFastpayRefundQueryModel queryModel = new AlipayTradeFastpayRefundQueryModel();
|
||||
// 退款请求号
|
||||
|
@@ -6,8 +6,8 @@ import cn.daxpay.single.code.RefundSyncStatusEnum;
|
||||
import cn.daxpay.single.service.code.UnionPayCode;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PaySyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundRemoteSyncResult;
|
||||
import cn.daxpay.single.service.sdk.union.api.UnionPayKit;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
@@ -39,8 +39,8 @@ public class UnionPaySyncService {
|
||||
/**
|
||||
* 支付信息查询
|
||||
*/
|
||||
public PaySyncResult syncPayStatus(PayOrder order, UnionPayKit unionPayKit) {
|
||||
PaySyncResult syncResult = new PaySyncResult().setSyncStatus(PaySyncStatusEnum.FAIL);
|
||||
public PayRemoteSyncResult syncPayStatus(PayOrder order, UnionPayKit unionPayKit) {
|
||||
PayRemoteSyncResult syncResult = new PayRemoteSyncResult().setSyncStatus(PaySyncStatusEnum.FAIL);
|
||||
|
||||
AssistOrder query = new AssistOrder();
|
||||
query.setOutTradeNo(order.getOrderNo());
|
||||
@@ -98,8 +98,8 @@ public class UnionPaySyncService {
|
||||
* 退款信息查询
|
||||
* 云闪付退款和支付查询接口是一个
|
||||
*/
|
||||
public RefundSyncResult syncRefundStatus(RefundOrder refundOrder, UnionPayKit unionPayKit){
|
||||
RefundSyncResult syncResult = new RefundSyncResult();
|
||||
public RefundRemoteSyncResult syncRefundStatus(RefundOrder refundOrder, UnionPayKit unionPayKit){
|
||||
RefundRemoteSyncResult syncResult = new RefundRemoteSyncResult();
|
||||
|
||||
AssistOrder query = new AssistOrder();
|
||||
query.setOutTradeNo(String.valueOf(refundOrder.getRefundNo()));
|
||||
|
@@ -9,7 +9,7 @@ import cn.daxpay.single.service.code.WeChatPayCode;
|
||||
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocRemoteSyncResult;
|
||||
import cn.daxpay.single.service.dto.channel.wechat.WeChatPayAllocationReceiver;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
@@ -109,7 +109,7 @@ public class WeChatPayAllocationService {
|
||||
/**
|
||||
* 同步分账状态
|
||||
*/
|
||||
public AllocSyncResult sync(AllocationOrder allocationOrder, List<AllocationOrderDetail> allocationOrderDetails, WeChatPayConfig config){
|
||||
public AllocRemoteSyncResult sync(AllocationOrder allocationOrder, List<AllocationOrderDetail> allocationOrderDetails, WeChatPayConfig config){
|
||||
// 不要传输AppId参数, 否则会失败
|
||||
Map<String, String> params = ProfitSharingModel.builder()
|
||||
.mch_id(config.getWxMchId())
|
||||
@@ -138,7 +138,7 @@ public class WeChatPayAllocationService {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new AllocSyncResult().setSyncInfo(JSONUtil.toJsonStr(receivers));
|
||||
return new AllocRemoteSyncResult().setSyncInfo(JSONUtil.toJsonStr(receivers));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import cn.bootx.platform.common.spring.exception.RetryableException;
|
||||
import cn.daxpay.single.code.PayMethodEnum;
|
||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||
import cn.daxpay.single.param.payment.pay.PayParam;
|
||||
import cn.daxpay.single.result.pay.SyncResult;
|
||||
import cn.daxpay.single.result.sync.PaySyncResult;
|
||||
import cn.daxpay.single.service.code.WeChatPayCode;
|
||||
import cn.daxpay.single.service.code.WeChatPayWay;
|
||||
import cn.daxpay.single.service.common.context.PayLocal;
|
||||
@@ -275,9 +275,9 @@ public class WeChatPayService {
|
||||
@Async("bigExecutor")
|
||||
@Retryable(value = RetryableException.class, maxAttempts = 10, backoff = @Backoff(value = 5000L))
|
||||
public void rotationSync(PayOrder payOrder) {
|
||||
SyncResult syncResult = paySyncService.syncPayOrder(payOrder);
|
||||
PaySyncResult paySyncResult = paySyncService.syncPayOrder(payOrder);
|
||||
// 不为支付中状态后, 调用系统同步更新状态, 支付状态则继续重试
|
||||
if (Objects.equals(PROGRESS.getCode(), syncResult.getStatus())) {
|
||||
if (Objects.equals(PROGRESS.getCode(), paySyncResult.getStatus())) {
|
||||
throw new RetryableException();
|
||||
}
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@ import cn.daxpay.single.service.code.WeChatPayCode;
|
||||
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PaySyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundRemoteSyncResult;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
@@ -41,8 +41,8 @@ public class WeChatPaySyncService {
|
||||
/**
|
||||
* 支付信息查询
|
||||
*/
|
||||
public PaySyncResult syncPayStatus(PayOrder order, WeChatPayConfig weChatPayConfig) {
|
||||
PaySyncResult syncResult = new PaySyncResult().setSyncStatus(PaySyncStatusEnum.FAIL);
|
||||
public PayRemoteSyncResult syncPayStatus(PayOrder order, WeChatPayConfig weChatPayConfig) {
|
||||
PayRemoteSyncResult syncResult = new PayRemoteSyncResult().setSyncStatus(PaySyncStatusEnum.FAIL);
|
||||
Map<String, String> params = OrderQueryModel.builder()
|
||||
.appid(weChatPayConfig.getWxAppId())
|
||||
.mch_id(weChatPayConfig.getWxMchId())
|
||||
@@ -103,8 +103,8 @@ public class WeChatPaySyncService {
|
||||
/**
|
||||
* 退款信息查询
|
||||
*/
|
||||
public RefundSyncResult syncRefundStatus(RefundOrder refundOrder, WeChatPayConfig weChatPayConfig){
|
||||
RefundSyncResult syncResult = new RefundSyncResult();
|
||||
public RefundRemoteSyncResult syncRefundStatus(RefundOrder refundOrder, WeChatPayConfig weChatPayConfig){
|
||||
RefundRemoteSyncResult syncResult = new RefundRemoteSyncResult();
|
||||
Map<String, String> params = RefundQueryModel.builder()
|
||||
.appid(weChatPayConfig.getWxAppId())
|
||||
.mch_id(weChatPayConfig.getWxMchId())
|
||||
|
@@ -8,7 +8,7 @@ import cn.bootx.table.modify.mysql.annotation.DbMySqlFieldType;
|
||||
import cn.bootx.table.modify.mysql.constants.MySqlFieldTypeEnum;
|
||||
import cn.daxpay.single.code.PayStatusEnum;
|
||||
import cn.daxpay.single.code.RefundStatusEnum;
|
||||
import cn.daxpay.single.result.allocation.AllocOrderResult;
|
||||
import cn.daxpay.single.result.order.AllocOrderResult;
|
||||
import cn.daxpay.single.service.code.ClientNoticeTypeEnum;
|
||||
import cn.daxpay.single.service.core.payment.notice.result.PayNoticeResult;
|
||||
import cn.daxpay.single.service.core.payment.notice.result.RefundNoticeResult;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.daxpay.single.service.core.order.allocation.convert;
|
||||
|
||||
import cn.daxpay.single.result.allocation.AllocOrderDetailResult;
|
||||
import cn.daxpay.single.result.allocation.AllocOrderResult;
|
||||
import cn.daxpay.single.result.order.AllocOrderDetailResult;
|
||||
import cn.daxpay.single.result.order.AllocOrderResult;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
|
||||
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDetailDto;
|
||||
|
@@ -13,10 +13,14 @@ import cn.daxpay.single.code.PayOrderAllocStatusEnum;
|
||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||
import cn.daxpay.single.param.payment.allocation.AllocReceiverParam;
|
||||
import cn.daxpay.single.param.payment.allocation.AllocationParam;
|
||||
import cn.daxpay.single.service.common.context.NoticeLocal;
|
||||
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderDetailManager;
|
||||
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderExtraManager;
|
||||
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderManager;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderExtra;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.OrderAndDetail;
|
||||
import cn.daxpay.single.service.core.order.pay.dao.PayOrderManager;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||
@@ -57,6 +61,8 @@ public class AllocationOrderService {
|
||||
|
||||
private final PayOrderManager payOrderManager;
|
||||
|
||||
private final AllocationOrderExtraManager allocationOrderExtraManager;
|
||||
|
||||
|
||||
/**
|
||||
* 获取可以分账的通道
|
||||
@@ -171,7 +177,7 @@ public class AllocationOrderService {
|
||||
if (receivers.size() != receiverNos.size()){
|
||||
throw new PayFailureException("分账接收方列表存在无效的分账接收方");
|
||||
}
|
||||
long orderId = IdUtil.getSnowflakeNextId();
|
||||
long allocId = IdUtil.getSnowflakeNextId();
|
||||
|
||||
// 订单明细
|
||||
List<AllocationOrderDetail> details = receivers.stream()
|
||||
@@ -182,7 +188,7 @@ public class AllocationOrderService {
|
||||
.divide(BigDecimal.valueOf(payOrder.getAmount()), 4, RoundingMode.DOWN)
|
||||
.multiply(BigDecimal.valueOf(10000)).intValue();
|
||||
AllocationOrderDetail detail = new AllocationOrderDetail();
|
||||
detail.setAllocationId(orderId)
|
||||
detail.setAllocationId(allocId)
|
||||
.setReceiverId(o.getId())
|
||||
.setReceiverNo(o.getReceiverNo())
|
||||
.setAmount(amount)
|
||||
@@ -211,11 +217,19 @@ public class AllocationOrderService {
|
||||
.setDescription(param.getDescription())
|
||||
.setStatus(AllocOrderStatusEnum.ALLOCATION_PROCESSING.getCode())
|
||||
.setAmount(sumAmount);
|
||||
allocationOrder.setId(orderId);
|
||||
allocationOrder.setId(allocId);
|
||||
// 分账订单扩展
|
||||
NoticeLocal noticeInfo = PaymentContextLocal.get().getNoticeInfo();
|
||||
AllocationOrderExtra extend = new AllocationOrderExtra()
|
||||
.setNotifyUrl(noticeInfo.getNotifyUrl())
|
||||
.setAttach(param.getAttach());
|
||||
extend.setId(allocId);
|
||||
|
||||
// 更新支付订单分账状态
|
||||
payOrder.setAllocationStatus(PayOrderAllocStatusEnum.ALLOCATION.getCode());
|
||||
payOrderManager.updateById(payOrder);
|
||||
allocationOrderDetailManager.saveAll(details);
|
||||
allocationOrderExtraManager.save(extend);
|
||||
allocationOrderManager.save(allocationOrder);
|
||||
return new OrderAndDetail().setOrder(allocationOrder).setDetails(details);
|
||||
}
|
||||
|
@@ -61,4 +61,11 @@ public class AllocationGroupManager extends BaseManager<AllocationGroupMapper, A
|
||||
.eq(AllocationGroup::isDefaultGroup,true)
|
||||
.oneOpt();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分账组编号是否存在
|
||||
*/
|
||||
public boolean existedByGroupNo(String groupNo) {
|
||||
return existedByField(AllocationGroup::getGroupNo,groupNo);
|
||||
}
|
||||
}
|
||||
|
@@ -54,4 +54,8 @@ public class AllocationReceiverManager extends BaseManager<AllocationReceiverMap
|
||||
public List<AllocationReceiver> findAllByChannel(String channel) {
|
||||
return findAllByField(AllocationReceiver::getChannel, channel);
|
||||
}
|
||||
|
||||
public boolean existedByReceiverNo(String receiverNo) {
|
||||
return existedByField(AllocationReceiver::getReceiverNo, receiverNo);
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +0,0 @@
|
||||
package cn.daxpay.single.service.core.payment.allocation.result;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 分账网关同步结果
|
||||
* @author xxm
|
||||
* @since 2024/4/15
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "分账网关同步结果")
|
||||
public class AllocationGatewaySyncResult {
|
||||
|
||||
}
|
@@ -13,6 +13,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 分账支撑方法
|
||||
* @author xxm
|
||||
@@ -38,7 +40,7 @@ public class AllocationAssistService {
|
||||
PlatformLocal platform = PaymentContextLocal.get()
|
||||
.getPlatformInfo();
|
||||
// 异步回调为开启状态
|
||||
if (apiInfo.isNotice()) {
|
||||
if (!Objects.equals(allocationParam.getNotNotify(), false) && apiInfo.isNotice()){
|
||||
// 首先读取请求参数
|
||||
noticeInfo.setNotifyUrl(allocationParam.getNotifyUrl());
|
||||
// 读取接口配置
|
||||
@@ -65,9 +67,5 @@ public class AllocationAssistService {
|
||||
.setReqTime(allocationParam.getReqTime());
|
||||
|
||||
allocationOrderExtraManager.updateById(orderExtra);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -246,4 +246,10 @@ public class AllocationGroupService {
|
||||
groupManager.updateById(group);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断分账组编号是否存在
|
||||
*/
|
||||
public boolean existsByGroupNo(String groupNo) {
|
||||
return groupManager.existedByGroupNo(groupNo);
|
||||
}
|
||||
}
|
||||
|
@@ -68,6 +68,13 @@ public class AllocationReceiverService {
|
||||
return manager.findById(id).map(AllocationReceiver::toDto).orElseThrow(() -> new DataNotExistException("分账接收方不存在"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码是否存在
|
||||
*/
|
||||
public boolean existsByReceiverNo(String receiverNo){
|
||||
return manager.existedByReceiverNo(receiverNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可以分账的通道
|
||||
*/
|
||||
|
@@ -9,8 +9,8 @@ import cn.daxpay.single.exception.pay.PayFailureException;
|
||||
import cn.daxpay.single.param.payment.allocation.AllocFinishParam;
|
||||
import cn.daxpay.single.param.payment.allocation.AllocationParam;
|
||||
import cn.daxpay.single.param.payment.allocation.QueryAllocOrderParam;
|
||||
import cn.daxpay.single.result.allocation.AllocOrderDetailResult;
|
||||
import cn.daxpay.single.result.allocation.AllocOrderResult;
|
||||
import cn.daxpay.single.result.order.AllocOrderDetailResult;
|
||||
import cn.daxpay.single.result.order.AllocOrderResult;
|
||||
import cn.daxpay.single.result.allocation.AllocationResult;
|
||||
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||
import cn.daxpay.single.service.core.order.allocation.convert.AllocationConvert;
|
||||
@@ -77,6 +77,7 @@ public class AllocationService {
|
||||
// 判断是否已经有分账订单
|
||||
AllocationOrder allocationOrder = allocationOrderManager.findByBizAllocationNo(param.getBizAllocationNo())
|
||||
.orElse(null);
|
||||
allocationAssistService.initNotice(param);
|
||||
if (Objects.nonNull(allocationOrder)){
|
||||
// 重复分账
|
||||
return this.retryAllocation(param, allocationOrder);
|
||||
|
@@ -6,7 +6,7 @@ import cn.daxpay.single.code.AllocDetailResultEnum;
|
||||
import cn.daxpay.single.code.AllocOrderResultEnum;
|
||||
import cn.daxpay.single.code.AllocOrderStatusEnum;
|
||||
import cn.daxpay.single.param.payment.allocation.AllocSyncParam;
|
||||
import cn.daxpay.single.result.allocation.AllocationSyncResult;
|
||||
import cn.daxpay.single.result.sync.AllocSyncResult;
|
||||
import cn.daxpay.single.service.code.PaymentTypeEnum;
|
||||
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderDetailManager;
|
||||
@@ -15,7 +15,7 @@ import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
|
||||
import cn.daxpay.single.service.core.payment.allocation.factory.AllocationFactory;
|
||||
import cn.daxpay.single.service.core.payment.notice.service.ClientNoticeService;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocRemoteSyncResult;
|
||||
import cn.daxpay.single.service.core.record.sync.entity.PaySyncRecord;
|
||||
import cn.daxpay.single.service.core.record.sync.service.PaySyncRecordService;
|
||||
import cn.daxpay.single.service.func.AbsAllocationStrategy;
|
||||
@@ -55,7 +55,7 @@ public class AllocationSyncService {
|
||||
* 分账同步, 开启一个新的事务, 不受外部抛出异常的影响
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public AllocationSyncResult sync(AllocSyncParam param) {
|
||||
public AllocSyncResult sync(AllocSyncParam param) {
|
||||
// 获取分账订单
|
||||
AllocationOrder allocationOrder = null;
|
||||
if (Objects.nonNull(param.getAllocationNo())){
|
||||
@@ -67,7 +67,7 @@ public class AllocationSyncService {
|
||||
.orElseThrow(() -> new DataNotExistException("分账单不存在"));
|
||||
}
|
||||
this.sync(allocationOrder);
|
||||
return new AllocationSyncResult();
|
||||
return new AllocSyncResult();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,9 +85,9 @@ public class AllocationSyncService {
|
||||
allocationStrategy.initParam(allocationOrder, detailList);
|
||||
// 分账完结预处理
|
||||
allocationStrategy.doBeforeHandler();
|
||||
AllocSyncResult allocSyncResult = allocationStrategy.doSync();
|
||||
AllocRemoteSyncResult allocRemoteSyncResult = allocationStrategy.doSync();
|
||||
// 保存分账同步记录
|
||||
this.saveRecord(allocationOrder, allocSyncResult,null,null);
|
||||
this.saveRecord(allocationOrder, allocRemoteSyncResult,null,null);
|
||||
// 根据订单明细更新订单的状态和处理结果
|
||||
this.updateOrderStatus(allocationOrder, detailList);
|
||||
} finally {
|
||||
@@ -150,7 +150,7 @@ public class AllocationSyncService {
|
||||
/**
|
||||
* 保存同步记录
|
||||
*/
|
||||
private void saveRecord(AllocationOrder order, AllocSyncResult syncResult, String errorCode, String errorMsg){
|
||||
private void saveRecord(AllocationOrder order, AllocRemoteSyncResult syncResult, String errorCode, String errorMsg){
|
||||
PaySyncRecord paySyncRecord = new PaySyncRecord()
|
||||
.setBizTradeNo(order.getBizAllocationNo())
|
||||
.setTradeNo(order.getAllocationNo())
|
||||
|
@@ -5,7 +5,7 @@ import cn.daxpay.single.exception.pay.PayFailureException;
|
||||
import cn.daxpay.single.service.core.channel.alipay.entity.AliPayConfig;
|
||||
import cn.daxpay.single.service.core.channel.alipay.service.AliPayAllocationService;
|
||||
import cn.daxpay.single.service.core.channel.alipay.service.AliPayConfigService;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocRemoteSyncResult;
|
||||
import cn.daxpay.single.service.func.AbsAllocationStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -75,7 +75,7 @@ public class AliPayAllocationStrategy extends AbsAllocationStrategy {
|
||||
* 同步状态
|
||||
*/
|
||||
@Override
|
||||
public AllocSyncResult doSync() {
|
||||
public AllocRemoteSyncResult doSync() {
|
||||
return aliPayAllocationService.sync(this.getAllocationOrder(), this.getAllocationOrderDetails());
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import cn.daxpay.single.exception.pay.PayFailureException;
|
||||
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.daxpay.single.service.core.channel.wechat.service.WeChatPayAllocationService;
|
||||
import cn.daxpay.single.service.core.channel.wechat.service.WeChatPayConfigService;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocRemoteSyncResult;
|
||||
import cn.daxpay.single.service.func.AbsAllocationStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -73,7 +73,7 @@ public class WeChatPayAllocationStrategy extends AbsAllocationStrategy {
|
||||
* 同步状态
|
||||
*/
|
||||
@Override
|
||||
public AllocSyncResult doSync() {
|
||||
public AllocRemoteSyncResult doSync() {
|
||||
return weChatPayAllocationService.sync(this.getAllocationOrder(),this.getAllocationOrderDetails(),weChatPayConfig);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package cn.daxpay.single.service.core.payment.notice.service;
|
||||
|
||||
import cn.bootx.platform.common.jackson.util.JacksonUtil;
|
||||
import cn.daxpay.single.result.allocation.AllocOrderDetailResult;
|
||||
import cn.daxpay.single.result.allocation.AllocOrderResult;
|
||||
import cn.daxpay.single.result.order.AllocOrderDetailResult;
|
||||
import cn.daxpay.single.result.order.AllocOrderResult;
|
||||
import cn.daxpay.single.service.code.ClientNoticeTypeEnum;
|
||||
import cn.daxpay.single.service.core.notice.entity.ClientNoticeTask;
|
||||
import cn.daxpay.single.service.core.order.allocation.convert.AllocationConvert;
|
||||
|
@@ -10,7 +10,7 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AllocSyncResult {
|
||||
public class AllocRemoteSyncResult {
|
||||
/** 同步时网关返回的对象, 序列化为json字符串 */
|
||||
private String syncInfo;
|
||||
}
|
@@ -16,7 +16,7 @@ import static cn.daxpay.single.code.PaySyncStatusEnum.FAIL;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PaySyncResult {
|
||||
public class PayRemoteSyncResult {
|
||||
|
||||
/**
|
||||
* 支付网关订单状态
|
@@ -15,7 +15,7 @@ import static cn.daxpay.single.code.RefundSyncStatusEnum.PROGRESS;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RefundSyncResult {
|
||||
public class RefundRemoteSyncResult {
|
||||
|
||||
/**
|
||||
* 支付网关订单状态, 默认为退款中
|
@@ -7,7 +7,7 @@ import cn.daxpay.single.code.PayStatusEnum;
|
||||
import cn.daxpay.single.code.PaySyncStatusEnum;
|
||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||
import cn.daxpay.single.param.payment.pay.PaySyncParam;
|
||||
import cn.daxpay.single.result.pay.SyncResult;
|
||||
import cn.daxpay.single.result.sync.PaySyncResult;
|
||||
import cn.daxpay.single.service.code.PayRepairSourceEnum;
|
||||
import cn.daxpay.single.service.code.PayRepairWayEnum;
|
||||
import cn.daxpay.single.service.code.PaymentTypeEnum;
|
||||
@@ -19,7 +19,7 @@ import cn.daxpay.single.service.core.order.pay.service.PayOrderService;
|
||||
import cn.daxpay.single.service.core.payment.repair.result.PayRepairResult;
|
||||
import cn.daxpay.single.service.core.payment.repair.service.PayRepairService;
|
||||
import cn.daxpay.single.service.core.payment.sync.factory.PaySyncStrategyFactory;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PaySyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult;
|
||||
import cn.daxpay.single.service.core.record.sync.entity.PaySyncRecord;
|
||||
import cn.daxpay.single.service.core.record.sync.service.PaySyncRecordService;
|
||||
import cn.daxpay.single.service.func.AbsPaySyncStrategy;
|
||||
@@ -62,7 +62,7 @@ public class PaySyncService {
|
||||
* 支付同步, 开启一个新的事务, 不受外部抛出异常的影响
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public SyncResult sync(PaySyncParam param) {
|
||||
public PaySyncResult sync(PaySyncParam param) {
|
||||
PayOrder payOrder = payOrderQueryService.findByBizOrOrderNo(param.getOrderNo(), param.getBizOrderNo())
|
||||
.orElseThrow(() -> new PayFailureException("支付订单不存在"));
|
||||
// 钱包支付钱包不需要
|
||||
@@ -79,7 +79,7 @@ public class PaySyncService {
|
||||
* 3. 会更新关联网关订单号
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public SyncResult syncPayOrder(PayOrder payOrder) {
|
||||
public PaySyncResult syncPayOrder(PayOrder payOrder) {
|
||||
// 加锁
|
||||
LockInfo lock = lockTemplate.lock("sync:pay" + payOrder.getId(),10000,200);
|
||||
if (Objects.isNull(lock)){
|
||||
@@ -91,20 +91,20 @@ public class PaySyncService {
|
||||
AbsPaySyncStrategy syncPayStrategy = PaySyncStrategyFactory.create(payOrder.getChannel());
|
||||
syncPayStrategy.initPayParam(payOrder);
|
||||
// 执行操作, 获取支付网关同步的结果
|
||||
PaySyncResult paySyncResult = syncPayStrategy.doSyncStatus();
|
||||
PayRemoteSyncResult payRemoteSyncResult = syncPayStrategy.doSyncStatus();
|
||||
// 判断是否同步成功
|
||||
if (Objects.equals(paySyncResult.getSyncStatus(), PaySyncStatusEnum.FAIL)){
|
||||
if (Objects.equals(payRemoteSyncResult.getSyncStatus(), PaySyncStatusEnum.FAIL)){
|
||||
// 同步失败, 返回失败响应, 同时记录失败的日志
|
||||
this.saveRecord(payOrder, paySyncResult, false, null, paySyncResult.getErrorMsg());
|
||||
throw new PayFailureException(paySyncResult.getErrorMsg());
|
||||
this.saveRecord(payOrder, payRemoteSyncResult, false, null, payRemoteSyncResult.getErrorMsg());
|
||||
throw new PayFailureException(payRemoteSyncResult.getErrorMsg());
|
||||
}
|
||||
// 支付订单的网关订单号是否一致, 不一致进行更新
|
||||
if (!Objects.equals(paySyncResult.getOutOrderNo(), payOrder.getOutOrderNo())){
|
||||
payOrder.setOutOrderNo(paySyncResult.getOutOrderNo());
|
||||
if (!Objects.equals(payRemoteSyncResult.getOutOrderNo(), payOrder.getOutOrderNo())){
|
||||
payOrder.setOutOrderNo(payRemoteSyncResult.getOutOrderNo());
|
||||
payOrderService.updateById(payOrder);
|
||||
}
|
||||
// 判断网关状态是否和支付单一致, 同时特定情况下更新网关同步状态
|
||||
boolean statusSync = this.checkAndAdjustSyncStatus(paySyncResult,payOrder);
|
||||
boolean statusSync = this.checkAndAdjustSyncStatus(payRemoteSyncResult,payOrder);
|
||||
PayRepairResult repairResult = new PayRepairResult();
|
||||
try {
|
||||
// 状态不一致,执行支付单修复逻辑
|
||||
@@ -115,19 +115,19 @@ public class PaySyncService {
|
||||
repairInfo.setSource(PayRepairSourceEnum.SYNC);
|
||||
}
|
||||
// 设置支付单完成时间
|
||||
repairInfo.setFinishTime(paySyncResult.getPayTime());
|
||||
repairResult = this.repairHandler(paySyncResult, payOrder);
|
||||
repairInfo.setFinishTime(payRemoteSyncResult.getPayTime());
|
||||
repairResult = this.repairHandler(payRemoteSyncResult, payOrder);
|
||||
}
|
||||
} catch (PayFailureException e) {
|
||||
// 同步失败, 返回失败响应, 同时记录失败的日志
|
||||
paySyncResult.setSyncStatus(PaySyncStatusEnum.FAIL);
|
||||
this.saveRecord(payOrder, paySyncResult, false, null, e.getMessage());
|
||||
payRemoteSyncResult.setSyncStatus(PaySyncStatusEnum.FAIL);
|
||||
this.saveRecord(payOrder, payRemoteSyncResult, false, null, e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
|
||||
// 同步成功记录日志
|
||||
this.saveRecord( payOrder, paySyncResult, !statusSync, repairResult.getRepairNo(), null);
|
||||
return new SyncResult().setStatus(paySyncResult.getSyncStatus().getCode());
|
||||
this.saveRecord( payOrder, payRemoteSyncResult, !statusSync, repairResult.getRepairNo(), null);
|
||||
return new PaySyncResult().setStatus(payRemoteSyncResult.getSyncStatus().getCode());
|
||||
} finally {
|
||||
lockTemplate.releaseLock(lock);
|
||||
}
|
||||
@@ -136,8 +136,8 @@ public class PaySyncService {
|
||||
/**
|
||||
* 判断支付单和网关状态是否一致, 同时待支付状态下, 支付单支付超时进行状态的更改
|
||||
*/
|
||||
private boolean checkAndAdjustSyncStatus(PaySyncResult syncResult, PayOrder order){
|
||||
PaySyncStatusEnum syncStatus = syncResult.getSyncStatus();
|
||||
private boolean checkAndAdjustSyncStatus(PayRemoteSyncResult payRemoteSyncResult, PayOrder order){
|
||||
PaySyncStatusEnum syncStatus = payRemoteSyncResult.getSyncStatus();
|
||||
String orderStatus = order.getStatus();
|
||||
// 本地支付成功/网关支付成功
|
||||
if (orderStatus.equals(PayStatusEnum.SUCCESS.getCode()) && syncStatus.equals(SUCCESS)){
|
||||
@@ -153,7 +153,7 @@ public class PaySyncService {
|
||||
// 判断支付单是否支付超时, 如果待支付状态下触发超时
|
||||
if (LocalDateTimeUtil.le(order.getExpiredTime(), LocalDateTime.now())){
|
||||
// 将支付单同步状态状态调整为支付超时, 进行订单的关闭
|
||||
syncResult.setSyncStatus(PaySyncStatusEnum.TIMEOUT);
|
||||
payRemoteSyncResult.setSyncStatus(PaySyncStatusEnum.TIMEOUT);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -183,8 +183,8 @@ public class PaySyncService {
|
||||
/**
|
||||
* 根据同步的结果对支付单进行修复处理
|
||||
*/
|
||||
private PayRepairResult repairHandler(PaySyncResult syncResult, PayOrder payOrder){
|
||||
PaySyncStatusEnum syncStatusEnum = syncResult.getSyncStatus();
|
||||
private PayRepairResult repairHandler(PayRemoteSyncResult payRemoteSyncResult, PayOrder payOrder){
|
||||
PaySyncStatusEnum syncStatusEnum = payRemoteSyncResult.getSyncStatus();
|
||||
PayRepairResult repair = new PayRepairResult();
|
||||
// 对支付网关同步的结果进行处理
|
||||
switch (syncStatusEnum) {
|
||||
@@ -229,20 +229,20 @@ public class PaySyncService {
|
||||
/**
|
||||
* 保存同步记录
|
||||
* @param payOrder 支付单
|
||||
* @param syncResult 同步结果
|
||||
* @param payRemoteSyncResult 同步结果
|
||||
* @param repair 是否修复
|
||||
* @param repairOrderNo 修复号
|
||||
* @param errorMsg 错误信息
|
||||
*/
|
||||
private void saveRecord(PayOrder payOrder, PaySyncResult syncResult, boolean repair, String repairOrderNo, String errorMsg){
|
||||
private void saveRecord(PayOrder payOrder, PayRemoteSyncResult payRemoteSyncResult, boolean repair, String repairOrderNo, String errorMsg){
|
||||
PaySyncRecord paySyncRecord = new PaySyncRecord()
|
||||
.setBizTradeNo(payOrder.getBizOrderNo())
|
||||
.setTradeNo(payOrder.getOrderNo())
|
||||
.setOutTradeNo(payOrder.getOutOrderNo())
|
||||
.setOutTradeStatus(syncResult.getSyncStatus().getCode())
|
||||
.setOutTradeStatus(payRemoteSyncResult.getSyncStatus().getCode())
|
||||
.setSyncType(PaymentTypeEnum.PAY.getCode())
|
||||
.setChannel(payOrder.getChannel())
|
||||
.setSyncInfo(syncResult.getSyncInfo())
|
||||
.setSyncInfo(payRemoteSyncResult.getSyncInfo())
|
||||
.setRepair(repair)
|
||||
.setRepairNo(repairOrderNo)
|
||||
.setErrorMsg(errorMsg)
|
||||
|
@@ -6,7 +6,7 @@ import cn.daxpay.single.code.RefundStatusEnum;
|
||||
import cn.daxpay.single.code.RefundSyncStatusEnum;
|
||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||
import cn.daxpay.single.param.payment.refund.RefundSyncParam;
|
||||
import cn.daxpay.single.result.pay.SyncResult;
|
||||
import cn.daxpay.single.result.sync.RefundSyncResult;
|
||||
import cn.daxpay.single.service.code.PayRepairSourceEnum;
|
||||
import cn.daxpay.single.service.code.PaymentTypeEnum;
|
||||
import cn.daxpay.single.service.code.RefundRepairWayEnum;
|
||||
@@ -18,7 +18,7 @@ import cn.daxpay.single.service.core.order.refund.service.RefundOrderQueryServic
|
||||
import cn.daxpay.single.service.core.payment.repair.result.RefundRepairResult;
|
||||
import cn.daxpay.single.service.core.payment.repair.service.RefundRepairService;
|
||||
import cn.daxpay.single.service.core.payment.sync.factory.RefundSyncStrategyFactory;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundRemoteSyncResult;
|
||||
import cn.daxpay.single.service.core.record.sync.entity.PaySyncRecord;
|
||||
import cn.daxpay.single.service.core.record.sync.service.PaySyncRecordService;
|
||||
import cn.daxpay.single.service.func.AbsRefundSyncStrategy;
|
||||
@@ -55,13 +55,13 @@ public class RefundSyncService {
|
||||
* 退款同步, 开启一个新的事务, 不受外部抛出异常的影响
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public SyncResult sync(RefundSyncParam param){
|
||||
public RefundSyncResult sync(RefundSyncParam param){
|
||||
// 先获取退款单
|
||||
RefundOrder refundOrder = refundOrderQueryService.findByBizOrRefundNo(param.getRefundNo(), param.getBizRefundNo())
|
||||
.orElseThrow(() -> new PayFailureException("未查询到退款订单"));
|
||||
// 如果订单已经关闭, 直接返回退款关闭
|
||||
if (Objects.equals(refundOrder.getStatus(), RefundStatusEnum.CLOSE.getCode())){
|
||||
return new SyncResult().setStatus(RefundStatusEnum.CLOSE.getCode());
|
||||
return new RefundSyncResult().setStatus(RefundStatusEnum.CLOSE.getCode());
|
||||
}
|
||||
return this.syncRefundOrder(refundOrder);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class RefundSyncService {
|
||||
* 退款订单信息同步
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public SyncResult syncRefundOrder(RefundOrder refundOrder) {
|
||||
public RefundSyncResult syncRefundOrder(RefundOrder refundOrder) {
|
||||
// 加锁
|
||||
LockInfo lock = lockTemplate.lock("sync:refund:" + refundOrder.getId(),10000,200);
|
||||
if (Objects.isNull(lock)) {
|
||||
@@ -83,21 +83,21 @@ public class RefundSyncService {
|
||||
// 同步前处理, 主要预防请求过于迅速
|
||||
syncPayStrategy.doBeforeHandler();
|
||||
// 执行操作, 获取支付网关同步的结果
|
||||
RefundSyncResult refundSyncResult = syncPayStrategy.doSyncStatus();
|
||||
RefundRemoteSyncResult refundRemoteSyncResult = syncPayStrategy.doSyncStatus();
|
||||
|
||||
// 判断是否同步成功
|
||||
if (Objects.equals(refundSyncResult.getSyncStatus(), RefundSyncStatusEnum.FAIL)) {
|
||||
if (Objects.equals(refundRemoteSyncResult.getSyncStatus(), RefundSyncStatusEnum.FAIL)) {
|
||||
// 同步失败, 返回失败响应, 同时记录失败的日志
|
||||
this.saveRecord(refundOrder, refundSyncResult, false, null, refundSyncResult.getErrorMsg());
|
||||
throw new PayFailureException(refundSyncResult.getErrorMsg());
|
||||
this.saveRecord(refundOrder, refundRemoteSyncResult, false, null, refundRemoteSyncResult.getErrorMsg());
|
||||
throw new PayFailureException(refundRemoteSyncResult.getErrorMsg());
|
||||
}
|
||||
// 订单的通道交易号是否一致, 不一致进行更新
|
||||
if (Objects.nonNull(refundSyncResult.getOutRefundNo()) && !Objects.equals(refundSyncResult.getOutRefundNo(), refundOrder.getOutRefundNo())){
|
||||
refundOrder.setOutRefundNo(refundSyncResult.getOutRefundNo());
|
||||
if (Objects.nonNull(refundRemoteSyncResult.getOutRefundNo()) && !Objects.equals(refundRemoteSyncResult.getOutRefundNo(), refundOrder.getOutRefundNo())){
|
||||
refundOrder.setOutRefundNo(refundRemoteSyncResult.getOutRefundNo());
|
||||
refundOrderManager.updateById(refundOrder);
|
||||
}
|
||||
// 判断网关状态是否和支付单一致
|
||||
boolean statusSync = this.checkSyncStatus(refundSyncResult, refundOrder);
|
||||
boolean statusSync = this.checkSyncStatus(refundRemoteSyncResult, refundOrder);
|
||||
RefundRepairResult repairResult = new RefundRepairResult();
|
||||
try {
|
||||
// 状态不一致,执行退款单修复逻辑
|
||||
@@ -107,18 +107,18 @@ public class RefundSyncService {
|
||||
if (Objects.isNull(repairInfo.getSource())){
|
||||
repairInfo.setSource(PayRepairSourceEnum.SYNC);
|
||||
}
|
||||
repairInfo.setFinishTime(refundSyncResult.getFinishTime());
|
||||
repairResult = this.repairHandler(refundSyncResult, refundOrder);
|
||||
repairInfo.setFinishTime(refundRemoteSyncResult.getFinishTime());
|
||||
repairResult = this.repairHandler(refundRemoteSyncResult, refundOrder);
|
||||
}
|
||||
} catch (PayFailureException e) {
|
||||
// 同步失败, 返回失败响应, 同时记录失败的日志
|
||||
refundSyncResult.setSyncStatus(RefundSyncStatusEnum.FAIL);
|
||||
this.saveRecord(refundOrder, refundSyncResult, false, null, e.getMessage());
|
||||
refundRemoteSyncResult.setSyncStatus(RefundSyncStatusEnum.FAIL);
|
||||
this.saveRecord(refundOrder, refundRemoteSyncResult, false, null, e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
// 同步成功记录日志
|
||||
this.saveRecord(refundOrder, refundSyncResult, !statusSync, repairResult.getRepairNo(), null);
|
||||
return new SyncResult().setStatus(refundSyncResult.getSyncStatus().getCode());
|
||||
this.saveRecord(refundOrder, refundRemoteSyncResult, !statusSync, repairResult.getRepairNo(), null);
|
||||
return new RefundSyncResult().setStatus(refundRemoteSyncResult.getSyncStatus().getCode());
|
||||
} finally {
|
||||
lockTemplate.releaseLock(lock);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class RefundSyncService {
|
||||
* @see RefundSyncStatusEnum 同步返回类型
|
||||
* @see RefundStatusEnum 退款单状态
|
||||
*/
|
||||
private boolean checkSyncStatus(RefundSyncResult syncResult, RefundOrder order){
|
||||
private boolean checkSyncStatus(RefundRemoteSyncResult syncResult, RefundOrder order){
|
||||
RefundSyncStatusEnum syncStatus = syncResult.getSyncStatus();
|
||||
String orderStatus = order.getStatus();
|
||||
// 退款完成
|
||||
@@ -155,7 +155,7 @@ public class RefundSyncService {
|
||||
/**
|
||||
* 进行退款订单和支付订单的补偿
|
||||
*/
|
||||
private RefundRepairResult repairHandler(RefundSyncResult syncResult, RefundOrder order){
|
||||
private RefundRepairResult repairHandler(RefundRemoteSyncResult syncResult, RefundOrder order){
|
||||
RefundSyncStatusEnum syncStatusEnum = syncResult.getSyncStatus();
|
||||
RefundRepairResult repair = new RefundRepairResult();
|
||||
// 对支付网关同步的结果进行处理
|
||||
@@ -188,7 +188,7 @@ public class RefundSyncService {
|
||||
* @param repairOrderNo 修复号
|
||||
* @param errorMsg 错误信息
|
||||
*/
|
||||
private void saveRecord(RefundOrder refundOrder, RefundSyncResult syncResult, boolean repair, String repairOrderNo, String errorMsg){
|
||||
private void saveRecord(RefundOrder refundOrder, RefundRemoteSyncResult syncResult, boolean repair, String repairOrderNo, String errorMsg){
|
||||
PaySyncRecord paySyncRecord = new PaySyncRecord()
|
||||
.setTradeNo(refundOrder.getRefundNo())
|
||||
.setBizTradeNo(refundOrder.getBizRefundNo())
|
||||
|
@@ -5,7 +5,7 @@ import cn.daxpay.single.code.PaySyncStatusEnum;
|
||||
import cn.daxpay.single.service.core.channel.alipay.entity.AliPayConfig;
|
||||
import cn.daxpay.single.service.core.channel.alipay.service.AliPayConfigService;
|
||||
import cn.daxpay.single.service.core.channel.alipay.service.AliPaySyncService;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundRemoteSyncResult;
|
||||
import cn.daxpay.single.service.func.AbsRefundSyncStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -41,7 +41,7 @@ public class AliRefundSyncStrategy extends AbsRefundSyncStrategy {
|
||||
* @see PaySyncStatusEnum
|
||||
*/
|
||||
@Override
|
||||
public RefundSyncResult doSyncStatus() {
|
||||
public RefundRemoteSyncResult doSyncStatus() {
|
||||
AliPayConfig config = alipayConfigService.getConfig();
|
||||
alipayConfigService.initConfig(config);
|
||||
return aliPaySyncService.syncRefundStatus(this.getRefundOrder());
|
||||
|
@@ -5,7 +5,7 @@ import cn.daxpay.single.code.PaySyncStatusEnum;
|
||||
import cn.daxpay.single.service.core.channel.union.entity.UnionPayConfig;
|
||||
import cn.daxpay.single.service.core.channel.union.service.UnionPayConfigService;
|
||||
import cn.daxpay.single.service.core.channel.union.service.UnionPaySyncService;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundRemoteSyncResult;
|
||||
import cn.daxpay.single.service.func.AbsRefundSyncStrategy;
|
||||
import cn.daxpay.single.service.sdk.union.api.UnionPayKit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -33,7 +33,7 @@ public class UnionRefundSyncStrategy extends AbsRefundSyncStrategy {
|
||||
* @see PaySyncStatusEnum
|
||||
*/
|
||||
@Override
|
||||
public RefundSyncResult doSyncStatus() {
|
||||
public RefundRemoteSyncResult doSyncStatus() {
|
||||
UnionPayConfig config = unionPayConfigService.getConfig();
|
||||
UnionPayKit unionPayKit = unionPayConfigService.initPayService(config);
|
||||
return unionPaySyncService.syncRefundStatus(this.getRefundOrder(),unionPayKit);
|
||||
|
@@ -4,7 +4,7 @@ import cn.daxpay.single.code.PayChannelEnum;
|
||||
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.daxpay.single.service.core.channel.wechat.service.WeChatPayConfigService;
|
||||
import cn.daxpay.single.service.core.channel.wechat.service.WeChatPaySyncService;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundRemoteSyncResult;
|
||||
import cn.daxpay.single.service.func.AbsRefundSyncStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -36,7 +36,7 @@ public class WeChatRefundSyncStrategy extends AbsRefundSyncStrategy {
|
||||
* 异步支付单与支付网关进行状态比对后的结果
|
||||
*/
|
||||
@Override
|
||||
public RefundSyncResult doSyncStatus() {
|
||||
public RefundRemoteSyncResult doSyncStatus() {
|
||||
WeChatPayConfig config = weChatPayConfigService.getConfig();
|
||||
return weChatPaySyncService.syncRefundStatus(this.getRefundOrder(), config);
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import cn.daxpay.single.service.core.channel.alipay.entity.AliPayConfig;
|
||||
import cn.daxpay.single.service.core.channel.alipay.service.AliPayConfigService;
|
||||
import cn.daxpay.single.service.core.channel.alipay.service.AliPaySyncService;
|
||||
import cn.daxpay.single.service.func.AbsPaySyncStrategy;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PaySyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -39,7 +39,7 @@ public class AliPaySyncStrategy extends AbsPaySyncStrategy {
|
||||
* 异步支付单与支付网关进行状态比对
|
||||
*/
|
||||
@Override
|
||||
public PaySyncResult doSyncStatus() {
|
||||
public PayRemoteSyncResult doSyncStatus() {
|
||||
this.initAlipayConfig();
|
||||
return alipaySyncService.syncPayStatus(this.getOrder());
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import cn.daxpay.single.code.PaySyncStatusEnum;
|
||||
import cn.daxpay.single.service.core.channel.union.entity.UnionPayConfig;
|
||||
import cn.daxpay.single.service.core.channel.union.service.UnionPayConfigService;
|
||||
import cn.daxpay.single.service.core.channel.union.service.UnionPaySyncService;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PaySyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult;
|
||||
import cn.daxpay.single.service.func.AbsPaySyncStrategy;
|
||||
import cn.daxpay.single.service.sdk.union.api.UnionPayKit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -34,7 +34,7 @@ public class UnionPaySyncStrategy extends AbsPaySyncStrategy {
|
||||
* @see PaySyncStatusEnum
|
||||
*/
|
||||
@Override
|
||||
public PaySyncResult doSyncStatus() {
|
||||
public PayRemoteSyncResult doSyncStatus() {
|
||||
UnionPayConfig config = unionPayConfigService.getConfig();
|
||||
UnionPayKit unionPayKit = unionPayConfigService.initPayService(config);
|
||||
return unionPaySyncService.syncPayStatus(this.getOrder(),unionPayKit);
|
||||
|
@@ -4,7 +4,7 @@ import cn.daxpay.single.code.PayChannelEnum;
|
||||
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.daxpay.single.service.core.channel.wechat.service.WeChatPayConfigService;
|
||||
import cn.daxpay.single.service.core.channel.wechat.service.WeChatPaySyncService;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PaySyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult;
|
||||
import cn.daxpay.single.service.func.AbsPaySyncStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -40,7 +40,7 @@ public class WeChatPaySyncStrategy extends AbsPaySyncStrategy {
|
||||
* 异步支付单与支付网关进行状态比对
|
||||
*/
|
||||
@Override
|
||||
public PaySyncResult doSyncStatus() {
|
||||
public PayRemoteSyncResult doSyncStatus() {
|
||||
// 检查并获取微信支付配置
|
||||
this.initWeChatPayConfig();
|
||||
return weChatPaySyncService.syncPayStatus(this.getOrder(), this.weChatPayConfig);
|
||||
|
@@ -18,6 +18,9 @@ import lombok.experimental.Accessors;
|
||||
@Schema(title = "分账组")
|
||||
public class AllocationGroupDto extends BaseDto {
|
||||
|
||||
@Schema(description = "分账组编号")
|
||||
private String groupNo;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
|
@@ -27,6 +27,9 @@ public class AllocationReceiverDto extends BaseDto {
|
||||
@Schema(description = "账号别名")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "接收方编号")
|
||||
private String receiverNo;
|
||||
|
||||
/**
|
||||
* @see PayChannelEnum
|
||||
*/
|
||||
|
@@ -0,0 +1,17 @@
|
||||
package cn.daxpay.single.service.dto.order.allocation;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.dto.BaseDto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 分账订单扩展
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "")
|
||||
public class AllocationOrderExtraDto extends BaseDto {
|
||||
}
|
@@ -2,7 +2,7 @@ package cn.daxpay.single.service.func;
|
||||
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
|
||||
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.AllocRemoteSyncResult;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -49,5 +49,5 @@ public abstract class AbsAllocationStrategy implements PayStrategy{
|
||||
/**
|
||||
* 同步状态
|
||||
*/
|
||||
public abstract AllocSyncResult doSync();
|
||||
public abstract AllocRemoteSyncResult doSync();
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package cn.daxpay.single.service.func;
|
||||
|
||||
import cn.daxpay.single.code.PaySyncStatusEnum;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PaySyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -30,6 +30,6 @@ public abstract class AbsPaySyncStrategy implements PayStrategy{
|
||||
* 异步支付单与支付网关进行状态比对后的结果
|
||||
* @see PaySyncStatusEnum
|
||||
*/
|
||||
public abstract PaySyncResult doSyncStatus();
|
||||
public abstract PayRemoteSyncResult doSyncStatus();
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package cn.daxpay.single.service.func;
|
||||
|
||||
import cn.daxpay.single.code.PaySyncStatusEnum;
|
||||
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundSyncResult;
|
||||
import cn.daxpay.single.service.core.payment.sync.result.RefundRemoteSyncResult;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -25,5 +25,5 @@ public abstract class AbsRefundSyncStrategy implements PayStrategy{
|
||||
* 异步支付单与支付网关进行状态比对后的结果
|
||||
* @see PaySyncStatusEnum
|
||||
*/
|
||||
public abstract RefundSyncResult doSyncStatus();
|
||||
public abstract RefundRemoteSyncResult doSyncStatus();
|
||||
}
|
||||
|
@@ -17,6 +17,9 @@ public class AllocationGroupParam {
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "分账组编号")
|
||||
private String groupNo;
|
||||
|
||||
@Schema(description = "分组名称")
|
||||
private String name;
|
||||
|
||||
|
@@ -20,6 +20,10 @@ public class AllocationReceiverQuery {
|
||||
@Schema(description = "账号别名")
|
||||
private String name;
|
||||
|
||||
@QueryParam(type = QueryParam.CompareTypeEnum.LIKE)
|
||||
@Schema(description = "接收方编号")
|
||||
private String receiverNo;
|
||||
|
||||
/**
|
||||
* @see PayChannelEnum
|
||||
*/
|
||||
@@ -47,7 +51,4 @@ public class AllocationReceiverQuery {
|
||||
*/
|
||||
@Schema(description = "分账关系类型")
|
||||
private String relationType;
|
||||
|
||||
@Schema(description = "是否已经同步到网关")
|
||||
private Boolean sync;
|
||||
}
|
||||
|
Reference in New Issue
Block a user