功能:新增下一阶段运营能力和生产部署
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
const paymentApi = require('../../api/payment')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -78,6 +79,19 @@ function formatRating(value) {
|
||||
return rating % 1 === 0 ? String(rating) : rating.toFixed(1)
|
||||
}
|
||||
|
||||
function getPaymentStatusText(status) {
|
||||
if (status === 'PAID') {
|
||||
return '已支付'
|
||||
}
|
||||
if (status === 'PAYING') {
|
||||
return '支付中'
|
||||
}
|
||||
if (status === 'REFUNDED') {
|
||||
return '已退款'
|
||||
}
|
||||
return '未支付'
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isSubmittedReview supports index.js by holding or executing the is submitted review page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -261,11 +275,15 @@ function formatOrderItem(order, item, userInfo, assistData) {
|
||||
function formatOrder(order, userInfo, assistData) {
|
||||
const items = safeList(order.items).map(item => formatOrderItem(order, item, userInfo, assistData))
|
||||
const orderReviewSummary = buildReviewSummary(order.reviewSummary)
|
||||
const paymentStatus = order.paymentStatus || 'UNPAID'
|
||||
return {
|
||||
...order,
|
||||
displayStatusText: format.getOrderStatusText(order),
|
||||
displayPaymentStatusText: getPaymentStatusText(paymentStatus),
|
||||
displayCreateTime: format.formatDateTime(order.createTime),
|
||||
displayPayAmount: format.formatPrice(order.payAmount || order.actualAmount),
|
||||
displayPaidAmount: format.formatPrice(order.paidAmount),
|
||||
canManualConfirmPay: paymentStatus !== 'PAID' && paymentStatus !== 'REFUNDED',
|
||||
items,
|
||||
reviewSummary: orderReviewSummary,
|
||||
reviewStatusText: orderReviewSummary ? orderReviewSummary.displayText : ''
|
||||
@@ -351,6 +369,7 @@ Page({
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
userInfo: null,
|
||||
canManualConfirmPay: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -368,8 +387,10 @@ Page({
|
||||
}
|
||||
|
||||
const userInfo = getApp().globalData.userInfo
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
userInfo
|
||||
userInfo,
|
||||
canManualConfirmPay: permission.hasPermission(permissionCodes, 'payment:manage')
|
||||
})
|
||||
|
||||
if (!this.data.initialized || consumeDirty('admin-orders')) {
|
||||
@@ -377,6 +398,54 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
async handleManualConfirmPay(event) {
|
||||
if (!this.data.canManualConfirmPay) {
|
||||
wx.showToast({
|
||||
title: '当前账号没有确认支付权限',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const order = event.currentTarget.dataset.order
|
||||
if (!order) {
|
||||
return
|
||||
}
|
||||
const confirmed = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '手动确认支付',
|
||||
content: `确认将订单 ${order.orderNo || order.id} 标记为已支付?`,
|
||||
editable: true,
|
||||
placeholderText: '备注,可留空',
|
||||
confirmText: '确认',
|
||||
success: result => {
|
||||
if (!result.confirm) {
|
||||
resolve(null)
|
||||
return
|
||||
}
|
||||
resolve(String(result.content || '').trim())
|
||||
},
|
||||
fail: () => resolve(null)
|
||||
})
|
||||
})
|
||||
if (confirmed === null) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await paymentApi.manualConfirmOrder(order.id, confirmed)
|
||||
markDirty('admin-workbench')
|
||||
wx.showToast({
|
||||
title: '支付已确认',
|
||||
icon: 'none'
|
||||
})
|
||||
this.loadOrders()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '确认支付失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onPullDownRefresh supports index.js by holding or executing the on pull down refresh page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
|
||||
Reference in New Issue
Block a user