mirror of
https://github.com/34892002/edgeKey.git
synced 2026-09-03 06:47:41 +08:00
feat: 邮件模板新增 顾客邮箱
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -105,21 +105,21 @@ const defaultTemplates: Record<EmailScene, EmailTemplateValue> = {
|
||||
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,
|
||||
|
||||
@@ -80,6 +80,7 @@ export const EMAIL_TEMPLATE_VARIABLES: Record<EmailScene, EmailTemplateVariable[
|
||||
ORDER_PAID: [
|
||||
{ name: "siteName", description: "站点名称(来自站点设置)" },
|
||||
{ name: "orderNo", description: "订单号" },
|
||||
{ name: "contactEmail", description: "顾客邮箱" },
|
||||
{ name: "productName", description: "商品名称" },
|
||||
{ name: "amount", description: "订单金额" },
|
||||
{ name: "buyerNote", description: "买家备注" },
|
||||
@@ -89,6 +90,7 @@ export const EMAIL_TEMPLATE_VARIABLES: Record<EmailScene, EmailTemplateVariable[
|
||||
DELIVERY_SUCCESS: [
|
||||
{ name: "siteName", description: "站点名称(来自站点设置)" },
|
||||
{ name: "orderNo", description: "订单号" },
|
||||
{ name: "contactEmail", description: "顾客邮箱" },
|
||||
{ name: "productName", description: "商品名称" },
|
||||
{ name: "quantity", description: "购买数量" },
|
||||
{ name: "buyerNote", description: "买家备注" },
|
||||
@@ -99,6 +101,7 @@ export const EMAIL_TEMPLATE_VARIABLES: Record<EmailScene, EmailTemplateVariable[
|
||||
DELIVERY_FAILED: [
|
||||
{ name: "siteName", description: "站点名称(来自站点设置)" },
|
||||
{ name: "orderNo", description: "订单号" },
|
||||
{ name: "contactEmail", description: "顾客邮箱" },
|
||||
{ name: "productName", description: "商品名称" },
|
||||
{ name: "buyerNote", description: "买家备注" },
|
||||
{ name: "errorMessage", description: "失败原因" },
|
||||
|
||||
@@ -673,6 +673,7 @@ export async function handlePaymentNotify(
|
||||
productName: order.productNameSnapshot,
|
||||
amount: order.amount,
|
||||
toEmail: order.contactValue,
|
||||
contactEmail: order.contactValue,
|
||||
buyerNote: order.buyerNote,
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -27,6 +27,7 @@ VALUES
|
||||
('ORDER_PAID', '支付成功通知', '[{{siteName}}] 订单 {{orderNo}} 支付成功', '您的订单已支付成功。
|
||||
|
||||
订单号:{{orderNo}}
|
||||
顾客邮箱:{{contactEmail}}
|
||||
商品:{{productName}}
|
||||
金额:{{amount}}
|
||||
备注:{{buyerNote}}
|
||||
@@ -36,6 +37,7 @@ VALUES
|
||||
('DELIVERY_SUCCESS', '发货成功通知', '[{{siteName}}] 订单 {{orderNo}} 已发货', '您的订单已完成发货。
|
||||
|
||||
订单号:{{orderNo}}
|
||||
顾客邮箱:{{contactEmail}}
|
||||
商品:{{productName}}
|
||||
数量:{{quantity}}
|
||||
备注:{{buyerNote}}
|
||||
@@ -47,6 +49,7 @@ VALUES
|
||||
('DELIVERY_FAILED', '发货失败通知', '[{{siteName}}] 订单 {{orderNo}} 发货失败', '订单发货失败,请尽快处理。
|
||||
|
||||
订单号:{{orderNo}}
|
||||
顾客邮箱:{{contactEmail}}
|
||||
商品:{{productName}}
|
||||
备注:{{buyerNote}}
|
||||
失败原因:{{errorMessage}}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"binding": "DB",
|
||||
"database_name": "edgekey-db",
|
||||
"migrations_dir": "prisma/migrations",
|
||||
"database_id": "24390dbc-b9c6-4ae6-8c7f-507fb2eb36f2", // 执行 wrangler d1 命令必须,但是与cf一键部署冲突所以注释
|
||||
// "database_id": "24390dbc-b9c6-4ae6-8c7f-507fb2eb36f2", // 执行 wrangler d1 命令必须,但是与cf一键部署冲突所以注释
|
||||
}
|
||||
],
|
||||
"triggers": {
|
||||
|
||||
Reference in New Issue
Block a user