From 836afd30a9661760f2d2cb7a17ab9670305075ee Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Sat, 21 Nov 2026 10:55:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E5=8D=95=E9=80=9A=E7=9F=A5=20?= =?UTF-8?q?H5=20=E5=8F=8C=E9=80=9A=E9=81=93=E8=AE=A2=E9=98=85=E4=B8=8E?= =?UTF-8?q?=E8=BF=90=E5=8D=95=E8=AF=A6=E6=83=85=E9=80=9A=E7=9F=A5=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 配置页支持系统 SMTP;H5 可分别订阅微信/邮件;运单操作日志增加全部/业务/通知筛选。 Co-authored-by: Cursor --- src/api/customer/wechatNotify.ts | 31 +- src/api/order/index.ts | 59 ++ src/api/system/wechatOrderNotify.ts | 214 ++++- src/locale/en-US.ts | 56 +- src/locale/zh-CN.ts | 56 +- .../components/H5WechatNotifySheet.vue | 98 ++- src/views/h5/customer-center/locale/en-US.ts | 15 +- src/views/h5/customer-center/locale/zh-CN.ts | 16 +- .../components/OrderDetailDrawer.vue | 144 +++- src/views/system/otherConfig/index.vue | 748 +++++++++++++++--- 10 files changed, 1277 insertions(+), 160 deletions(-) diff --git a/src/api/customer/wechatNotify.ts b/src/api/customer/wechatNotify.ts index fee7a10..55172aa 100644 --- a/src/api/customer/wechatNotify.ts +++ b/src/api/customer/wechatNotify.ts @@ -5,29 +5,46 @@ export interface CustomerWechatNotifyPrefItem { eventCode: string eventName: string opsEnabled: boolean + opsEmailEnabled: boolean isSubscribed: boolean + isEmailSubscribed: boolean } export interface CustomerWechatNotifyStatus { hasOpenId: boolean + hasEmail: boolean hasFollowUrl: boolean items: CustomerWechatNotifyPrefItem[] } +function mapPrefItem(raw: any): CustomerWechatNotifyPrefItem { + return { + eventCode: String(raw?.eventCode ?? raw?.EventCode ?? ''), + eventName: String(raw?.eventName ?? raw?.EventName ?? ''), + opsEnabled: !!(raw?.opsEnabled ?? raw?.OpsEnabled), + opsEmailEnabled: !!(raw?.opsEmailEnabled ?? raw?.OpsEmailEnabled), + isSubscribed: !!(raw?.isSubscribed ?? raw?.IsSubscribed), + isEmailSubscribed: !!(raw?.isEmailSubscribed ?? raw?.IsEmailSubscribed), + } +} + export async function getCustomerWechatNotifyStatus() { const res = await axiosInstance.get(omsUrl('/customer/wechat-notify/status')) - const data = unwrapData( - res.data - ) + const data = unwrapData(res.data) return { - hasOpenId: !!(data?.hasOpenId ?? (data as any)?.HasOpenId), - hasFollowUrl: !!(data?.hasFollowUrl ?? (data as any)?.HasFollowUrl), - items: data?.items ?? data?.Items ?? [], + hasOpenId: !!(data?.hasOpenId ?? data?.HasOpenId), + hasEmail: !!(data?.hasEmail ?? data?.HasEmail), + hasFollowUrl: !!(data?.hasFollowUrl ?? data?.HasFollowUrl), + items: (data?.items ?? data?.Items ?? []).map(mapPrefItem), } satisfies CustomerWechatNotifyStatus } export async function saveCustomerWechatNotifyPrefs( - items: { eventCode: string; isSubscribed: boolean }[] + items: { + eventCode: string + isSubscribed: boolean + isEmailSubscribed: boolean + }[] ) { const res = await axiosInstance.post(omsUrl('/customer/wechat-notify/prefs'), { items }) assertBusinessOk(res.data) diff --git a/src/api/order/index.ts b/src/api/order/index.ts index 05da310..b2ddf32 100644 --- a/src/api/order/index.ts +++ b/src/api/order/index.ts @@ -1429,6 +1429,65 @@ export async function getOrderOperationLogList( return { items } } +export interface OrderNotifyLogItem { + id: number + orderId: number + channel: string + channelName: string + eventCode: string + eventName: string + recipient?: string | null + templateRef?: string | null + subject?: string | null + status: string + providerMsgId?: string | null + errCode?: number | null + errMsg?: string | null + smtpUsername?: string | null + summary: string + payloadJson?: string | null + createTime?: string +} + +export interface OrderNotifyLogListResult { + items: OrderNotifyLogItem[] +} + +function mapNotifyLogItem(raw: any): OrderNotifyLogItem { + return { + id: Number(raw?.id ?? raw?.Id ?? 0), + orderId: Number(raw?.orderId ?? raw?.OrderId ?? 0), + channel: String(raw?.channel ?? raw?.Channel ?? ''), + channelName: String(raw?.channelName ?? raw?.ChannelName ?? ''), + eventCode: String(raw?.eventCode ?? raw?.EventCode ?? ''), + eventName: String(raw?.eventName ?? raw?.EventName ?? ''), + recipient: raw?.recipient ?? raw?.Recipient ?? null, + templateRef: raw?.templateRef ?? raw?.TemplateRef ?? null, + subject: raw?.subject ?? raw?.Subject ?? null, + status: String(raw?.status ?? raw?.Status ?? ''), + providerMsgId: raw?.providerMsgId ?? raw?.ProviderMsgId ?? null, + errCode: raw?.errCode ?? raw?.ErrCode ?? null, + errMsg: raw?.errMsg ?? raw?.ErrMsg ?? null, + smtpUsername: raw?.smtpUsername ?? raw?.SmtpUsername ?? null, + summary: String(raw?.summary ?? raw?.Summary ?? ''), + payloadJson: raw?.payloadJson ?? raw?.PayloadJson ?? null, + createTime: raw?.createTime ?? raw?.CreateTime, + } +} + +/** GET /order/notify-log/list */ +export async function getOrderNotifyLogList( + orderId: number | string, +): Promise { + const res = await axiosInstance.get(orderUrl('/order/notify-log/list'), { + params: { orderId: Number(orderId) }, + }) + const data = unwrapData(res.data) ?? {} + const itemsRaw = data?.items ?? data?.Items ?? [] + const items = Array.isArray(itemsRaw) ? itemsRaw.map(mapNotifyLogItem) : [] + return { items } +} + /** GET /order/exception-events/list */ export async function getOrderExceptionEventList(orderId: number | string): Promise { const res = await axiosInstance.get(orderUrl('/order/exception-events/list'), { diff --git a/src/api/system/wechatOrderNotify.ts b/src/api/system/wechatOrderNotify.ts index 2c24eda..2cadefd 100644 --- a/src/api/system/wechatOrderNotify.ts +++ b/src/api/system/wechatOrderNotify.ts @@ -9,6 +9,11 @@ export interface WechatOrderNotifyTemplateDto { urlTemplate?: string | null fieldMappingJson?: string | null isEnabled?: boolean + emailEnabled?: boolean + emailTemplateName?: string | null + emailTemplateOwnerUserId?: number | null + emailSmtpOwnerUserId?: number | null + emailUseSystemSmtp?: boolean remark?: string | null } @@ -18,29 +23,224 @@ export interface SaveWechatOrderNotifyTemplateBody { urlTemplate?: string | null fieldMappingJson?: string | null isEnabled: boolean + emailEnabled: boolean + emailTemplateName?: string | null + emailUseSystemSmtp?: boolean remark?: string | null } +export interface OrderNotifySystemSmtpStatus { + configured: boolean + smtpUsername?: string | null + fromName?: string | null +} + +export interface TrialOrderNotifyEmailResult { + success: boolean + skipped: boolean + status: string + message?: string | null + toEmail?: string | null + templateName?: string | null + subject?: string | null + body?: string | null + smtpUsername?: string | null +} + +export interface TrialWechatOrderNotifyResult { + success: boolean + skipped: boolean + status: string + message?: string | null + orderId: number + serviceNo?: string | null + eventCode: string + eventName?: string | null + openId?: string | null + templateId?: string | null + url?: string | null + requestUrl?: string | null + requestBody?: string | null + responseBody?: string | null + wxMsgId?: string | null + errCode?: number | null + email?: TrialOrderNotifyEmailResult | null +} + +function mapEmailResult(raw: any): TrialOrderNotifyEmailResult | null { + if (raw == null) return null + return { + success: !!(raw.success ?? raw.Success), + skipped: !!(raw.skipped ?? raw.Skipped), + status: String(raw.status ?? raw.Status ?? ''), + message: raw.message ?? raw.Message ?? null, + toEmail: raw.toEmail ?? raw.ToEmail ?? null, + templateName: raw.templateName ?? raw.TemplateName ?? null, + subject: raw.subject ?? raw.Subject ?? null, + body: raw.body ?? raw.Body ?? null, + smtpUsername: raw.smtpUsername ?? raw.SmtpUsername ?? null, + } +} + +function mapTrialResult(raw: any): TrialWechatOrderNotifyResult { + return { + success: !!(raw?.success ?? raw?.Success), + skipped: !!(raw?.skipped ?? raw?.Skipped), + status: String(raw?.status ?? raw?.Status ?? ''), + message: raw?.message ?? raw?.Message ?? null, + orderId: Number(raw?.orderId ?? raw?.OrderId ?? 0), + serviceNo: raw?.serviceNo ?? raw?.ServiceNo ?? null, + eventCode: String(raw?.eventCode ?? raw?.EventCode ?? ''), + eventName: raw?.eventName ?? raw?.EventName ?? null, + openId: raw?.openId ?? raw?.OpenId ?? null, + templateId: raw?.templateId ?? raw?.TemplateId ?? null, + url: raw?.url ?? raw?.Url ?? null, + requestUrl: raw?.requestUrl ?? raw?.RequestUrl ?? null, + requestBody: raw?.requestBody ?? raw?.RequestBody ?? null, + responseBody: raw?.responseBody ?? raw?.ResponseBody ?? null, + wxMsgId: raw?.wxMsgId ?? raw?.WxMsgId ?? null, + errCode: raw?.errCode ?? raw?.ErrCode ?? null, + email: mapEmailResult(raw?.email ?? raw?.Email), + } +} + +function prettyJson(raw: string): string { + try { + return JSON.stringify(JSON.parse(raw), null, 2) + } catch { + return raw + } +} + +function formatEmailBlock(email: TrialOrderNotifyEmailResult): string { + const lines = [ + '【邮件试发】', + `状态:${email.status || '-'}`, + `成功:${email.success ? '是' : '否'}`, + ] + if (email.skipped) { + lines.push(`跳过:${email.message || '未知原因'}`) + return lines.join('\n') + } + if (email.message) lines.push(`说明:${email.message}`) + if (email.templateName) lines.push(`模板:${email.templateName}`) + if (email.smtpUsername) lines.push(`发件 SMTP:${email.smtpUsername}`) + if (email.toEmail) lines.push(`收件:${email.toEmail}`) + if (email.subject) { + lines.push('主题:') + lines.push(email.subject) + } + if (email.body) { + lines.push('正文:') + lines.push(email.body) + } + return lines.join('\n') +} + +/** 格式化试发结果(微信 + 邮件) */ +export function formatWechatTrialResultText(result: TrialWechatOrderNotifyResult): string { + const title = result.eventName + ? `${result.eventName}(${result.eventCode})` + : result.eventCode || '-' + const lines = [ + `【微信试发】${title}`, + `运单号:${result.serviceNo || '-'}`, + `订单 Id:${result.orderId || '-'}`, + `状态:${result.status || '-'}`, + `成功:${result.success ? '是' : '否'}`, + ] + if (result.skipped) { + lines.push(`跳过:${result.message || '未知原因'}`) + } else { + if (result.message) lines.push(`说明:${result.message}`) + if (result.openId) lines.push(`OpenId:${result.openId}`) + if (result.templateId) lines.push(`模板 ID:${result.templateId}`) + if (result.url) lines.push(`跳转 URL:${result.url}`) + if (result.wxMsgId) lines.push(`msgid:${result.wxMsgId}`) + if (result.errCode != null) lines.push(`errcode:${result.errCode}`) + if (result.requestUrl) lines.push(`请求:${result.requestUrl}`) + if (result.requestBody) { + lines.push('请求体:') + lines.push(prettyJson(result.requestBody)) + } + if (result.responseBody) { + lines.push('响应:') + lines.push(prettyJson(result.responseBody)) + } + } + + if (result.email) { + lines.push('') + lines.push(formatEmailBlock(result.email)) + } + + return lines.join('\n') +} + +function mapTemplate(raw: any): WechatOrderNotifyTemplateDto { + return { + id: raw?.id ?? raw?.Id, + eventCode: String(raw?.eventCode ?? raw?.EventCode ?? ''), + eventName: String(raw?.eventName ?? raw?.EventName ?? ''), + templateId: raw?.templateId ?? raw?.TemplateId ?? null, + urlTemplate: raw?.urlTemplate ?? raw?.UrlTemplate ?? null, + fieldMappingJson: raw?.fieldMappingJson ?? raw?.FieldMappingJson ?? null, + isEnabled: !!(raw?.isEnabled ?? raw?.IsEnabled), + emailEnabled: !!(raw?.emailEnabled ?? raw?.EmailEnabled), + emailTemplateName: raw?.emailTemplateName ?? raw?.EmailTemplateName ?? null, + emailTemplateOwnerUserId: + raw?.emailTemplateOwnerUserId ?? raw?.EmailTemplateOwnerUserId ?? null, + emailSmtpOwnerUserId: raw?.emailSmtpOwnerUserId ?? raw?.EmailSmtpOwnerUserId ?? null, + emailUseSystemSmtp: !!(raw?.emailUseSystemSmtp ?? raw?.EmailUseSystemSmtp), + remark: raw?.remark ?? raw?.Remark ?? null, + } +} + +function mapSystemSmtp(raw: any): OrderNotifySystemSmtpStatus { + return { + configured: !!(raw?.configured ?? raw?.Configured), + smtpUsername: raw?.smtpUsername ?? raw?.SmtpUsername ?? null, + fromName: raw?.fromName ?? raw?.FromName ?? null, + } +} + export async function getWechatOrderNotifyTemplates() { const res = await axiosInstance.get(omsUrl('/system/wechat-order-notify/templates')) const data = unwrapData<{ - items?: WechatOrderNotifyTemplateDto[] - Items?: WechatOrderNotifyTemplateDto[] - } | WechatOrderNotifyTemplateDto[]>(res.data) - if (Array.isArray(data)) return data - return data?.items ?? data?.Items ?? [] + items?: any[] + Items?: any[] + } | any[]>(res.data) + const list = Array.isArray(data) ? data : (data?.items ?? data?.Items ?? []) + return list.map(mapTemplate) } export async function saveWechatOrderNotifyTemplate(body: SaveWechatOrderNotifyTemplateBody) { const res = await axiosInstance.post(omsUrl('/system/wechat-order-notify/templates/save'), body) - return unwrapData(res.data) + return mapTemplate(unwrapData(res.data)) } export async function trialWechatOrderNotify(body: { eventCode: string orderId?: number serviceNo?: string -}) { +}): Promise { const res = await axiosInstance.post(omsUrl('/system/wechat-order-notify/trial-send'), body) assertBusinessOk(res.data) + return mapTrialResult(unwrapData(res.data)) +} + +export async function getOrderNotifySystemSmtp() { + const res = await axiosInstance.get(omsUrl('/system/wechat-order-notify/system-smtp')) + return mapSystemSmtp(unwrapData(res.data)) +} + +export async function saveOrderNotifySystemSmtp(body: { + smtpUsername: string + smtpPassword: string + serverType?: string + fromName?: string | null +}) { + const res = await axiosInstance.post(omsUrl('/system/wechat-order-notify/system-smtp/save'), body) + assertBusinessOk(res.data) + return mapSystemSmtp(unwrapData(res.data)) } diff --git a/src/locale/en-US.ts b/src/locale/en-US.ts index 558f334..9ec6565 100644 --- a/src/locale/en-US.ts +++ b/src/locale/en-US.ts @@ -2529,8 +2529,18 @@ export default { 'order.myOrders.drawer.tabs.stockBind': 'Bound stock', 'order.myOrders.drawer.tabs.operationLog': 'Operation log', 'order.myOrders.drawer.operationLog.empty': 'No operation logs', + 'order.myOrders.drawer.operationLog.notifyEmpty': 'No notify logs', 'order.myOrders.drawer.operationLog.refresh': 'Refresh', 'order.myOrders.drawer.operationLog.count': '{count} items', + 'order.myOrders.drawer.operationLog.filterAll': 'All', + 'order.myOrders.drawer.operationLog.filterBusiness': 'Business', + 'order.myOrders.drawer.operationLog.filterNotify': 'Notify', + 'order.myOrders.drawer.operationLog.channel': 'Channel', + 'order.myOrders.drawer.operationLog.event': 'Event', + 'order.myOrders.drawer.operationLog.status': 'Status', + 'order.myOrders.drawer.operationLog.statusSent': 'Sent', + 'order.myOrders.drawer.operationLog.statusFailed': 'Failed', + 'order.myOrders.drawer.operationLog.statusSkipped': 'Skipped', 'order.myOrders.drawer.operationLog.field': 'Field', 'order.myOrders.drawer.operationLog.before': 'Before', 'order.myOrders.drawer.operationLog.after': 'After', @@ -4277,11 +4287,34 @@ export default { 'system.otherConfig.brandLogo.uploadSuccess': 'Brand logo updated', 'system.otherConfig.brandLogo.uploadFailed': 'Upload failed', 'system.otherConfig.brandLogo.loadFailed': 'Failed to load brand logo', - 'system.otherConfig.actions.wechatOrderNotify': 'WeChat order notify', - 'system.otherConfig.wechatOrderNotify.title': 'WeChat order notify templates', + 'system.otherConfig.actions.wechatOrderNotify': 'Order notify', + 'system.otherConfig.wechatOrderNotify.title': 'Order notify (WeChat / Email)', 'system.otherConfig.wechatOrderNotify.tip': - 'Pick an event on the left, fill the template, then enable. Customers opt in on H5 Me (off by default). Secrets stay in wechat_mp.', - 'system.otherConfig.wechatOrderNotify.enableLabel': 'Enable', + 'Pick an event; configure WeChat and/or email. Both channels need H5 opt-in; email goes to the customer profile address. Prefer system SMTP so it is not tied to the operator.', + 'system.otherConfig.wechatOrderNotify.enableLabel': 'Enable WeChat', + 'system.otherConfig.wechatOrderNotify.emailEnableLabel': 'Enable email', + 'system.otherConfig.wechatOrderNotify.emailTemplate': 'Email template', + 'system.otherConfig.wechatOrderNotify.emailTemplatePh': 'Select a batch-email template', + 'system.otherConfig.wechatOrderNotify.emailTemplateRequired': 'Select a template when email is enabled', + 'system.otherConfig.wechatOrderNotify.emailGoBatch': 'Open Batch Email to edit templates / SMTP', + 'system.otherConfig.wechatOrderNotify.emailHint': + 'Subject/body placeholders match Batch Email; English tokens like {serviceNo}{latestTrack} also work.', + 'system.otherConfig.wechatOrderNotify.emailHintShort': + 'Same placeholders as Batch Email; optional system SMTP', + 'system.otherConfig.wechatOrderNotify.emailUseSystemSmtp': 'Sender', + 'system.otherConfig.wechatOrderNotify.emailUseSystemSmtpHint': 'Use system SMTP (not tied to operator)', + 'system.otherConfig.wechatOrderNotify.systemSmtpTitle': 'System SMTP', + 'system.otherConfig.wechatOrderNotify.systemSmtpConfigured': 'Configured: {account}', + 'system.otherConfig.wechatOrderNotify.systemSmtpMissing': 'System SMTP not configured yet', + 'system.otherConfig.wechatOrderNotify.systemSmtpEdit': 'Configure', + 'system.otherConfig.wechatOrderNotify.systemSmtpCollapse': 'Collapse', + 'system.otherConfig.wechatOrderNotify.systemSmtpSave': 'Save system SMTP', + 'system.otherConfig.wechatOrderNotify.systemSmtpSaveSuccess': 'System SMTP saved', + 'system.otherConfig.wechatOrderNotify.systemSmtpSaveFailed': 'Failed to save system SMTP', + 'system.otherConfig.wechatOrderNotify.systemSmtpUsernameRequired': 'Enter SMTP username', + 'system.otherConfig.wechatOrderNotify.systemSmtpFromName': 'From display name', + 'system.otherConfig.wechatOrderNotify.channelWechat': 'WeChat', + 'system.otherConfig.wechatOrderNotify.channelEmail': 'Email', 'system.otherConfig.wechatOrderNotify.emptySelect': 'Select an event', 'system.otherConfig.wechatOrderNotify.templateId': 'Template ID', 'system.otherConfig.wechatOrderNotify.templateIdPh': 'MP template message ID', @@ -4292,18 +4325,25 @@ export default { 'Placeholders: {baseUrl} {orderId} {serviceNo}', 'system.otherConfig.wechatOrderNotify.fieldMapping': 'Field mapping JSON', 'system.otherConfig.wechatOrderNotify.fieldMappingPh': - '[{"key":"keyword1","placeholder":"serviceNo"}]', + '[{"key":"character_string2","placeholder":"clientNo"}]', + 'system.otherConfig.wechatOrderNotify.fieldMappingTipTitle': 'Mapping example', + 'system.otherConfig.wechatOrderNotify.fieldMappingTipDesc': + 'key = WeChat template field (without .DATA); placeholder = OMS value. e.g. order no → character_string2, waybill → character_string15, destination → thing9, signed at → time14.', 'system.otherConfig.wechatOrderNotify.fieldMappingHelp': - 'Placeholders: serviceNo / clientNo / orderStatusName / eventName / eventTime / remark / customerName / consigneeCountry', - 'system.otherConfig.wechatOrderNotify.trialServiceNo': 'Trial waybill no.', + 'Placeholders: serviceNo / clientNo / orderId / orderStatus / orderStatusName / eventName / eventTime / remark / customerName / consigneeCountry / payableAmount / issueContent / issueTitle / issueRemark / inboundTime / outboundTime / signTime / payTime / latestTrack', + 'system.otherConfig.wechatOrderNotify.trialServiceNo': 'Waybill no.', 'system.otherConfig.wechatOrderNotify.trialServiceNoRequired': 'Enter a waybill number', 'system.otherConfig.wechatOrderNotify.trial': 'Trial send', + 'system.otherConfig.wechatOrderNotify.trialPanel': 'Trial send', + 'system.otherConfig.wechatOrderNotify.trialHint': + 'Trial by waybill: skips subscribe/dedupe; email uses enabled template + chosen SMTP', 'system.otherConfig.wechatOrderNotify.save': 'Save event', 'system.otherConfig.wechatOrderNotify.saveSuccess': 'Saved', 'system.otherConfig.wechatOrderNotify.saveFailed': 'Save failed', 'system.otherConfig.wechatOrderNotify.loadFailed': 'Load failed', - 'system.otherConfig.wechatOrderNotify.trialSuccess': 'Trial submitted (check log / WeChat)', + 'system.otherConfig.wechatOrderNotify.trialSuccess': 'Trial finished', 'system.otherConfig.wechatOrderNotify.trialFailed': 'Trial failed', + 'system.otherConfig.wechatOrderNotify.trialResultTitle': 'WeChat trial result', 'system.otherConfig.paymentQr.title': 'Deposit Payment QR', 'system.otherConfig.paymentQr.tip': 'Shown on PC/H5 deposit pages. Changes take effect immediately; default images are used when empty.', diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index 3678723..2a30850 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -2329,8 +2329,18 @@ export default { 'order.myOrders.drawer.tabs.stockBind': '绑定包裹/库存', 'order.myOrders.drawer.tabs.operationLog': '操作日志', 'order.myOrders.drawer.operationLog.empty': '暂无操作日志', + 'order.myOrders.drawer.operationLog.notifyEmpty': '暂无通知日志', 'order.myOrders.drawer.operationLog.refresh': '刷新', 'order.myOrders.drawer.operationLog.count': '{count} 条', + 'order.myOrders.drawer.operationLog.filterAll': '全部', + 'order.myOrders.drawer.operationLog.filterBusiness': '业务', + 'order.myOrders.drawer.operationLog.filterNotify': '通知', + 'order.myOrders.drawer.operationLog.channel': '通道', + 'order.myOrders.drawer.operationLog.event': '事件', + 'order.myOrders.drawer.operationLog.status': '状态', + 'order.myOrders.drawer.operationLog.statusSent': '成功', + 'order.myOrders.drawer.operationLog.statusFailed': '失败', + 'order.myOrders.drawer.operationLog.statusSkipped': '跳过', 'order.myOrders.drawer.operationLog.field': '字段', 'order.myOrders.drawer.operationLog.before': '修改前', 'order.myOrders.drawer.operationLog.after': '修改后', @@ -4289,11 +4299,34 @@ export default { 'system.otherConfig.brandLogo.uploadSuccess': '品牌 Logo 已更新', 'system.otherConfig.brandLogo.uploadFailed': '上传失败', 'system.otherConfig.brandLogo.loadFailed': '加载品牌 Logo 失败', - 'system.otherConfig.actions.wechatOrderNotify': '微信订单通知', - 'system.otherConfig.wechatOrderNotify.title': '微信订单通知模板', + 'system.otherConfig.actions.wechatOrderNotify': '订单通知', + 'system.otherConfig.wechatOrderNotify.title': '订单通知(微信 / 邮件)', 'system.otherConfig.wechatOrderNotify.tip': - '左侧选事件,右侧填模板后启用。客户需在 H5「我的」自行订阅(默认全关)。密钥沿用 wechat_mp。', - 'system.otherConfig.wechatOrderNotify.enableLabel': '启用推送', + '左侧选事件;右侧分别配置微信模板消息与邮件。微信/邮件均需客户 H5 订阅;邮件发给客户资料中的邮箱。发信可选用系统 SMTP,避免绑个人账号。', + 'system.otherConfig.wechatOrderNotify.enableLabel': '启用微信', + 'system.otherConfig.wechatOrderNotify.emailEnableLabel': '启用邮件', + 'system.otherConfig.wechatOrderNotify.emailTemplate': '邮件模板', + 'system.otherConfig.wechatOrderNotify.emailTemplatePh': '选择 batch-email 模板', + 'system.otherConfig.wechatOrderNotify.emailTemplateRequired': '启用邮件时请选择模板', + 'system.otherConfig.wechatOrderNotify.emailGoBatch': '去批量邮件编辑模板 / SMTP', + 'system.otherConfig.wechatOrderNotify.emailHint': + '主题/正文占位与批量邮件一致,另支持 {serviceNo}{payableAmount}{latestTrack}{signTime} 等英文字段。', + 'system.otherConfig.wechatOrderNotify.emailHintShort': + '占位同批量邮件;可选用系统 SMTP', + 'system.otherConfig.wechatOrderNotify.emailUseSystemSmtp': '发信账号', + 'system.otherConfig.wechatOrderNotify.emailUseSystemSmtpHint': '使用系统发信 SMTP(与配置人解耦)', + 'system.otherConfig.wechatOrderNotify.systemSmtpTitle': '系统发信 SMTP', + 'system.otherConfig.wechatOrderNotify.systemSmtpConfigured': '已配置:{account}', + 'system.otherConfig.wechatOrderNotify.systemSmtpMissing': '尚未配置系统发信账号', + 'system.otherConfig.wechatOrderNotify.systemSmtpEdit': '配置', + 'system.otherConfig.wechatOrderNotify.systemSmtpCollapse': '收起', + 'system.otherConfig.wechatOrderNotify.systemSmtpSave': '保存系统 SMTP', + 'system.otherConfig.wechatOrderNotify.systemSmtpSaveSuccess': '系统 SMTP 已保存', + 'system.otherConfig.wechatOrderNotify.systemSmtpSaveFailed': '系统 SMTP 保存失败', + 'system.otherConfig.wechatOrderNotify.systemSmtpUsernameRequired': '请填写 SMTP 账号', + 'system.otherConfig.wechatOrderNotify.systemSmtpFromName': '发件人显示名', + 'system.otherConfig.wechatOrderNotify.channelWechat': '微信', + 'system.otherConfig.wechatOrderNotify.channelEmail': '邮件', 'system.otherConfig.wechatOrderNotify.emptySelect': '请选择左侧事件', 'system.otherConfig.wechatOrderNotify.templateId': '微信模板 ID', 'system.otherConfig.wechatOrderNotify.templateIdPh': '公众号后台模板消息 ID', @@ -4304,18 +4337,25 @@ export default { '可用占位:{baseUrl} {orderId} {serviceNo}', 'system.otherConfig.wechatOrderNotify.fieldMapping': '字段映射 JSON', 'system.otherConfig.wechatOrderNotify.fieldMappingPh': - '[{"key":"keyword1","placeholder":"serviceNo"}]', + '[{"key":"character_string2","placeholder":"clientNo"}]', + 'system.otherConfig.wechatOrderNotify.fieldMappingTipTitle': '映射示例', + 'system.otherConfig.wechatOrderNotify.fieldMappingTipDesc': + 'key = 微信模板字段名(去掉 .DATA);placeholder = 系统取值。例如:订单号 → character_string2、物流单号 → character_string15、目的地 → thing9、签收时间 → time14。', 'system.otherConfig.wechatOrderNotify.fieldMappingHelp': - 'placeholder 可用:serviceNo / clientNo / orderStatusName / eventName / eventTime / remark / customerName / consigneeCountry', - 'system.otherConfig.wechatOrderNotify.trialServiceNo': '试发运单号', + 'placeholder 可用:serviceNo / clientNo / orderId / orderStatus / orderStatusName / eventName / eventTime / remark / customerName / consigneeCountry / payableAmount / issueContent / issueTitle / issueRemark / inboundTime / outboundTime / signTime / payTime / latestTrack(最新轨迹)', + 'system.otherConfig.wechatOrderNotify.trialServiceNo': '运单号', 'system.otherConfig.wechatOrderNotify.trialServiceNoRequired': '请输入试发运单号', 'system.otherConfig.wechatOrderNotify.trial': '试发', + 'system.otherConfig.wechatOrderNotify.trialPanel': '试发校验', + 'system.otherConfig.wechatOrderNotify.trialHint': + '按运单号试发:跳过客户订阅与去重;邮件走已启用模板与所选 SMTP', 'system.otherConfig.wechatOrderNotify.save': '保存当前事件', 'system.otherConfig.wechatOrderNotify.saveSuccess': '已保存', 'system.otherConfig.wechatOrderNotify.saveFailed': '保存失败', 'system.otherConfig.wechatOrderNotify.loadFailed': '加载失败', - 'system.otherConfig.wechatOrderNotify.trialSuccess': '已提交试发(请查看发送日志/微信)', + 'system.otherConfig.wechatOrderNotify.trialSuccess': '试发完成', 'system.otherConfig.wechatOrderNotify.trialFailed': '试发失败', + 'system.otherConfig.wechatOrderNotify.trialResultTitle': '微信试发结果', 'system.otherConfig.paymentQr.title': '充值收款码', 'system.otherConfig.paymentQr.tip': '用于客户 PC / H5 充值页展示。更换后立即生效;未上传时前端使用默认图。', diff --git a/src/views/h5/customer-center/components/H5WechatNotifySheet.vue b/src/views/h5/customer-center/components/H5WechatNotifySheet.vue index 2d32e10..ba2c789 100644 --- a/src/views/h5/customer-center/components/H5WechatNotifySheet.vue +++ b/src/views/h5/customer-center/components/H5WechatNotifySheet.vue @@ -22,7 +22,7 @@
- + {{ t('h5.me.wechatNotifyNeedBind') }} - + {{ t('h5.me.wechatNotifyReady') }} + + {{ t('h5.me.wechatNotifyNeedEmail') }} + + + {{ t('h5.me.wechatNotifyEmailReady') }} +

{{ t('h5.me.wechatNotifyGuideTip') }}

{{ t('h5.me.wechatNotifyTip') }}

-
+
-
@@ -66,7 +86,7 @@ +
@@ -806,11 +822,11 @@ - {{ $t('order.myOrders.drawer.operationLog.count', { count: operationLogList.length }) }} + {{ $t('order.myOrders.drawer.operationLog.count', { count: operationLogVisibleCount }) }}
@@ -1047,7 +1063,9 @@ import { postOrderRecalculateReceivable, postOrderRecalculatePayable, postOrderAdditionalServicesUpdate, + getOrderNotifyLogList, getOrderOperationLogList, + type OrderNotifyLogItem, type OrderOperationLogItem, } from '@/api/order'; import { getSalesProductDetail, getSalesProductList } from '@/api/channel/salesProduct'; @@ -1518,8 +1536,32 @@ const tabList = computed(() => [ { key: 'operationLog', label: t('order.myOrders.drawer.tabs.operationLog') }, ]); +const NOTIFY_OPS_ACTIONS = new Set(['notifyWechat', 'notifyEmail']); +type OperationLogFilter = 'all' | 'business' | 'notify'; + const operationLogList = ref([]); +const notifyLogList = ref([]); const operationLogLoading = ref(false); +const operationLogFilter = ref('all'); + +const operationLogFilterOptions = computed(() => [ + { key: 'all' as const, label: t('order.myOrders.drawer.operationLog.filterAll') }, + { key: 'business' as const, label: t('order.myOrders.drawer.operationLog.filterBusiness') }, + { key: 'notify' as const, label: t('order.myOrders.drawer.operationLog.filterNotify') }, +]); + +const filteredOperationLogList = computed(() => { + if (operationLogFilter.value === 'business') { + return operationLogList.value.filter((x) => !NOTIFY_OPS_ACTIONS.has(x.action)); + } + return operationLogList.value; +}); + +const operationLogVisibleCount = computed(() => + operationLogFilter.value === 'notify' + ? notifyLogList.value.length + : filteredOperationLogList.value.length, +); const operationLogColumns = computed(() => [ { @@ -1546,8 +1588,38 @@ const operationLogColumns = computed(() => [ }, ]); +const notifyLogColumns = computed(() => [ + { + title: t('order.myOrders.drawer.operationLog.time'), + dataIndex: 'createTime', + width: 188, + bodyCellClass: 'operation-log-time-cell', + }, + { + title: t('order.myOrders.drawer.operationLog.channel'), + dataIndex: 'channelName', + width: 80, + }, + { + title: t('order.myOrders.drawer.operationLog.event'), + dataIndex: 'eventName', + width: 110, + }, + { + title: t('order.myOrders.drawer.operationLog.status'), + dataIndex: 'statusLabel', + width: 80, + }, + { + title: t('order.myOrders.drawer.operationLog.content'), + dataIndex: 'summary', + ellipsis: true, + tooltip: true, + }, +]); + const operationLogTableData = computed(() => - operationLogList.value.map((item) => ({ + filteredOperationLogList.value.map((item) => ({ id: item.id, createTime: formatOperationLogTime(item.createTime), actionName: item.actionName || item.action || '--', @@ -1556,6 +1628,17 @@ const operationLogTableData = computed(() => })), ); +const notifyLogTableData = computed(() => + notifyLogList.value.map((item) => ({ + id: item.id, + createTime: formatOperationLogTime(item.createTime), + channelName: item.channelName || item.channel || '--', + eventName: item.eventName || item.eventCode || '--', + statusLabel: formatNotifyStatus(item.status), + summary: item.summary || item.errMsg || '—', + })), +); + const slidingTabItems = computed(() => tabList.value.map((tab) => ({ key: tab.key, label: tab.label })), ); @@ -2846,14 +2929,20 @@ async function loadOperationLogs() { const id = orderId.value; if (!id) { operationLogList.value = []; + notifyLogList.value = []; return; } operationLogLoading.value = true; try { - const res = await getOrderOperationLogList(id); - operationLogList.value = res.items || []; + const [ops, notify] = await Promise.all([ + getOrderOperationLogList(id), + getOrderNotifyLogList(id), + ]); + operationLogList.value = ops.items || []; + notifyLogList.value = notify.items || []; } catch { operationLogList.value = []; + notifyLogList.value = []; } finally { operationLogLoading.value = false; } @@ -2867,6 +2956,14 @@ function formatOperationLogTime(value?: string) { return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`; } +function formatNotifyStatus(status?: string) { + const key = String(status || '').toLowerCase(); + if (key === 'sent') return t('order.myOrders.drawer.operationLog.statusSent'); + if (key === 'failed') return t('order.myOrders.drawer.operationLog.statusFailed'); + if (key === 'skipped') return t('order.myOrders.drawer.operationLog.statusSkipped'); + return status || '--'; +} + function handleTabChange(tabKey: string) { resetEditState(); if (tabKey === 'basic') { @@ -4328,6 +4425,35 @@ defineExpose({ } } +.operation-log-filter { + display: inline-flex; + align-items: center; + gap: 2px; + margin-bottom: 10px; + padding: 2px; + border-radius: 8px; + background: var(--color-fill-2, #e5e6eb); + flex-shrink: 0; +} + +.operation-log-filter__btn { + height: 26px; + padding: 0 12px; + border: 0; + border-radius: 6px; + background: transparent; + color: var(--color-text-2); + font-size: 12px; + font-weight: 500; + cursor: pointer; + + &.is-active { + background: #fff; + color: var(--color-text-1); + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); + } +} + .operation-log-info { display: flex; flex-direction: column; diff --git a/src/views/system/otherConfig/index.vue b/src/views/system/otherConfig/index.vue index 01fa12c..b48cb7b 100644 --- a/src/views/system/otherConfig/index.vue +++ b/src/views/system/otherConfig/index.vue @@ -331,12 +331,66 @@ v-model:visible="wechatNotifyVisible" :title="t('system.otherConfig.wechatOrderNotify.title')" :footer="false" - width="920px" + width="1040px" :mask-closable="false" unmount-on-close modal-class="wechat-notify-modal" >

{{ t('system.otherConfig.wechatOrderNotify.tip') }}

+
+
+
+ {{ t('system.otherConfig.wechatOrderNotify.systemSmtpTitle') }} +

+ {{ + systemSmtpStatus?.configured + ? t('system.otherConfig.wechatOrderNotify.systemSmtpConfigured', { + account: systemSmtpStatus.smtpUsername || '-', + }) + : t('system.otherConfig.wechatOrderNotify.systemSmtpMissing') + }} +

+
+ + {{ + systemSmtpFormVisible + ? t('system.otherConfig.wechatOrderNotify.systemSmtpCollapse') + : t('system.otherConfig.wechatOrderNotify.systemSmtpEdit') + }} + +
+
+ + + + + + + + + + {{ t('system.batchEmail.server.qiye') }} + {{ t('system.batchEmail.server.qiyeSsl') }} + {{ t('system.batchEmail.server.aliyun') }} + {{ t('system.batchEmail.server.aliyunSsl') }} + {{ t('system.batchEmail.server.mxhichina') }} + + + + + + + {{ t('system.otherConfig.wechatOrderNotify.systemSmtpSave') }} + + +
+
@@ -354,83 +408,209 @@ {{ item.eventName }} {{ item.eventCode }} - - {{ - item.isEnabled - ? t('system.otherConfig.status.enabled') - : t('system.otherConfig.status.disabled') - }} + + + {{ t('system.otherConfig.wechatOrderNotify.channelWechat') }} + + + {{ t('system.otherConfig.wechatOrderNotify.channelEmail') }} +
-
+

{{ wechatNotifyActive.eventName }}

-

{{ wechatNotifyActive.eventCode }}

+ {{ wechatNotifyActive.eventCode }}
-
- {{ - t('system.otherConfig.wechatOrderNotify.enableLabel') - }} - +
+ +
- - + - - - - - - - - - - - - - - +
+ + +
+
+ + + + + + +
+ + + + + + + +
+ + + {{ t('system.otherConfig.wechatOrderNotify.emailGoBatch') }} + +
+ + + + + + + +
+
+ {{ t('system.batchEmail.subject') }} + {{ selectedBatchEmailTpl.subject || '-' }} +
+
{{
+                  selectedBatchEmailTpl.content || ''
+                }}
+
+
+