@pisell/pisellos 2.3.24 → 2.3.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Discount/index.d.ts +2 -5
- package/dist/modules/Discount/index.js +7 -30
- package/dist/modules/Discount/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +616 -568
- package/dist/modules/Order/types.d.ts +0 -2
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/server/index.d.ts +0 -50
- package/dist/server/index.js +749 -995
- package/dist/server/modules/products/index.d.ts +7 -26
- package/dist/server/modules/products/index.js +76 -167
- package/dist/server/modules/products/types.d.ts +0 -14
- package/dist/solution/BaseSales/index.d.ts +0 -2
- package/dist/solution/BaseSales/index.js +50 -36
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +21 -5
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Discount/index.d.ts +2 -5
- package/lib/modules/Discount/index.js +3 -23
- package/lib/modules/Discount/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +36 -20
- package/lib/modules/Order/types.d.ts +0 -2
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/server/index.d.ts +0 -50
- package/lib/server/index.js +29 -206
- package/lib/server/modules/products/index.d.ts +7 -26
- package/lib/server/modules/products/index.js +35 -114
- package/lib/server/modules/products/types.d.ts +0 -14
- package/lib/solution/BaseSales/index.d.ts +0 -2
- package/lib/solution/BaseSales/index.js +22 -12
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +18 -1
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
|
@@ -18,8 +18,7 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
18
18
|
private productsPriceCache;
|
|
19
19
|
private readonly CACHE_MAX_DAYS;
|
|
20
20
|
private formatters;
|
|
21
|
-
private
|
|
22
|
-
private isLegacyPriceFormatterEnabled;
|
|
21
|
+
private isPriceFormatterRegistered;
|
|
23
22
|
private quotationPriceBridge?;
|
|
24
23
|
private quotationBridgeChannel?;
|
|
25
24
|
private quotationBridgeLoadedKey?;
|
|
@@ -37,8 +36,6 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
37
36
|
private lastPreloadCompletedAtMs;
|
|
38
37
|
/** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
|
|
39
38
|
private productIndexDBSaveQueue;
|
|
40
|
-
/** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
|
|
41
|
-
private lastScheduleTimePoints;
|
|
42
39
|
constructor(name?: string, version?: string);
|
|
43
40
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
44
41
|
/**
|
|
@@ -111,10 +108,6 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
111
108
|
*/
|
|
112
109
|
private prepareProductsWithPrice;
|
|
113
110
|
private getProductsPriceCacheKey;
|
|
114
|
-
/**
|
|
115
|
-
* 稳定序列化策略上下文,避免对象 key 顺序不同导致缓存 key 抖动。
|
|
116
|
-
*/
|
|
117
|
-
private stringifyStable;
|
|
118
111
|
private normalizeProductIds;
|
|
119
112
|
/**
|
|
120
113
|
* 按轻量范围返回商品 ID,不做 structuredClone。
|
|
@@ -129,26 +122,14 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
129
122
|
*/
|
|
130
123
|
private applyFormatters;
|
|
131
124
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* 智能定价默认替代报价单逻辑;报价单 formatter 仅在 enableLegacyPriceFormatter=true 时启用。
|
|
125
|
+
* 注册内置的价格格式化器
|
|
126
|
+
* 这个格式化器负责将价格数据应用到商品上
|
|
135
127
|
* @private
|
|
136
128
|
*/
|
|
137
|
-
private
|
|
138
|
-
/**
|
|
139
|
-
* 是否启用旧报价单价格 formatter。
|
|
140
|
-
*
|
|
141
|
-
* 默认关闭,避免报价单逻辑覆盖智能定价结果。
|
|
142
|
-
*/
|
|
143
|
-
private shouldEnableLegacyPriceFormatter;
|
|
144
|
-
/**
|
|
145
|
-
* 返回最近一次 prepareProductsWithPrice / DataVariant 评估提取的变价时间点(HH:mm)。
|
|
146
|
-
* 供 OS Server 商品 query 订阅定时刷新使用。
|
|
147
|
-
*/
|
|
148
|
-
getLastScheduleTimePoints(): string[];
|
|
129
|
+
private registerBuiltinPriceFormatter;
|
|
149
130
|
/**
|
|
150
131
|
* 注册商品格式化器
|
|
151
|
-
*
|
|
132
|
+
* 格式化器会按注册顺序依次执行(内置价格格式化器始终是第一个)
|
|
152
133
|
* @param formatter 格式化函数
|
|
153
134
|
* @param prepend 是否插入到队列开头(默认 false,追加到末尾)
|
|
154
135
|
* @example
|
|
@@ -163,8 +144,8 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
163
144
|
*/
|
|
164
145
|
registerFormatter(formatter: ProductFormatter, prepend?: boolean): void;
|
|
165
146
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @param keepBuiltin
|
|
147
|
+
* 清空所有格式化器(包括内置价格格式化器)
|
|
148
|
+
* @param keepBuiltin 是否保留内置价格格式化器(默认 true)
|
|
168
149
|
*/
|
|
169
150
|
clearFormatters(keepBuiltin?: boolean): void;
|
|
170
151
|
/**
|
|
@@ -43,10 +43,8 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
43
43
|
// 最多缓存7天
|
|
44
44
|
// 商品格式化器列表
|
|
45
45
|
this.formatters = [];
|
|
46
|
-
//
|
|
47
|
-
this.
|
|
48
|
-
// 旧报价单格式化器默认关闭,仅显式开启时作为兼容兜底注册
|
|
49
|
-
this.isLegacyPriceFormatterEnabled = false;
|
|
46
|
+
// 是否已注册内置价格格式化器
|
|
47
|
+
this.isPriceFormatterRegistered = false;
|
|
50
48
|
this.quotationBridgeLoadedKey = "";
|
|
51
49
|
this.quotationScheduleCache = /* @__PURE__ */ new Map();
|
|
52
50
|
this.quotationScheduleCacheSource = null;
|
|
@@ -58,8 +56,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
58
56
|
this.lastPreloadCompletedAtMs = 0;
|
|
59
57
|
/** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
|
|
60
58
|
this.productIndexDBSaveQueue = Promise.resolve();
|
|
61
|
-
/** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
|
|
62
|
-
this.lastScheduleTimePoints = [];
|
|
63
59
|
}
|
|
64
60
|
async initialize(core, options) {
|
|
65
61
|
var _a;
|
|
@@ -86,7 +82,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
86
82
|
console.warn("[Products] IndexDB Manager 未找到");
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
|
-
this.
|
|
85
|
+
this.registerBuiltinPriceFormatter();
|
|
90
86
|
this.initProductDataSource();
|
|
91
87
|
this.setupProductSync();
|
|
92
88
|
this.logInfo("模块初始化完成", {
|
|
@@ -478,7 +474,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
478
474
|
* @private
|
|
479
475
|
*/
|
|
480
476
|
async prepareProductsWithPrice(schedule_date, extraContext, options) {
|
|
481
|
-
var _a, _b
|
|
477
|
+
var _a, _b;
|
|
482
478
|
const tTotal = performance.now();
|
|
483
479
|
const targetIds = options == null ? void 0 : options.productIds;
|
|
484
480
|
const isIncremental = Array.isArray(targetIds);
|
|
@@ -503,28 +499,21 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
503
499
|
(0, import_product.perfMark)("prepareProducts.extractIds", performance.now() - tIds, { count: ids.length });
|
|
504
500
|
}
|
|
505
501
|
this.logInfo("获取到商品列表", { productCount: products.length });
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
(0, import_product.perfMark)("prepareProducts.loadPrice", performance.now() - tPrice, { count: ids.length });
|
|
516
|
-
this.logInfo("获取商品报价单价格成功", { priceDataCount: (priceData == null ? void 0 : priceData.length) ?? 0 });
|
|
517
|
-
}
|
|
502
|
+
const tPrice = performance.now();
|
|
503
|
+
const priceData = await this.loadProductsPrice({
|
|
504
|
+
ids,
|
|
505
|
+
schedule_date,
|
|
506
|
+
schedule_datetime: extraContext == null ? void 0 : extraContext.schedule_datetime,
|
|
507
|
+
customer_id: extraContext == null ? void 0 : extraContext.customer_id
|
|
508
|
+
});
|
|
509
|
+
(0, import_product.perfMark)("prepareProducts.loadPrice", performance.now() - tPrice, { count: ids.length });
|
|
510
|
+
this.logInfo("获取商品报价单价格成功", { priceDataCount: (priceData == null ? void 0 : priceData.length) ?? 0 });
|
|
518
511
|
const context = {
|
|
519
512
|
schedule_date,
|
|
520
513
|
schedule_datetime: extraContext == null ? void 0 : extraContext.schedule_datetime,
|
|
521
514
|
customer_id: extraContext == null ? void 0 : extraContext.customer_id,
|
|
522
515
|
priceData,
|
|
523
516
|
locale: (_b = (_a = this.core) == null ? void 0 : _a.context) == null ? void 0 : _b.locale,
|
|
524
|
-
dataVariantEvaluator: (extraContext == null ? void 0 : extraContext.dataVariantEvaluator) || ((_d = (_c = this.core) == null ? void 0 : _c.context) == null ? void 0 : _d.dataVariantEvaluator),
|
|
525
|
-
menuList: (extraContext == null ? void 0 : extraContext.menuList) || [],
|
|
526
|
-
scheduleList: (extraContext == null ? void 0 : extraContext.scheduleList) || [],
|
|
527
|
-
strategy_context: extraContext == null ? void 0 : extraContext.strategy_context,
|
|
528
517
|
...extraContext
|
|
529
518
|
};
|
|
530
519
|
const tFormat = performance.now();
|
|
@@ -564,21 +553,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
564
553
|
getProductsPriceCacheKey(schedule_date, extraContext, productIds) {
|
|
565
554
|
const datetime = (extraContext == null ? void 0 : extraContext.schedule_datetime) || schedule_date;
|
|
566
555
|
const productScope = productIds ? `:products:${productIds.join(",")}` : "";
|
|
567
|
-
|
|
568
|
-
return `${datetime}:customer:${(extraContext == null ? void 0 : extraContext.customer_id) ?? ""}:strategy:${strategyScope}${productScope}`;
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* 稳定序列化策略上下文,避免对象 key 顺序不同导致缓存 key 抖动。
|
|
572
|
-
*/
|
|
573
|
-
stringifyStable(value) {
|
|
574
|
-
if (value == null)
|
|
575
|
-
return "";
|
|
576
|
-
if (Array.isArray(value))
|
|
577
|
-
return `[${value.map((item) => this.stringifyStable(item)).join(",")}]`;
|
|
578
|
-
if (typeof value === "object") {
|
|
579
|
-
return `{${Object.keys(value).sort().map((key) => `${key}:${this.stringifyStable(value[key])}`).join(",")}}`;
|
|
580
|
-
}
|
|
581
|
-
return String(value);
|
|
556
|
+
return `${datetime}:customer:${(extraContext == null ? void 0 : extraContext.customer_id) ?? ""}${productScope}`;
|
|
582
557
|
}
|
|
583
558
|
normalizeProductIds(productIds) {
|
|
584
559
|
if (!Array.isArray(productIds))
|
|
@@ -662,50 +637,21 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
662
637
|
return result;
|
|
663
638
|
}
|
|
664
639
|
/**
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
* 智能定价默认替代报价单逻辑;报价单 formatter 仅在 enableLegacyPriceFormatter=true 时启用。
|
|
640
|
+
* 注册内置的价格格式化器
|
|
641
|
+
* 这个格式化器负责将价格数据应用到商品上
|
|
668
642
|
* @private
|
|
669
643
|
*/
|
|
670
|
-
|
|
671
|
-
if (this.
|
|
672
|
-
console.warn("[ProductsModule]
|
|
644
|
+
registerBuiltinPriceFormatter() {
|
|
645
|
+
if (this.isPriceFormatterRegistered) {
|
|
646
|
+
console.warn("[ProductsModule] 内置价格格式化器已注册,跳过");
|
|
673
647
|
return;
|
|
674
648
|
}
|
|
675
|
-
|
|
676
|
-
const dataVariantFormatter = (products, context) => {
|
|
677
|
-
var _a, _b;
|
|
678
|
-
const evaluator = context.dataVariantEvaluator || ((_b = (_a = this.core) == null ? void 0 : _a.context) == null ? void 0 : _b.dataVariantEvaluator);
|
|
679
|
-
if (!evaluator || typeof evaluator.resolveProducts !== "function") {
|
|
680
|
-
this.lastScheduleTimePoints = [];
|
|
681
|
-
this.logWarning("智能定价评估器未注入,跳过 DataVariant 格式化", {
|
|
682
|
-
productCount: products.length
|
|
683
|
-
});
|
|
684
|
-
return products;
|
|
685
|
-
}
|
|
686
|
-
const strategyContext = context.strategy_context || {};
|
|
687
|
-
const businessData = {
|
|
688
|
-
products,
|
|
689
|
-
scheduleDateTime: context.schedule_datetime || context.schedule_date,
|
|
690
|
-
scheduleList: context.scheduleList || [],
|
|
691
|
-
menuList: context.menuList || [],
|
|
692
|
-
customerId: context.customer_id,
|
|
693
|
-
channel: strategyContext.channel,
|
|
694
|
-
orderType: strategyContext.orderType || strategyContext.order_type,
|
|
695
|
-
businessCode: strategyContext.business_code ?? strategyContext.businessCode,
|
|
696
|
-
availableWalletIds: strategyContext.available_wallet_ids,
|
|
697
|
-
custom: strategyContext
|
|
698
|
-
};
|
|
699
|
-
const result = evaluator.resolveProducts(businessData);
|
|
700
|
-
this.lastScheduleTimePoints = Array.isArray(result == null ? void 0 : result.scheduleTimePoints) ? [...result.scheduleTimePoints] : [];
|
|
701
|
-
return Array.isArray(result == null ? void 0 : result.products) ? result.products : products;
|
|
702
|
-
};
|
|
703
|
-
const legacyPriceFormatter = (products, context) => {
|
|
649
|
+
const priceFormatter = (products, context) => {
|
|
704
650
|
if (!context.priceData || context.priceData.length === 0) {
|
|
705
|
-
console.log("[ProductsModule] 💰
|
|
651
|
+
console.log("[ProductsModule] 💰 没有价格数据,跳过价格应用");
|
|
706
652
|
return products;
|
|
707
653
|
}
|
|
708
|
-
console.log(`[ProductsModule] 💰
|
|
654
|
+
console.log(`[ProductsModule] 💰 应用价格数据到 ${products.length} 个商品`);
|
|
709
655
|
return (0, import_product.applyPriceDataToProducts)(products, context.priceData);
|
|
710
656
|
};
|
|
711
657
|
const i18nFormatter = (products, context) => {
|
|
@@ -714,34 +660,15 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
714
660
|
const detailValueFormatter = (products, context) => {
|
|
715
661
|
return (0, import_product.applyDetailValueToProducts)(products, context);
|
|
716
662
|
};
|
|
717
|
-
|
|
718
|
-
this.formatters.push(legacyPriceFormatter);
|
|
719
|
-
}
|
|
720
|
-
this.formatters.push(dataVariantFormatter);
|
|
663
|
+
this.formatters.unshift(priceFormatter);
|
|
721
664
|
this.formatters.push(i18nFormatter);
|
|
722
665
|
this.formatters.push(detailValueFormatter);
|
|
723
|
-
this.
|
|
724
|
-
console.log("[ProductsModule] ✅
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* 是否启用旧报价单价格 formatter。
|
|
728
|
-
*
|
|
729
|
-
* 默认关闭,避免报价单逻辑覆盖智能定价结果。
|
|
730
|
-
*/
|
|
731
|
-
shouldEnableLegacyPriceFormatter() {
|
|
732
|
-
var _a, _b, _c;
|
|
733
|
-
return ((_a = this.otherParams) == null ? void 0 : _a.enableLegacyPriceFormatter) === true || ((_c = (_b = this.core) == null ? void 0 : _b.context) == null ? void 0 : _c.enableLegacyPriceFormatter) === true;
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* 返回最近一次 prepareProductsWithPrice / DataVariant 评估提取的变价时间点(HH:mm)。
|
|
737
|
-
* 供 OS Server 商品 query 订阅定时刷新使用。
|
|
738
|
-
*/
|
|
739
|
-
getLastScheduleTimePoints() {
|
|
740
|
-
return [...this.lastScheduleTimePoints];
|
|
666
|
+
this.isPriceFormatterRegistered = true;
|
|
667
|
+
console.log("[ProductsModule] ✅ 内置价格格式化器已注册(第 1 个)");
|
|
741
668
|
}
|
|
742
669
|
/**
|
|
743
670
|
* 注册商品格式化器
|
|
744
|
-
*
|
|
671
|
+
* 格式化器会按注册顺序依次执行(内置价格格式化器始终是第一个)
|
|
745
672
|
* @param formatter 格式化函数
|
|
746
673
|
* @param prepend 是否插入到队列开头(默认 false,追加到末尾)
|
|
747
674
|
* @example
|
|
@@ -756,7 +683,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
756
683
|
*/
|
|
757
684
|
registerFormatter(formatter, prepend = false) {
|
|
758
685
|
if (prepend) {
|
|
759
|
-
const insertIndex = this.
|
|
686
|
+
const insertIndex = this.isPriceFormatterRegistered ? 1 : 0;
|
|
760
687
|
this.formatters.splice(insertIndex, 0, formatter);
|
|
761
688
|
console.log(`[ProductsModule] 📌 已在位置 ${insertIndex + 1} 插入格式化器,当前共 ${this.formatters.length} 个`);
|
|
762
689
|
} else {
|
|
@@ -765,17 +692,16 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
765
692
|
}
|
|
766
693
|
}
|
|
767
694
|
/**
|
|
768
|
-
*
|
|
769
|
-
* @param keepBuiltin
|
|
695
|
+
* 清空所有格式化器(包括内置价格格式化器)
|
|
696
|
+
* @param keepBuiltin 是否保留内置价格格式化器(默认 true)
|
|
770
697
|
*/
|
|
771
698
|
clearFormatters(keepBuiltin = true) {
|
|
772
|
-
if (keepBuiltin && this.
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
console.log("[ProductsModule] 🧹 已清空自定义格式化器,保留内置智能定价格式化器");
|
|
699
|
+
if (keepBuiltin && this.isPriceFormatterRegistered) {
|
|
700
|
+
this.formatters = [this.formatters[0]];
|
|
701
|
+
console.log("[ProductsModule] 🧹 已清空自定义格式化器,保留内置价格格式化器");
|
|
776
702
|
} else {
|
|
777
703
|
this.formatters = [];
|
|
778
|
-
this.
|
|
704
|
+
this.isPriceFormatterRegistered = false;
|
|
779
705
|
console.log("[ProductsModule] 🧹 已清空所有格式化器");
|
|
780
706
|
}
|
|
781
707
|
}
|
|
@@ -876,8 +802,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
876
802
|
"resourceRelation",
|
|
877
803
|
"bundleGroup.bundleItem",
|
|
878
804
|
"optionGroup.optionItem",
|
|
879
|
-
"variantGroup.variantItem"
|
|
880
|
-
"dataVariants"
|
|
805
|
+
"variantGroup.variantItem"
|
|
881
806
|
],
|
|
882
807
|
open_deposit: 1,
|
|
883
808
|
is_append_product_description: 1,
|
|
@@ -1322,7 +1247,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1322
1247
|
* Server 层监听该事件后对变更商品增量执行 prepareProductsWithPrice 并更新缓存
|
|
1323
1248
|
*/
|
|
1324
1249
|
async processProductSyncMessages() {
|
|
1325
|
-
var _a, _b, _c, _d, _e, _f
|
|
1250
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1326
1251
|
const messages = [...this.pendingSyncMessages];
|
|
1327
1252
|
this.pendingSyncMessages = [];
|
|
1328
1253
|
if (messages.length === 0)
|
|
@@ -1376,10 +1301,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1376
1301
|
if ((_f = msg.relation_product_ids) == null ? void 0 : _f.length) {
|
|
1377
1302
|
sseRefreshIds.push(...msg.relation_product_ids);
|
|
1378
1303
|
}
|
|
1379
|
-
} else if (["product_data_variant"].includes(channelKey)) {
|
|
1380
|
-
if ((_g = msg.product_ids) == null ? void 0 : _g.length) {
|
|
1381
|
-
sseRefreshIds.push(...msg.product_ids);
|
|
1382
|
-
}
|
|
1383
1304
|
}
|
|
1384
1305
|
}
|
|
1385
1306
|
const uniqueDeleteIds = [...new Set(deleteIds)];
|
|
@@ -114,8 +114,6 @@ export interface ProductSyncMessage {
|
|
|
114
114
|
change_types?: string[];
|
|
115
115
|
/** 关联商品 ID(product_collection / product_category / product_quotation 变更时携带) */
|
|
116
116
|
relation_product_ids?: number[];
|
|
117
|
-
/** 关联商品 ID(product_data_variant 变更时携带) */
|
|
118
|
-
product_ids?: number[];
|
|
119
117
|
message_uuid?: string;
|
|
120
118
|
timestamp?: string;
|
|
121
119
|
/** 内部标记:来源频道 key */
|
|
@@ -130,18 +128,6 @@ export interface ProductFormatterContext {
|
|
|
130
128
|
customer_id?: number | string;
|
|
131
129
|
priceData?: LoadProductsPriceData[];
|
|
132
130
|
scheduleModule?: any;
|
|
133
|
-
/** 全量餐牌列表,供智能定价 menu_match 等条件判断使用 */
|
|
134
|
-
menuList?: any[];
|
|
135
|
-
/** 全量日程列表,供智能定价 schedule_match 等条件判断使用 */
|
|
136
|
-
scheduleList?: any[];
|
|
137
|
-
/** 外部传入的策略上下文,仅承载定价条件,不参与商品集合筛选 */
|
|
138
|
-
strategy_context?: Record<string, any>;
|
|
139
|
-
/** 智能定价评估器,由宿主统一注入到 PisellOS context */
|
|
140
|
-
dataVariantEvaluator?: {
|
|
141
|
-
resolveProducts: (businessData: any) => {
|
|
142
|
-
products: ProductData[];
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
131
|
locale?: string;
|
|
146
132
|
}
|
|
147
133
|
/**
|
|
@@ -187,9 +187,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
187
187
|
}): Promise<{
|
|
188
188
|
productList: Record<string, any>[];
|
|
189
189
|
discountList: Discount[];
|
|
190
|
-
availableWalletIds: number[];
|
|
191
190
|
}>;
|
|
192
|
-
getAvailableWalletIds(): number[];
|
|
193
191
|
bestDiscount(cb?: (result: any) => void): Promise<{
|
|
194
192
|
productList: Record<string, any>[];
|
|
195
193
|
discountList: Discount[];
|
|
@@ -1157,8 +1157,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1157
1157
|
if (hasManualDiscountSelection && currentDiscountList.length) {
|
|
1158
1158
|
return {
|
|
1159
1159
|
productList: tempOrder.products || [],
|
|
1160
|
-
discountList: currentDiscountList
|
|
1161
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
1160
|
+
discountList: currentDiscountList
|
|
1162
1161
|
};
|
|
1163
1162
|
}
|
|
1164
1163
|
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
@@ -1187,8 +1186,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1187
1186
|
});
|
|
1188
1187
|
return {
|
|
1189
1188
|
productList: tempOrder.products || [],
|
|
1190
|
-
discountList: nextDiscountList
|
|
1191
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
1189
|
+
discountList: nextDiscountList
|
|
1192
1190
|
};
|
|
1193
1191
|
}
|
|
1194
1192
|
if (rulesModule) {
|
|
@@ -1249,16 +1247,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1249
1247
|
});
|
|
1250
1248
|
return {
|
|
1251
1249
|
productList: tempOrder.products || [],
|
|
1252
|
-
discountList: nextDiscountList
|
|
1253
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
1250
|
+
discountList: nextDiscountList
|
|
1254
1251
|
};
|
|
1255
1252
|
}
|
|
1256
|
-
getAvailableWalletIds() {
|
|
1257
|
-
var _a;
|
|
1258
|
-
if (!((_a = this.store.order) == null ? void 0 : _a.getAvailableWalletIds))
|
|
1259
|
-
return [];
|
|
1260
|
-
return this.store.order.getAvailableWalletIds();
|
|
1261
|
-
}
|
|
1262
1253
|
async bestDiscount(cb) {
|
|
1263
1254
|
var _a, _b, _c;
|
|
1264
1255
|
if (!this.store.order)
|
|
@@ -1310,6 +1301,12 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1310
1301
|
}
|
|
1311
1302
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1312
1303
|
this.store.order.persistTempOrder();
|
|
1304
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
1305
|
+
productList: tempOrder.products || [],
|
|
1306
|
+
discountList: nextDiscountList,
|
|
1307
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
1308
|
+
tempOrder
|
|
1309
|
+
});
|
|
1313
1310
|
cb == null ? void 0 : cb(result);
|
|
1314
1311
|
return result;
|
|
1315
1312
|
}
|
|
@@ -1350,6 +1347,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1350
1347
|
if (raw.isAvailable) {
|
|
1351
1348
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1352
1349
|
this.store.order.persistTempOrder();
|
|
1350
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
1351
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
1352
|
+
productList: tempOrder.products || [],
|
|
1353
|
+
discountList: this.store.order.getDiscountList(),
|
|
1354
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
1355
|
+
tempOrder
|
|
1356
|
+
});
|
|
1353
1357
|
}
|
|
1354
1358
|
return {
|
|
1355
1359
|
isAvailable: raw.isAvailable,
|
|
@@ -1508,6 +1512,12 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1508
1512
|
}
|
|
1509
1513
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1510
1514
|
this.store.order.persistTempOrder();
|
|
1515
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
1516
|
+
productList: tempOrder.products || [],
|
|
1517
|
+
discountList: result.discountList || [],
|
|
1518
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
1519
|
+
tempOrder
|
|
1520
|
+
});
|
|
1511
1521
|
} catch (error) {
|
|
1512
1522
|
throw error;
|
|
1513
1523
|
}
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 1 |
|
|
314
|
+
weekNum: 0 | 1 | 5 | 3 | 2 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -350,6 +350,13 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
350
350
|
if (raw.isAvailable) {
|
|
351
351
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
352
352
|
this.store.order.persistTempOrder();
|
|
353
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
354
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
355
|
+
productList: tempOrder.products || [],
|
|
356
|
+
discountList: this.store.order.getDiscountList(),
|
|
357
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
358
|
+
tempOrder
|
|
359
|
+
});
|
|
353
360
|
}
|
|
354
361
|
return {
|
|
355
362
|
isAvailable: raw.isAvailable,
|
|
@@ -870,7 +877,17 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
870
877
|
void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
|
|
871
878
|
void ((_b = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _b.call(discountModule, []));
|
|
872
879
|
this.store.order.applyDiscount();
|
|
873
|
-
void this.store.order.recalculateSummary({ createIfMissing: true }).then(() =>
|
|
880
|
+
void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => {
|
|
881
|
+
var _a2;
|
|
882
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
883
|
+
this.store.order.persistTempOrder();
|
|
884
|
+
return this.effectsEmit("onDiscountApplied", {
|
|
885
|
+
productList: tempOrder.products || [],
|
|
886
|
+
discountList: ((_a2 = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _a2.call(discountModule)) || [],
|
|
887
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
888
|
+
tempOrder
|
|
889
|
+
});
|
|
890
|
+
}).catch((error) => {
|
|
874
891
|
console.error("Failed to recalculate summary after clearing customer:", error);
|
|
875
892
|
});
|
|
876
893
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
|
|
@@ -505,7 +505,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
505
505
|
try {
|
|
506
506
|
const orderId = this.store.orderId;
|
|
507
507
|
const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
|
|
508
|
-
const
|
|
508
|
+
const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
|
|
509
509
|
customer_id: customerId,
|
|
510
510
|
action: orderId ? "edit" : "create",
|
|
511
511
|
with_good_pass: 1,
|
|
@@ -514,7 +514,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
514
514
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
515
515
|
...orderId ? { order_id: orderId } : {}
|
|
516
516
|
}));
|
|
517
|
-
const goodPassList = (prepareConfigResult == null ? void 0 : prepareConfigResult.discountList) || [];
|
|
518
517
|
const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
|
|
519
518
|
(item) => item.isScan
|
|
520
519
|
);
|
package/package.json
CHANGED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { EvaluationResult, RuntimeContext } from '../../type';
|
|
2
|
-
import type { BusinessAdapter } from '../type';
|
|
3
|
-
import type { DataVariantBusinessData, DataVariantProduct } from './type';
|
|
4
|
-
/**
|
|
5
|
-
* Data Variant 适配器。
|
|
6
|
-
*
|
|
7
|
-
* 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
|
|
8
|
-
*/
|
|
9
|
-
export declare class DataVariantAdapter implements BusinessAdapter {
|
|
10
|
-
name: string;
|
|
11
|
-
version: string;
|
|
12
|
-
/**
|
|
13
|
-
* 准备批量全局上下文。
|
|
14
|
-
*
|
|
15
|
-
* 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
|
|
16
|
-
*/
|
|
17
|
-
prepareContext(businessData: DataVariantBusinessData): RuntimeContext;
|
|
18
|
-
/**
|
|
19
|
-
* 准备全局预计算上下文。
|
|
20
|
-
*/
|
|
21
|
-
prepareGlobalContext(businessData: DataVariantBusinessData): RuntimeContext;
|
|
22
|
-
/**
|
|
23
|
-
* 准备单商品上下文。
|
|
24
|
-
*
|
|
25
|
-
* 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
|
|
26
|
-
*/
|
|
27
|
-
prepareProductContext(businessData: DataVariantBusinessData, product: DataVariantProduct): RuntimeContext;
|
|
28
|
-
transformResult(result: EvaluationResult): EvaluationResult;
|
|
29
|
-
formatConfig(result: EvaluationResult, businessData?: DataVariantBusinessData): {
|
|
30
|
-
result: EvaluationResult;
|
|
31
|
-
businessData?: DataVariantBusinessData;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* 构建 menu_match 使用的轻量商品对象。
|
|
35
|
-
*
|
|
36
|
-
* collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
|
|
37
|
-
*/
|
|
38
|
-
buildProductValue(product: DataVariantProduct): {
|
|
39
|
-
id: number;
|
|
40
|
-
product_variant_id: number;
|
|
41
|
-
collection_ids: number[];
|
|
42
|
-
};
|
|
43
|
-
private toNumber;
|
|
44
|
-
/**
|
|
45
|
-
* 归一化客户 id:无效值返回 undefined,有效值统一为 number。
|
|
46
|
-
*/
|
|
47
|
-
private normalizeCustomerId;
|
|
48
|
-
private normalizeNumberArray;
|
|
49
|
-
}
|
|
50
|
-
export default DataVariantAdapter;
|