From 0eb94f2ba16ad9167503a54f40f6e630817d3567 Mon Sep 17 00:00:00 2001 From: Zhang Chengdong Date: Fri, 18 Sep 2026 12:12:51 +0000 Subject: [PATCH] feat(mall): claim and redeem shop coupons from the storefront The product page loads a shop's claimable coupons through the shared client and claims them in place; the buyer coupon list reads owned snapshots with their claimed/redeemed/expired state. Checkout offers each shop order at most one owned coupon and submits only the choice; the pay page and order detail render the server-persisted discount and reduced total, never a client figure. Coupon fixtures leave the pages; the fixed-data adapter still serves the coupon domain as the rollback path. The demo seed creates two deterministic templates and claims them for the demo customer. --- apps/mall/locales/checkout.ts | 6 +++ apps/mall/locales/product.ts | 6 +++ apps/mall/locales/user.ts | 8 ++++ apps/mall/pages/checkout/index.vue | 67 +++++++++++++++++++++++++--- apps/mall/pages/checkout/pay.vue | 9 ++++ apps/mall/pages/goods/[id].vue | 67 +++++++++++++++++++++++++--- apps/mall/pages/user/coupons.vue | 51 ++++++++++++++++++--- apps/mall/pages/user/orders/[id].vue | 10 +++++ scripts/seed-demo.mjs | 41 +++++++++++++++++ 9 files changed, 249 insertions(+), 16 deletions(-) diff --git a/apps/mall/locales/checkout.ts b/apps/mall/locales/checkout.ts index 03aaf31..f7dea0d 100644 --- a/apps/mall/locales/checkout.ts +++ b/apps/mall/locales/checkout.ts @@ -23,6 +23,9 @@ export default { alipay: "Alipay", payTitle: "Pay for your order", orderNo: "Order no.", + coupon: "Coupon", + noCoupon: "No coupon", + couponDiscount: "Coupon discount", grandTotal: "Total payment", confirmPay: "Confirm payment", noPendingOrders: "There are no orders waiting for payment.", @@ -58,6 +61,9 @@ export default { alipay: "支付宝", payTitle: "订单支付", orderNo: "订单号", + coupon: "优惠券", + noCoupon: "不使用优惠券", + couponDiscount: "优惠券抵扣", grandTotal: "应付总额", confirmPay: "确认支付", noPendingOrders: "暂无待支付订单。", diff --git a/apps/mall/locales/product.ts b/apps/mall/locales/product.ts index c4ba660..9427952 100644 --- a/apps/mall/locales/product.ts +++ b/apps/mall/locales/product.ts @@ -13,6 +13,9 @@ export default { coupon: "Coupon", coupons: "Available coupons", claim: "Claim", + claimed: "Claimed", + claimFailed: "Unable to claim this coupon", + loginToClaim: "Sign in to claim", choose: "Choose", selected: "Selected", quantity: "Quantity", @@ -58,6 +61,9 @@ export default { coupon: "优惠券", coupons: "可用优惠券", claim: "领取", + claimed: "已领取", + claimFailed: "优惠券领取失败", + loginToClaim: "登录后领取", choose: "选择", selected: "已选", quantity: "数量", diff --git a/apps/mall/locales/user.ts b/apps/mall/locales/user.ts index db58a22..3fea389 100644 --- a/apps/mall/locales/user.ts +++ b/apps/mall/locales/user.ts @@ -83,6 +83,10 @@ export default { threshold: "Minimum spend", expiresAt: "Expires", noCoupons: "No coupons yet.", + couponStatus: "Status", + couponClaimed: "Claimed", + couponRedeemed: "Used", + couponExpired: "Expired", invoicesTitle: "My invoices", invoiceNo: "Invoice no.", invoiceOrderNo: "Order no.", @@ -176,6 +180,10 @@ export default { threshold: "使用门槛", expiresAt: "有效期至", noCoupons: "暂无优惠券。", + couponStatus: "状态", + couponClaimed: "未使用", + couponRedeemed: "已使用", + couponExpired: "已过期", invoicesTitle: "我的发票", invoiceNo: "发票号", invoiceOrderNo: "订单号", diff --git a/apps/mall/pages/checkout/index.vue b/apps/mall/pages/checkout/index.vue index eb2b8d8..63e05a3 100644 --- a/apps/mall/pages/checkout/index.vue +++ b/apps/mall/pages/checkout/index.vue @@ -1,6 +1,6 @@