feat 支付订单联调

This commit is contained in:
nws
2024-01-12 00:51:09 +08:00
parent 0ecdfc4ddc
commit 7734bf95b9
6 changed files with 92 additions and 12 deletions

View File

@@ -48,7 +48,10 @@
- 2024-01-11:
- [x] (前端) 支付关闭记录
- [x] (前端) 支付修复记录
- [x] (前端)
- 2024-01-12:
- [x] (前端) 支付订单
- [ ] (前端) 退款订单
- [ ] (前端) 微信/支付宝支付通道配置
- **任务池**
- [ ] 支付宝方式支持撤销方式,
- [ ] 支持转账操作, 通过支付通道专有参数进行实现, 转账时只能单个通道进行操作

View File

@@ -5,10 +5,15 @@ 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.bootx.platform.daxpay.param.pay.PayCloseParam;
import cn.bootx.platform.daxpay.param.pay.PaySyncParam;
import cn.bootx.platform.daxpay.result.pay.PaySyncResult;
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.service.core.order.pay.service.PayOrderChannelService;
import cn.bootx.platform.daxpay.service.core.order.pay.service.PayOrderExtraService;
import cn.bootx.platform.daxpay.service.core.order.pay.service.PayOrderService;
import cn.bootx.platform.daxpay.service.core.payment.close.service.PayCloseService;
import cn.bootx.platform.daxpay.service.core.payment.sync.service.PaySyncService;
import cn.bootx.platform.daxpay.service.dto.order.pay.PayOrderChannelDto;
import cn.bootx.platform.daxpay.service.dto.order.pay.PayOrderDto;
import cn.bootx.platform.daxpay.service.dto.order.pay.PayOrderExtraDto;
@@ -17,6 +22,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -36,6 +42,9 @@ public class PayOrderController {
private final PayOrderExtraService payOrderExtraService;
private final PayOrderChannelService payOrderChannelService;
private final PayCloseService PayCloseService;
private final PaySyncService paySyncService;
@Operation(summary = "分页查询")
@GetMapping("/page")
public ResResult<PageResult<PayOrderDto>> page(PageParam pageParam, PayOrderQuery param){
@@ -62,4 +71,21 @@ public class PayOrderController {
public ResResult<List<PayOrderChannelDto>> getChannels(Long paymentId){
return Res.ok(payOrderChannelService.findAllByPaymentId(paymentId));
}
@Operation(summary = "同步支付状态")
@PostMapping("/sync")
public ResResult<PaySyncResult> sync(Long id){
PaySyncParam param = new PaySyncParam();
param.setPaymentId(id);
return Res.ok(paySyncService.sync(param));
}
@Operation(summary = "关闭支付记录")
@PostMapping("/close")
public ResResult<Void> close(Long id){
PayCloseParam param = new PayCloseParam();
param.setPaymentId(id);
PayCloseService.close(param);
return Res.ok();
}
}

View File

@@ -57,14 +57,4 @@ public abstract class PayCommonParam {
@JsonDeserialize(using = TimestampToLocalDateTimeDeserializer.class)
private LocalDateTime reqTime;
/**
* 如果需要进行签名,
* 1. 参数名ASCII码从小到大排序字典序
* 2. 如果参数的值为空不参与签名
* 3. 参数名不区分大小写
* 4. 嵌套对象转换成先转换成MAP再序列化为字符串
* 5. 支持两层嵌套, 更多层级嵌套未测试, 可能会导致不可预知的问题
*/
}

View File

@@ -69,7 +69,7 @@ public class PaySyncService {
}
// 如果不是异步支付, 直接返回返回
if (!payOrder.isAsyncPay()){
return new PaySyncResult().setSuccess(true).setRepair(false);
return new PaySyncResult().setSuccess(false).setRepair(false).setErrorMsg("订单没有异步支付方式,不需要同步");
}
// 执行订单同步逻辑
return this.syncPayOrder(payOrder);

View File

@@ -16,4 +16,19 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
@Schema(title = "支付订单关联通道信息")
public class PayOrderChannelDto extends BaseDto {
@Schema(description = "支付id")
private Long paymentId;
@Schema(description = "通道")
private String channel;
@Schema(description = "支付方式")
private String payWay;
@Schema(description = "异步支付方式")
private boolean async;
@Schema(description = "金额")
private Integer amount;
}

View File

@@ -6,6 +6,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 支付订单扩展信息
* @author xxm
@@ -16,4 +18,48 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
@Schema(title = "支付订单扩展信息")
public class PayOrderExtraDto extends BaseDto {
/** 描述 */
@Schema(description = "描述")
private String description;
/** 支付终端ip */
@Schema(description = "支付终端ip")
private String clientIp;
/** 是否不需要异步通知,以最后一次为准 */
@Schema(description = "是否不需要异步通知")
private boolean notNotify;
/** 异步通知地址 */
@Schema(description = "异步通知地址,以最后一次为准")
private String notifyUrl;
/** 签名类型 */
@Schema(description = "签名类型")
private String signType;
/** 签名,以最后一次为准 */
@Schema(description = "签名")
private String sign;
/** 商户扩展参数,回调时会原样返回 */
@Schema(description = "商户扩展参数")
private String attach;
/** API版本号 */
@Schema(description = "API版本号")
private String apiVersion;
/** 请求时间,时间戳转时间, 以最后一次为准 */
@Schema(description = "请求时间,传输时间戳,以最后一次为准")
private LocalDateTime reqTime;
/** 错误码 */
@Schema(description = "错误码")
private String errorCode;
/** 错误信息 */
@Schema(description = "错误信息")
private String errorMsg;
}