diff --git a/modules/delivery/service.ts b/modules/delivery/service.ts index 0d482b7..32e3092 100644 --- a/modules/delivery/service.ts +++ b/modules/delivery/service.ts @@ -85,6 +85,7 @@ export async function deliverOrder(prisma: PrismaClient, orderNo: string) { quantity: order.quantity, items: contents, toEmail: order.contactValue, + contactEmail: order.contactValue, buyerNote: order.buyerNote, }); } catch (error) { @@ -125,6 +126,7 @@ export async function deliverOrder(prisma: PrismaClient, orderNo: string) { queryToken: order.queryToken, productName: order.productNameSnapshot, toEmail: order.contactValue, + contactEmail: order.contactValue, errorMessage: getErrorMessage(error, "delivery failed"), buyerNote: order.buyerNote, }); @@ -193,6 +195,7 @@ export async function adminDeliverOrder(prisma: PrismaClient, orderId: number, i quantity: order.quantity, items: [content], toEmail: order.contactValue, + contactEmail: order.contactValue, buyerNote: order.buyerNote, }); } catch (error) { diff --git a/modules/email/service.ts b/modules/email/service.ts index c298129..da95d92 100644 --- a/modules/email/service.ts +++ b/modules/email/service.ts @@ -105,21 +105,21 @@ const defaultTemplates: Record = { scene: "ORDER_PAID", name: "支付成功通知", subject: "[{{siteName}}] 订单 {{orderNo}} 支付成功", - content: "您的订单已支付成功。\n\n订单号:{{orderNo}}\n商品:{{productName}}\n金额:{{amount}}\n备注:{{buyerNote}}\n查询地址:{{queryUrl}}\n\n{{footerText}}", + content: "您的订单已支付成功。\n\n订单号:{{orderNo}}\n顾客邮箱:{{contactEmail}}\n商品:{{productName}}\n金额:{{amount}}\n备注:{{buyerNote}}\n查询地址:{{queryUrl}}\n\n{{footerText}}", isEnabled: true, }, DELIVERY_SUCCESS: { scene: "DELIVERY_SUCCESS", name: "发货成功通知", subject: "[{{siteName}}] 订单 {{orderNo}} 已发货", - content: "您的订单已完成发货。\n\n订单号:{{orderNo}}\n商品:{{productName}}\n数量:{{quantity}}\n备注:{{buyerNote}}\n发货内容:\n{{deliveryItems}}\n\n查询地址:{{queryUrl}}\n客服联系方式:{{supportContact}}", + content: "您的订单已完成发货。\n\n订单号:{{orderNo}}\n顾客邮箱:{{contactEmail}}\n商品:{{productName}}\n数量:{{quantity}}\n备注:{{buyerNote}}\n发货内容:\n{{deliveryItems}}\n\n查询地址:{{queryUrl}}\n客服联系方式:{{supportContact}}", isEnabled: true, }, DELIVERY_FAILED: { scene: "DELIVERY_FAILED", name: "发货失败通知", subject: "[{{siteName}}] 订单 {{orderNo}} 发货失败", - content: "订单发货失败,请尽快处理。\n\n订单号:{{orderNo}}\n商品:{{productName}}\n备注:{{buyerNote}}\n失败原因:{{errorMessage}}\n\n查询地址:{{queryUrl}}\n客服联系方式:{{supportContact}}", + content: "订单发货失败,请尽快处理。\n\n订单号:{{orderNo}}\n顾客邮箱:{{contactEmail}}\n商品:{{productName}}\n备注:{{buyerNote}}\n失败原因:{{errorMessage}}\n\n查询地址:{{queryUrl}}\n客服联系方式:{{supportContact}}", isEnabled: true, }, }; @@ -839,6 +839,7 @@ export async function notifyOrderPaid(input: { productName: string; amount: number; toEmail?: string | null; + contactEmail?: string | null; buyerNote?: string | null; }) { const prisma = input.prisma ?? getEmailContext().prisma; @@ -852,6 +853,7 @@ export async function notifyOrderPaid(input: { const values = { siteName: baseValues.siteName, orderNo: input.orderNo, + contactEmail: input.contactEmail || "未知", productName: input.productName, amount: (input.amount / 100).toFixed(2), queryUrl: getQueryUrl(baseValues.baseOrigin, input.orderNo, input.queryToken), @@ -903,6 +905,7 @@ export async function notifyDeliverySuccess(input: { quantity: number; items: string[]; toEmail?: string | null; + contactEmail?: string | null; buyerNote?: string | null; }) { const prisma = input.prisma ?? getEmailContext().prisma; @@ -916,6 +919,7 @@ export async function notifyDeliverySuccess(input: { const values = { siteName: baseValues.siteName, orderNo: input.orderNo, + contactEmail: input.contactEmail || "未知", productName: input.productName, quantity: String(input.quantity), buyerNote: input.buyerNote || "无", @@ -966,6 +970,7 @@ export async function notifyDeliveryFailed(input: { queryToken: string; productName: string; toEmail?: string | null; + contactEmail?: string | null; errorMessage: string; buyerNote?: string | null; }) { @@ -980,6 +985,7 @@ export async function notifyDeliveryFailed(input: { const values = { siteName: baseValues.siteName, orderNo: input.orderNo, + contactEmail: input.contactEmail || "未知", productName: input.productName, buyerNote: input.buyerNote || "无", errorMessage: input.errorMessage, diff --git a/modules/email/types.ts b/modules/email/types.ts index 102fd7c..afdf819 100644 --- a/modules/email/types.ts +++ b/modules/email/types.ts @@ -80,6 +80,7 @@ export const EMAIL_TEMPLATE_VARIABLES: Record