完善服务模块缺少付款页的bug
This commit is contained in:
@@ -4695,16 +4695,26 @@ class SupabaseService {
|
||||
return 3
|
||||
}
|
||||
|
||||
private matchesServiceStatusTab(status: string, statusTab: string): boolean {
|
||||
private matchesServiceStatusTab(status: string, statusTab: string, dispatchStatus: string = ''): boolean {
|
||||
if (statusTab == 'all') return true
|
||||
const normalizedStatus = this.normalizeServiceStatus(status)
|
||||
if (statusTab == 'pending') return normalizedStatus == 'created'
|
||||
if (statusTab == 'accepted') return normalizedStatus == 'paid' || normalizedStatus == 'assigned'
|
||||
if (statusTab == 'accepted') {
|
||||
if (normalizedStatus == 'paid' && dispatchStatus != 'assigned' && dispatchStatus != 'failed') {
|
||||
return true
|
||||
}
|
||||
return normalizedStatus == 'assigned'
|
||||
}
|
||||
if (statusTab == 'scheduled') return normalizedStatus == 'accepted' || normalizedStatus == 'departed'
|
||||
if (statusTab == 'inservice') return normalizedStatus == 'arrived' || normalizedStatus == 'in_service'
|
||||
if (statusTab == 'completed') return normalizedStatus == 'completed' || normalizedStatus == 'pending_acceptance' || normalizedStatus == 'accepted_by_user' || normalizedStatus == 'reviewed' || normalizedStatus == 'settled'
|
||||
if (statusTab == 'aftersale') return false
|
||||
if (statusTab == 'inprogress') return normalizedStatus == 'paid' || normalizedStatus == 'assigned' || normalizedStatus == 'accepted' || normalizedStatus == 'departed' || normalizedStatus == 'arrived' || normalizedStatus == 'in_service'
|
||||
if (statusTab == 'inprogress') {
|
||||
if (normalizedStatus == 'paid' && dispatchStatus != 'failed') {
|
||||
return true
|
||||
}
|
||||
return normalizedStatus == 'assigned' || normalizedStatus == 'accepted' || normalizedStatus == 'departed' || normalizedStatus == 'arrived' || normalizedStatus == 'in_service'
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -4746,8 +4756,10 @@ class SupabaseService {
|
||||
const orderObj = JSON.parse(JSON.stringify(rawOrder)) as UTSJSONObject
|
||||
const addressSnapshotRaw = orderObj.get('address_snapshot_json')
|
||||
const serviceSnapshotRaw = orderObj.get('service_snapshot_json')
|
||||
const pricingSnapshotRaw = orderObj.get('pricing_snapshot_json')
|
||||
let addressObj: UTSJSONObject | null = null
|
||||
let serviceObj: UTSJSONObject | null = null
|
||||
let pricingObj: UTSJSONObject | null = null
|
||||
|
||||
try {
|
||||
if (addressSnapshotRaw != null) {
|
||||
@@ -4775,11 +4787,33 @@ class SupabaseService {
|
||||
serviceObj = null
|
||||
}
|
||||
|
||||
try {
|
||||
if (pricingSnapshotRaw != null) {
|
||||
const pricingText = JSON.stringify(pricingSnapshotRaw)
|
||||
if (pricingText.startsWith('"')) {
|
||||
pricingObj = JSON.parse(orderObj.getString('pricing_snapshot_json') ?? '{}') as UTSJSONObject
|
||||
} else {
|
||||
pricingObj = JSON.parse(pricingText) as UTSJSONObject
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
pricingObj = null
|
||||
}
|
||||
|
||||
const normalizedStatus = this.getUnifiedServiceStatusNumber(orderObj.getString('status') ?? '')
|
||||
const fullAddress = addressObj != null ? (addressObj.getString('fullAddress') ?? '') : ''
|
||||
const providerName = orderObj.getString('staff_name') ?? ''
|
||||
const serviceName = orderObj.getString('service_name') ?? (serviceObj != null ? (serviceObj.getString('serviceName') ?? '') : '')
|
||||
const servicePrice = serviceObj != null ? (serviceObj.getNumber('price') ?? 0) : 0
|
||||
let servicePrice = orderObj.getNumber('total_amount') ?? 0
|
||||
if (servicePrice <= 0 && orderObj.getNumber('payable_amount') != null) {
|
||||
servicePrice = orderObj.getNumber('payable_amount') ?? 0
|
||||
}
|
||||
if (servicePrice <= 0 && pricingObj != null) {
|
||||
servicePrice = pricingObj.getNumber('price') ?? 0
|
||||
}
|
||||
if (servicePrice <= 0 && serviceObj != null) {
|
||||
servicePrice = serviceObj.getNumber('price') ?? 0
|
||||
}
|
||||
|
||||
const serviceInfo = new UTSJSONObject()
|
||||
serviceInfo.set('service_name', serviceName)
|
||||
@@ -4789,6 +4823,8 @@ class SupabaseService {
|
||||
serviceInfo.set('contact_name', orderObj.getString('contact_name') ?? '')
|
||||
serviceInfo.set('contact_phone', orderObj.getString('contact_phone') ?? '')
|
||||
serviceInfo.set('provider_name', providerName)
|
||||
serviceInfo.set('package_name', pricingObj != null ? (pricingObj.getString('package_name') ?? '') : '')
|
||||
serviceInfo.set('pricing_data_source', pricingObj != null ? (pricingObj.getString('data_source') ?? '') : '')
|
||||
|
||||
const unifiedOrder = new UTSJSONObject()
|
||||
const rawPaymentStatus = orderObj.getNumber('payment_status')
|
||||
@@ -4817,10 +4853,16 @@ class SupabaseService {
|
||||
unifiedOrder.set('shipping_fee', 0)
|
||||
unifiedOrder.set('total_amount', servicePrice)
|
||||
unifiedOrder.set('paid_amount', servicePrice)
|
||||
unifiedOrder.set('pricing_data_source', pricingObj != null ? (pricingObj.getString('data_source') ?? '') : '')
|
||||
const dispatchStatus = orderObj.getString('dispatch_status') ?? ''
|
||||
const dispatchErrorMessage = orderObj.getString('dispatch_error_message') ?? ''
|
||||
unifiedOrder.set('merchant_id', orderObj.getString('current_staff_id') ?? '')
|
||||
unifiedOrder.set('shop_name', providerName != '' ? providerName : '康养上门服务')
|
||||
unifiedOrder.set('service_info', serviceInfo)
|
||||
unifiedOrder.set('ml_order_items', [] as UTSJSONObject[])
|
||||
unifiedOrder.set('dispatch_status', dispatchStatus)
|
||||
unifiedOrder.set('dispatch_error_code', orderObj.getString('dispatch_error_code') ?? '')
|
||||
unifiedOrder.set('dispatch_error_message', dispatchErrorMessage)
|
||||
return unifiedOrder
|
||||
}
|
||||
|
||||
@@ -4870,7 +4912,7 @@ class SupabaseService {
|
||||
if (!matchedKeyword) {
|
||||
continue
|
||||
}
|
||||
if (!this.matchesServiceStatusTab(rawObj.getString('status') ?? '', params.statusTab)) {
|
||||
if (!this.matchesServiceStatusTab(rawObj.getString('status') ?? '', params.statusTab, rawObj.getString('dispatch_status') ?? '')) {
|
||||
continue
|
||||
}
|
||||
filtered.push(this.buildUnifiedServiceOrder(rawItem))
|
||||
@@ -5016,7 +5058,7 @@ class SupabaseService {
|
||||
|
||||
const response = await supa
|
||||
.from('hss_service_orders')
|
||||
.select('status')
|
||||
.select('status,payment_status,dispatch_status')
|
||||
.eq('user_id', userId)
|
||||
.is('consumer_deleted_at', null)
|
||||
.limit(500)
|
||||
@@ -5031,9 +5073,11 @@ class SupabaseService {
|
||||
for (let i = 0; i < rawList.length; i++) {
|
||||
const rawObj = JSON.parse(JSON.stringify(rawList[i])) as UTSJSONObject
|
||||
const normalizedStatus = this.normalizeServiceStatus(rawObj.getString('status') ?? '')
|
||||
if (normalizedStatus == 'created') {
|
||||
const dispatchStatus = rawObj.getString('dispatch_status') ?? ''
|
||||
const paymentStatus = rawObj.getNumber('payment_status') ?? 0
|
||||
if (normalizedStatus == 'created' && paymentStatus == 1) {
|
||||
counts.set('pending', (counts.getNumber('pending') ?? 0) + 1)
|
||||
} else if (normalizedStatus == 'paid' || normalizedStatus == 'assigned') {
|
||||
} else if ((normalizedStatus == 'paid' || normalizedStatus == 'assigned') && dispatchStatus != 'failed') {
|
||||
counts.set('accepted', (counts.getNumber('accepted') ?? 0) + 1)
|
||||
} else if (normalizedStatus == 'accepted' || normalizedStatus == 'departed') {
|
||||
counts.set('scheduled', (counts.getNumber('scheduled') ?? 0) + 1)
|
||||
@@ -5041,6 +5085,8 @@ class SupabaseService {
|
||||
counts.set('inservice', (counts.getNumber('inservice') ?? 0) + 1)
|
||||
} else if (normalizedStatus == 'completed' || normalizedStatus == 'pending_acceptance' || normalizedStatus == 'accepted_by_user' || normalizedStatus == 'reviewed' || normalizedStatus == 'settled') {
|
||||
counts.set('completed', (counts.getNumber('completed') ?? 0) + 1)
|
||||
} else if (dispatchStatus == 'failed') {
|
||||
counts.set('accepted', (counts.getNumber('accepted') ?? 0) + 1)
|
||||
}
|
||||
}
|
||||
return counts
|
||||
@@ -5608,6 +5654,10 @@ class SupabaseService {
|
||||
console.error('[payUnifiedOrder] 订单状态已变更,拒绝支付:', latestStatus, latestPaymentStatus)
|
||||
return false
|
||||
}
|
||||
if (source == 'service' && (latestOrder.getString('pricing_data_source') ?? '') == 'dev_seed') {
|
||||
console.error('[payUnifiedOrder] 测试套餐订单禁止真实支付')
|
||||
return false
|
||||
}
|
||||
|
||||
const tableName = this.getUnifiedOrderTableName(orderId, source)
|
||||
const isService = tableName == 'hss_service_orders'
|
||||
|
||||
Reference in New Issue
Block a user