增加展示选择
This commit is contained in:
@@ -768,59 +768,6 @@ export function buildAddressSnapshot(address: UserAddress, latitude: number, lon
|
||||
}
|
||||
}
|
||||
|
||||
async function getLegacyServiceOrderDetail(orderId: string): Promise<DeliveryOrderType | null> {
|
||||
return await getOrderDetail(orderId)
|
||||
}
|
||||
|
||||
async function tryCreateCareTask(params: CreateServiceOrderParams): Promise<ServiceOrderType | null> {
|
||||
// LEGACY/TODO: 本函数为前端直接 INSERT ec_care_tasks 的过渡逻辑。
|
||||
// 按新架构,履约工单应在支付完成后由后端 RPC 生成/激活,前端不得直接创建。
|
||||
// 当前因缺少后端接口(rpc_consumer_create_homecare_task 或支付回调自动创建)暂时保留。
|
||||
if (ecCareTaskCreateUnavailable) {
|
||||
return null
|
||||
}
|
||||
const userId = getCurrentUserId()
|
||||
if (userId == '') {
|
||||
return null
|
||||
}
|
||||
const taskId = generateUuid()
|
||||
const taskNo = buildOrderNo()
|
||||
const now = nowIso()
|
||||
const scheduledAt = normalizeAppointmentTime(params.appointmentTime)
|
||||
const response = await supa.from('ec_care_tasks').insert({
|
||||
id: taskId,
|
||||
task_no: taskNo,
|
||||
user_id: userId,
|
||||
service_catalog_id: params.service.id,
|
||||
service_name: params.service.name,
|
||||
service_category: params.service.category,
|
||||
service_snapshot_json: params.service as any,
|
||||
elder_name: params.recipientName,
|
||||
elder_phone: params.recipientPhone,
|
||||
contact_name: params.contactName,
|
||||
contact_phone: params.contactPhone,
|
||||
address_snapshot_json: params.address as any,
|
||||
scheduled_at: scheduledAt,
|
||||
appointment_time: scheduledAt,
|
||||
remark: params.remark,
|
||||
status: 'ORDER_CREATED',
|
||||
created_at: now,
|
||||
updated_at: now
|
||||
}).execute()
|
||||
if (shouldBypassEcCareTaskCreate(response.error)) {
|
||||
ecCareTaskCreateUnavailable = true
|
||||
console.error('[tryCreateCareTask] ec_care_tasks 缺少必要字段,已停用前端直接创建:', response.error)
|
||||
return null
|
||||
}
|
||||
if (response.error != null) {
|
||||
console.error('tryCreateCareTask failed', response.error)
|
||||
return null
|
||||
}
|
||||
// 已移除前端直接写入 hc_work_order_events;事件应由后端 RPC 统一生成。
|
||||
console.warn('[LEGACY] tryCreateCareTask skipped direct insertWorkOrderEvent for', taskId)
|
||||
return await getOrderDetail(taskId) as any
|
||||
}
|
||||
|
||||
export async function createServiceOrder(params: CreateServiceOrderParams): Promise<ServiceOrderType | null> {
|
||||
// 当前下单链路分为两层:
|
||||
// 1) 交易支付层:hss_service_orders(旧表,仍承担套餐价格快照与支付状态)。
|
||||
|
||||
Reference in New Issue
Block a user