feat 修复回调消息签名不一致问题, SDK支持分账操作, 调整前端查询接口

This commit is contained in:
DaxPay
2024-05-30 20:59:27 +08:00
parent 1b3277533a
commit fa54a853a5
37 changed files with 684 additions and 192 deletions

View File

@@ -15,8 +15,9 @@
- [x] 分账完结
- [x] 分账同步
- [x] 保存分账同步记录
- [ ] SDK支持分账相关接口
- [x] SDK支持分账相关接口
- [ ] 分账回调处理
- [ ] 分账重试支持完结失败
- [x] 分账通知发送功能
- [x] 分账支持手动和自动分账两种
- [x] 金额过小不进行分账, 增加新状态, 金额小于0.01元直接忽略
@@ -25,6 +26,7 @@
- [x] 订单超时任务注册任务错误id改为订单号
- [x] 系统中金额分转元精度异常问题
- [x] 同步回调处理参数订单号接收失败
- [x] 支付和退款消息签名值不一致问题
2.0.7: 对账完善和系统优化
- [ ] DEMO增加获取微信OpenID和支付宝OpenId功能

View File

@@ -86,7 +86,10 @@ public class PermMenu extends MpBaseEntity implements EntityBaseFunction<PermMen
/** 隐藏的标题内容 */
private boolean hiddenHeaderContent;
/** 系统菜单 */
/**
*
* TODO 替换为非关键词, 来兼容更多类型数据库
*/
@TableField("`admin`")
private boolean admin;

View File

