mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-08 01:48:56 +08:00
feat(buyer): 更新电子卡券(E_COUPON)相关逻辑与展示
- 优化购物车与支付页面,确保电子卡券只能通过立即购买结算 - 增强商品详情页,添加限时折扣与第N件优惠展示 - 更新促销逻辑,支持拼团与积分购买选项 - 规范化商品类型与库存提示,提升用户体验
This commit is contained in:
@@ -11,18 +11,21 @@
|
||||
export const CARD_KEY_STATUS = {
|
||||
UNUSED: "UNUSED",
|
||||
ALLOCATED: "ALLOCATED",
|
||||
RESERVED: "RESERVED",
|
||||
VOIDED: "VOIDED",
|
||||
};
|
||||
|
||||
export const CARD_KEY_STATUS_TEXT = {
|
||||
UNUSED: "未使用",
|
||||
ALLOCATED: "已分配",
|
||||
RESERVED: "已预占",
|
||||
VOIDED: "已作废",
|
||||
};
|
||||
|
||||
export const CARD_KEY_STATUS_TAG = {
|
||||
UNUSED: "success",
|
||||
ALLOCATED: "info",
|
||||
RESERVED: "warning",
|
||||
VOIDED: "danger",
|
||||
};
|
||||
|
||||
@@ -30,6 +33,7 @@ export const CARD_KEY_STATUS_TAG = {
|
||||
export const CARD_KEY_STATUS_TABS = [
|
||||
{ key: "", label: "全部" },
|
||||
{ key: CARD_KEY_STATUS.UNUSED, label: "未使用" },
|
||||
{ key: CARD_KEY_STATUS.RESERVED, label: "已预占" },
|
||||
{ key: CARD_KEY_STATUS.ALLOCATED, label: "已分配" },
|
||||
{ key: CARD_KEY_STATUS.VOIDED, label: "已作废" },
|
||||
];
|
||||
|
||||
152
seller/src/constants/goodsType.js
Normal file
152
seller/src/constants/goodsType.js
Normal file
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* 卡密商品(E_COUPON)— 商家端公共常量
|
||||
*
|
||||
* @author Mike
|
||||
* @date 2026-08-02
|
||||
*/
|
||||
export const E_COUPON_GOODS_TYPE = "E_COUPON";
|
||||
|
||||
export function isECoupon(goodsType) {
|
||||
return goodsType === E_COUPON_GOODS_TYPE;
|
||||
}
|
||||
|
||||
export function goodsTypeLabel(goodsType) {
|
||||
const map = {
|
||||
E_COUPON: "电子卡券",
|
||||
VIRTUAL_GOODS: "虚拟商品",
|
||||
PHYSICAL_GOODS: "实物商品",
|
||||
};
|
||||
return map[goodsType] || goodsType || "—";
|
||||
}
|
||||
|
||||
export function goodsTypeTagType(goodsType) {
|
||||
if (goodsType === E_COUPON_GOODS_TYPE) return "warning";
|
||||
if (goodsType === "VIRTUAL_GOODS") return "info";
|
||||
return "";
|
||||
}
|
||||
|
||||
/** E_COUPON 活动库存提示 */
|
||||
export function eCouponStockHint(goodsType) {
|
||||
if (!isECoupon(goodsType)) return "";
|
||||
return "库存来自卡池同步(quantity)";
|
||||
}
|
||||
|
||||
/** 活动价下限:E_COUPON 允许 0 元 */
|
||||
export function promotionPriceMin(goodsType) {
|
||||
return isECoupon(goodsType) ? 0 : 0.01;
|
||||
}
|
||||
|
||||
/** 活动价下限:E_COUPON 允许 0 元 */
|
||||
export function promotionPriceMin(goodsType) {
|
||||
return isECoupon(goodsType) ? 0 : 0.01;
|
||||
}
|
||||
|
||||
export const CARD_KEY_FULFILL_STATUS = {
|
||||
PENDING: "PENDING",
|
||||
DELIVERED: "DELIVERED",
|
||||
FAILED: "FAILED",
|
||||
NOT_APPLICABLE: "NOT_APPLICABLE",
|
||||
};
|
||||
|
||||
export const CARD_KEY_FULFILL_STATUS_TEXT = {
|
||||
PENDING: "待发放",
|
||||
DELIVERED: "已发放",
|
||||
FAILED: "发放失败",
|
||||
NOT_APPLICABLE: "不适用",
|
||||
};
|
||||
|
||||
export function cardKeyFulfillAlertType(status) {
|
||||
const map = { PENDING: "info", DELIVERED: "success", FAILED: "warning" };
|
||||
return map[status] || "info";
|
||||
}
|
||||
|
||||
export function formatCardKeyFulfillStatus(status) {
|
||||
return CARD_KEY_FULFILL_STATUS_TEXT[status] || status || "—";
|
||||
}
|
||||
|
||||
export function resolveCardKeyFulfillMessage(line) {
|
||||
if (line && line.message) return line.message;
|
||||
return formatCardKeyFulfillStatus(line?.status);
|
||||
}
|
||||
|
||||
export function isCardKeyFulfillApplicable(item) {
|
||||
if (!item) return false;
|
||||
const status = item.cardKeyFulfillStatus;
|
||||
if (status) return status !== CARD_KEY_FULFILL_STATUS.NOT_APPLICABLE;
|
||||
if (item.cardKeyDelivered != null || (item.cardKeys && item.cardKeys.length)) return true;
|
||||
return item.goodsType === E_COUPON_GOODS_TYPE;
|
||||
}
|
||||
|
||||
function normalizeCardKeyFulfillLine(source) {
|
||||
const status =
|
||||
source.cardKeyFulfillStatus ||
|
||||
(source.cardKeyDelivered
|
||||
? CARD_KEY_FULFILL_STATUS.DELIVERED
|
||||
: CARD_KEY_FULFILL_STATUS.PENDING);
|
||||
const cardKeys =
|
||||
status === CARD_KEY_FULFILL_STATUS.DELIVERED && source.cardKeyDelivered
|
||||
? source.cardKeys || []
|
||||
: [];
|
||||
return {
|
||||
key: source.sn || source.orderSn || source.id || source.skuId,
|
||||
goodsName: source.goodsName,
|
||||
status,
|
||||
message: source.cardKeyFulfillMessage,
|
||||
cardKeys,
|
||||
isGift: !!source.isGift,
|
||||
};
|
||||
}
|
||||
|
||||
export function collectCardKeyFulfillLines(orderItems = [], giftSummaries = []) {
|
||||
const lines = [];
|
||||
(orderItems || []).forEach((item) => {
|
||||
if (!isCardKeyFulfillApplicable(item)) return;
|
||||
lines.push(normalizeCardKeyFulfillLine(item));
|
||||
});
|
||||
(giftSummaries || []).forEach((gift) => {
|
||||
lines.push(normalizeCardKeyFulfillLine({ ...gift, isGift: true }));
|
||||
});
|
||||
return lines;
|
||||
}
|
||||
|
||||
export function orderHasCardKeySection({ orderItems, giftSummaries, isECouponOrder } = {}) {
|
||||
if (isECouponOrder) return true;
|
||||
if (Array.isArray(giftSummaries) && giftSummaries.length > 0) return true;
|
||||
if (collectCardKeyFulfillLines(orderItems, []).length > 0) return true;
|
||||
return (orderItems || []).some(
|
||||
(item) =>
|
||||
item.goodsType === E_COUPON_GOODS_TYPE ||
|
||||
(Array.isArray(item.cardKeys) && item.cardKeys.length > 0)
|
||||
);
|
||||
}
|
||||
|
||||
export function flattenCardKeyFulfillLines(lines, withGoodsName = false) {
|
||||
const rows = [];
|
||||
(lines || []).forEach((line) => {
|
||||
if (line.status !== CARD_KEY_FULFILL_STATUS.DELIVERED) return;
|
||||
(line.cardKeys || []).forEach((ck) => {
|
||||
rows.push(withGoodsName ? { ...ck, goodsName: line.goodsName } : { ...ck });
|
||||
});
|
||||
});
|
||||
return rows;
|
||||
}
|
||||
|
||||
/** 订单是否含已交付卡密(含满赠子单) */
|
||||
export function orderHasCardKeyContent(orderItems, giftSummaries) {
|
||||
return flattenCardKeyFulfillLines(collectCardKeyFulfillLines(orderItems, giftSummaries)).length > 0;
|
||||
}
|
||||
|
||||
export function flattenOrderCardKeys(orderItems, withGoodsName = false, giftSummaries) {
|
||||
const lines = collectCardKeyFulfillLines(orderItems, giftSummaries);
|
||||
if (lines.some((line) => line.status)) {
|
||||
return flattenCardKeyFulfillLines(lines, withGoodsName);
|
||||
}
|
||||
const rows = [];
|
||||
(orderItems || []).forEach((item) => {
|
||||
if (!item.cardKeyDelivered || !item.cardKeys || !item.cardKeys.length) return;
|
||||
item.cardKeys.forEach((ck) => {
|
||||
rows.push(withGoodsName ? { ...ck, goodsName: item.goodsName } : { ...ck });
|
||||
});
|
||||
});
|
||||
return rows;
|
||||
}
|
||||
Reference in New Issue
Block a user