Compare commits

..
2 Commits
Author SHA1 Message Date
lik 4976ade905 feat: 订单详情新增尝试再次退款入口
退款中的订单可重新发起原路退款,并保留人工核销兜底。
2026-11-06 22:20:09 +08:00
lik 2f397b9fda tmp 2026-11-06 20:59:45 +08:00
8 changed files with 95 additions and 3 deletions
+1
View File
@@ -0,0 +1 @@
VITE_API_BASE=https://api.huashengtec.com
+6
View File
@@ -54,4 +54,10 @@ export const escortApi = {
request<{ record: EscortRecord }>(`/health/escort-record/${id}/refund/manual`, { request<{ record: EscortRecord }>(`/health/escort-record/${id}/refund/manual`, {
method: 'POST', method: 'POST',
}), }),
refundRetry: (id: string) =>
request<{ refund: Record<string, unknown> | null; paymentStatus: string }>(
`/health/escort-record/${id}/refund/retry`,
{ method: 'POST' }
),
} }
+7
View File
@@ -36,4 +36,11 @@ export const profileApi = {
request<{ profile: HealthProfile }>(`/health/health-profile/${id}`, { request<{ profile: HealthProfile }>(`/health/health-profile/${id}`, {
method: 'DELETE', method: 'DELETE',
}), }),
// 批量统计每位用户的就诊人数量(一次最多 200 个用户)
counts: (userIds: string[]) =>
request<{ counts: Record<string, number> }>('/health/health-profile/counts', {
query: { userIds: userIds.join(',') },
silent: true,
}),
} }
+5
View File
@@ -18,6 +18,11 @@ export type UserProfile = {
export type UserView = { export type UserView = {
_id: string _id: string
profile?: UserProfile profile?: UserProfile
location?: {
province?: string
city?: string
district?: string
}
status?: { status?: {
account?: 'normal' | 'lock' account?: 'normal' | 'lock'
} }
+4 -1
View File
@@ -1,5 +1,8 @@
import { notify } from '~/utils/notify' import { notify } from '~/utils/notify'
// 生产环境走 https://api.huashengtec.com;本地为空,仍由 vite proxy 转发
const API_BASE = (import.meta.env.VITE_API_BASE || '').replace(/\/+$/, '')
let authToken = '' let authToken = ''
let unauthorizedHandler: (() => void) | null = null let unauthorizedHandler: (() => void) | null = null
@@ -47,7 +50,7 @@ export async function request<T>(path: string, options: RequestOptions = {}): Pr
let response: Response let response: Response
try { try {
response = await fetch(`${path}${buildQuery(query)}`, { response = await fetch(`${API_BASE}${path}${buildQuery(query)}`, {
method, method,
headers, headers,
body: body === undefined ? undefined : JSON.stringify(body), body: body === undefined ? undefined : JSON.stringify(body),
+35
View File
@@ -53,6 +53,14 @@
> >
查询退款结果 查询退款结果
</BButton> </BButton>
<BButton
v-if="record.payment?.status === 'refunding'"
variant="primary"
:disabled="actionLoading"
@click="retryRefundVisible = true"
>
尝试再次退款
</BButton>
<BButton <BButton
v-if="record.payment?.status === 'refunding'" v-if="record.payment?.status === 'refunding'"
variant="danger" variant="danger"
@@ -345,6 +353,17 @@
<p class="text-muted mb-0 fs-12">核销后订单支付状态将变为「已退款」,且不可撤销。</p> <p class="text-muted mb-0 fs-12">核销后订单支付状态将变为「已退款」,且不可撤销。</p>
</ConfirmModal> </ConfirmModal>
<ConfirmModal
v-model="retryRefundVisible"
title="尝试再次退款"
ok-title="确认退款"
ok-variant="warning"
@confirm="submitRetryRefund"
>
<p class="mb-1">将按原退款单号再次向微信发起原路退款。</p>
<p class="text-muted mb-0 fs-12">若上次退款已受理,微信会返回原退款结果,不会重复退款。</p>
</ConfirmModal>
<ConfirmModal <ConfirmModal
v-model="deleteVisible" v-model="deleteVisible"
title="删除订单" title="删除订单"
@@ -405,6 +424,7 @@ const paymentVisible = ref(false)
const paymentForm = reactive({ method: 'offline_cash', amount: 0 }) const paymentForm = reactive({ method: 'offline_cash', amount: 0 })
const manualRefundVisible = ref(false) const manualRefundVisible = ref(false)
const retryRefundVisible = ref(false)
const deleteVisible = ref(false) const deleteVisible = ref(false)
const sexRequirementLabel = computed(() => { const sexRequirementLabel = computed(() => {
@@ -528,6 +548,21 @@ const queryRefund = async () => {
} }
} }
const submitRetryRefund = async () => {
if (!record.value) return
actionLoading.value = true
try {
const result = await escortApi.refundRetry(record.value._id)
notify.success(`已重新发起退款,支付状态:${PAYMENT_LABELS[result.paymentStatus] || result.paymentStatus}`)
retryRefundVisible.value = false
await load()
} catch {
// 错误提示由请求层统一弹出
} finally {
actionLoading.value = false
}
}
const submitManualRefund = async () => { const submitManualRefund = async () => {
if (!record.value) return if (!record.value) return
actionLoading.value = true actionLoading.value = true
+33
View File
@@ -82,6 +82,20 @@
{{ item.profile?.email || '-' }} {{ item.profile?.email || '-' }}
</template> </template>
<template #cell(province)="{ item }">
<template v-if="item.location?.province">
{{ item.location.province }}
<span v-if="item.location.city" class="text-muted fs-12">/ {{ item.location.city }}</span>
</template>
<span v-else class="text-muted">-</span>
</template>
<template #cell(profiles)="{ item }">
<RouterLink :to="`/profiles?userId=${item._id}`" class="link-reset">
{{ profileCounts[item._id] ?? 0 }} 位
</RouterLink>
</template>
<template #cell(apps)="{ item }"> <template #cell(apps)="{ item }">
<template v-if="item.apps?.length"> <template v-if="item.apps?.length">
<span <span
@@ -154,6 +168,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, reactive, ref, watch } from 'vue' import { onMounted, reactive, ref, watch } from 'vue'
import { profileApi } from '~/api/profile'
import { userApi } from '~/api/user' import { userApi } from '~/api/user'
import ConfirmModal from '~/components/ConfirmModal.vue' import ConfirmModal from '~/components/ConfirmModal.vue'
import PageBreadcrumb from '~/components/PageBreadcrumb.vue' import PageBreadcrumb from '~/components/PageBreadcrumb.vue'
@@ -185,6 +200,8 @@ const filters = reactive({
const fields = [ const fields = [
{ key: 'user', label: '用户' }, { key: 'user', label: '用户' },
{ key: 'email', label: '邮箱' }, { key: 'email', label: '邮箱' },
{ key: 'province', label: '所在省份' },
{ key: 'profiles', label: '就诊人' },
{ key: 'apps', label: '应用与角色' }, { key: 'apps', label: '应用与角色' },
{ key: 'account', label: '账号状态' }, { key: 'account', label: '账号状态' },
{ key: 'createdAt', label: '注册时间' }, { key: 'createdAt', label: '注册时间' },
@@ -192,6 +209,7 @@ const fields = [
] ]
const users = ref<UserView[]>([]) const users = ref<UserView[]>([])
const profileCounts = ref<Record<string, number>>({})
const total = ref(0) const total = ref(0)
const page = ref(1) const page = ref(1)
const pageSize = ref(20) const pageSize = ref(20)
@@ -200,6 +218,20 @@ const loading = ref(false)
const lockVisible = ref(false) const lockVisible = ref(false)
const lockTarget = ref<UserView | null>(null) const lockTarget = ref<UserView | null>(null)
// 就诊人数量仅用于展示,接口失败时显示 0,不影响用户列表
const loadProfileCounts = async (list: UserView[]) => {
if (!list.length) {
profileCounts.value = {}
return
}
try {
const data = await profileApi.counts(list.map((item) => item._id))
profileCounts.value = data.counts
} catch {
profileCounts.value = {}
}
}
const load = async () => { const load = async () => {
loading.value = true loading.value = true
try { try {
@@ -213,6 +245,7 @@ const load = async () => {
}) })
users.value = data.users users.value = data.users
total.value = data.total total.value = data.total
await loadProfileCounts(data.users)
const maxPage = Math.max(1, Math.ceil(data.total / pageSize.value)) const maxPage = Math.max(1, Math.ceil(data.total / pageSize.value))
if (page.value > maxPage) { if (page.value > maxPage) {
page.value = maxPage page.value = maxPage
+4 -2
View File
@@ -7,7 +7,9 @@ import Components from 'unplugin-vue-components/vite'
import { BootstrapVueNextResolver } from 'bootstrap-vue-next' import { BootstrapVueNextResolver } from 'bootstrap-vue-next'
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig(({ command }) => ({
// 线上部署在 https://escort.huashengtec.com/admin/,本地开发仍保持根路径
base: command === 'build' ? '/admin/' : '/',
plugins: [ plugins: [
vue(), vue(),
vueDevTools(), vueDevTools(),
@@ -32,4 +34,4 @@ export default defineConfig({
}, },
}, },
}, },
}) }))