| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- import request from "@/utils/request";
- const API_PATH = "/payment/account/batch";
- /** 制单授权记录(后端 BatchAuthorizeEntity,全局 SNAKE_CASE 序列化) */
- export interface BatchAuthorizeVO {
- out_biz_no: string;
- status: string;
- agreement_no?: string;
- authorize_link?: string;
- participant_id: string;
- participant_id_type?: string;
- authorize_expire_time?: string;
- created_time?: string;
- }
- /** 批次(后端 BatchOrderEntity) */
- export interface BatchOrderVO {
- out_batch_no: string;
- batch_trans_id?: string;
- total_amount: string;
- total_count: number;
- order_title?: string;
- /** INIT / SUCCESS / DISUSE / FAIL */
- status: string;
- created_time?: string;
- pay_url?: string;
- enterprise_id?: string;
- payer_uid?: string;
- agreement_no?: string;
- transfer_scene_name?: string;
- time_expire?: string;
- remark?: string;
- error_code?: string;
- error_msg?: string;
- }
- /** 批次明细(后端 BatchDetailEntity) */
- export interface BatchDetailItem {
- out_biz_no: string;
- amount: string;
- remark?: string;
- payee_identity: string;
- /** ALIPAY_LOGON_ID / ALIPAY_USER_ID / ALIPAY_OPEN_ID(默认 LOGON_ID) */
- payee_identity_type?: string;
- payee_name?: string;
- status?: string;
- error_code?: string;
- error_msg?: string;
- }
- /** 创建批次请求体(BatchCreateDTO,snake_case) */
- export interface BatchCreateParams {
- enterprise_id?: string;
- order_title: string;
- payer_uid: string;
- agreement_no?: string;
- transfer_scene_name?: string;
- transfer_scene_report_infos?: Array<{ info_type: string; info_content: string }>;
- time_expire?: string;
- remark?: string;
- details: BatchDetailItem[];
- }
- export const BatchPayAPI = {
- /** 生成制单授权链接(PC 渠道,付款方 UID 必须 2088 开头) */
- authorizeApply(enterpriseId: string, participantId: string) {
- return request<ApiResponse<{ authorize_link: string; out_biz_no: string; status: string }>>({
- url: `${API_PATH}/authorize/apply`,
- method: "post",
- data: { enterprise_id: enterpriseId, participant_id: participantId },
- });
- },
- /** 查询制单授权状态(AUTHED 时回写协议号) */
- queryAuthorize(enterpriseId: string, outBizNo: string) {
- return request<ApiResponse<{ agreement_no: string; status: string }>>({
- url: `${API_PATH}/authorize/query`,
- method: "get",
- params: { enterprise_id: enterpriseId, out_biz_no: outBizNo },
- });
- },
- /** 制单授权记录(分页) */
- authorizeList(params: { enterprise_id?: string; page_no?: number; page_size?: number }) {
- return request<ApiResponse<PageResult<BatchAuthorizeVO[]>>>({
- url: `${API_PATH}/authorize/list`,
- method: "get",
- params,
- });
- },
- /** 创建批次(幂等键 out_batch_no 由后端生成) */
- batchCreate(data: BatchCreateParams) {
- return request<ApiResponse<{ out_batch_no: string; batch_trans_id: string; status: string }>>({
- url: `${API_PATH}/create`,
- method: "post",
- data,
- });
- },
- /** 生成 PC 支付页面 — pageExecute 返回 HTML 表单(与充值/签约同款处理) */
- renderPay(enterpriseId: string, outBatchNo: string) {
- return request<ApiResponse<{ pay_url: string }>>({
- url: `${API_PATH}/pay`,
- method: "post",
- data: { enterprise_id: enterpriseId, out_batch_no: outBatchNo },
- });
- },
- /** 查询批次状态(同步支付宝并回写 DB) */
- batchQuery(enterpriseId: string, outBatchNo: string) {
- return request<ApiResponse<{ out_batch_no: string; status: string }>>({
- url: `${API_PATH}/query`,
- method: "get",
- params: { enterprise_id: enterpriseId, out_batch_no: outBatchNo },
- });
- },
- /** 关闭未支付批次 */
- batchClose(enterpriseId: string, outBatchNo: string) {
- return request<ApiResponse<{ status: string }>>({
- url: `${API_PATH}/close`,
- method: "post",
- data: { enterprise_id: enterpriseId, out_batch_no: outBatchNo },
- });
- },
- /** 批次列表(分页,状态/时间筛选) */
- batchList(params: {
- enterprise_id?: string;
- status?: string;
- start_time?: string;
- end_time?: string;
- page_no?: number;
- page_size?: number;
- }) {
- return request<ApiResponse<PageResult<BatchOrderVO[]>>>({
- url: `${API_PATH}/list`,
- method: "get",
- params,
- });
- },
- /** 批次详情 + 明细分页(后端要求 enterprise_id 租户隔离) */
- batchDetail(enterpriseId: string, outBatchNo: string, pageNo = 1, pageSize = 20) {
- return request<ApiResponse<{ order: BatchOrderVO; details: PageResult<BatchDetailItem[]> }>>({
- url: `${API_PATH}/detail`,
- method: "get",
- params: {
- enterprise_id: enterpriseId,
- out_batch_no: outBatchNo,
- page_no: pageNo,
- page_size: pageSize,
- },
- });
- },
- /** 批次报表导出(xlsx 下载,接口直出字节流非 Result 包装) */
- batchExport(params: {
- enterprise_id?: string;
- status?: string;
- start_time?: string;
- end_time?: string;
- }) {
- return request({
- url: `${API_PATH}/export`,
- method: "get",
- params,
- responseType: "blob",
- });
- },
- };
- export default BatchPayAPI;
|