2026-06-24 f4bd1f3c89d906131495a0aca5aaf82966378510
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package cn.iocoder.yudao.module.pay.service.order;
 
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
 
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
 
/**
 * 支付订单 Service 接口
 *
 * @author aquan
 */
public interface PayOrderService {
 
    /**
     * 获得支付订单
     *
     * @param id 编号
     * @return 支付订单
     */
    PayOrderDO getOrder(Long id);
 
    /**
     * 获得支付订单
     *
     * @param no 支付订单号
     * @return 支付订单
     */
    PayOrderDO getOrder(String no);
 
    /**
     * 获得支付订单
     *
     * @param appId           应用编号
     * @param merchantOrderId 商户订单编号
     * @return 支付订单
     */
    PayOrderDO getOrder(Long appId, String merchantOrderId);
 
    /**
     * 获得支付订单列表
     *
     * @param ids 编号数组
     * @return 支付订单列表
     */
    List<PayOrderDO> getOrderList(Collection<Long> ids);
 
    /**
     * 获得指定应用的订单数量
     *
     * @param appId 应用编号
     * @return 订单数量
     */
    Long getOrderCountByAppId(Long appId);
 
    /**
     * 获得支付订单分页
     *
     * @param pageReqVO 分页查询
     * @return 支付订单分页
     */
    PageResult<PayOrderDO> getOrderPage(PayOrderPageReqVO pageReqVO);
 
    /**
     * 获得支付订单列表, 用于 Excel 导出
     *
     * @param exportReqVO 查询条件
     * @return 支付订单列表
     */
    List<PayOrderDO> getOrderList(PayOrderExportReqVO exportReqVO);
 
    /**
     * 创建支付单
     *
     * @param reqDTO 创建请求
     * @return 支付单编号
     */
    Long createOrder(@Valid PayOrderCreateReqDTO reqDTO);
 
    /**
     * 提交支付
     * 此时,会发起支付渠道的调用
     *
     * @param reqVO  提交请求
     * @param userIp 提交 IP
     * @return 提交结果
     */
    PayOrderSubmitRespVO submitOrder(@Valid PayOrderSubmitReqVO reqVO,
                                     @NotEmpty(message = "提交 IP 不能为空") String userIp);
 
    /**
     * 通知支付单成功
     *
     * @param channelId 渠道编号
     * @param notify    通知
     */
    void notifyOrder(Long channelId, PayOrderRespDTO notify);
 
    /**
     * 更新支付订单的退款金额
     *
     * @param id              编号
     * @param incrRefundPrice 增加的退款金额
     */
    void updateOrderRefundPrice(Long id, Integer incrRefundPrice);
 
    /**
     * 更新支付订单价格
     *
     * @param id 支付单编号
     * @param payPrice   支付单价格
     */
    void updatePayOrderPrice(Long id, Integer payPrice);
 
    /**
     * 获得支付订单
     *
     * @param id 编号
     * @return 支付订单
     */
    PayOrderExtensionDO getOrderExtension(Long id);
 
    /**
     * 获得支付订单
     *
     * @param no 支付订单 no
     * @return 支付订单
     */
    PayOrderExtensionDO getOrderExtensionByNo(String no);
 
    /**
     * 同步订单的支付状态
     *
     * @param minCreateTime 最小创建时间
     * @return 同步到已支付的订单数量
     */
    int syncOrder(LocalDateTime minCreateTime);
 
    /**
     * 同步订单的支付状态
     *
     * 1. Quietly 表示,即使同步失败,也不会抛出异常
     * 2. 什么时候回出现异常?因为是主动同步,可能和支付渠道的异步回调存在并发冲突,导致抛出异常
     *
     * @param id 订单编号
     */
    void syncOrderQuietly(Long id);
 
    /**
     * 将已过期的订单,状态修改为已关闭
     *
     * @return 过期的订单数量
     */
    int expireOrder();
 
}