diff --git a/package.json b/package.json index 8b6a84e..eddb54c 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "release": "pnpm run package && electron-builder --publish always", "lint": "eslint --ext .ts,.tsx .", "typecheck": "tsc --noEmit", - "openapi": "dotenv -e .env -- openapi-ts", + "openapi": "dotenv -e .env -- openapi-ts && node scripts/restore-api-request.mjs", "generate-prod-entry": "node build/scripts/generateProdEntry.js", "clean": "node build/scripts/clean.js", "build:encrypt": "pnpm run clean && pnpm run build:vite && pnpm run package", diff --git a/scripts/restore-api-request.mjs b/scripts/restore-api-request.mjs new file mode 100644 index 0000000..c6f54c9 --- /dev/null +++ b/scripts/restore-api-request.mjs @@ -0,0 +1,36 @@ +#!/usr/bin/env node + +/** + * 在 openapi-ts 生成后恢复 request.ts 文件 + * 解决 openapi-ts-request 的 full 模式会删除整个 serversPath 目录的问题 + */ + +import { copyFileSync, existsSync, mkdirSync } from 'fs'; +import { dirname, resolve } from 'path'; +import { fileURLToPath } from 'url'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const rootDir = resolve(__dirname, '..'); + +const templatePath = resolve(rootDir, 'src/utils/api-request.ts'); +const targetPath = resolve(rootDir, 'src/api/request.ts'); + +console.log('🔄 Restoring request.ts after openapi generation...'); + +// 确保目标目录存在 +const targetDir = dirname(targetPath); +if (!existsSync(targetDir)) { + mkdirSync(targetDir, { recursive: true }); + console.log('📁 Created directory:', targetDir); +} + +// 复制模板文件 +if (existsSync(templatePath)) { + copyFileSync(templatePath, targetPath); + console.log('✅ Restored:', targetPath); +} else { + console.error('❌ Template not found:', templatePath); + process.exit(1); +} + +console.log('🎉 Request file restoration complete!'); diff --git a/src/api/code.ts b/src/api/code.ts new file mode 100644 index 0000000..8658495 --- /dev/null +++ b/src/api/code.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 创建图形验证码 GET /auth/code/image */ +export function authCodeImageUsingGet({ + params, + options, +}: { + // 叠加生成的Param类型 (非body参数openapi默认没有生成对象) + params: API.AuthCodeImageUsingGetParams; + options?: { [key: string]: unknown }; +}) { + return request('/auth/code/image', { + method: 'GET', + params: { + ...params, + }, + ...(options || {}), + }); +} diff --git a/src/api/commodityOrderList.ts b/src/api/commodityOrderList.ts new file mode 100644 index 0000000..8e88016 --- /dev/null +++ b/src/api/commodityOrderList.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 商品订单列表 商品订单列表 POST /order/commodityOrderList */ +export function orderCommodityOrderListUsingPost({ + body, + options, +}: { + body: API.CommodityOrderListSearchForm; + options?: { [key: string]: unknown }; +}) { + return request('/order/commodityOrderList', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} diff --git a/src/api/configChannel.ts b/src/api/configChannel.ts new file mode 100644 index 0000000..fcaf869 --- /dev/null +++ b/src/api/configChannel.ts @@ -0,0 +1,71 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** + * 绑定渠道账号 绑定渠道账号 + * 绑定渠道账号 + * POST /hotelStaff/configChannel/binding + */ +export function hotelStaffConfigChannelBindingUsingPost({ + body, + options, +}: { + body: API.PcConfigChannel; + options?: { [key: string]: unknown }; +}) { + return request('/hotelStaff/configChannel/binding', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} + +/** + * 创建账号渠道 创建账号渠道 + * 创建账号渠道 + * POST /hotelStaff/configChannel/createPcConfigChannel + */ +export function hotelStaffConfigChannelCreatePcConfigChannelUsingPost({ + body, + options, +}: { + body: API.PcConfig; + options?: { [key: string]: unknown }; +}) { + return request( + '/hotelStaff/configChannel/createPcConfigChannel', + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + } + ); +} + +/** + * 查询配置与渠道关系列表 查询配置与渠道关系列表 + * 查询配置与渠道关系列表 + * POST /hotelStaff/configChannel/pageList + */ +export function hotelStaffConfigChannelPageListUsingPost({ + options, +}: { + options?: { [key: string]: unknown }; +}) { + return request( + '/hotelStaff/configChannel/pageList', + { + method: 'POST', + ...(options || {}), + } + ); +} diff --git a/src/api/createEvent.ts b/src/api/createEvent.ts new file mode 100644 index 0000000..ce1f963 --- /dev/null +++ b/src/api/createEvent.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 创建事件 创建事件 POST /event/createEvent */ +export function eventCreateEventUsingPost({ + body, + options, +}: { + body: API.CreateEventForm; + options?: { [key: string]: unknown }; +}) { + return request('/event/createEvent', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} diff --git a/src/api/eventList.ts b/src/api/eventList.ts new file mode 100644 index 0000000..ac8d636 --- /dev/null +++ b/src/api/eventList.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 事件列表 事件列表 POST /event/eventList */ +export function eventEventListUsingPost({ + body, + options, +}: { + body: API.EventListSearchForm; + options?: { [key: string]: unknown }; +}) { + return request('/event/eventList', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..9cd4dd7 --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,14 @@ +/* eslint-disable */ +// @ts-ignore +export * from './types'; + +export * from './code'; +export * from './oauth2'; +export * from './pcUser'; +export * from './configChannel'; +export * from './typeMapping'; +export * from './writeOff'; +export * from './commodityOrderList'; +export * from './userOrderDetail'; +export * from './createEvent'; +export * from './eventList'; diff --git a/src/api/oauth2.ts b/src/api/oauth2.ts new file mode 100644 index 0000000..47e3d68 --- /dev/null +++ b/src/api/oauth2.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 登录 POST /auth/oauth2/token */ +export function authOauth2TokenUsingPost({ + body, + options, +}: { + body: API.AuthOauth2TokenUsingPostBody; + options?: { [key: string]: unknown }; +}) { + return request('/auth/oauth2/token', { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + data: body, + ...(options || {}), + }); +} diff --git a/src/api/pcUser.ts b/src/api/pcUser.ts new file mode 100644 index 0000000..3267468 --- /dev/null +++ b/src/api/pcUser.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 修改pc桌面端平台用户密码 修改pc桌面端平台用户密码 POST /hotelStaff/pcUser/updatePassword */ +export function hotelStaffPcUserUpdatePasswordUsingPost({ + body, + options, +}: { + body: API.UpdatePasswordForm; + options?: { [key: string]: unknown }; +}) { + return request('/hotelStaff/pcUser/updatePassword', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} diff --git a/src/api/request.ts b/src/api/request.ts index be7d2ce..60daefe 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -1,19 +1,54 @@ -import { hostApiFetch } from '../lib/host-api'; +import { hostApiFetch } from '@/lib/host-api'; -type RequestOptions = { +interface RequestOptions { + method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; + headers?: Record; data?: unknown; - headers?: HeadersInit; - method?: string; + params?: Record; [key: string]: unknown; -}; - -export default function request(url: string, options: RequestOptions = {}): Promise { - const { data, method = 'GET', headers, ...rest } = options; - - return hostApiFetch(url, { - ...rest, - method, - headers, - body: data == null ? undefined : data, - }); } + +interface ApiResponse { + code: number; + data: T; + message?: string; +} + +async function request(url: string, options: RequestOptions = {}): Promise { + const { method = 'GET', headers = {}, data, params, ...rest } = options; + + let finalUrl = url; + if (params && Object.keys(params).length > 0) { + const searchParams = new URLSearchParams(); + Object.entries(params).forEach(([key, value]) => { + searchParams.append(key, String(value)); + }); + finalUrl = `${url}?${searchParams.toString()}`; + } + + const init: RequestInit = { + method, + headers: { + 'Content-Type': 'application/json', + ...headers, + }, + }; + + if (data && method !== 'GET') { + init.body = JSON.stringify(data); + } + + const response = await hostApiFetch>(finalUrl, { + ...init, + ...rest, + body: init.body, + }); + + if (response && typeof response === 'object' && 'data' in response) { + return response.data; + } + + return response as T; +} + +export default request; diff --git a/src/api/typeMapping.ts b/src/api/typeMapping.ts index b6c7839..8ecad51 100644 --- a/src/api/typeMapping.ts +++ b/src/api/typeMapping.ts @@ -1,55 +1,71 @@ -import { hostApiFetch } from '../lib/host-api'; -import type * as API from './types'; +/* eslint-disable */ +// @ts-ignore +import request from './request'; -type RequestOptions = { [key: string]: unknown }; +import * as API from './types'; +/** + * 查询房型映射列表 查询房型映射列表 + * 查询房型映射列表 + * POST /hotelStaff/typeMapping/list + */ export function hotelStaffTypeMappingListUsingPost({ body, options, }: { body: API.RoomTypeMapping; - options?: RequestOptions; + options?: { [key: string]: unknown }; }) { - return hostApiFetch('/hotelStaff/typeMapping/list', { + return request('/hotelStaff/typeMapping/list', { method: 'POST', headers: { 'Content-Type': 'application/json', - ...((options?.headers as Record | undefined) ?? {}), }, - body: JSON.stringify(body), + data: body, + ...(options || {}), }); } +/** + * 分页查询房型映射列表 查询房型映射列表 + * 查询房型映射列表 + * POST /hotelStaff/typeMapping/pageList + */ export function hotelStaffTypeMappingPageListUsingPost({ body, options, }: { body: API.RoomTypeMapping; - options?: RequestOptions; + options?: { [key: string]: unknown }; }) { - return hostApiFetch('/hotelStaff/typeMapping/pageList', { + return request('/hotelStaff/typeMapping/pageList', { method: 'POST', headers: { 'Content-Type': 'application/json', - ...((options?.headers as Record | undefined) ?? {}), }, - body: JSON.stringify(body), + data: body, + ...(options || {}), }); } +/** + * 修改房型映射 修改房型映射 + * 修改房型映射 + * POST /hotelStaff/typeMapping/update + */ export function hotelStaffTypeMappingUpdateUsingPost({ body, options, }: { body: API.RoomTypeMapping; - options?: RequestOptions; + options?: { [key: string]: unknown }; }) { - return hostApiFetch('/hotelStaff/typeMapping/update', { + return request('/hotelStaff/typeMapping/update', { method: 'POST', headers: { 'Content-Type': 'application/json', - ...((options?.headers as Record | undefined) ?? {}), }, - body: JSON.stringify(body), + data: body, + ...(options || {}), }); } diff --git a/src/api/types.ts b/src/api/types.ts index 516d076..e6627b7 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -1,8 +1,319 @@ +/* eslint-disable */ +// @ts-ignore + +export type AuthCodeImageUsingGetParams = { + randomStr?: string; +}; + +export type AuthCodeImageUsingGetResponse = Record; + +export type AuthCodeImageUsingGetResponses = { + 200: AuthCodeImageUsingGetResponse; +}; + +export type AuthOauth2TokenUsingPostBody = { + openIdCode?: unknown[]; + grant_type?: string; + scope?: string; + clientId: string; +}; + +export type AuthOauth2TokenUsingPostResponse = Record; + +export type AuthOauth2TokenUsingPostResponses = { + 200: AuthOauth2TokenUsingPostResponse; +}; + +export type CommodityEquipmentDTO = { + /** 设施图标 */ + icon?: string; + /** 设施标题 */ + title?: string; + /** 设施描述 */ + desc?: string[]; +}; + +export type CommodityOrderDTO = { + /** 订单号 */ + id?: string; + /** 订单金额 */ + orderAmt?: string; + /** 游客姓名 */ + visitorName?: string; + /** 联系电话 */ + contactPhone?: string; + /** 入住时间(yyyy-MM-dd) */ + checkInData?: string; + /** 离店时间(yyyy-MM-dd) */ + checkOutData?: string; + /** + * 订单状态 + * 0-待支付 + * 1-待确认 + * 2-待使用 + * 3-已取消 + * 4-退款中 + * 5-已关闭 + * 6-已完成 + * 订单状态 0-待支付 1-待确认 2-待使用 3-已取消 4-退款中 5-已关闭 6-已完成 + */ + orderStatus?: string; + /** 用户id */ + userId?: string; + /** 组织id */ + organizationId?: string; + /** + * 支付状态 + * 0-未支付 + * 1-已支付 + * 支付状态 0-未支付 1-已支付 + */ + payStatus?: string; + /** 支付金额 */ + payAmt?: string; + /** 优惠金额 */ + discountAmt?: string; + /** 支付时间 */ + payTime?: string; + /** + * 订单类型 + * 0-酒店 + * 1-门票 + * 2-餐饮 + */ + orderType?: string; + /** 创建时间 */ + createTime?: string; + /** 房间确认后的房间号 */ + roomId?: string; + /** 商品信息 */ + commodityName?: string; +}; + +export type CommodityOrderInfoWriteOffForm = { + /** 订单号 */ + orderId?: string; + /** 套餐名称 */ + packageName?: string; +}; + +export type CommodityOrderListSearchForm = { + /** 页码 */ + pageNum: number; + /** 页面数量 */ + pageSize: number; + /** + * 商品类型编码0-酒店 + * 1-门票 + * 2-餐饮 + */ + commodityTypeCode?: string; + /** 订单状态 */ + orderStatus?: string; + /** 创建时间的开始时间(yyyy-MM-dd) */ + orderCreateTimeStartDate?: string; + /** 创建时间的结束时间(yyyy-MM-dd) */ + orderCreateTimeEndDate?: string; + /** 房间号 */ + roomId?: string; + /** 订单号 */ + orderId?: string; + /** 联系电话 */ + contactPhone?: string; + /** 组织id */ + organizationId: string; +}; + +export type CommodityPackageConfigDTO = { + /** 套餐商品名称 */ + name?: string; + /** 商品数量 */ + count?: number; + /** 商品颜色 */ + color?: string; + /** 套餐状态 0 未核销 1 已核销 */ + packageStatus?: number; +}; + +export type CommodityPurchaseInstructionModuleEntity = { + /** 模块标题 */ + moduleTitle?: string; + /** 模块图标 */ + moduleIcon?: string; + /** 模块内容 */ + moduleContent?: string; +}; + +export type CommodityPurchaseInstructionTemplateDTO = { + /** 模板id */ + templateId?: string; + /** 模板名称 */ + templateName?: string; + /** 一级标题 */ + templateTitle?: string; + /** 退款标题 */ + refundTitle?: string; + /** 退款logo */ + refundLogo?: string; + /** 退款内容(退款政策) */ + refundContent?: string; + /** 购买须知的内容 */ + commodityPurchaseInstructionModuleEntityList?: CommodityPurchaseInstructionModuleEntity[]; +}; + +export type CommodityServiceEntity = { + /** 服务项名称 */ + serviceTitle?: string; + /** 分组名称 */ + groupName?: string; + /** 服务份数 */ + serviceAmount?: string; +}; + +export type ConsumerInfoEntity = { + /** 游客姓名 */ + visitorName?: string; + /** 联系电话 */ + contactPhone?: string; +}; + +export type CreateEventForm = { + /** 实体名称 */ + entityName?: string; + /** 事件描述 */ + eventDescription?: string; + /** 发布员工名称 */ + createByName?: string; + /** 弹窗提醒 0-否 1-是 */ + popUpReminder?: number; + /** 发布时间(yyyy-MM-dd HH:mm:ss) */ + publicTime?: string; + /** 事件生效开始时间(yyyy-MM-dd HH:mm:ss) */ + effectiveStartTime?: string; + /** 事件生效结束时间(yyyy-MM-dd HH:mm:ss) */ + effectiveEndTime?: string; +}; + +export type EventCreateEventUsingPostResponses = { + 200: RBoolean; +}; + +export type EventDataDTO = { + /** 主键id */ + id?: string; + /** 实体名称 */ + entityName?: string; + /** 事件描述 */ + eventDescription?: string; + /** 事件状态 0-开启 1-关闭 */ + eventStatus?: number; + /** 事件生效开始时间 */ + effectiveStartTime?: string; + /** 事件生效结束时间 */ + effectiveEndTime?: string; + /** 发布员工名称 */ + createByName?: string; + /** 弹窗提醒 0-否 1-是 */ + popUpReminder?: number; + /** 发布时间 */ + publicTime?: string; + /** 显示状态 待生效 生效中 已过期 */ + showStatusDesc?: string; +}; + +export type EventEventListUsingPostResponses = { + 200: RPageEventDataDTO; +}; + +export type EventListSearchForm = { + /** 页码 */ + pageNum: number; + /** 页面数量 */ + pageSize: number; + /** 实体名称 */ + entityName?: string; + /** 事件状态 0-开启 1-关闭 */ + eventStatus?: number; +}; + +export type HotelStaffConfigChannelBindingUsingPostResponses = { + 200: RBoolean; +}; + +export type HotelStaffConfigChannelCreatePcConfigChannelUsingPostResponses = { + 200: RBoolean; +}; + +export type HotelStaffConfigChannelPageListUsingPostResponses = { + 200: RListPcConfigChannel; +}; + +export type HotelStaffPcUserUpdatePasswordUsingPostResponses = { + 200: RBoolean; +}; + +export type HotelStaffTypeMappingListUsingPostResponses = { + 200: RListRoomTypeMapping; +}; + +export type HotelStaffTypeMappingPageListUsingPostResponses = { + 200: RPageRoomTypeMapping; +}; + +export type HotelStaffTypeMappingUpdateUsingPostResponses = { + 200: RBoolean; +}; + +export type OpenDateRangeDTO = { + /** 起始时间 */ + begin?: string; + /** 结束时间 */ + end?: string; +}; + +export type OrderCommodityOrderListUsingPostResponses = { + 200: RPageCommodityOrderDTO; +}; + export type OrderItem = { column?: string; asc?: boolean; }; +export type OrderUserOrderDetailUsingPostResponses = { + 200: RUserOrderDetailDTO; +}; + +export type OrderWriteOffUsingPostResponses = { + 200: RBoolean; +}; + +export type PageCommodityOrderDTO = { + records?: CommodityOrderDTO[]; + total?: number; + size?: number; + current?: number; + orders?: OrderItem[]; + optimizeCountSql?: boolean; + searchCount?: boolean; + optimizeJoinOfCountSql?: boolean; + maxLimit?: number; + countId?: string; +}; + +export type PageEventDataDTO = { + records?: EventDataDTO[]; + total?: number; + size?: number; + current?: number; + orders?: OrderItem[]; + optimizeCountSql?: boolean; + searchCount?: boolean; + optimizeJoinOfCountSql?: boolean; + maxLimit?: number; + countId?: string; +}; + export type PageRoomTypeMapping = { records?: RoomTypeMapping[]; total?: number; @@ -16,22 +327,73 @@ export type PageRoomTypeMapping = { countId?: string; }; -export type RoomTypeMapping = { +export type PcConfig = { + /** + * 创建者 + * 创建人 + */ createBy?: string; + /** 创建时间 */ createTime?: string; + /** + * 更新者 + * 更新人 + */ updateBy?: string; + /** 更新时间 */ updateTime?: string; + /** 主键 */ id?: string; - pmsName?: string; - xcName?: string; - fzName?: string; - mtName?: string; - dyHotelName?: string; - dyHotSrpingName?: string; - dyHotSpringName?: string; + /** 配置信息id */ pcConfigId?: string; + /** 账号id */ + platformUserId?: string; + /** 租户id */ + tenantId?: number; + /** 组织id */ + organizationId?: string; + /** 删除标志 true/false 删除/未删除 */ delFlag?: number; + /** 分页数量 */ size?: number; + /** 分页标识 从1开始 */ + current?: number; +}; + +export type PcConfigChannel = { + /** + * 创建者 + * 创建人 + */ + createBy?: string; + /** 创建时间 */ + createTime?: string; + /** + * 更新者 + * 更新人 + */ + updateBy?: string; + /** 更新时间 */ + updateTime?: string; + /** 主键 */ + id?: string; + /** 配置信息id */ + pcConfigId?: string; + /** 系统渠道id */ + systemChannelId?: string; + /** 是否绑定 0未绑定 1已绑定 */ + bindingFlag?: number; + /** 绑定账号 */ + bindingUsername?: string; + /** 绑定密码 */ + bindingPassword?: string; + /** 当前登录token信息 */ + loginToken?: string; + /** 删除标志 true/false 删除/未删除 */ + delFlag?: number; + /** 分页数量 */ + size?: number; + /** 分页标识 从1开始 */ current?: number; }; @@ -41,14 +403,199 @@ export type RBoolean = { data?: boolean; }; +export type RListPcConfigChannel = { + code?: number; + msg?: string; + data?: PcConfigChannel[]; +}; + export type RListRoomTypeMapping = { code?: number; msg?: string; data?: RoomTypeMapping[]; }; +export type RoomTypeMapping = { + /** + * 创建者 + * 创建人 + */ + createBy?: string; + /** 创建时间 */ + createTime?: string; + /** + * 更新者 + * 更新人 + */ + updateBy?: string; + /** 更新时间 */ + updateTime?: string; + /** 主键 */ + id?: string; + /** pms名称 */ + pmsName?: string; + /** 携程渠道名称 */ + xcName?: string; + /** 飞猪渠道名称 */ + fzName?: string; + /** 美团渠道名称 */ + mtName?: string; + /** 抖音酒店渠道名称 */ + dyHotelName?: string; + /** 抖音温泉渠道名称 */ + dyHotSrpingName?: string; + /** 配置信息id */ + pcConfigId?: string; + /** 删除标志 true/false 删除/未删除 */ + delFlag?: number; + /** 分页数量 */ + size?: number; + /** 分页标识 从1开始 */ + current?: number; +}; + +export type RPageCommodityOrderDTO = { + code?: number; + msg?: string; + data?: PageCommodityOrderDTO; +}; + +export type RPageEventDataDTO = { + code?: number; + msg?: string; + data?: PageEventDataDTO; +}; + export type RPageRoomTypeMapping = { code?: number; msg?: string; data?: PageRoomTypeMapping; }; + +export type RUserOrderDetailDTO = { + code?: number; + msg?: string; + data?: UserOrderDetailDTO; +}; + +export type UpdatePasswordForm = { + /** 旧密码 */ + oldPassword?: string; + /** 新密码 */ + newPassword?: string; +}; + +export type UserOrderDetailDTO = { + /** 订单id */ + orderId?: string; + /** 订单金额 */ + orderAmt?: string; + /** 消费者信息 */ + consumerInfoList?: ConsumerInfoEntity[]; + /** 入住时间(yyyy-MM-dd) */ + checkInData?: string; + /** 离店时间(yyyy-MM-dd) */ + checkOutData?: string; + /** + * 订单状态 + * 0-待支付 + * 1-待确认 + * 2-待使用 + * 3-已取消 + * 4-退款中 + * 5-已关闭 + * 6-已完成 + * 订单状态 0-待支付 1-待确认 2-待使用 3-已取消 4-退款中 5-已关闭 6-已完成 + */ + orderStatus?: string; + /** 用户id */ + userId?: string; + /** 组织id */ + organizationId?: string; + /** + * 支付状态 + * 0-未支付 + * 1-已支付 + * 支付状态 0-未支付 1-已支付 + */ + payStatus?: string; + /** 支付金额 */ + payAmt?: string; + /** 优惠金额 */ + discountAmt?: string; + /** + * 支付时间 + * 支付时间(yyyy-MM-dd HH:mm:ss) + */ + payTime?: string; + /** 创建时间 */ + createTime?: string; + /** 商品封面图片 */ + commodityCoverPhoto?: string; + /** 商品核销地址 */ + writeOffUrl?: string; + /** 商品名称 */ + commodityName?: string; + /** 商品地址 */ + commodityAddress?: string; + /** 商品纬度 */ + commodityLatitude?: string; + /** 商品经度 */ + commodityLongitude?: string; + /** 商品服务项列表 */ + commodityServiceList?: CommodityServiceEntity[]; + /** 商品购买须知 */ + commodityTip?: string; + /** 支付方式 0-微信 1-支付宝 2-云闪付 */ + payWay?: string; + /** 支付流水号 */ + paySerialNumber?: string; + /** 支付渠道 0-app 1-小程序 2-h5 */ + paySource?: string; + /** + * 订单类型 + * 0-酒店 + * 1-门票 + * 2-餐饮 + */ + orderType?: string; + /** 购买数量 */ + commodityAmount?: string; + /** 退款单号 */ + refundOrderNo?: string; + /** 门店名称 */ + storeName?: string; + /** 投诉电话 */ + complaintHotline?: string; + /** 一级地址 */ + oneLevelAddress?: string; + /** 二级地址 */ + twoLevelAddress?: string; + /** 是否可退款 */ + refundable?: boolean; + /** 商品购买须知的内容 */ + commodityPurchaseInstruction?: CommodityPurchaseInstructionTemplateDTO; + /** 商品id */ + commodityId?: string; + /** 商品分类的编码 */ + commodityTypeCode?: string; + /** 商品权益列表 */ + commodityFacilityList?: string[]; + /** 设施列表 */ + commodityEquipment?: CommodityEquipmentDTO[]; + /** 商品描述 */ + commodityDescription?: string; + /** 套餐内容配置 */ + commodityPackageConfig?: CommodityPackageConfigDTO[]; + /** 是否启用预约(0-否 1-是) */ + reservationEnabled?: number; + /** 开放日期范围 */ + openDateRange?: OpenDateRangeDTO[]; + /** 预约规则说明 */ + reservationRuleDesc?: string; +}; + +export type UserOrderDetailSearchForm = { + /** 订单id */ + orderId?: string; +}; diff --git a/src/api/userOrderDetail.ts b/src/api/userOrderDetail.ts new file mode 100644 index 0000000..e3967d9 --- /dev/null +++ b/src/api/userOrderDetail.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 获取订单详情 获取订单详情 POST /order/userOrderDetail */ +export function orderUserOrderDetailUsingPost({ + body, + options, +}: { + body: API.UserOrderDetailSearchForm; + options?: { [key: string]: unknown }; +}) { + return request('/order/userOrderDetail', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} diff --git a/src/api/writeOff.ts b/src/api/writeOff.ts new file mode 100644 index 0000000..3089fae --- /dev/null +++ b/src/api/writeOff.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 核销订单 核销订单 POST /order/writeOff */ +export function orderWriteOffUsingPost({ + body, + options, +}: { + body: API.CommodityOrderInfoWriteOffForm; + options?: { [key: string]: unknown }; +}) { + return request('/order/writeOff', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} diff --git a/src/utils/api-request.ts b/src/utils/api-request.ts new file mode 100644 index 0000000..60daefe --- /dev/null +++ b/src/utils/api-request.ts @@ -0,0 +1,54 @@ +import { hostApiFetch } from '@/lib/host-api'; + +interface RequestOptions { + method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; + headers?: Record; + data?: unknown; + params?: Record; + [key: string]: unknown; +} + +interface ApiResponse { + code: number; + data: T; + message?: string; +} + +async function request(url: string, options: RequestOptions = {}): Promise { + const { method = 'GET', headers = {}, data, params, ...rest } = options; + + let finalUrl = url; + if (params && Object.keys(params).length > 0) { + const searchParams = new URLSearchParams(); + Object.entries(params).forEach(([key, value]) => { + searchParams.append(key, String(value)); + }); + finalUrl = `${url}?${searchParams.toString()}`; + } + + const init: RequestInit = { + method, + headers: { + 'Content-Type': 'application/json', + ...headers, + }, + }; + + if (data && method !== 'GET') { + init.body = JSON.stringify(data); + } + + const response = await hostApiFetch>(finalUrl, { + ...init, + ...rest, + body: init.body, + }); + + if (response && typeof response === 'object' && 'data' in response) { + return response.data; + } + + return response as T; +} + +export default request;