Compare commits
4
Commits
main
..
b8b5c81352
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8b5c81352 | ||
|
|
a6ffc7f543 | ||
|
|
4976ade905 | ||
|
|
2f397b9fda |
@@ -0,0 +1 @@
|
||||
VITE_API_BASE=https://api.huashengtec.com
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="">
|
||||
<html lang="en" data-skin="neon" data-bs-theme="light" data-menu-color="dark" data-topbar-color="light" data-layout-width="fluid" dir="ltr" data-sidenav-size="default" data-sidenav-user="true">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/images/favicon.ico">
|
||||
|
||||
+8
-1
@@ -50,8 +50,15 @@ export const escortApi = {
|
||||
{ method: 'POST' }
|
||||
),
|
||||
|
||||
refundManual: (id: string) =>
|
||||
refundManual: (id: string, refundNo?: string) =>
|
||||
request<{ record: EscortRecord }>(`/health/escort-record/${id}/refund/manual`, {
|
||||
method: 'POST',
|
||||
body: { refundNo: refundNo || '' },
|
||||
}),
|
||||
|
||||
refundRetry: (id: string) =>
|
||||
request<{ refund: Record<string, unknown> | null; paymentStatus: string }>(
|
||||
`/health/escort-record/${id}/refund/retry`,
|
||||
{ method: 'POST' }
|
||||
),
|
||||
}
|
||||
|
||||
@@ -36,4 +36,11 @@ export const profileApi = {
|
||||
request<{ profile: HealthProfile }>(`/health/health-profile/${id}`, {
|
||||
method: 'DELETE',
|
||||
}),
|
||||
|
||||
// 批量统计每位用户的就诊人数量(一次最多 200 个用户)
|
||||
counts: (userIds: string[]) =>
|
||||
request<{ counts: Record<string, number> }>('/health/health-profile/counts', {
|
||||
query: { userIds: userIds.join(',') },
|
||||
silent: true,
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -18,6 +18,11 @@ export type UserProfile = {
|
||||
export type UserView = {
|
||||
_id: string
|
||||
profile?: UserProfile
|
||||
location?: {
|
||||
province?: string
|
||||
city?: string
|
||||
district?: string
|
||||
}
|
||||
status?: {
|
||||
account?: 'normal' | 'lock'
|
||||
}
|
||||
@@ -84,6 +89,8 @@ export type EscortRecord = {
|
||||
payChannel?: string
|
||||
paymentRecordId?: string | null
|
||||
status?: string
|
||||
refundNo?: string
|
||||
refundedAt?: string | null
|
||||
}
|
||||
paymentWindowEnd?: string | null
|
||||
notes?: {
|
||||
@@ -209,6 +216,18 @@ export type PaymentStatusResult = {
|
||||
prepayExpiresAt: string | null
|
||||
timeExpireAt: string | null
|
||||
}
|
||||
refund?: null | {
|
||||
outRefundNo: string
|
||||
refundId: string
|
||||
status: string
|
||||
refundAmount: number
|
||||
successTime: string | null
|
||||
lastError?: null | {
|
||||
code: string
|
||||
message: string
|
||||
at: string | null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type QrLoginResult = {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { notify } from '~/utils/notify'
|
||||
|
||||
// 生产环境走 https://api.huashengtec.com;本地为空,仍由 vite proxy 转发
|
||||
const API_BASE = (import.meta.env.VITE_API_BASE || '').replace(/\/+$/, '')
|
||||
|
||||
let authToken = ''
|
||||
let unauthorizedHandler: (() => void) | null = null
|
||||
|
||||
@@ -47,7 +50,7 @@ export async function request<T>(path: string, options: RequestOptions = {}): Pr
|
||||
|
||||
let response: Response
|
||||
try {
|
||||
response = await fetch(`${path}${buildQuery(query)}`, {
|
||||
response = await fetch(`${API_BASE}${path}${buildQuery(query)}`, {
|
||||
method,
|
||||
headers,
|
||||
body: body === undefined ? undefined : JSON.stringify(body),
|
||||
|
||||
+85
-10
@@ -53,13 +53,21 @@
|
||||
>
|
||||
查询退款结果
|
||||
</BButton>
|
||||
<BButton
|
||||
v-if="record.payment?.status === 'refunding'"
|
||||
variant="primary"
|
||||
:disabled="actionLoading"
|
||||
@click="retryRefundVisible = true"
|
||||
>
|
||||
尝试再次退款
|
||||
</BButton>
|
||||
<BButton
|
||||
v-if="record.payment?.status === 'refunding'"
|
||||
variant="danger"
|
||||
:disabled="actionLoading"
|
||||
@click="manualRefundVisible = true"
|
||||
@click="openManualRefund"
|
||||
>
|
||||
人工核销退款
|
||||
人工核实退款
|
||||
</BButton>
|
||||
<BButton variant="outline-danger" :disabled="actionLoading" @click="deleteVisible = true">删除订单</BButton>
|
||||
</div>
|
||||
@@ -219,6 +227,14 @@
|
||||
<hr class="border-dashed my-3" />
|
||||
<p class="text-muted mb-1 fs-12">支付流水ID</p>
|
||||
<p class="mb-0 text-break fs-12">{{ record.payment?.paymentRecordId || '-' }}</p>
|
||||
<template v-if="outRefundNoDisplay || refundNoDisplay">
|
||||
<p v-if="outRefundNoDisplay" class="text-muted mb-0 fs-12 mt-1">退款单号:{{ outRefundNoDisplay }}</p>
|
||||
<p v-if="refundNoDisplay" class="text-muted mb-0 fs-12 mt-1">退款流水号:{{ refundNoDisplay }}</p>
|
||||
</template>
|
||||
<p v-if="refundErrorText && record.payment?.status !== 'refunded'" class="text-danger mb-0 fs-12 mt-1 text-break">
|
||||
退款失败原因:{{ refundErrorText }}
|
||||
</p>
|
||||
<p v-if="refundStatusLabel" class="text-danger mb-0 fs-12 mt-1">退款状态:{{ refundStatusLabel }}</p>
|
||||
<p v-if="record.paymentWindowEnd" class="text-muted mb-0 fs-12 mt-2">
|
||||
支付截止:{{ formatDateTime(record.paymentWindowEnd) }}
|
||||
</p>
|
||||
@@ -334,15 +350,28 @@
|
||||
</BFormGroup>
|
||||
</BModal>
|
||||
|
||||
<BModal v-model="manualRefundVisible" title="人工核实退款" centered>
|
||||
<p class="mb-1">请先核实该订单的退款结果(线上退款查微信支付商户平台,线下退款与收款方确认),再选择对应操作。</p>
|
||||
<p class="text-muted mb-0 fs-12">确认已退款:订单支付状态置为「已退款」,不可撤销。</p>
|
||||
<p class="text-muted mb-0 fs-12">确认未退款:订单保持「退款中」,可稍后尝试再次退款。</p>
|
||||
<BFormGroup label="退款流水号" label-for="manualRefundNo" class="mb-0 mt-3">
|
||||
<BFormInput id="manualRefundNo" v-model="manualRefundNo" placeholder="选填,如微信退款单号" />
|
||||
</BFormGroup>
|
||||
<template #footer>
|
||||
<BButton variant="light" :disabled="actionLoading" @click="confirmNotRefunded">确认未退款</BButton>
|
||||
<BButton variant="danger" :disabled="actionLoading" @click="submitManualRefund">确认已退款</BButton>
|
||||
</template>
|
||||
</BModal>
|
||||
|
||||
<ConfirmModal
|
||||
v-model="manualRefundVisible"
|
||||
title="人工核销退款"
|
||||
ok-title="确认已退款"
|
||||
ok-variant="danger"
|
||||
@confirm="submitManualRefund"
|
||||
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>
|
||||
<p class="mb-1">将按原退款单号再次向微信发起原路退款。</p>
|
||||
<p class="text-muted mb-0 fs-12">若上次退款已受理,微信会返回原退款结果,不会重复退款。</p>
|
||||
</ConfirmModal>
|
||||
|
||||
<ConfirmModal
|
||||
@@ -405,6 +434,8 @@ const paymentVisible = ref(false)
|
||||
const paymentForm = reactive({ method: 'offline_cash', amount: 0 })
|
||||
|
||||
const manualRefundVisible = ref(false)
|
||||
const manualRefundNo = ref('')
|
||||
const retryRefundVisible = ref(false)
|
||||
const deleteVisible = ref(false)
|
||||
|
||||
const sexRequirementLabel = computed(() => {
|
||||
@@ -412,6 +443,25 @@ const sexRequirementLabel = computed(() => {
|
||||
return map[record.value?.escort?.sexRequirement || 'none'] || '不限'
|
||||
})
|
||||
|
||||
const refundNoDisplay = computed(
|
||||
() => record.value?.payment?.refundNo || payInfo.value?.refund?.refundId || ''
|
||||
)
|
||||
|
||||
const outRefundNoDisplay = computed(() => payInfo.value?.refund?.outRefundNo || '')
|
||||
|
||||
const refundErrorText = computed(() => {
|
||||
const err = payInfo.value?.refund?.lastError
|
||||
if (!err?.message) return ''
|
||||
return err.code ? `${err.message}(${err.code})` : err.message
|
||||
})
|
||||
|
||||
const refundStatusLabel = computed(() => {
|
||||
const status = payInfo.value?.refund?.status
|
||||
if (status === 'abnormal') return '异常,需人工处理'
|
||||
if (status === 'closed') return '已关闭'
|
||||
return ''
|
||||
})
|
||||
|
||||
const canRecordOffline = computed(() => {
|
||||
if (!record.value) return false
|
||||
return record.value.payment?.status === 'unpaid'
|
||||
@@ -528,11 +578,36 @@ 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 openManualRefund = () => {
|
||||
manualRefundNo.value = payInfo.value?.refund?.refundId || ''
|
||||
manualRefundVisible.value = true
|
||||
}
|
||||
|
||||
const confirmNotRefunded = () => {
|
||||
manualRefundVisible.value = false
|
||||
notify.info('已确认未退款,订单保持退款中,可稍后尝试再次退款')
|
||||
}
|
||||
|
||||
const submitManualRefund = async () => {
|
||||
if (!record.value) return
|
||||
actionLoading.value = true
|
||||
try {
|
||||
await escortApi.refundManual(record.value._id)
|
||||
await escortApi.refundManual(record.value._id, manualRefundNo.value.trim())
|
||||
notify.success('退款已核销')
|
||||
manualRefundVisible.value = false
|
||||
await load()
|
||||
|
||||
@@ -82,6 +82,20 @@
|
||||
{{ item.profile?.email || '-' }}
|
||||
</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 v-if="item.apps?.length">
|
||||
<span
|
||||
@@ -154,6 +168,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, watch } from 'vue'
|
||||
import { profileApi } from '~/api/profile'
|
||||
import { userApi } from '~/api/user'
|
||||
import ConfirmModal from '~/components/ConfirmModal.vue'
|
||||
import PageBreadcrumb from '~/components/PageBreadcrumb.vue'
|
||||
@@ -185,6 +200,8 @@ const filters = reactive({
|
||||
const fields = [
|
||||
{ key: 'user', label: '用户' },
|
||||
{ key: 'email', label: '邮箱' },
|
||||
{ key: 'province', label: '所在省份' },
|
||||
{ key: 'profiles', label: '就诊人' },
|
||||
{ key: 'apps', label: '应用与角色' },
|
||||
{ key: 'account', label: '账号状态' },
|
||||
{ key: 'createdAt', label: '注册时间' },
|
||||
@@ -192,6 +209,7 @@ const fields = [
|
||||
]
|
||||
|
||||
const users = ref<UserView[]>([])
|
||||
const profileCounts = ref<Record<string, number>>({})
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
@@ -200,6 +218,20 @@ const loading = ref(false)
|
||||
const lockVisible = ref(false)
|
||||
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 () => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -213,6 +245,7 @@ const load = async () => {
|
||||
})
|
||||
users.value = data.users
|
||||
total.value = data.total
|
||||
await loadProfileCounts(data.users)
|
||||
const maxPage = Math.max(1, Math.ceil(data.total / pageSize.value))
|
||||
if (page.value > maxPage) {
|
||||
page.value = maxPage
|
||||
|
||||
+4
-2
@@ -7,7 +7,9 @@ import Components from 'unplugin-vue-components/vite'
|
||||
import { BootstrapVueNextResolver } from 'bootstrap-vue-next'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
export default defineConfig(({ command }) => ({
|
||||
// 线上部署在 https://escort.huashengtec.com/admin/,本地开发仍保持根路径
|
||||
base: command === 'build' ? '/admin/' : '/',
|
||||
plugins: [
|
||||
vue(),
|
||||
vueDevTools(),
|
||||
@@ -32,4 +34,4 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user