接单工单与资金申请列表支持创建时间区间筛选
This commit is contained in:
@@ -414,6 +414,9 @@ export type ListInput = {
|
||||
sort?: 'id_desc' | 'worker_claimed_at_desc'
|
||||
/** 后台使用拼单聚合业务状态;大厅和打手列表使用原始生命周期。 */
|
||||
useOperationalStatus?: boolean
|
||||
/** 创建时间区间(YYYY-MM-DD,上海时区,含起止日);后台列表筛选使用。 */
|
||||
createdFrom?: string
|
||||
createdTo?: string
|
||||
}
|
||||
|
||||
export type WorkOrderStatistics = {
|
||||
@@ -465,6 +468,9 @@ export type FinanceRequestListInput = {
|
||||
status?: string
|
||||
requestType?: string
|
||||
keyword?: string
|
||||
/** 申请时间区间(YYYY-MM-DD,上海时区,含起止日);后台列表筛选使用。 */
|
||||
createdFrom?: string
|
||||
createdTo?: string
|
||||
}
|
||||
|
||||
export type CreateWorkerInput = {
|
||||
|
||||
@@ -170,6 +170,8 @@ export async function listWorkOrders({
|
||||
useOperationalStatus = false,
|
||||
pinnedFirst = false,
|
||||
sort = 'id_desc',
|
||||
createdFrom = '',
|
||||
createdTo = '',
|
||||
}: ListInput = {}): Promise<{ items: WorkOrderRow[]; total: number }> {
|
||||
const effectiveStatuses = statuses.length > 0 ? statuses : status.trim() ? [status.trim()] : []
|
||||
const { joins, whereClause, params } = buildWorkOrderWhere({
|
||||
@@ -185,6 +187,8 @@ export async function listWorkOrders({
|
||||
excludeFilledSharing,
|
||||
vipEvidencePending,
|
||||
useOperationalStatus,
|
||||
createdFrom,
|
||||
createdTo,
|
||||
})
|
||||
const totalResult = await query<{ total: number }>(
|
||||
`
|
||||
@@ -519,10 +523,24 @@ export function buildWorkOrderWhere({
|
||||
excludeFilledSharing = false,
|
||||
vipEvidencePending = false,
|
||||
useOperationalStatus = false,
|
||||
createdFrom = '',
|
||||
createdTo = '',
|
||||
}: ListInput) {
|
||||
const filters: string[] = []
|
||||
const params: unknown[] = []
|
||||
const joins: string[] = []
|
||||
if (createdFrom) {
|
||||
params.push(createdFrom)
|
||||
filters.push(
|
||||
`wo.created_at >= ($${params.length}::date)::timestamp AT TIME ZONE 'Asia/Shanghai'`,
|
||||
)
|
||||
}
|
||||
if (createdTo) {
|
||||
params.push(createdTo)
|
||||
filters.push(
|
||||
`wo.created_at < (($${params.length}::date + 1)::timestamp AT TIME ZONE 'Asia/Shanghai')`,
|
||||
)
|
||||
}
|
||||
let workerSharePlaceholder = ''
|
||||
|
||||
if (excludeFilledSharing) {
|
||||
|
||||
@@ -203,6 +203,8 @@ export async function listWorkerFinanceRequests({
|
||||
status = '',
|
||||
requestType = '',
|
||||
keyword = '',
|
||||
createdFrom = '',
|
||||
createdTo = '',
|
||||
}: FinanceRequestListInput = {}): Promise<{ items: WorkerFinanceRequestRow[]; total: number }> {
|
||||
const { whereClause, params } = buildWorkerFinanceRequestWhere({
|
||||
requestId,
|
||||
@@ -210,6 +212,8 @@ export async function listWorkerFinanceRequests({
|
||||
status,
|
||||
requestType,
|
||||
keyword,
|
||||
createdFrom,
|
||||
createdTo,
|
||||
})
|
||||
const totalResult = await query<{ total: number }>(
|
||||
`SELECT COUNT(*)::int AS total FROM worker_finance_requests wfr
|
||||
@@ -415,9 +419,23 @@ function buildWorkerFinanceRequestWhere({
|
||||
status = '',
|
||||
requestType = '',
|
||||
keyword = '',
|
||||
createdFrom = '',
|
||||
createdTo = '',
|
||||
}: FinanceRequestListInput) {
|
||||
const filters: string[] = []
|
||||
const params: unknown[] = []
|
||||
if (createdFrom) {
|
||||
params.push(createdFrom)
|
||||
filters.push(
|
||||
`wfr.created_at >= ($${params.length}::date)::timestamp AT TIME ZONE 'Asia/Shanghai'`,
|
||||
)
|
||||
}
|
||||
if (createdTo) {
|
||||
params.push(createdTo)
|
||||
filters.push(
|
||||
`wfr.created_at < (($${params.length}::date + 1)::timestamp AT TIME ZONE 'Asia/Shanghai')`,
|
||||
)
|
||||
}
|
||||
if (requestId) {
|
||||
params.push(requestId)
|
||||
filters.push(`wfr.id = $${params.length}`)
|
||||
|
||||
Reference in New Issue
Block a user