|
@@ -206,57 +206,57 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
|
|
|
|
|
// 设置商户订单号 - 优先使用订单号
|
|
// 设置商户订单号 - 优先使用订单号
|
|
|
extraData.merchant_trade_no = order.orderNo || `ORDER_${order.id}`
|
|
extraData.merchant_trade_no = order.orderNo || `ORDER_${order.id}`
|
|
|
- console.debug('使用商户订单号:', extraData.merchant_trade_no)
|
|
|
|
|
|
|
+ //console.debug('使用商户订单号:', extraData.merchant_trade_no)
|
|
|
|
|
|
|
|
// 如果订单已支付,尝试获取支付记录信息(可选)
|
|
// 如果订单已支付,尝试获取支付记录信息(可选)
|
|
|
if (order.payState === 2) { // 已支付状态
|
|
if (order.payState === 2) { // 已支付状态
|
|
|
- console.debug('订单已支付,尝试查询支付记录...')
|
|
|
|
|
|
|
+ //console.debug('订单已支付,尝试查询支付记录...')
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
// 使用订单API查询支付记录(新端点)
|
|
// 使用订单API查询支付记录(新端点)
|
|
|
- console.debug('使用订单API查询支付记录,订单ID:', order.id)
|
|
|
|
|
|
|
+ //console.debug('使用订单API查询支付记录,订单ID:', order.id)
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
// 调用新的订单支付记录查询端点:GET /api/v1/orders/{orderId}/payment-record
|
|
// 调用新的订单支付记录查询端点:GET /api/v1/orders/{orderId}/payment-record
|
|
|
const paymentRecordResponse = await orderClient[order.id!.toString()]['payment-record'].$get()
|
|
const paymentRecordResponse = await orderClient[order.id!.toString()]['payment-record'].$get()
|
|
|
|
|
|
|
|
- console.debug('支付记录API响应状态:', paymentRecordResponse.status, 'ok:', paymentRecordResponse.ok)
|
|
|
|
|
|
|
+ // console.debug('支付记录API响应状态:', paymentRecordResponse.status, 'ok:', paymentRecordResponse.ok)
|
|
|
|
|
|
|
|
if (paymentRecordResponse.ok) {
|
|
if (paymentRecordResponse.ok) {
|
|
|
const result = await paymentRecordResponse.json()
|
|
const result = await paymentRecordResponse.json()
|
|
|
- console.debug('支付记录查询结果:', result)
|
|
|
|
|
|
|
+ //console.debug('支付记录查询结果:', result)
|
|
|
|
|
|
|
|
if (result.success && result.data?.exists) {
|
|
if (result.success && result.data?.exists) {
|
|
|
const paymentInfo = result.data
|
|
const paymentInfo = result.data
|
|
|
- console.debug('找到支付记录信息:', paymentInfo)
|
|
|
|
|
|
|
+ //console.debug('找到支付记录信息:', paymentInfo)
|
|
|
|
|
|
|
|
// 1. 优先使用支付记录中的商户订单号
|
|
// 1. 优先使用支付记录中的商户订单号
|
|
|
if (paymentInfo.outTradeNo) {
|
|
if (paymentInfo.outTradeNo) {
|
|
|
extraData.merchant_trade_no = paymentInfo.outTradeNo
|
|
extraData.merchant_trade_no = paymentInfo.outTradeNo
|
|
|
- console.debug('使用支付记录中的商户订单号:', paymentInfo.outTradeNo)
|
|
|
|
|
|
|
+ //console.debug('使用支付记录中的商户订单号:', paymentInfo.outTradeNo)
|
|
|
} else {
|
|
} else {
|
|
|
- console.debug('支付记录中没有商户订单号,使用订单号:', extraData.merchant_trade_no)
|
|
|
|
|
|
|
+ //console.debug('支付记录中没有商户订单号,使用订单号:', extraData.merchant_trade_no)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 2. 获取微信交易ID
|
|
// 2. 获取微信交易ID
|
|
|
if (paymentInfo.wechatTransactionId) {
|
|
if (paymentInfo.wechatTransactionId) {
|
|
|
extraData.transaction_id = paymentInfo.wechatTransactionId
|
|
extraData.transaction_id = paymentInfo.wechatTransactionId
|
|
|
- console.debug("获取到微信交易ID:", paymentInfo.wechatTransactionId);
|
|
|
|
|
|
|
+ //console.debug("获取到微信交易ID:", paymentInfo.wechatTransactionId);
|
|
|
} else {
|
|
} else {
|
|
|
- console.debug('支付记录中没有微信交易ID,可能的原因:')
|
|
|
|
|
- console.debug('1. 微信支付回调还未到达(异步回调可能有延迟)')
|
|
|
|
|
- console.debug('2. 支付状态:', paymentInfo.paymentStatus)
|
|
|
|
|
- console.debug('3. 微信交易ID在支付回调成功时才会生成')
|
|
|
|
|
- console.debug('4. 当前时间:', new Date().toISOString())
|
|
|
|
|
|
|
+ // console.debug('支付记录中没有微信交易ID,可能的原因:')
|
|
|
|
|
+ // console.debug('1. 微信支付回调还未到达(异步回调可能有延迟)')
|
|
|
|
|
+ // console.debug('2. 支付状态:', paymentInfo.paymentStatus)
|
|
|
|
|
+ // console.debug('3. 微信交易ID在支付回调成功时才会生成')
|
|
|
|
|
+ // console.debug('4. 当前时间:', new Date().toISOString())
|
|
|
|
|
|
|
|
// 添加调试信息,帮助诊断问题
|
|
// 添加调试信息,帮助诊断问题
|
|
|
- console.debug('支付记录详情:', {
|
|
|
|
|
- 订单ID: order.id,
|
|
|
|
|
- 支付状态: paymentInfo.paymentStatus,
|
|
|
|
|
- 是否存在微信交易ID: !!paymentInfo.wechatTransactionId,
|
|
|
|
|
- 商户订单号: paymentInfo.outTradeNo,
|
|
|
|
|
- 记录存在: paymentInfo.exists
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // console.debug('支付记录详情:', {
|
|
|
|
|
+ // 订单ID: order.id,
|
|
|
|
|
+ // 支付状态: paymentInfo.paymentStatus,
|
|
|
|
|
+ // 是否存在微信交易ID: !!paymentInfo.wechatTransactionId,
|
|
|
|
|
+ // 商户订单号: paymentInfo.outTradeNo,
|
|
|
|
|
+ // 记录存在: paymentInfo.exists
|
|
|
|
|
+ // })
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
console.debug('未找到支付记录或查询失败:', result.message)
|
|
console.debug('未找到支付记录或查询失败:', result.message)
|
|
@@ -330,23 +330,23 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
const payment = payments.data?.[0]
|
|
const payment = payments.data?.[0]
|
|
|
|
|
|
|
|
if (payment) {
|
|
if (payment) {
|
|
|
- console.debug('找到支付记录:', {
|
|
|
|
|
- paymentId: payment.id,
|
|
|
|
|
- outTradeNo: payment.outTradeNo,
|
|
|
|
|
- wechatTransactionId: payment.wechatTransactionId,
|
|
|
|
|
- paymentStatus: payment.paymentStatus,
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // console.debug('找到支付记录:', {
|
|
|
|
|
+ // paymentId: payment.id,
|
|
|
|
|
+ // outTradeNo: payment.outTradeNo,
|
|
|
|
|
+ // wechatTransactionId: payment.wechatTransactionId,
|
|
|
|
|
+ // paymentStatus: payment.paymentStatus,
|
|
|
|
|
+ // })
|
|
|
|
|
|
|
|
// 1. 优先使用支付记录中的商户订单号
|
|
// 1. 优先使用支付记录中的商户订单号
|
|
|
if (payment.outTradeNo) {
|
|
if (payment.outTradeNo) {
|
|
|
extraData.merchant_trade_no = payment.outTradeNo
|
|
extraData.merchant_trade_no = payment.outTradeNo
|
|
|
- console.debug('使用支付记录中的商户订单号:', payment.outTradeNo)
|
|
|
|
|
|
|
+ //console.debug('使用支付记录中的商户订单号:', payment.outTradeNo)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 2. 获取微信交易ID
|
|
// 2. 获取微信交易ID
|
|
|
if (payment.wechatTransactionId) {
|
|
if (payment.wechatTransactionId) {
|
|
|
extraData.transaction_id = payment.wechatTransactionId
|
|
extraData.transaction_id = payment.wechatTransactionId
|
|
|
- console.debug("获取到微信交易ID:", payment.wechatTransactionId);
|
|
|
|
|
|
|
+ //console.debug("获取到微信交易ID:", payment.wechatTransactionId);
|
|
|
} else {
|
|
} else {
|
|
|
console.debug('支付记录中没有微信交易ID')
|
|
console.debug('支付记录中没有微信交易ID')
|
|
|
}
|
|
}
|
|
@@ -389,28 +389,28 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
...(extraData.order_no && { order_no: extraData.order_no }),
|
|
...(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...')
|
|
|
|
|
|
|
+ // 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是否存在
|
|
// 检查Taro.openBusinessView是否存在
|
|
|
if (typeof Taro.openBusinessView !== 'function') {
|
|
if (typeof Taro.openBusinessView !== 'function') {
|
|
|
- console.error('Taro.openBusinessView不存在!可能的原因:')
|
|
|
|
|
- console.error('1. 微信基础库版本过低')
|
|
|
|
|
- console.error('2. 该API需要特定的微信版本')
|
|
|
|
|
- console.error('3. 开发工具需要更新')
|
|
|
|
|
|
|
+ // console.error('Taro.openBusinessView不存在!可能的原因:')
|
|
|
|
|
+ // console.error('1. 微信基础库版本过低')
|
|
|
|
|
+ // console.error('2. 该API需要特定的微信版本')
|
|
|
|
|
+ // console.error('3. 开发工具需要更新')
|
|
|
|
|
|
|
|
Taro.showModal({
|
|
Taro.showModal({
|
|
|
title: '功能不可用',
|
|
title: '功能不可用',
|
|
@@ -432,14 +432,14 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
|
|
|
|
|
// 使用固定的businessType: weappOrderConfirm
|
|
// 使用固定的businessType: weappOrderConfirm
|
|
|
try {
|
|
try {
|
|
|
- console.debug(`调用微信openBusinessView,businessType: ${businessType}`)
|
|
|
|
|
|
|
+ // console.debug(`调用微信openBusinessView,businessType: ${businessType}`)
|
|
|
|
|
|
|
|
await Taro.openBusinessView({
|
|
await Taro.openBusinessView({
|
|
|
businessType,
|
|
businessType,
|
|
|
extraData: optimizedExtraData,
|
|
extraData: optimizedExtraData,
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- console.log(`微信openBusinessView调用成功,businessType: ${businessType}`)
|
|
|
|
|
|
|
+ // console.log(`微信openBusinessView调用成功,businessType: ${businessType}`)
|
|
|
|
|
|
|
|
} catch (wxError) {
|
|
} catch (wxError) {
|
|
|
console.warn(`微信openBusinessView调用失败:`, wxError)
|
|
console.warn(`微信openBusinessView调用失败:`, wxError)
|
|
@@ -464,7 +464,7 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
businessType,
|
|
businessType,
|
|
|
extraData: minimalExtraData,
|
|
extraData: minimalExtraData,
|
|
|
})
|
|
})
|
|
|
- console.log('使用简化参数调用成功')
|
|
|
|
|
|
|
+ //console.log('使用简化参数调用成功')
|
|
|
} catch (minimalError) {
|
|
} catch (minimalError) {
|
|
|
console.warn('简化参数也失败:', minimalError)
|
|
console.warn('简化参数也失败:', minimalError)
|
|
|
}
|
|
}
|
|
@@ -482,7 +482,7 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
if (modalRes.confirm) {
|
|
if (modalRes.confirm) {
|
|
|
- console.log('用户通过微信Modal确认收货')
|
|
|
|
|
|
|
+ //console.log('用户通过微信Modal确认收货')
|
|
|
// 显示处理中的提示
|
|
// 显示处理中的提示
|
|
|
Taro.showToast({
|
|
Taro.showToast({
|
|
|
title: '正在确认收货...',
|
|
title: '正在确认收货...',
|
|
@@ -490,7 +490,7 @@ export default function OrderButtonBar({ order, onViewDetail, onCancelOrder, hid
|
|
|
duration: 1500
|
|
duration: 1500
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
- console.log('用户取消确认收货')
|
|
|
|
|
|
|
+ //console.log('用户取消确认收货')
|
|
|
Taro.showToast({
|
|
Taro.showToast({
|
|
|
title: '已取消',
|
|
title: '已取消',
|
|
|
icon: 'none',
|
|
icon: 'none',
|