@@ -2,6 +2,7 @@ package cn.daxpay.single.demo.controller;
import cn.bootx.platform.common.core.annotation.IgnoreAuth;
import cn.daxpay.single.demo.configuration.DaxPayDemoProperties;
import cn.daxpay.single.sdk.model.notice.AllocNoticeModel;
import cn.daxpay.single.sdk.model.notice.PayNoticeModel;
import cn.daxpay.single.sdk.model.notice.RefundNoticeModel;
import cn.daxpay.single.sdk.util.PaySignUtil;
@@ -46,7 +47,7 @@ public class ClientNoticeReceiveController {
@PostMapping("/payObject")
public String pay(@RequestBody PayNoticeModel model){
log.info("接收到支付回调消息: {}",model);
log.info("验签结果: {}", PaySignUtil.hmacSha256Sign(model, daxPayDemoProperties.getSignSecret()));
log.info("验签结果: {}", PaySignUtil.verifyHmacSha256Sign(model, daxPayDemoProperties.getSignSecret(),model.getSign()));
return "SUCCESS";
}
@@ -64,8 +65,26 @@ public class ClientNoticeReceiveController {
@PostMapping("/refundObject")
public String refund(@RequestBody RefundNoticeModel model) {
log.info("接收到退款回调消息: {}",model);
log.info("验签结果: {}", PaySignUtil.verifyHmacSha256Sign(model, daxPayDemoProperties.getSignSecret(),model.getSign()));
return "SUCCESS";
}
@Operation(summary = "分账消息")
@PostMapping("/allocation")
public String allocation(@RequestBody Map<String,Object> map) {
log.info("接收到退款分账消息: {}",map);
// 转换为对象
AllocNoticeModel model = BeanUtil.toBean(map, AllocNoticeModel.class);
log.info("验签结果: {}", PaySignUtil.hmacSha256Sign(model, daxPayDemoProperties.getSignSecret()));
return "SUCCESS";
}
@Operation(summary = "分账消息(对象)")
@PostMapping("/allocationObject")
public String allocation(@RequestBody AllocNoticeModel model) {
log.info("接收到分账回调消息: {}",model);
log.info("验签结果: {}", PaySignUtil.verifyHmacSha256Sign(model, daxPayDemoProperties.getSignSecret(),model.getSign()));
return "SUCCESS";
}
}

View File

@@ -0,0 +1,24 @@
package cn.daxpay.single.sdk.code;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 分账明细处理结果
* @author xxm
* @since 2024/4/16
*/
@Getter
@AllArgsConstructor
public enum AllocDetailResultEnum {
PENDING("pending", "待分账"),
SUCCESS("success", "分账成功"),
FAIL("fail", "分账失败"),
/** 金额为0时不进行分账 */
IGNORE("ignore", "忽略分账"),
;
private final String code;
private final String name;
}

View File

@@ -0,0 +1,23 @@
package cn.daxpay.single.sdk.code;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 分账订单处理结果
* @author xxm
* @since 2024/4/16
*/
@Getter
@AllArgsConstructor
public enum AllocOrderResultEnum {
ALL_PENDING("all_pending", "全部处理中"),
ALL_SUCCESS("all_success", "全部成功"),
PART_SUCCESS("part_success", "部分成功"),
ALL_FAILED("all_failed", "全部失败"),
;
private final String code;
private final String name;
}

View File

@@ -14,4 +14,9 @@ import lombok.ToString;
@Setter
@ToString
public class AllocationModel extends DaxPayResponseModel {
/** 分账订单号 */
private String allocationNo;
/** 分账状态 */
private String status;
}

View File

@@ -0,0 +1,51 @@
package cn.daxpay.single.sdk.model.notice;
import cn.daxpay.single.sdk.code.AllocDetailResultEnum;
import cn.daxpay.single.sdk.code.AllocReceiverTypeEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* 分账明细
* @author xxm
* @since 2024/5/30
*/
@Getter
@Setter
@ToString
public class AllocDetailNoticeModel {
/** 分账接收方编号 */
private String receiverNo;
/** 分账金额 */
private Integer amount;
/**
* 分账接收方类型
* @see AllocReceiverTypeEnum
*/
private String receiverType;
/** 接收方账号 */
private String receiverAccount;
/** 接收方姓名 */
private String receiverName;
/**
* 分账结果
* @see AllocDetailResultEnum
*/
private String result;
/** 错误代码 */
private String errorCode;
/** 错误原因 */
private String errorMsg;
/** 分账完成时间 */
private Long finishTime;
}

View File

@@ -0,0 +1,99 @@
package cn.daxpay.single.sdk.model.notice;
import cn.daxpay.single.sdk.code.AllocOrderResultEnum;
import cn.daxpay.single.sdk.code.AllocOrderStatusEnum;
import cn.daxpay.single.sdk.code.PayChannelEnum;
import cn.daxpay.single.sdk.net.DaxPayResponseModel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* 分账异步通知类
* @author xxm
* @since 2024/5/21
*/
@Getter
@Setter
@ToString
public class AllocNoticeModel extends DaxPayResponseModel {
/**
* 分账单号
*/
private String allocationNo;
/**
* 商户分账单号
*/
private String bizAllocationNo;
/**
* 通道分账号
*/
private String outAllocationNo;
/**
* 支付订单号
*/
private String orderNo;
/**
* 商户支付订单号
*/
private String bizOrderNo;
/**
* 支付订单标题
*/
private String title;
/**
* 所属通道
* @see PayChannelEnum
*/
private String channel;
/**
* 总分账金额
*/
private Integer amount;
/**
* 分账描述
*/
private String description;
/**
* 状态
* @see AllocOrderStatusEnum
*/
private String status;
/**
* 处理结果
* @see AllocOrderResultEnum
*/
private String result;
/** 分账订单完成时间 */
private Long finishTime;
/** 商户扩展参数 */
private String attach;
/** 分账明细 */
private List<AllocDetailNoticeModel> details;
/**
* 错误码
*/
private String errorCode;
/**
* 错误信息
*/
private String errorMsg;
}

View File

@@ -1,6 +1,7 @@
package cn.daxpay.single.sdk.model.notice;
import cn.daxpay.single.sdk.code.PayChannelEnum;
import cn.daxpay.single.sdk.code.PayOrderAllocStatusEnum;
import cn.daxpay.single.sdk.code.PayStatusEnum;
import cn.daxpay.single.sdk.net.DaxPayResponseModel;
import lombok.Getter;
@@ -23,9 +24,20 @@ public class PayNoticeModel extends DaxPayResponseModel {
/** 商户订单号 */
private String bizOrderNo;
/** 通道系统交易号 */
private String outOrderNo;
/** 标题 */
private String title;
/** 描述 */
private String description;
/** 是否支持分账 */
private Boolean allocation;
/** 是否开启自动分账,*/
private Boolean autoAllocation;
/**
* 支付通道
* @see PayChannelEnum
@@ -44,9 +56,18 @@ public class PayNoticeModel extends DaxPayResponseModel {
*/
private String status;
/**
* 分账状态
* @see PayOrderAllocStatusEnum
*/
private String allocationStatus;
/** 支付成功时间 */
private Long payTime;
/** 过期时间 */
private Long expiredTime;
/** 支付关闭时间 */
private Long closeTime;

View File

@@ -1,7 +1,6 @@
package cn.daxpay.single.sdk.model.notice;
import cn.daxpay.single.sdk.code.PayChannelEnum;
import cn.daxpay.single.sdk.code.RefundStatusEnum;
import cn.daxpay.single.sdk.net.DaxPayResponseModel;
import lombok.Getter;
import lombok.Setter;
@@ -17,26 +16,41 @@ import lombok.ToString;
@ToString
public class RefundNoticeModel extends DaxPayResponseModel {
/** 支付订单号 */
private String orderNo;
/** 商户支付订单号 */
private String bizOrderNo;
/** 通道支付订单号 */
private String outOrderNo;
/** 支付标题 */
private String title;
/** 退款号 */
private String refundNo;
/** 商户退款号 */
private String bizRefundNo;
/** 通道退款交易号 */
private String outRefundNo;
/**
* 支付通道
* 退款通道
* @see PayChannelEnum
*/
private String channel;
/** 订单金额 */
private Integer orderAmount;
/** 退款金额 */
private Integer amount;
/**
* 退款状态
* @see RefundStatusEnum
*/
private String status;
/** 退款原因 */
private String reason;
/** 退款成功时间 */
private Long finishTime;

View File

@@ -95,10 +95,9 @@ public class AllocationTest {
AllocationParam param = new AllocationParam();
param.setBizAllocationNo("A"+ RandomUtil.randomNumbers(5));
param.setAttach("88899");
param.setBizOrderNo("P1213");
param.setBizOrderNo("P1717073355992");
param.setDescription("测试分账");
param.setClientIp("127.0.0.1");
param.setBizOrderNo("112324");
DaxPayResult<AllocationModel> execute = DaxPayKit.execute(param);
System.out.println(execute);

View File

@@ -6,13 +6,14 @@ import cn.bootx.platform.common.core.rest.ResResult;
import cn.bootx.platform.common.core.rest.dto.LabelValue;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.daxpay.single.code.PaymentApiCode;
import cn.daxpay.single.param.payment.allocation.AllocationParam;
import cn.daxpay.single.param.payment.allocation.AllocSyncParam;
import cn.daxpay.single.param.payment.allocation.AllocFinishParam;
import cn.daxpay.single.service.annotation.PlatformInitContext;
import cn.daxpay.single.service.core.order.allocation.service.AllocationOrderService;
import cn.daxpay.single.param.payment.allocation.AllocSyncParam;
import cn.daxpay.single.param.payment.allocation.AllocationParam;
import cn.daxpay.single.service.annotation.InitPaymentContext;
import cn.daxpay.single.service.core.order.allocation.service.AllocationOrderQueryService;
import cn.daxpay.single.service.core.payment.allocation.service.AllocationService;
import cn.daxpay.single.service.core.payment.allocation.service.AllocationSyncService;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderAndExtraDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDetailDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderExtraDto;
@@ -38,7 +39,7 @@ import java.util.List;
@RequiredArgsConstructor
public class AllocationOrderController {
private final AllocationOrderService allocationOrderService;
private final AllocationOrderQueryService queryService;
private final AllocationService allocationService;
@@ -47,40 +48,44 @@ public class AllocationOrderController {
@Operation(summary = "分页")
@GetMapping("/page")
public ResResult<PageResult<AllocationOrderDto>> page(PageParam pageParam, AllocationOrderQuery param){
return Res.ok(allocationOrderService.page(pageParam,param));
return Res.ok(queryService.page(pageParam,param));
}
@Operation(summary = "分账明细列表")
@GetMapping("/detail/findAll")
public ResResult<List<AllocationOrderDetailDto>> findDetailsByOrderId(Long orderId){
return Res.ok(allocationOrderService.findDetailsByOrderId(orderId));
return Res.ok(queryService.findDetailsByOrderId(orderId));
}
@Operation(summary = "查询详情")
@GetMapping("/findById")
public ResResult<AllocationOrderDto> findById(Long id){
return Res.ok(allocationOrderService.findById(id));
return Res.ok(queryService.findById(id));
}
@Operation(summary = "查询明细详情")
@GetMapping("/detail/findById")
public ResResult<AllocationOrderDetailDto> findDetailById(Long id){
return Res.ok(allocationOrderService.findDetailById(id));
return Res.ok(queryService.findDetailById(id));
}
@Operation(summary = "查询扩展信息")
@GetMapping("/extra/findById")
public ResResult<AllocationOrderExtraDto> findExtraById(Long id){
return Res.ok(allocationOrderService.findExtraById(id));
@GetMapping("/findByAllocNo")
public ResResult<AllocationOrderAndExtraDto> findByAllocNo(String allocNo){
AllocationOrderAndExtraDto result = new AllocationOrderAndExtraDto();
AllocationOrderDto order = queryService.findByAllocNo(allocNo);
AllocationOrderExtraDto extra = queryService.findExtraById(order.getId());
result.setOrder(order).setExtra(extra);
return Res.ok(result);
}
@Operation(summary = "获取可以分账的通道")
@GetMapping("/findChannels")
public ResResult<List<LabelValue>> findChannels(){
return Res.ok(allocationOrderService.findChannels());
return Res.ok(queryService.findChannels());
}
@PlatformInitContext(PaymentApiCode.SYNC_ALLOCATION)
@InitPaymentContext(PaymentApiCode.SYNC_ALLOCATION)
@Operation(summary = "同步分账结果")
@PostMapping("/sync")
public ResResult<Void> sync(String allocationNo){
@@ -90,7 +95,7 @@ public class AllocationOrderController {
return Res.ok();
}
@PlatformInitContext(PaymentApiCode.SYNC_REFUND)
@InitPaymentContext(PaymentApiCode.SYNC_REFUND)
@Operation(summary = "分账完结")
@PostMapping("/finish")
public ResResult<Void> finish(String allocationNo){
@@ -100,7 +105,7 @@ public class AllocationOrderController {
return Res.ok();
}
@PlatformInitContext(PaymentApiCode.ALLOCATION)
@InitPaymentContext(PaymentApiCode.ALLOCATION)
@Operation(summary = "重新发起分账")
@PostMapping("/retry")
public ResResult<Void> retryAllocation(String bizAllocationNo){

View File

@@ -5,17 +5,19 @@ import cn.bootx.platform.common.core.rest.PageResult;
import cn.bootx.platform.common.core.rest.Res;
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.allocation.AllocationParam;
import cn.daxpay.single.param.payment.pay.PayCloseParam;
import cn.daxpay.single.param.payment.pay.PaySyncParam;
import cn.daxpay.single.result.sync.PaySyncResult;
import cn.daxpay.single.service.annotation.InitPaymentContext;
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;
import cn.daxpay.single.service.core.payment.allocation.service.AllocationService;
import cn.daxpay.single.service.core.payment.close.service.PayCloseService;
import cn.daxpay.single.service.core.payment.sync.service.PaySyncService;
import cn.daxpay.single.service.dto.order.pay.PayOrderInfoDto;
import cn.daxpay.single.service.dto.order.pay.PayOrderAndExtraDto;
import cn.daxpay.single.service.dto.order.pay.PayOrderDto;
import cn.daxpay.single.service.dto.order.pay.PayOrderExtraDto;
import cn.daxpay.single.service.param.order.PayOrderQuery;
@@ -63,11 +65,11 @@ public class PayOrderController {
@Operation(summary = "查询订单详情")
@GetMapping("/findByOrderNo")
public ResResult<PayOrderInfoDto> findByOrderNo(String orderNo){
public ResResult<PayOrderAndExtraDto> findByOrderNo(String orderNo){
PayOrderDto order = queryService.findByOrderNo(orderNo)
.map(PayOrder::toDto)
.orElseThrow(() -> new DataNotExistException("支付订单不存在"));
PayOrderInfoDto detailDto=new PayOrderInfoDto();
PayOrderAndExtraDto detailDto=new PayOrderAndExtraDto();
detailDto.setPayOrder(order);
detailDto.setPayOrderExtra(payOrderExtraService.findById(order.getId()));
return Res.ok(detailDto);
@@ -97,6 +99,7 @@ public class PayOrderController {
}
@Operation(summary = "发起分账")
@InitPaymentContext(PaymentApiCode.ALLOCATION)
@PostMapping("/allocation")
public ResResult<Void> allocation(String orderNo){
AllocationParam param = new AllocationParam();

View File

@@ -6,13 +6,12 @@ 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.sync.PaySyncResult;
import cn.daxpay.single.result.sync.RefundSyncResult;
import cn.daxpay.single.service.annotation.PlatformInitContext;
import cn.daxpay.single.service.annotation.InitPaymentContext;
import cn.daxpay.single.service.core.order.refund.service.RefundOrderQueryService;
import cn.daxpay.single.service.core.order.refund.service.RefundOrderService;
import cn.daxpay.single.service.core.payment.sync.service.RefundSyncService;
import cn.daxpay.single.service.dto.order.refund.RefundOrderDetailDto;
import cn.daxpay.single.service.dto.order.refund.RefundOrderAndExtraDto;
import cn.daxpay.single.service.dto.order.refund.RefundOrderDto;
import cn.daxpay.single.service.dto.order.refund.RefundOrderExtraDto;
import cn.daxpay.single.service.param.order.PayOrderQuery;
@@ -45,10 +44,10 @@ public class RefundOrderController {
@Operation(summary = "查询退款订单详情")
@GetMapping("/findByOrderNo")
public ResResult<RefundOrderDetailDto> findByRefundNo(String refundNo){
@GetMapping("/findByRefundNo")
public ResResult<RefundOrderAndExtraDto> findByRefundNo(String refundNo){
RefundOrderDto order = queryService.findByRefundNo(refundNo);
RefundOrderDetailDto detailDto = new RefundOrderDetailDto();
RefundOrderAndExtraDto detailDto = new RefundOrderAndExtraDto();
detailDto.setRefundOrder(order);
detailDto.setRefundOrderExtra(queryService.findExtraById(order.getId()));
return Res.ok(detailDto);
@@ -66,7 +65,7 @@ public class RefundOrderController {
return Res.ok(queryService.findExtraById(id));
}
@PlatformInitContext(PaymentApiCode.REFUND)
@InitPaymentContext(PaymentApiCode.REFUND)
@Operation(summary = "手动发起退款")
@PostMapping("/refund")
public ResResult<Void> refund(@RequestBody PayOrderRefundParam param){
@@ -74,7 +73,7 @@ public class RefundOrderController {
return Res.ok();
}
@PlatformInitContext(PaymentApiCode.REFUND)
@InitPaymentContext(PaymentApiCode.REFUND)
@Operation(summary = "重新发起退款")
@PostMapping("/resetRefund")
public ResResult<Void> resetRefund(Long id){

View File

@@ -1,6 +1,7 @@
package cn.daxpay.single.gateway.controller;
import cn.bootx.platform.common.core.annotation.IgnoreAuth;
import com.ijpay.alipay.AliPayApi;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
@@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -26,7 +28,13 @@ public class PayNoticeReceiverController {
@Operation(summary = "支付宝消息通知")
@PostMapping("/alipay")
public String aliPayNotice() {
public String aliPayNotice(HttpServletRequest request) {
Map<String, String> map = AliPayApi.toMap(request);
// 通过 msg_method 获取消息类型
String msgMethod = map.get("msg_method");
// 通过 biz_content 获取值
String bizContent = map.get("biz_content");
return "success";
}

View File

@@ -1,5 +1,6 @@
package cn.daxpay.single.gateway.controller;
import cn.bootx.platform.common.core.annotation.IgnoreAuth;
import cn.daxpay.single.code.PaymentApiCode;
import cn.daxpay.single.param.payment.allocation.AllocFinishParam;
import cn.daxpay.single.param.payment.allocation.AllocReceiverAddParam;
@@ -10,7 +11,7 @@ import cn.daxpay.single.result.allocation.AllocReceiverAddResult;
import cn.daxpay.single.result.allocation.AllocReceiverRemoveResult;
import cn.daxpay.single.result.allocation.AllocationResult;
import cn.daxpay.single.service.annotation.PaymentSign;
import cn.daxpay.single.service.annotation.PlatformInitContext;
import cn.daxpay.single.service.annotation.InitPaymentContext;
import cn.daxpay.single.service.core.payment.allocation.service.AllocationReceiverService;
import cn.daxpay.single.service.core.payment.allocation.service.AllocationService;
import cn.daxpay.single.util.DaxRes;
@@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author xxm
* @since 2024/5/17
*/
@IgnoreAuth
@Tag(name = "分账控制器")
@RestController
@RequestMapping("/unipay/allocation")
@@ -38,7 +40,7 @@ public class UniAllocationController {
private final AllocationReceiverService receiverService;
@PaymentSign
@PlatformInitContext(PaymentApiCode.ALLOCATION)
@InitPaymentContext(PaymentApiCode.ALLOCATION)
@Operation(summary = "触发分账")
@PostMapping("/open")
public DaxResult<AllocationResult> open(@RequestBody AllocationParam param){
@@ -46,7 +48,7 @@ public class UniAllocationController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.ALLOCATION_FINISH)
@InitPaymentContext(PaymentApiCode.ALLOCATION_FINISH)
@Operation(summary = "分账完结接口")
@PostMapping("/finish")
public DaxResult<AllocationResult> finish(@RequestBody AllocFinishParam param){
@@ -54,7 +56,7 @@ public class UniAllocationController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.ALLOCATION_RECEIVER_ADD)
@InitPaymentContext(PaymentApiCode.ALLOCATION_RECEIVER_ADD)
@Operation(summary = "添加分账接收方接口")
@PostMapping("/receiver/add")
public DaxResult<AllocReceiverAddResult> receiverAdd(@RequestBody AllocReceiverAddParam param){
@@ -62,7 +64,7 @@ public class UniAllocationController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.ALLOCATION_RECEIVER_REMOVE)
@InitPaymentContext(PaymentApiCode.ALLOCATION_RECEIVER_REMOVE)
@Operation(summary = "删除分账接收方接口")
@PostMapping("/receiver/remove")
public DaxResult<AllocReceiverRemoveResult> receiverRemove(@RequestBody AllocReceiverRemoveParam param){

View File

@@ -9,7 +9,7 @@ import cn.daxpay.single.param.assist.WxAuthUrlParam;
import cn.daxpay.single.result.DaxResult;
import cn.daxpay.single.result.assist.WxAccessTokenResult;
import cn.daxpay.single.result.assist.WxAuthUrlResult;
import cn.daxpay.single.service.annotation.PlatformInitContext;
import cn.daxpay.single.service.annotation.InitPaymentContext;
import cn.daxpay.single.service.annotation.PaymentSign;
import cn.daxpay.single.service.core.payment.assist.service.UniPayAssistService;
import cn.daxpay.single.util.DaxRes;
@@ -35,7 +35,7 @@ public class UniPayAssistController {
private final UniPayAssistService uniPayAssistService;
@PaymentSign
@PlatformInitContext(PaymentApiCode.GET_WX_AUTH_URL)
@InitPaymentContext(PaymentApiCode.GET_WX_AUTH_URL)
@Operation(summary = "获取微信OAuth2授权链接")
@PostMapping("/getWxAuthUrl")
public DaxResult<WxAuthUrlResult> getWxAuthUrl(@RequestBody WxAuthUrlParam param){
@@ -43,7 +43,7 @@ public class UniPayAssistController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.GET_WX_ACCESS_TOKEN)
@InitPaymentContext(PaymentApiCode.GET_WX_ACCESS_TOKEN)
@Operation(summary = "获取微信AccessToken")
@PostMapping("/getWxAccessToken")
public ResResult<WxAccessTokenResult> getWxAccessToken(@RequestBody WxAccessTokenParam param){

View File

@@ -11,7 +11,7 @@ import cn.daxpay.single.result.pay.PayCloseResult;
import cn.daxpay.single.result.pay.PayResult;
import cn.daxpay.single.result.pay.RefundResult;
import cn.daxpay.single.service.annotation.PaymentSign;
import cn.daxpay.single.service.annotation.PlatformInitContext;
import cn.daxpay.single.service.annotation.InitPaymentContext;
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;
@@ -40,7 +40,7 @@ public class UniPayController {
private final PayCloseService payCloseService;
@PaymentSign
@PlatformInitContext(PaymentApiCode.PAY)
@InitPaymentContext(PaymentApiCode.PAY)
@Operation(summary = "统一支付接口")
@PostMapping("/pay")
public DaxResult<PayResult> pay(@RequestBody PayParam payParam){
@@ -48,7 +48,7 @@ public class UniPayController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.CLOSE)
@InitPaymentContext(PaymentApiCode.CLOSE)
@Operation(summary = "支付关闭接口")
@PostMapping("/close")
public DaxResult<PayCloseResult> close(@RequestBody PayCloseParam param){
@@ -56,7 +56,7 @@ public class UniPayController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.REFUND)
@InitPaymentContext(PaymentApiCode.REFUND)
@Operation(summary = "统一退款接口")
@PostMapping("/refund")
public DaxResult<RefundResult> refund(@RequestBody RefundParam param){
@@ -64,7 +64,7 @@ public class UniPayController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.TRANSFER)
@InitPaymentContext(PaymentApiCode.TRANSFER)
@Operation(summary = "统一转账接口")
@PostMapping("/transfer")
public DaxResult<Void> transfer(@RequestBody TransferParam param){

View File

@@ -1,5 +1,6 @@
package cn.daxpay.single.gateway.controller;
import cn.bootx.platform.common.core.annotation.IgnoreAuth;
import cn.daxpay.single.code.PaymentApiCode;
import cn.daxpay.single.param.payment.allocation.AllocSyncParam;
import cn.daxpay.single.param.payment.pay.PaySyncParam;
@@ -9,7 +10,7 @@ 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.annotation.InitPaymentContext;
import cn.daxpay.single.service.core.payment.allocation.service.AllocationSyncService;
import cn.daxpay.single.service.core.payment.sync.service.PaySyncService;
import cn.daxpay.single.service.core.payment.sync.service.RefundSyncService;
@@ -27,7 +28,8 @@ import org.springframework.web.bind.annotation.RestController;
* @author xxm
* @since 2024/5/26
*/
@Tag(name = "")
@IgnoreAuth
@Tag(name = "统一同步接口")
@RestController
@RequestMapping("/unipay/sync")
@RequiredArgsConstructor
@@ -38,7 +40,7 @@ public class UniPaySyncController {
private final AllocationSyncService allocationSyncService;
@PaymentSign
@PlatformInitContext(PaymentApiCode.SYNC_PAY)
@InitPaymentContext(PaymentApiCode.SYNC_PAY)
@Operation(summary = "支付同步接口")
@PostMapping("/pay")
public DaxResult<PaySyncResult> pay(@RequestBody PaySyncParam param){
@@ -46,7 +48,7 @@ public class UniPaySyncController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.SYNC_REFUND)
@InitPaymentContext(PaymentApiCode.SYNC_REFUND)
@Operation(summary = "退款同步接口")
@PostMapping("/refund")
public DaxResult<RefundSyncResult> refund(@RequestBody RefundSyncParam param){
@@ -55,7 +57,7 @@ public class UniPaySyncController {
@PaymentSign
@PlatformInitContext(PaymentApiCode.SYNC_ALLOCATION)
@InitPaymentContext(PaymentApiCode.SYNC_ALLOCATION)
@Operation(summary = "分账同步接口")
@PostMapping("/allocation")
public DaxResult<AllocSyncResult> allocation(@RequestBody AllocSyncParam param){
@@ -63,7 +65,7 @@ public class UniPaySyncController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.SYNC_TRANSFER)
@InitPaymentContext(PaymentApiCode.SYNC_TRANSFER)
@Operation(summary = "转账同步接口")
@PostMapping("/transfer")
public DaxResult<Void> transfer(@RequestBody AllocSyncParam param){

View File

@@ -13,7 +13,7 @@ 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.PaymentSign;
import cn.daxpay.single.service.annotation.PlatformInitContext;
import cn.daxpay.single.service.annotation.InitPaymentContext;
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;
@@ -45,7 +45,7 @@ public class UniQueryController {
private final AllocationService allocationService;
@PaymentSign
@PlatformInitContext(PaymentApiCode.QUERY_PAY_ORDER)
@InitPaymentContext(PaymentApiCode.QUERY_PAY_ORDER)
@Operation(summary = "支付订单查询接口")
@PostMapping("/payOrder")
public DaxResult<PayOrderResult> queryPayOrder(@RequestBody QueryPayParam param){
@@ -53,7 +53,7 @@ public class UniQueryController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.QUERY_REFUND_ORDER)
@InitPaymentContext(PaymentApiCode.QUERY_REFUND_ORDER)
@Operation(summary = "退款订单查询接口")
@PostMapping("/refundOrder")
public DaxResult<RefundOrderResult> queryRefundOrder(@RequestBody QueryRefundParam param){
@@ -61,7 +61,7 @@ public class UniQueryController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.QUERY_ALLOCATION_ORDER)
@InitPaymentContext(PaymentApiCode.QUERY_ALLOCATION_ORDER)
@Operation(summary = "分账订单查询接口")
@PostMapping("/allocationOrder")
public DaxResult<AllocOrderResult> queryAllocationOrder(@RequestBody QueryAllocOrderParam param){
@@ -69,7 +69,7 @@ public class UniQueryController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.QUERY_TRANSFER_ORDER)
@InitPaymentContext(PaymentApiCode.QUERY_TRANSFER_ORDER)
@Operation(summary = "转账订单查询接口")
@PostMapping("/transferOrder")
public DaxResult<Void> transferOrder(@RequestBody QueryTransferParam param){
@@ -77,7 +77,7 @@ public class UniQueryController {
}
@PaymentSign
@PlatformInitContext(PaymentApiCode.QUERY_ALLOCATION_RECEIVER)
@InitPaymentContext(PaymentApiCode.QUERY_ALLOCATION_RECEIVER)
@Operation(summary = "分账接收方查询接口")
@PostMapping("/allocReceiver")
public DaxResult<AllocReceiversResult> queryAllocReceive(@RequestBody QueryAllocReceiverParam param){

View File

@@ -1,9 +1,10 @@
package cn.daxpay.single.gateway.controller;
import cn.bootx.platform.common.core.annotation.IgnoreAuth;
import cn.daxpay.single.code.PaymentApiCode;
import cn.daxpay.single.result.DaxResult;
import cn.daxpay.single.service.annotation.PaymentSign;
import cn.daxpay.single.service.annotation.PlatformInitContext;
import cn.daxpay.single.service.annotation.InitPaymentContext;
import cn.daxpay.single.util.DaxRes;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author xxm
* @since 2024/5/17
*/
@IgnoreAuth
@Tag(name = "对账接口处理器")
@RestController
@RequestMapping("/unipay/reconcile")
@@ -24,7 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
public class UniReconcileController {
@PaymentSign
@PlatformInitContext(PaymentApiCode.PAY)
@InitPaymentContext(PaymentApiCode.PAY)
@Operation(summary = "下载指定日期的资金流水")
@PostMapping("/pay")
public DaxResult<?> down(){

View File

@@ -13,7 +13,7 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface PlatformInitContext {
public @interface InitPaymentContext {
/**
* 接口标识

View File

@@ -12,7 +12,9 @@ import lombok.Getter;
@AllArgsConstructor
public enum ClientNoticeTypeEnum {
PAY("pay", "支付通知"),
REFUND("refund", "退款通知");
REFUND("refund", "退款通知"),
ALLOCATION("Allocation", "分账通知"),
;
private final String type;
private final String name;

View File

@@ -5,6 +5,8 @@ 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.core.order.allocation.entity.AllocationOrderExtra;
import cn.daxpay.single.service.core.payment.notice.result.AllocDetailNoticeResult;
import cn.daxpay.single.service.core.payment.notice.result.AllocNoticeResult;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDetailDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderExtraDto;
@@ -20,7 +22,6 @@ import org.mapstruct.factory.Mappers;
public interface AllocationConvert {
AllocationConvert CONVERT = Mappers.getMapper(AllocationConvert.class);
AllocationOrderDto convert(AllocationOrder in);
AllocationOrderExtraDto convert(AllocationOrderExtra in);
@@ -31,4 +32,8 @@ public interface AllocationConvert {
AllocationOrderDetailDto convert(AllocationOrderDetail in);
AllocNoticeResult toNotice(AllocationOrder in);
AllocDetailNoticeResult toNotice(AllocationOrderDetail in);
}

View File

@@ -0,0 +1,93 @@
package cn.daxpay.single.service.core.order.allocation.service;
import cn.bootx.platform.common.core.exception.DataNotExistException;
import cn.bootx.platform.common.core.rest.PageResult;
import cn.bootx.platform.common.core.rest.dto.LabelValue;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.core.util.ResultConvertUtil;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.daxpay.single.code.PayChannelEnum;
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.dto.order.allocation.AllocationOrderDetailDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderExtraDto;
import cn.daxpay.single.service.param.order.AllocationOrderQuery;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
/**
* 分账订单查询服务类
* @author xxm
* @since 2024/5/30
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class AllocationOrderQueryService {
private final AllocationOrderDetailManager allocationOrderDetailManager;
private final AllocationOrderManager allocationOrderManager;
private final AllocationOrderExtraManager allocationOrderExtraManager;
/**
* 获取可以分账的通道
*/
public List<LabelValue> findChannels(){
return Arrays.asList(
new LabelValue(PayChannelEnum.ALI.getName(),PayChannelEnum.ALI.getCode()),
new LabelValue(PayChannelEnum.WECHAT.getName(),PayChannelEnum.WECHAT.getCode())
);
}
/**
* 分页查询
*/
public PageResult<AllocationOrderDto> page(PageParam pageParam, AllocationOrderQuery param){
return MpUtil.convert2DtoPageResult(allocationOrderManager.page(pageParam, param));
}
/**
* 查询详情
*/
public AllocationOrderDto findById(Long id) {
return allocationOrderManager.findById(id).map(AllocationOrder::toDto).orElseThrow(() -> new DataNotExistException("分账订单不存在"));
}
/**
* 查询详情
*/
public AllocationOrderDto findByAllocNo(String allocNo) {
return allocationOrderManager.findByAllocationNo(allocNo).map(AllocationOrder::toDto).orElseThrow(() -> new DataNotExistException("分账订单不存在"));
}
/**
* 查询订单明细列表
*/
public List<AllocationOrderDetailDto> findDetailsByOrderId(Long orderId){
return ResultConvertUtil.dtoListConvert(allocationOrderDetailManager.findAllByOrderId(orderId));
}
/**
* 查询订单明细详情
*/
public AllocationOrderDetailDto findDetailById(Long id){
return allocationOrderDetailManager.findById(id).map(AllocationOrderDetail::toDto).orElseThrow(() -> new DataNotExistException("分账订单明细不存在"));
}
/**
* 查询扩展订单信息
*/
public AllocationOrderExtraDto findExtraById(Long id) {
return allocationOrderExtraManager.findById(id).map(AllocationOrderExtra::toDto)
.orElseThrow(() -> new DataNotExistException("未找到"));
}
}

View File

@@ -1,14 +1,7 @@
package cn.daxpay.single.service.core.order.allocation.service;
import cn.bootx.platform.common.core.exception.DataNotExistException;
import cn.bootx.platform.common.core.rest.PageResult;
import cn.bootx.platform.common.core.rest.dto.LabelValue;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.core.util.ResultConvertUtil;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.daxpay.single.code.AllocDetailResultEnum;
import cn.daxpay.single.code.AllocOrderStatusEnum;
import cn.daxpay.single.code.PayChannelEnum;
import cn.daxpay.single.code.PayOrderAllocStatusEnum;
import cn.daxpay.single.exception.pay.PayFailureException;
import cn.daxpay.single.param.payment.allocation.AllocReceiverParam;
@@ -27,10 +20,6 @@ import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
import cn.daxpay.single.service.core.payment.allocation.dao.AllocationReceiverManager;
import cn.daxpay.single.service.core.payment.allocation.entity.AllocationReceiver;
import cn.daxpay.single.service.dto.allocation.AllocationGroupReceiverResult;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDetailDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderExtraDto;
import cn.daxpay.single.service.param.order.AllocationOrderQuery;
import cn.daxpay.single.util.OrderNoGenerateUtil;
import cn.hutool.core.util.IdUtil;
import lombok.RequiredArgsConstructor;
@@ -41,7 +30,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -66,54 +54,6 @@ public class AllocationOrderService {
private final AllocationOrderExtraManager allocationOrderExtraManager;
/**
* 获取可以分账的通道
*/
public List<LabelValue> findChannels(){
return Arrays.asList(
new LabelValue(PayChannelEnum.ALI.getName(),PayChannelEnum.ALI.getCode()),
new LabelValue(PayChannelEnum.WECHAT.getName(),PayChannelEnum.WECHAT.getCode())
);
}
/**
* 分页查询
*/
public PageResult<AllocationOrderDto> page(PageParam pageParam, AllocationOrderQuery param){
return MpUtil.convert2DtoPageResult(allocationOrderManager.page(pageParam, param));
}
/**
* 查询详情
*/
public AllocationOrderDto findById(Long id) {
return allocationOrderManager.findById(id).map(AllocationOrder::toDto).orElseThrow(() -> new DataNotExistException("分账订单不存在"));
}
/**
* 查询订单明细列表
*/
public List<AllocationOrderDetailDto> findDetailsByOrderId(Long orderId){
return ResultConvertUtil.dtoListConvert(allocationOrderDetailManager.findAllByOrderId(orderId));
}
/**
* 查询订单明细详情
*/
public AllocationOrderDetailDto findDetailById(Long id){
return allocationOrderDetailManager.findById(id).map(AllocationOrderDetail::toDto).orElseThrow(() -> new DataNotExistException("分账订单明细不存在"));
}
/**
* 查询扩展订单信息
*/
public AllocationOrderExtraDto findExtraById(Long id) {
return allocationOrderExtraManager.findById(id).map(AllocationOrderExtra::toDto)
.orElseThrow(() -> new DataNotExistException("未找到"));
}
/**
* 生成分账订单, 根据分账组创建
*/

View File

@@ -2,7 +2,7 @@ package cn.daxpay.single.service.core.payment.common.aop;
import cn.bootx.platform.common.core.exception.DataNotExistException;
import cn.daxpay.single.exception.pay.PayFailureException;
import cn.daxpay.single.service.annotation.PlatformInitContext;
import cn.daxpay.single.service.annotation.InitPaymentContext;
import cn.daxpay.single.service.core.system.config.dao.PayApiConfigManager;
import cn.daxpay.single.service.core.system.config.entity.PayApiConfig;
import cn.daxpay.single.service.core.system.config.service.PayApiConfigService;
@@ -36,7 +36,7 @@ public class InitPlatformInfoAop {
* 拦截注解
*/
@Around("@annotation(platformContext)")
public Object beforeMethod(ProceedingJoinPoint pjp, PlatformInitContext platformContext) throws Throwable {
public Object beforeMethod(ProceedingJoinPoint pjp, InitPaymentContext platformContext) throws Throwable {
String code = platformContext.value();
// 接口信息
PayApiConfig api = payApiConfigManager.findByCode(code)

View File

@@ -0,0 +1,64 @@
package cn.daxpay.single.service.core.payment.notice.result;
import cn.daxpay.single.code.AllocDetailResultEnum;
import cn.daxpay.single.code.AllocReceiverTypeEnum;
import cn.daxpay.single.serializer.LocalDateTimeToTimestampSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 分账响应结果
* @author xxm
* @since 2024/5/30
*/
@Data
@Accessors(chain = true)
@Schema(title = "分账响应结果")
public class AllocDetailNoticeResult {
@Schema(description = "分账接收方编号")
private String receiverNo;
/** 分账金额 */
@Schema(description = "分账金额")
private Integer amount;
/**
* 分账接收方类型
* @see AllocReceiverTypeEnum
*/
@Schema(description = "分账接收方类型")
private String receiverType;
/** 接收方账号 */
@Schema(description = "接收方账号")
private String receiverAccount;
/** 接收方姓名 */
@Schema(description = "接收方姓名")
private String receiverName;
/**
* 分账结果
* @see AllocDetailResultEnum
*/
@Schema(description = "分账结果")
private String result;
/** 错误代码 */
@Schema(description = "错误代码")
private String errorCode;
/** 错误原因 */
@Schema(description = "错误原因")
private String errorMsg;
/** 分账完成时间 */
@Schema(description = "分账完成时间")
@JsonSerialize(using = LocalDateTimeToTimestampSerializer.class)
private LocalDateTime finishTime;
}

View File

@@ -0,0 +1,121 @@
package cn.daxpay.single.service.core.payment.notice.result;
import cn.daxpay.single.code.AllocOrderResultEnum;
import cn.daxpay.single.code.AllocOrderStatusEnum;
import cn.daxpay.single.code.PayChannelEnum;
import cn.daxpay.single.result.PaymentCommonResult;
import cn.daxpay.single.serializer.LocalDateTimeToTimestampSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.List;
/**
* 分账通知方法
* @author xxm
* @since 2024/5/21
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "分账通知方法")
public class AllocNoticeResult extends PaymentCommonResult {
/**
* 分账单号
*/
@Schema(description = "分账单号")
private String allocationNo;
/**
* 商户分账单号
*/
@Schema(description = "商户分账单号")
private String bizAllocationNo;
/**
* 通道分账号
*/
@Schema(description = "通道分账号")
private String outAllocationNo;
/**
* 支付订单号
*/
@Schema(description = "支付订单号")
private String orderNo;
/**
* 商户支付订单号
*/
@Schema(description = "商户支付订单号")
private String bizOrderNo;
/**
* 支付订单标题
*/
@Schema(description = "支付订单标题")
private String title;
/**
* 所属通道
* @see PayChannelEnum
*/
@Schema(description = "所属通道")
private String channel;
/**
* 总分账金额
*/
@Schema(description = "总分账金额")
private Integer amount;
/**
* 分账描述
*/
@Schema(description = "分账描述")
private String description;
/**
* 状态
* @see AllocOrderStatusEnum
*/
@Schema(description = "状态")
private String status;
/**
* 处理结果
* @see AllocOrderResultEnum
*/
@Schema(description = "处理结果")
private String result;
/** 分账订单完成时间 */
@Schema(description = "分账订单完成时间")
@JsonSerialize(using = LocalDateTimeToTimestampSerializer.class)
private LocalDateTime finishTime;
/** 商户扩展参数,回调时会原样返回 */
@Schema(description = "商户扩展参数,回调时会原样返回")
private String attach;
/** 分账明细 */
@Schema(description = "分账明细")
private List<AllocDetailNoticeResult> details;
/**
* 错误码
*/
@Schema(description = "错误码")
private String errorCode;
/**
* 错误信息
*/
@Schema(description = "错误原因")
private String errorMsg;
}

View File

@@ -1,20 +0,0 @@
package cn.daxpay.single.service.core.payment.notice.result;
import cn.daxpay.single.result.PaymentCommonResult;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 分账通知方法
* @author xxm
* @since 2024/5/21
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "分账通知方法")
public class AllocationNoticeResult extends PaymentCommonResult {
}

View File

@@ -24,13 +24,13 @@ import java.time.LocalDateTime;
@Schema(title = "支付异步通知类")
public class PayNoticeResult extends PaymentCommonResult {
@Schema(description = "支付订单号")
private String orderNo;
/** 商户订单号 */
@Schema(description = "商户订单号")
private String bizOrderNo;
@Schema(description = "支付订单号")
private String orderNo;
/** 通道系统交易号 */
@Schema(description = "通道支付订单号")
private String outOrderNo;
@@ -47,7 +47,7 @@ public class PayNoticeResult extends PaymentCommonResult {
@Schema(description = "是否需要分账")
private Boolean allocation;
/** 是否开启自动分账, 不传输为不开启 */
/** 是否开启自动分账 */
@Schema(description = "是否开启自动分账")
private Boolean autoAllocation;
@@ -68,10 +68,6 @@ public class PayNoticeResult extends PaymentCommonResult {
@Schema(description = "金额")
private Integer amount;
/** 可退款余额 */
@Schema(description = "可退款余额")
private Integer refundableBalance;
/**
* 支付状态
* @see PayStatusEnum

View File

@@ -1,8 +1,6 @@
package cn.daxpay.single.service.core.payment.notice.service;
import cn.bootx.platform.common.jackson.util.JacksonUtil;
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;
@@ -16,6 +14,8 @@ import cn.daxpay.single.service.core.order.refund.convert.RefundOrderConvert;
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
import cn.daxpay.single.service.core.order.refund.entity.RefundOrderExtra;
import cn.daxpay.single.service.core.payment.common.service.PaymentSignService;
import cn.daxpay.single.service.core.payment.notice.result.AllocDetailNoticeResult;
import cn.daxpay.single.service.core.payment.notice.result.AllocNoticeResult;
import cn.daxpay.single.service.core.payment.notice.result.PayNoticeResult;
import cn.daxpay.single.service.core.payment.notice.result.RefundNoticeResult;
import lombok.RequiredArgsConstructor;
@@ -80,20 +80,21 @@ public class ClientNoticeAssistService {
*/
public ClientNoticeTask buildAllocTask(AllocationOrder order, AllocationOrderExtra orderExtra, List<AllocationOrderDetail> list){
// 分账
AllocOrderResult allocOrderResult = AllocationConvert.CONVERT.toResult(order);
AllocNoticeResult allocOrderResult = AllocationConvert.CONVERT.toNotice(order);
// 分账详情
List<AllocOrderDetailResult> details = list.stream()
.map(AllocationConvert.CONVERT::toResult)
List<AllocDetailNoticeResult> details = list.stream()
.map(AllocationConvert.CONVERT::toNotice)
.collect(Collectors.toList());
// 分账扩展
allocOrderResult.setAttach(orderExtra.getAttach());
// 分账扩展和明细
allocOrderResult.setAttach(orderExtra.getAttach())
.setDetails(details);
// 签名
paymentSignService.sign(allocOrderResult);
return new ClientNoticeTask()
.setUrl(orderExtra.getNotifyUrl())
// 时间序列化进行了重写
.setContent(JacksonUtil.toJson(allocOrderResult))
.setNoticeType(ClientNoticeTypeEnum.REFUND.getType())
.setNoticeType(ClientNoticeTypeEnum.ALLOCATION.getType())
.setSendCount(0)
.setTradeId(order.getId())
.setTradeNo(order.getAllocationNo())

View File

@@ -0,0 +1,20 @@
package cn.daxpay.single.service.dto.order.allocation;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 分账订单和扩展信息
* @author xxm
* @since 2024/5/29
*/
@Data
@Accessors(chain = true)
@Schema(title = "分账订单和扩展信息")
public class AllocationOrderAndExtraDto {
@Schema(description = "分账订单")
private AllocationOrderDto order;
@Schema(description = "分账订单扩展信息")
private AllocationOrderExtraDto extra;
}

View File

@@ -25,6 +25,17 @@ public class AllocationOrderDto extends BaseDto {
@Schema(description = "分账订单号")
private String allocationNo;
/**
* 商户分账单号
*/
@Schema(description = "商户分账单号")
private String bizAllocationNo;
/**
* 通道分账单号
*/
@Schema(description = "通道分账单号")
private String outAllocationNo;
/**
* 支付订单ID
*/
@@ -55,12 +66,6 @@ public class AllocationOrderDto extends BaseDto {
@Schema(description = "支付订单标题")
private String title;
/**
* 通道分账单号
*/
@Schema(description = "通道分账单号")
private String outAllocationNo;
/**
* 所属通道
*/

View File

@@ -1,16 +0,0 @@
package cn.daxpay.single.service.dto.order.allocation;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
/**
*
* @author xxm
* @since 2024/5/29
*/
@Data
@Accessors(chain = true)
@Schema(title = "")
public class AllocationOrderInfoDto {
}

View File

@@ -10,7 +10,7 @@ import lombok.Data;
*/
@Data
@Schema(title = "支付订单和扩展信息")
public class PayOrderInfoDto {
public class PayOrderAndExtraDto {
@Schema(description = "支付订单")
private PayOrderDto payOrder;
@Schema(description = "支付订单扩展信息")

View File

@@ -12,7 +12,7 @@ import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
@Schema(title = "退款订单信息")
public class RefundOrderDetailDto {
public class RefundOrderAndExtraDto {
@Schema(description = "退款订单")
RefundOrderDto refundOrder;
@Schema(description = "退款订单扩展信息")