| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- import request from "@/utils/request";
- const API_PATH = "/payment/batch";
- /** 制单授权记录(后端 BatchAuthorizeEntity,全局 SNAKE_CASE 序列化) */
- export interface BatchAuthorizeVO {
- /** 雪花ID序列化为字符串(后端 @JsonSerialize(ToStringSerializer)),防止 JS 精度丢失 */
- id?: string;
- out_biz_no: string;
- status: string;
- agreement_no?: string;
- authorize_link?: string;
- participant_id: string;
- participant_id_type?: string;
- /**
- * 个人账号(ALIPAY_LOGON_ID)主体扫码授权获取的支付宝账号ID(2088 开头)— 制单时付款方 identity 用(ALIPAY_USER_ID)。
- * 注: 本应用未开通支付宝 open_id 能力(user.info.share 响应实证),故不用 open_id 体系
- */
- alipay_user_id?: string;
- /** 主体名称(表单录入,同时作为授权申请 principal_info.name) */
- participant_name?: string;
- /** 服务商(表单下拉选择,授权申请 client 解析依据) */
- service_provider_id?: number;
- authorize_expire_time?: string;
- created_time?: string;
- }
- /**
- * 分页结果类型 — 后端 PageResult 全局 SNAKE_CASE 序列化后 JSON key 为 `list`
- * (全局 PageResult<T> 类型声明为 items,与后端契约不符,本模块以后端实际契约为准,
- * 保留 items 兼容字段以支持 `?.items ?? ?.list ?? []` 双保险解包,与存量 index.vue 一致)
- */
- export interface BatchPageResult<T> {
- items?: T;
- list: T;
- total: number;
- page_no: number;
- page_size: number;
- }
- /** 批次(后端 BatchOrderEntity) */
- export interface BatchOrderVO {
- out_batch_no: string;
- batch_trans_id?: string;
- total_amount: string;
- total_count: number;
- order_title?: string;
- /** INIT=受理中 / WAIT_PAY=等待支付 / SUCCESS=成功 / DISUSE=已关闭 / FAIL=失败 / INVALID=无效 */
- status: string;
- created_time?: string;
- pay_url?: 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 {
- /** 付款主体(授权主体支付宝账号/uid/openid,制单时从已授权主体选择;后端按主体类型映射制单 identity) */
- participant_id: string;
- order_title: 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 = {
- /** 生成制单授权链接(账号级: 主体信息来自表单,服务商下拉选择) */
- authorizeApply(data: {
- participant_name: string;
- participant_id: string;
- /** 主体类型: ALIPAY_USER_ID 支付宝账号ID(默认) / ALIPAY_LOGON_ID 登录号 / ALIPAY_OPEN_ID OpenID */
- participant_id_type?: string;
- service_provider_id: number;
- }) {
- return request<ApiResponse<{ authorize_link: string; out_biz_no: string; status: string }>>({
- url: `${API_PATH}/authorize/apply`,
- method: "post",
- data,
- });
- },
- /** 制单授权重新生成:作废当前 AUTHING 申请(旧链接失效),换新 out_biz_no 重新申请 */
- authorizeRebind(id: string) {
- return request<ApiResponse<{ authorize_link: string; out_biz_no: string; status: string }>>({
- url: `${API_PATH}/authorize/rebind`,
- method: "post",
- data: { id },
- });
- },
- /** 查询制单授权状态(AUTHED 时回写协议号) */
- queryAuthorize(outBizNo: string) {
- return request<ApiResponse<{ agreement_no: string; status: string }>>({
- url: `${API_PATH}/authorize/query`,
- method: "get",
- params: { out_biz_no: outBizNo },
- });
- },
- /** 生成 user.info.share OAuth 授权链接(LOGON_ID 主体扫码获取支付宝ID 制单用)— 前端新窗口打开 */
- openidAuthorizeUrl(id: string) {
- return request<ApiResponse<string>>({
- url: `${API_PATH}/authorize/openid/url`,
- method: "get",
- params: { id },
- });
- },
- /** 制单授权记录(分页,可按主体筛选) */
- authorizeList(params: { participant_id?: string; page_no?: number; page_size?: number }) {
- return request<ApiResponse<BatchPageResult<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(outBatchNo: string) {
- return request<ApiResponse<{ pay_url: string }>>({
- url: `${API_PATH}/pay`,
- method: "post",
- data: { out_batch_no: outBatchNo },
- });
- },
- /** 查询批次状态(同步支付宝并回写 DB) */
- batchQuery(outBatchNo: string) {
- return request<ApiResponse<{ out_batch_no: string; status: string }>>({
- url: `${API_PATH}/query`,
- method: "get",
- params: { out_batch_no: outBatchNo },
- });
- },
- /** 关闭未支付批次 */
- batchClose(outBatchNo: string) {
- return request<ApiResponse<{ status: string }>>({
- url: `${API_PATH}/close`,
- method: "post",
- data: { out_batch_no: outBatchNo },
- });
- },
- /** 批次列表(分页,主体/状态/时间筛选) */
- batchList(params: {
- participant_id?: string;
- status?: string;
- start_time?: string;
- end_time?: string;
- page_no?: number;
- page_size?: number;
- }) {
- return request<ApiResponse<BatchPageResult<BatchOrderVO[]>>>({
- url: `${API_PATH}/list`,
- method: "get",
- params,
- });
- },
- /** 批次详情 + 明细分页(租户隔离由后端拦截器自动追加) */
- batchDetail(outBatchNo: string, pageNo = 1, pageSize = 20) {
- return request<ApiResponse<{ order: BatchOrderVO; details: BatchPageResult<BatchDetailItem[]> }>>({
- url: `${API_PATH}/detail`,
- method: "get",
- params: {
- out_batch_no: outBatchNo,
- page_no: pageNo,
- page_size: pageSize,
- },
- });
- },
- /** 批次报表导出(xlsx 下载,接口直出字节流非 Result 包装) */
- batchExport(params: {
- participant_id?: string;
- status?: string;
- start_time?: string;
- end_time?: string;
- }) {
- return request({
- url: `${API_PATH}/export`,
- method: "get",
- params,
- responseType: "blob",
- });
- },
- };
- export default BatchPayAPI;
|