|
|
@@ -40,10 +40,13 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
}
|
|
|
return response.json()
|
|
|
},
|
|
|
- onSuccess: (data) => {
|
|
|
- // 取消成功后刷新订单列表数据
|
|
|
+ onSuccess: () => {
|
|
|
+ // 取消成功后刷新订单列表数据(使用模糊匹配)
|
|
|
queryClient.invalidateQueries({ queryKey: ['orders'] })
|
|
|
- queryClient.invalidateQueries({ queryKey: ['order', order.id] })
|
|
|
+ // 刷新当前订单的详情数据(使用部分匹配)
|
|
|
+ if (order?.id) {
|
|
|
+ queryClient.invalidateQueries({ queryKey: ['order', order.id] })
|
|
|
+ }
|
|
|
|
|
|
// 显示取消成功信息
|
|
|
Taro.showToast({
|
|
|
@@ -155,9 +158,12 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
return response.json()
|
|
|
},
|
|
|
onSuccess: () => {
|
|
|
- // // 刷新订单列表数据
|
|
|
+ // 刷新订单列表数据(使用模糊匹配)
|
|
|
queryClient.invalidateQueries({ queryKey: ['orders'] })
|
|
|
- // queryClient.invalidateQueries({ queryKey: ['order', order.id] })
|
|
|
+ // 刷新当前订单的详情数据(使用部分匹配)
|
|
|
+ if (order?.id) {
|
|
|
+ queryClient.invalidateQueries({ queryKey: ['order', order.id] })
|
|
|
+ }
|
|
|
|
|
|
// 显示成功信息
|
|
|
Taro.showToast({
|
|
|
@@ -198,7 +204,7 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
if (res.confirm) {
|
|
|
try {
|
|
|
// 准备微信openBusinessView参数
|
|
|
- const extraData: any = {
|
|
|
+ const extraData: Record<string, any> = {
|
|
|
orderId: order.id!.toString(),
|
|
|
// 商户信息 - 需要根据实际微信商户配置填写
|
|
|
merchant_id: order.merchantId?.toString() || '1230000109'
|
|
|
@@ -209,8 +215,9 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
//console.debug('使用商户订单号:', extraData.merchant_trade_no)
|
|
|
|
|
|
// 如果订单已支付,尝试获取支付记录信息(可选)
|
|
|
- if (order.payState === 2) { // 已支付状态
|
|
|
- //console.debug('订单已支付,尝试查询支付记录...')
|
|
|
+ // 注意:额度支付(payType === 3)不需要查询微信交易ID
|
|
|
+ if (order.payState === 2 && order.payType === 4) { // 已支付状态且是微信支付
|
|
|
+ //console.debug('订单已支付且是微信支付,尝试查询支付记录...')
|
|
|
|
|
|
try {
|
|
|
// 使用订单API查询支付记录(新端点)
|
|
|
@@ -375,6 +382,13 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
console.debug('订单未支付或支付状态不是已支付')
|
|
|
}
|
|
|
|
|
|
+ // 额度支付(payType === 3)不需要调用微信确认收货界面,直接调用后端API
|
|
|
+ if (order.payType === 3) {
|
|
|
+ console.debug('额度支付订单,直接调用后端确认收货API')
|
|
|
+ confirmReceiptMutation.mutate({ orderId: order.id! })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// 参数验证和优化
|
|
|
const businessType = 'weappOrderConfirm' // 固定配置的业务类型
|
|
|
|
|
|
@@ -388,59 +402,16 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
...(extraData.transaction_id && { transaction_id: extraData.transaction_id }),
|
|
|
...(extraData.order_no && { order_no: extraData.order_no }),
|
|
|
}
|
|
|
-
|
|
|
- // console.debug('微信openBusinessView参数:', {
|
|
|
- // businessType,
|
|
|
- // optimizedExtraData,
|
|
|
- // // 检查必要参数是否存在
|
|
|
- // hasOrderId: !!optimizedExtraData.orderId,
|
|
|
- // hasMerchantId: !!optimizedExtraData.merchant_id,
|
|
|
- // hasMerchantTradeNo: !!optimizedExtraData.merchant_trade_no,
|
|
|
- // hasTransactionId: !!optimizedExtraData.transaction_id,
|
|
|
- // orderState: order.state,
|
|
|
- // payState: order.payState,
|
|
|
- // // 原始extraData用于调试
|
|
|
- // originalExtraData: extraData
|
|
|
- // })
|
|
|
-
|
|
|
- // console.debug('开始调用微信openBusinessView...')
|
|
|
-
|
|
|
- // 检查Taro.openBusinessView是否存在
|
|
|
- if (typeof Taro.openBusinessView !== 'function') {
|
|
|
- // console.error('Taro.openBusinessView不存在!可能的原因:')
|
|
|
- // console.error('1. 微信基础库版本过低')
|
|
|
- // console.error('2. 该API需要特定的微信版本')
|
|
|
- // console.error('3. 开发工具需要更新')
|
|
|
-
|
|
|
- Taro.showModal({
|
|
|
- title: '功能不可用',
|
|
|
- content: '当前微信版本过低,无法使用确认收货功能,请升级微信后重试。',
|
|
|
- showCancel: false
|
|
|
- })
|
|
|
-
|
|
|
- // 降级到普通确认
|
|
|
- Taro.showToast({
|
|
|
- title: '正在确认收货...',
|
|
|
- icon: 'none',
|
|
|
- duration: 1500
|
|
|
- })
|
|
|
-
|
|
|
- // 直接调用后端API
|
|
|
- confirmReceiptMutation.mutate({ orderId: order.id! })
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
// 使用固定的businessType: weappOrderConfirm
|
|
|
try {
|
|
|
- // console.debug(`调用微信openBusinessView,businessType: ${businessType}`)
|
|
|
|
|
|
await Taro.openBusinessView({
|
|
|
businessType,
|
|
|
- extraData: optimizedExtraData,
|
|
|
+ extraData: optimizedExtraData as any,
|
|
|
})
|
|
|
|
|
|
- // console.log(`微信openBusinessView调用成功,businessType: ${businessType}`)
|
|
|
-
|
|
|
+
|
|
|
} catch (wxError) {
|
|
|
console.warn(`微信openBusinessView调用失败:`, wxError)
|
|
|
|
|
|
@@ -462,7 +433,7 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
console.debug('尝试使用简化参数:', minimalExtraData)
|
|
|
await Taro.openBusinessView({
|
|
|
businessType,
|
|
|
- extraData: minimalExtraData,
|
|
|
+ extraData: minimalExtraData as any,
|
|
|
})
|
|
|
//console.log('使用简化参数调用成功')
|
|
|
} catch (minimalError) {
|
|
|
@@ -507,17 +478,7 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
duration: 1500
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
- // 记录详细错误信息便于调试
|
|
|
- console.error('微信openBusinessView详细错误:', {
|
|
|
- error: wxError,
|
|
|
- businessType,
|
|
|
- optimizedExtraData,
|
|
|
- originalExtraData: extraData,
|
|
|
- orderId: order.id,
|
|
|
- orderState: order.state,
|
|
|
- payState: order.payState
|
|
|
- })
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 微信界面操作成功后(或降级后),调用后端确认收货API
|