@pisell/pisellos
Version:
一个可扩展的前端模块化SDK框架,支持插件系统
193 lines (191 loc) • 4.66 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/model/strategy/adapter/promotion/examples.ts
var examples_exports = {};
__export(examples_exports, {
BUY_X_GET_Y_FREE_STRATEGY: () => BUY_X_GET_Y_FREE_STRATEGY,
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => X_ITEMS_FOR_Y_PRICE_STRATEGY
});
module.exports = __toCommonJS(examples_exports);
var X_ITEMS_FOR_Y_PRICE_STRATEGY = {
metadata: {
id: "STRATEGY_001",
name: {
en: "2 items for $10",
"zh-CN": "2杯10元",
"zh-HK": "2杯10元"
},
type: "promotion",
custom: {
display: {
product_card: {
text: {
en: "2 for $10",
"zh-CN": "2杯10元",
"zh-HK": "2杯10元"
},
type: "tag"
}
}
}
},
conditions: {
operator: "and",
rules: [
{
type: "operator",
field: "currentDateTime",
value: "2023-01-01 00:00:00",
operator: ">="
},
{
type: "operator",
field: "currentDateTime",
value: "2027-01-01 00:00:00",
operator: "<="
},
{
type: "operator",
field: "productIdAndVariantId",
value: [
{
product_id: 60736,
product_variant_id: 0
// 0 = 匹配任意变体
},
{
product_id: 60737,
product_variant_id: 0
// 0 = 匹配任意变体
}
],
operator: "product_match"
}
],
actionIds: ["1"]
},
actions: [
{
id: "1",
type: "X_ITEMS_FOR_Y_PRICE",
value: {
x: 2,
// 每X件
price: 10
// 固定价格Y元
},
valueType: "object",
target: "product",
priority: 1,
config: {
allowCrossProduct: true,
// 允许跨商品组合(A+B可以凑成一组)
cumulative: true
// 可累计(买5件 = 2组优惠 + 1件原价)
}
}
]
};
var BUY_X_GET_Y_FREE_STRATEGY = {
metadata: {
id: "STRATEGY_002",
name: {
en: "Buy 1 Get 1 Free",
"zh-CN": "买1送1",
"zh-HK": "買1送1"
},
type: "promotion",
custom: {
display: {
product_card: {
text: {
en: "Buy 1 Get 1",
"zh-CN": "买1送1",
"zh-HK": "買1送1"
},
type: "tag"
}
}
}
},
conditions: {
operator: "and",
rules: [
{
type: "operator",
field: "currentDateTime",
value: "2023-01-01 00:00:00",
operator: ">="
},
{
type: "operator",
field: "currentDateTime",
value: "2027-01-01 00:00:00",
operator: "<="
},
{
type: "operator",
field: "productIdAndVariantId",
value: [
{
product_id: 60736,
product_variant_id: 0
// 0 = 匹配任意变体
},
{
product_id: 60737,
product_variant_id: 0
// 0 = 匹配任意变体
}
],
operator: "product_match"
}
],
actionIds: ["1"]
},
actions: [
{
id: "1",
type: "BUY_X_GET_Y_FREE",
value: {
buyQuantity: 1,
// 买X件
freeQuantity: 1
// 送Y件
},
valueType: "object",
target: "product",
priority: 1,
config: {
// 可累计(买2送2、买3送3...)
cumulative: true,
// 可选的赠品列表
giftProducts: [
{ product_id: 60757, product_variant_id: 0 },
{ product_id: 38782, product_variant_id: 0 },
{ product_id: 60749, product_variant_id: 27267 }
]
}
}
]
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
BUY_X_GET_Y_FREE_STRATEGY,
X_ITEMS_FOR_Y_PRICE_STRATEGY
});