import { axiosInstance } from '@/api/rbac' import { assertBusinessOk, omsUrl, parseListPayload, unwrapData } from '@/api/oms/common' export interface SystemOtherConfigDto { id?: number | string configCode?: string configName?: string enabled?: boolean baseUrl?: string appKey?: string appSecret?: string timeoutSeconds?: number remark?: string createTime?: string updateTime?: string } export type SystemOtherConfigListParams = { page?: number pageSize?: number keyword?: string } export async function getSystemOtherConfigList(params: SystemOtherConfigListParams) { const res = await axiosInstance.get(omsUrl('/system/other-config/list'), { params }) return parseListPayload(res.data) } export async function getSystemOtherConfigDetail(id: number | string) { const res = await axiosInstance.get(omsUrl('/system/other-config/detail'), { params: { id } }) return unwrapData(res.data) } export async function createSystemOtherConfig( body: Omit ) { const res = await axiosInstance.post(omsUrl('/system/other-config/create'), body) assertBusinessOk(res.data) } export type SystemOtherConfigUpdateBody = Omit & { id: number | string } export async function updateSystemOtherConfig(body: SystemOtherConfigUpdateBody) { const res = await axiosInstance.post(omsUrl('/system/other-config/update'), body) assertBusinessOk(res.data) } export async function deleteSystemOtherConfig(id: number | string) { const res = await axiosInstance.post(omsUrl('/system/other-config/delete'), { id }) assertBusinessOk(res.data) } export type PaymentReceiveQrChannel = 'alipay' | 'wechat' export interface PaymentReceiveQrDto { alipayUrl?: string wechatUrl?: string } /** 获取充值收款码(支付宝 / 微信)可访问地址 */ export async function getPaymentReceiveQr() { const res = await axiosInstance.get(omsUrl('/system/other-config/payment-qr')) return unwrapData(res.data) } /** 上传并替换充值收款码图片 */ export async function uploadPaymentReceiveQr(channel: PaymentReceiveQrChannel, file: File) { const form = new FormData() form.append('channel', channel) form.append('file', file) const res = await axiosInstance.post(omsUrl('/system/other-config/payment-qr/upload'), form, { headers: { 'Content-Type': 'multipart/form-data' }, }) return unwrapData(res.data) } /** 清除指定渠道充值收款码 */ export async function clearPaymentReceiveQr(channel: PaymentReceiveQrChannel) { const res = await axiosInstance.post( omsUrl(`/system/other-config/payment-qr/clear?channel=${encodeURIComponent(channel)}`), ) return unwrapData(res.data) } export type BrandLogoChannel = 'portal' | 'site' | 'favicon' | 'mascot' export interface BrandLogoDto { portalUrl?: string siteUrl?: string faviconUrl?: string mascotUrl?: string } /** 获取品牌 Logo(系统顶栏 / 官网 / 标签 / 吉祥物)可访问地址 */ export async function getBrandLogo() { const res = await axiosInstance.get(omsUrl('/system/other-config/brand-logo')) return unwrapData(res.data) } /** 上传并替换品牌 Logo */ export async function uploadBrandLogo(channel: BrandLogoChannel, file: File) { const form = new FormData() form.append('channel', channel) form.append('file', file) const res = await axiosInstance.post(omsUrl('/system/other-config/brand-logo/upload'), form, { headers: { 'Content-Type': 'multipart/form-data' }, }) return unwrapData(res.data) } /** 清除指定渠道品牌 Logo(前端回退文字 LOGO) */ export async function clearBrandLogo(channel: BrandLogoChannel) { const res = await axiosInstance.post( omsUrl(`/system/other-config/brand-logo/clear?channel=${encodeURIComponent(channel)}`), ) return unwrapData(res.data) } /** 轨迹服务默认配置编码 */ export const TRACK_SERVICE_CONFIG_CODE = 'track_service' /** API 中心(接口通 / itfx)网关 */ export const API_CENTER_CONFIG_CODE = 'api_center' /** 国内揽收开放接口(历史配置;鉴权在 itfx,OMS 不再校验 AppKey) */ export const PICKUP_OPEN_API_CONFIG_CODE = 'pickup_open_api' /** 微信公众号 */ export const WECHAT_MP_CONFIG_CODE = 'wechat_mp' /** 微信公众号关注跳转链接 */ export const WECHAT_MP_FOLLOW_CONFIG_CODE = 'wechat_mp_follow' /** 店铺授权平台配置编码 */ export const PLATFORM_SHOP_CONFIG_CODES = { common: 'platform_shop', tiktok: 'platform_shop_tiktok', temu: 'platform_shop_temu', shopee: 'platform_shop_shopee', lazada: 'platform_shop_lazada', } as const