104 lines
2.8 KiB
TypeScript
104 lines
2.8 KiB
TypeScript
|
|
import { http } from '@/lib/http'
|
||
|
|
|
||
|
|
export interface OpsMediaSupplyResource {
|
||
|
|
id: number
|
||
|
|
supplier_resource_id: string
|
||
|
|
model_id: number
|
||
|
|
name: string
|
||
|
|
status: string
|
||
|
|
cost_price_cents: number
|
||
|
|
cost_prices: Record<string, number>
|
||
|
|
sell_price_cents: number
|
||
|
|
resource_url?: string | null
|
||
|
|
baidu_weight?: number | null
|
||
|
|
resource_remark?: string | null
|
||
|
|
customer_visible: boolean
|
||
|
|
channel_type?: string | null
|
||
|
|
region?: string | null
|
||
|
|
inclusion_effect?: string | null
|
||
|
|
link_type?: string | null
|
||
|
|
publish_rate?: string | null
|
||
|
|
delivery_speed?: string | null
|
||
|
|
last_synced_at: string
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface OpsMediaSupplyResourcesParams {
|
||
|
|
model_id?: number
|
||
|
|
keyword?: string
|
||
|
|
remark_keyword?: string
|
||
|
|
channel_type?: string
|
||
|
|
region?: string
|
||
|
|
inclusion_effect?: string
|
||
|
|
link_type?: string
|
||
|
|
min_price_cents?: number
|
||
|
|
max_price_cents?: number
|
||
|
|
visibility?: string
|
||
|
|
page?: number
|
||
|
|
page_size?: number
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface OpsMediaSupplyResourcesResponse {
|
||
|
|
items: OpsMediaSupplyResource[]
|
||
|
|
total: number
|
||
|
|
page: number
|
||
|
|
size: number
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface OpsMediaSupplyWallet {
|
||
|
|
tenant_id: number
|
||
|
|
tenant_name?: string | null
|
||
|
|
user_id: number
|
||
|
|
user_name?: string | null
|
||
|
|
user_phone?: string | null
|
||
|
|
balance_cents: number
|
||
|
|
updated_at: string
|
||
|
|
last_ledger_at?: string | null
|
||
|
|
ledger_entries: number
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface OpsMediaSupplyWalletsResponse {
|
||
|
|
items: OpsMediaSupplyWallet[]
|
||
|
|
total: number
|
||
|
|
page: number
|
||
|
|
size: number
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface OpsMediaSupplyWalletsParams {
|
||
|
|
keyword?: string
|
||
|
|
tenant_id?: number
|
||
|
|
page?: number
|
||
|
|
page_size?: number
|
||
|
|
}
|
||
|
|
|
||
|
|
export const opsMediaSupplyApi = {
|
||
|
|
listResources(params: OpsMediaSupplyResourcesParams) {
|
||
|
|
return http.get<OpsMediaSupplyResourcesResponse>(
|
||
|
|
'/media-supply/resources',
|
||
|
|
params as Record<string, unknown>,
|
||
|
|
)
|
||
|
|
},
|
||
|
|
setPrice(id: number, payload: { price_type?: string; sell_price_cents: number; enabled?: boolean }) {
|
||
|
|
return http.put<{ updated: boolean }, typeof payload>(`/media-supply/resources/${id}/price`, payload)
|
||
|
|
},
|
||
|
|
setVisibility(id: number, customerVisible: boolean) {
|
||
|
|
return http.put<{ updated: boolean }, { customer_visible: boolean }>(
|
||
|
|
`/media-supply/resources/${id}/visibility`,
|
||
|
|
{ customer_visible: customerVisible },
|
||
|
|
)
|
||
|
|
},
|
||
|
|
queueSync(modelId = 1) {
|
||
|
|
return http.post<{ job_id: number }, { model_id: number }>('/media-supply/sync-jobs', {
|
||
|
|
model_id: modelId,
|
||
|
|
})
|
||
|
|
},
|
||
|
|
listWallets(params: OpsMediaSupplyWalletsParams) {
|
||
|
|
return http.get<OpsMediaSupplyWalletsResponse>(
|
||
|
|
'/media-supply/wallets',
|
||
|
|
params as Record<string, unknown>,
|
||
|
|
)
|
||
|
|
},
|
||
|
|
adjustWallet(payload: { tenant_id: number; user_id: number; delta_cents: number; note?: string }) {
|
||
|
|
return http.post<OpsMediaSupplyWallet, typeof payload>('/media-supply/wallets/adjustments', payload)
|
||
|
|
},
|
||
|
|
}
|