feat(admin): complete integration of auth, delivery, and system infrastructure modules
This commit is contained in:
129
services/admin/deliveryService.uts
Normal file
129
services/admin/deliveryService.uts
Normal file
@@ -0,0 +1,129 @@
|
||||
import { rpcOrNull, rpcOrValue } from '@/services/analytics/rpc.uts'
|
||||
|
||||
/**
|
||||
* 配送员模型
|
||||
*/
|
||||
export type DeliveryStaff = {
|
||||
id: string
|
||||
uid: string | null
|
||||
nickname: string
|
||||
avatar: string | null
|
||||
phone: string
|
||||
status: number
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 提货点模型
|
||||
*/
|
||||
export type DeliveryStation = {
|
||||
id: string
|
||||
name: string
|
||||
phone: string
|
||||
address: string
|
||||
image: string | null
|
||||
lng: number | null
|
||||
lat: number | null
|
||||
status: number
|
||||
sort_order: number
|
||||
business_hours: UTSJSONObject | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配送员列表
|
||||
*/
|
||||
export async function fetchDeliveryStaffPage(
|
||||
page: number,
|
||||
pageSize: number,
|
||||
search: string | null = null,
|
||||
status: number | null = null
|
||||
): Promise<{ total: number, items: Array<DeliveryStaff> }> {
|
||||
const res = await rpcOrNull('rpc_admin_get_delivery_staff_list', {
|
||||
p_page: page,
|
||||
p_page_size: pageSize,
|
||||
p_search: search,
|
||||
p_status: status
|
||||
} as UTSJSONObject)
|
||||
|
||||
if (res == null) return { total: 0, items: [] as Array<DeliveryStaff> }
|
||||
return {
|
||||
total: (res as any).total as number,
|
||||
items: (res as any).items as Array<DeliveryStaff>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存配送员
|
||||
*/
|
||||
export async function saveDeliveryStaff(staff: any): Promise<string | null> {
|
||||
const res = await rpcOrValue('rpc_admin_save_delivery_staff', {
|
||||
p_id: staff.id,
|
||||
p_nickname: staff.nickname,
|
||||
p_avatar: staff.avatar,
|
||||
p_phone: staff.phone,
|
||||
p_status: staff.status
|
||||
} as any)
|
||||
return res != null ? String(res) : null
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配送员
|
||||
*/
|
||||
export async function deleteDeliveryStaff(id: string): Promise<boolean> {
|
||||
const ok = await rpcOrValue('rpc_admin_delete_delivery_staff', { p_id: id } as any)
|
||||
return ok === true
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提货点列表
|
||||
*/
|
||||
export async function fetchDeliveryStationPage(
|
||||
page: number,
|
||||
pageSize: number,
|
||||
search: string | null = null,
|
||||
status: number | null = null
|
||||
): Promise<{ total: number, items: Array<DeliveryStation> }> {
|
||||
const res = await rpcOrNull('rpc_admin_get_delivery_station_list', {
|
||||
p_page: page,
|
||||
p_page_size: pageSize,
|
||||
p_search: search,
|
||||
p_status: status
|
||||
} as UTSJSONObject)
|
||||
|
||||
if (res == null) return { total: 0, items: [] as Array<DeliveryStation> }
|
||||
return {
|
||||
total: (res as any).total as number,
|
||||
items: (res as any).items as Array<DeliveryStation>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存提货点
|
||||
*/
|
||||
export async function saveDeliveryStation(station: any): Promise<string | null> {
|
||||
const res = await rpcOrValue('rpc_admin_save_delivery_station', {
|
||||
p_id: station.id,
|
||||
p_name: station.name,
|
||||
p_phone: station.phone,
|
||||
p_address: station.address,
|
||||
p_image: station.image,
|
||||
p_lng: station.lng,
|
||||
p_lat: station.lat,
|
||||
p_status: station.status,
|
||||
p_sort_order: station.sort_order,
|
||||
p_business_hours: station.business_hours
|
||||
} as any)
|
||||
return res != null ? String(res) : null
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除提货点
|
||||
*/
|
||||
export async function deleteDeliveryStation(id: string): Promise<boolean> {
|
||||
const ok = await rpcOrValue('rpc_admin_delete_delivery_station', { p_id: id } as any)
|
||||
return ok === true
|
||||
}
|
||||
Reference in New Issue
Block a user