可以接收到咸鱼的订单创建连接
This commit is contained in:
@@ -64,7 +64,8 @@ export interface AdminOrderListItem {
|
||||
orderStatus: string
|
||||
payStatus: string
|
||||
buyerName: string
|
||||
totalAmount: number
|
||||
totalAmount: string
|
||||
totalAmountFen: number
|
||||
currency: string
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
@@ -124,7 +125,8 @@ export interface AdminOrderDetail {
|
||||
buyerId: string
|
||||
buyerName: string
|
||||
receiverContact: string
|
||||
totalAmount: number
|
||||
totalAmount: string
|
||||
totalAmountFen: number
|
||||
currency: string
|
||||
paidAt: string | null
|
||||
createdAt: string
|
||||
@@ -225,13 +227,32 @@ export interface AdminCdkListItem {
|
||||
|
||||
export interface AdminWebhookEventListItem {
|
||||
eventId: number
|
||||
provider: string
|
||||
platform: string
|
||||
platformRaw: string
|
||||
shopId: string
|
||||
shopName: string
|
||||
eventType: string
|
||||
eventKey: string
|
||||
signatureValid: boolean
|
||||
processed: boolean
|
||||
processError: string
|
||||
relatedOrderId: number | null
|
||||
platformOrderId: string
|
||||
buyerId: string
|
||||
buyerName: string
|
||||
totalAmount: string
|
||||
totalAmountFen: number
|
||||
currency: string
|
||||
itemCount: number
|
||||
taskCount: number
|
||||
messageText: string
|
||||
requestTimestamp: string
|
||||
requestSign: string
|
||||
aopic: string
|
||||
sourceHost: string
|
||||
sourceIp: string
|
||||
userAgent: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
@@ -239,6 +260,7 @@ export interface AdminWebhookEventDetail extends AdminWebhookEventListItem {
|
||||
headers: Record<string, unknown>
|
||||
query: Record<string, unknown>
|
||||
body: Record<string, unknown>
|
||||
payload: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface AdminWebhookReplayResponse {
|
||||
@@ -246,6 +268,11 @@ export interface AdminWebhookReplayResponse {
|
||||
replayed: boolean
|
||||
result: {
|
||||
accepted: boolean
|
||||
provider: string
|
||||
platform: string
|
||||
platformRaw: string
|
||||
shopId: string
|
||||
shopName: string
|
||||
eventType: string
|
||||
platformOrderId: string
|
||||
orderId: number
|
||||
|
||||
@@ -37,7 +37,8 @@ export interface ClaimOrderInfo {
|
||||
platformOrderId: string
|
||||
payStatus: string
|
||||
orderStatus: string
|
||||
totalAmount: number
|
||||
totalAmount: string
|
||||
totalAmountFen: number
|
||||
currency: string
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { fetchAdminWebhookEventDetail, replayAdminWebhookEvent } from '@/service
|
||||
import AdminStatusTag from '@/components/admin/AdminStatusTag.vue'
|
||||
import type { AdminWebhookEventDetail, AdminWebhookReplayResponse } from '@/types/admin'
|
||||
import { hasAdminRole } from '@/utils/admin-auth'
|
||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||
import { stringifyDisplayJson } from '@/utils/date-time'
|
||||
import { formatAdminWebhookEventType } from '@/utils/admin-webhook'
|
||||
|
||||
@@ -68,6 +69,21 @@ function prettyJson(value: Record<string, unknown>) {
|
||||
return stringifyDisplayJson(value, 2)
|
||||
}
|
||||
|
||||
function formatRequestTimestamp(value: string) {
|
||||
const normalized = String(value || '').trim()
|
||||
|
||||
if (!/^\d{10,13}$/.test(normalized)) {
|
||||
return normalized || '-'
|
||||
}
|
||||
|
||||
const epochMs = normalized.length === 13 ? Number(normalized) : Number(normalized) * 1000
|
||||
return formatAdminDateTime(new Date(epochMs).toISOString())
|
||||
}
|
||||
|
||||
function formatAmount(detail: AdminWebhookEventDetail) {
|
||||
return detail.totalAmount ? `${detail.totalAmount} ${detail.currency}` : '-'
|
||||
}
|
||||
|
||||
onMounted(loadDetail)
|
||||
</script>
|
||||
|
||||
@@ -86,22 +102,86 @@ onMounted(loadDetail)
|
||||
|
||||
<template v-else-if="detail">
|
||||
<section class="info-card">
|
||||
<p>ID:{{ detail.eventId }} · 平台:{{ detail.platform }} · 类型:{{ formatAdminWebhookEventType(detail.eventType) }}</p>
|
||||
<p>
|
||||
验签:<AdminStatusTag :status="detail.signatureValid ? 'success' : 'failed'" />
|
||||
· 订单:{{ detail.relatedOrderId || '-' }}
|
||||
</p>
|
||||
<p>
|
||||
处理状态:
|
||||
<AdminStatusTag :status="detail.processed ? 'success' : 'failed'" />
|
||||
<span v-if="!detail.processed && detail.processError" class="inline-error">{{ detail.processError }}</span>
|
||||
</p>
|
||||
<div class="overview-top">
|
||||
<div>
|
||||
<h3>{{ formatAdminWebhookEventType(detail.eventType) }}</h3>
|
||||
<p class="muted-copy">
|
||||
#{{ detail.eventId }} · {{ detail.provider }} / {{ detail.platform }}
|
||||
<template v-if="detail.platformRaw && detail.platformRaw !== detail.platform">
|
||||
· 原始平台 {{ detail.platformRaw }}
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
<div class="tag-row">
|
||||
<AdminStatusTag :status="detail.signatureValid ? 'success' : 'failed'" />
|
||||
<AdminStatusTag :status="detail.processed ? 'success' : 'failed'" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="summary-grid">
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">店铺</span>
|
||||
<strong>{{ detail.shopName || detail.shopId || '-' }}</strong>
|
||||
<span class="summary-note">ID: {{ detail.shopId || '-' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">平台订单</span>
|
||||
<strong>{{ detail.platformOrderId || '-' }}</strong>
|
||||
<span class="summary-note">aopic: {{ detail.aopic || '-' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">关联订单</span>
|
||||
<strong v-if="detail.relatedOrderId">
|
||||
<RouterLink class="inline-link" :to="`/admin/orders/${detail.relatedOrderId}`">{{ detail.relatedOrderId }}</RouterLink>
|
||||
</strong>
|
||||
<strong v-else>-</strong>
|
||||
<span class="summary-note">任务数: {{ detail.taskCount }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">买家</span>
|
||||
<strong>{{ detail.buyerName || detail.buyerId || '-' }}</strong>
|
||||
<span class="summary-note">买家 ID: {{ detail.buyerId || '-' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">金额</span>
|
||||
<strong>{{ formatAmount(detail) }}</strong>
|
||||
<span class="summary-note">商品数: {{ detail.itemCount }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">请求时间</span>
|
||||
<strong>{{ formatRequestTimestamp(detail.requestTimestamp) }}</strong>
|
||||
<span class="summary-note">入库时间: {{ formatAdminDateTime(detail.createdAt) }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">来源 Host</span>
|
||||
<strong>{{ detail.sourceHost || '-' }}</strong>
|
||||
<span class="summary-note">来源 IP: {{ detail.sourceIp || '-' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">消息说明</span>
|
||||
<strong>{{ detail.messageText || '-' }}</strong>
|
||||
<span class="summary-note">签名: {{ detail.requestSign || '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="event-key-block">
|
||||
<span class="summary-label">事件 Key</span>
|
||||
<code>{{ detail.eventKey }}</code>
|
||||
</div>
|
||||
|
||||
<div v-if="detail.processError" class="inline-error">{{ detail.processError }}</div>
|
||||
</section>
|
||||
|
||||
<section v-if="lastReplayResult" class="table-card">
|
||||
<h3>最近一次重放结果</h3>
|
||||
<p class="result-copy">
|
||||
平台订单:{{ lastReplayResult.platformOrderId }} · 事件:{{ formatAdminWebhookEventType(lastReplayResult.eventType) }} · 任务数:{{ lastReplayResult.taskCount }}
|
||||
{{ lastReplayResult.provider }} / {{ lastReplayResult.platform }}
|
||||
<template v-if="lastReplayResult.platformRaw && lastReplayResult.platformRaw !== lastReplayResult.platform">
|
||||
· 原始平台 {{ lastReplayResult.platformRaw }}
|
||||
</template>
|
||||
· 平台订单 {{ lastReplayResult.platformOrderId }}
|
||||
· 事件 {{ formatAdminWebhookEventType(lastReplayResult.eventType) }}
|
||||
· 任务数 {{ lastReplayResult.taskCount }}
|
||||
</p>
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
@@ -121,6 +201,11 @@ onMounted(loadDetail)
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="table-card">
|
||||
<h3>解析后的 Payload</h3>
|
||||
<pre class="json-block">{{ prettyJson(detail.payload) }}</pre>
|
||||
</section>
|
||||
|
||||
<section class="table-card">
|
||||
<h3>Headers</h3>
|
||||
<pre class="json-block">{{ prettyJson(detail.headers) }}</pre>
|
||||
@@ -147,11 +232,69 @@ onMounted(loadDetail)
|
||||
.info-card,.table-card,.empty-block,.error-copy {
|
||||
padding: 18px; border-radius: 20px; background: rgba(255,255,255,.94); border: 1px solid rgba(86,108,138,.1);
|
||||
}
|
||||
.overview-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
|
||||
.overview-top h3 { margin: 0; color: #0f172a; }
|
||||
.muted-copy { margin: 8px 0 0; color: #64748b; }
|
||||
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
|
||||
.summary-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
.summary-item {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
padding: 14px;
|
||||
border-radius: 16px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||
}
|
||||
.summary-label {
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.summary-item strong {
|
||||
color: #0f172a;
|
||||
word-break: break-all;
|
||||
}
|
||||
.summary-note {
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
}
|
||||
.event-key-block {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin-top: 16px;
|
||||
padding: 14px;
|
||||
border-radius: 16px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||
}
|
||||
.event-key-block code {
|
||||
color: #334155;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
word-break: break-all;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.error-copy { color: #b42318; }
|
||||
.inline-error { margin-left: 8px; color: #b42318; }
|
||||
.inline-error {
|
||||
margin-top: 16px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
color: #b42318;
|
||||
background: #fef3f2;
|
||||
border: 1px solid #fecdca;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.result-copy { margin: 0 0 12px; color: #64748b; }
|
||||
.data-table { width: 100%; border-collapse: collapse; }
|
||||
.data-table th,.data-table td { padding: 12px 10px; text-align: left; border-bottom: 1px solid rgba(86,108,138,.08); color: #334155; }
|
||||
.inline-link { color: #175cd3; }
|
||||
.json-block {
|
||||
margin: 12px 0 0;
|
||||
padding: 14px;
|
||||
@@ -162,4 +305,13 @@ onMounted(loadDetail)
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
@media (max-width: 960px) {
|
||||
.overview-top {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.summary-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -15,6 +15,7 @@ const loading = ref(true)
|
||||
const actionLoadingId = ref<number | null>(null)
|
||||
const errorMessage = ref('')
|
||||
const items = ref<AdminWebhookEventListItem[]>([])
|
||||
const provider = ref('')
|
||||
const platform = ref('')
|
||||
const processed = ref('')
|
||||
const relatedOrderId = ref('')
|
||||
@@ -34,6 +35,7 @@ async function loadEvents(page = pagination.value.page) {
|
||||
const response = await fetchAdminWebhookEvents({
|
||||
page,
|
||||
pageSize: pagination.value.pageSize,
|
||||
provider: provider.value.trim(),
|
||||
platform: platform.value.trim(),
|
||||
processed: processed.value.trim(),
|
||||
relatedOrderId: relatedOrderId.value.trim(),
|
||||
@@ -77,6 +79,21 @@ async function submitReplay(item: AdminWebhookEventListItem) {
|
||||
}
|
||||
}
|
||||
|
||||
function formatRequestTimestamp(value: string) {
|
||||
const normalized = String(value || '').trim()
|
||||
|
||||
if (!/^\d{10,13}$/.test(normalized)) {
|
||||
return normalized || '-'
|
||||
}
|
||||
|
||||
const epochMs = normalized.length === 13 ? Number(normalized) : Number(normalized) * 1000
|
||||
return formatAdminDateTime(new Date(epochMs).toISOString())
|
||||
}
|
||||
|
||||
function formatAmount(item: AdminWebhookEventListItem) {
|
||||
return item.totalAmount ? `${item.totalAmount} ${item.currency}` : '-'
|
||||
}
|
||||
|
||||
onMounted(loadEvents)
|
||||
</script>
|
||||
|
||||
@@ -90,7 +107,8 @@ onMounted(loadEvents)
|
||||
</header>
|
||||
|
||||
<section class="filter-bar">
|
||||
<input v-model="platform" class="text-input" placeholder="平台,如 agiso" />
|
||||
<input v-model="provider" class="text-input" placeholder="服务商,如 agiso" />
|
||||
<input v-model="platform" class="text-input" placeholder="业务平台,如 xianyu / taobao" />
|
||||
<select v-model="processed" class="text-input select-input">
|
||||
<option v-for="option in adminWebhookProcessedOptions" :key="option.value" :value="option.value">
|
||||
{{ option.label }}
|
||||
@@ -113,11 +131,11 @@ onMounted(loadEvents)
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>平台</th>
|
||||
<th>事件类型</th>
|
||||
<th>验签</th>
|
||||
<th>处理结果</th>
|
||||
<th>订单</th>
|
||||
<th>来源</th>
|
||||
<th>事件摘要</th>
|
||||
<th>订单与店铺</th>
|
||||
<th>验签与处理</th>
|
||||
<th>请求来源</th>
|
||||
<th>时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
@@ -127,15 +145,70 @@ onMounted(loadEvents)
|
||||
<td>
|
||||
<RouterLink :to="`/admin/webhook-events/${item.eventId}`">{{ item.eventId }}</RouterLink>
|
||||
</td>
|
||||
<td>{{ item.platform }}</td>
|
||||
<td>{{ formatAdminWebhookEventType(item.eventType) }}</td>
|
||||
<td><AdminStatusTag :status="item.signatureValid ? 'success' : 'failed'" /></td>
|
||||
<td>
|
||||
<AdminStatusTag :status="item.processed ? 'success' : 'failed'" />
|
||||
<span v-if="!item.processed && item.processError" class="error-inline">{{ item.processError }}</span>
|
||||
<div class="cell-stack">
|
||||
<div class="cell-title">{{ item.provider }} / {{ item.platform }}</div>
|
||||
<div v-if="item.platformRaw && item.platformRaw !== item.platform" class="cell-subtle">
|
||||
原始平台:{{ item.platformRaw }}
|
||||
</div>
|
||||
<div class="meta-chip-row">
|
||||
<span class="meta-chip">店铺 {{ item.shopName || item.shopId || '-' }}</span>
|
||||
<span v-if="item.shopId" class="meta-chip">ID {{ item.shopId }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="cell-stack">
|
||||
<div class="cell-title">{{ formatAdminWebhookEventType(item.eventType) }}</div>
|
||||
<div v-if="item.messageText" class="cell-subtle">{{ item.messageText }}</div>
|
||||
<div class="meta-chip-row">
|
||||
<span v-if="item.aopic" class="meta-chip">aopic {{ item.aopic }}</span>
|
||||
<span v-if="item.itemCount" class="meta-chip">商品 {{ item.itemCount }}</span>
|
||||
</div>
|
||||
<div class="mono-inline">Key: {{ item.eventKey }}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="cell-stack">
|
||||
<div class="cell-title">平台单:{{ item.platformOrderId || '-' }}</div>
|
||||
<div class="cell-subtle">买家:{{ item.buyerName || item.buyerId || '-' }}</div>
|
||||
<div class="cell-subtle">金额:{{ formatAmount(item) }}</div>
|
||||
<div class="meta-chip-row">
|
||||
<span class="meta-chip">
|
||||
关联订单
|
||||
<template v-if="item.relatedOrderId">
|
||||
<RouterLink class="inline-link" :to="`/admin/orders/${item.relatedOrderId}`">{{ item.relatedOrderId }}</RouterLink>
|
||||
</template>
|
||||
<template v-else>-</template>
|
||||
</span>
|
||||
<span class="meta-chip">任务 {{ item.taskCount }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="cell-stack">
|
||||
<div class="tag-row">
|
||||
<AdminStatusTag :status="item.signatureValid ? 'success' : 'failed'" />
|
||||
<AdminStatusTag :status="item.processed ? 'success' : 'failed'" />
|
||||
</div>
|
||||
<div class="cell-subtle">签名:{{ item.requestSign || '-' }}</div>
|
||||
<div v-if="item.processError" class="error-inline">{{ item.processError }}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="cell-stack">
|
||||
<div class="cell-title">{{ item.sourceHost || '-' }}</div>
|
||||
<div class="cell-subtle">IP:{{ item.sourceIp || '-' }}</div>
|
||||
<div class="cell-subtle line-clamp-2">UA:{{ item.userAgent || '-' }}</div>
|
||||
<div class="cell-subtle">请求时间:{{ formatRequestTimestamp(item.requestTimestamp) }}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="cell-stack">
|
||||
<div class="cell-title">{{ formatAdminDateTime(item.createdAt) }}</div>
|
||||
<div class="cell-subtle">事件 ID #{{ item.eventId }}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ item.relatedOrderId || '-' }}</td>
|
||||
<td>{{ formatAdminDateTime(item.createdAt) }}</td>
|
||||
<td>
|
||||
<el-button
|
||||
v-if="hasAdminRole('admin')"
|
||||
@@ -183,6 +256,49 @@ onMounted(loadEvents)
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.cell-stack {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.cell-title {
|
||||
color: #0f172a;
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.cell-subtle {
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.meta-chip-row,
|
||||
.tag-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.meta-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-height: 24px;
|
||||
padding: 0 8px;
|
||||
border-radius: 999px;
|
||||
color: #475467;
|
||||
background: #f8fafc;
|
||||
border: 1px solid rgba(148, 163, 184, 0.24);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.inline-link {
|
||||
color: #175cd3;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.table-card,
|
||||
.empty-block,
|
||||
.error-copy {
|
||||
@@ -198,9 +314,9 @@ onMounted(loadEvents)
|
||||
|
||||
.error-inline {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
color: #b42318;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.text-input {
|
||||
@@ -234,4 +350,18 @@ onMounted(loadEvents)
|
||||
color: #64748b;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.mono-inline {
|
||||
color: #475467;
|
||||
font-size: 12px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.line-clamp-2 {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user