batch.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import request from "@/utils/request";
  2. const API_PATH = "/payment/account/batch";
  3. /** 制单授权记录(后端 BatchAuthorizeEntity,全局 SNAKE_CASE 序列化) */
  4. export interface BatchAuthorizeVO {
  5. out_biz_no: string;
  6. status: string;
  7. agreement_no?: string;
  8. authorize_link?: string;
  9. participant_id: string;
  10. participant_id_type?: string;
  11. authorize_expire_time?: string;
  12. created_time?: string;
  13. }
  14. /** 批次(后端 BatchOrderEntity) */
  15. export interface BatchOrderVO {
  16. out_batch_no: string;
  17. batch_trans_id?: string;
  18. total_amount: string;
  19. total_count: number;
  20. order_title?: string;
  21. /** INIT / SUCCESS / DISUSE / FAIL */
  22. status: string;
  23. created_time?: string;
  24. pay_url?: string;
  25. enterprise_id?: string;
  26. payer_uid?: string;
  27. agreement_no?: string;
  28. transfer_scene_name?: string;
  29. time_expire?: string;
  30. remark?: string;
  31. error_code?: string;
  32. error_msg?: string;
  33. }
  34. /** 批次明细(后端 BatchDetailEntity) */
  35. export interface BatchDetailItem {
  36. out_biz_no: string;
  37. amount: string;
  38. remark?: string;
  39. payee_identity: string;
  40. /** ALIPAY_LOGON_ID / ALIPAY_USER_ID / ALIPAY_OPEN_ID(默认 LOGON_ID) */
  41. payee_identity_type?: string;
  42. payee_name?: string;
  43. status?: string;
  44. error_code?: string;
  45. error_msg?: string;
  46. }
  47. /** 创建批次请求体(BatchCreateDTO,snake_case) */
  48. export interface BatchCreateParams {
  49. enterprise_id?: string;
  50. order_title: string;
  51. payer_uid: string;
  52. agreement_no?: string;
  53. transfer_scene_name?: string;
  54. transfer_scene_report_infos?: Array<{ info_type: string; info_content: string }>;
  55. time_expire?: string;
  56. remark?: string;
  57. details: BatchDetailItem[];
  58. }
  59. export const BatchPayAPI = {
  60. /** 生成制单授权链接(PC 渠道,付款方 UID 必须 2088 开头) */
  61. authorizeApply(enterpriseId: string, participantId: string) {
  62. return request<ApiResponse<{ authorize_link: string; out_biz_no: string; status: string }>>({
  63. url: `${API_PATH}/authorize/apply`,
  64. method: "post",
  65. data: { enterprise_id: enterpriseId, participant_id: participantId },
  66. });
  67. },
  68. /** 查询制单授权状态(AUTHED 时回写协议号) */
  69. queryAuthorize(enterpriseId: string, outBizNo: string) {
  70. return request<ApiResponse<{ agreement_no: string; status: string }>>({
  71. url: `${API_PATH}/authorize/query`,
  72. method: "get",
  73. params: { enterprise_id: enterpriseId, out_biz_no: outBizNo },
  74. });
  75. },
  76. /** 制单授权记录(分页) */
  77. authorizeList(params: { enterprise_id?: string; page_no?: number; page_size?: number }) {
  78. return request<ApiResponse<PageResult<BatchAuthorizeVO[]>>>({
  79. url: `${API_PATH}/authorize/list`,
  80. method: "get",
  81. params,
  82. });
  83. },
  84. /** 创建批次(幂等键 out_batch_no 由后端生成) */
  85. batchCreate(data: BatchCreateParams) {
  86. return request<ApiResponse<{ out_batch_no: string; batch_trans_id: string; status: string }>>({
  87. url: `${API_PATH}/create`,
  88. method: "post",
  89. data,
  90. });
  91. },
  92. /** 生成 PC 支付页面 — pageExecute 返回 HTML 表单(与充值/签约同款处理) */
  93. renderPay(enterpriseId: string, outBatchNo: string) {
  94. return request<ApiResponse<{ pay_url: string }>>({
  95. url: `${API_PATH}/pay`,
  96. method: "post",
  97. data: { enterprise_id: enterpriseId, out_batch_no: outBatchNo },
  98. });
  99. },
  100. /** 查询批次状态(同步支付宝并回写 DB) */
  101. batchQuery(enterpriseId: string, outBatchNo: string) {
  102. return request<ApiResponse<{ out_batch_no: string; status: string }>>({
  103. url: `${API_PATH}/query`,
  104. method: "get",
  105. params: { enterprise_id: enterpriseId, out_batch_no: outBatchNo },
  106. });
  107. },
  108. /** 关闭未支付批次 */
  109. batchClose(enterpriseId: string, outBatchNo: string) {
  110. return request<ApiResponse<{ status: string }>>({
  111. url: `${API_PATH}/close`,
  112. method: "post",
  113. data: { enterprise_id: enterpriseId, out_batch_no: outBatchNo },
  114. });
  115. },
  116. /** 批次列表(分页,状态/时间筛选) */
  117. batchList(params: {
  118. enterprise_id?: string;
  119. status?: string;
  120. start_time?: string;
  121. end_time?: string;
  122. page_no?: number;
  123. page_size?: number;
  124. }) {
  125. return request<ApiResponse<PageResult<BatchOrderVO[]>>>({
  126. url: `${API_PATH}/list`,
  127. method: "get",
  128. params,
  129. });
  130. },
  131. /** 批次详情 + 明细分页(后端要求 enterprise_id 租户隔离) */
  132. batchDetail(enterpriseId: string, outBatchNo: string, pageNo = 1, pageSize = 20) {
  133. return request<ApiResponse<{ order: BatchOrderVO; details: PageResult<BatchDetailItem[]> }>>({
  134. url: `${API_PATH}/detail`,
  135. method: "get",
  136. params: {
  137. enterprise_id: enterpriseId,
  138. out_batch_no: outBatchNo,
  139. page_no: pageNo,
  140. page_size: pageSize,
  141. },
  142. });
  143. },
  144. /** 批次报表导出(xlsx 下载,接口直出字节流非 Result 包装) */
  145. batchExport(params: {
  146. enterprise_id?: string;
  147. status?: string;
  148. start_time?: string;
  149. end_time?: string;
  150. }) {
  151. return request({
  152. url: `${API_PATH}/export`,
  153. method: "get",
  154. params,
  155. responseType: "blob",
  156. });
  157. },
  158. };
  159. export default BatchPayAPI;