@pisell/pisellos 2.3.29 → 2.3.30
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 +28 -10
- package/dist/modules/Order/index.js +747 -498
- package/dist/modules/Order/payment-utils.d.ts +23 -0
- package/dist/modules/Order/payment-utils.js +203 -0
- package/dist/modules/Order/types.d.ts +33 -3
- package/dist/modules/Order/utils.js +4 -4
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +78 -49
- package/dist/modules/Payment/types.d.ts +26 -24
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- 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 +14 -50
- package/dist/server/index.js +1975 -1395
- package/dist/server/modules/order/index.d.ts +40 -3
- package/dist/server/modules/order/index.js +1200 -501
- package/dist/server/modules/order/types.d.ts +11 -3
- package/dist/server/modules/order/types.js +1 -1
- 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 +33 -5
- package/dist/solution/BaseSales/index.js +622 -345
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -1
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- 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 +28 -10
- package/lib/modules/Order/index.js +181 -73
- package/lib/modules/Order/payment-utils.d.ts +23 -0
- package/lib/modules/Order/payment-utils.js +193 -0
- package/lib/modules/Order/types.d.ts +33 -3
- package/lib/modules/Order/utils.js +2 -3
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +33 -12
- package/lib/modules/Payment/types.d.ts +26 -24
- package/lib/modules/Product/index.d.ts +1 -1
- 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 +14 -50
- package/lib/server/index.js +633 -214
- package/lib/server/modules/order/index.d.ts +40 -3
- package/lib/server/modules/order/index.js +434 -31
- package/lib/server/modules/order/types.d.ts +11 -3
- 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 +33 -5
- package/lib/solution/BaseSales/index.js +170 -19
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- 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
|
@@ -213,10 +213,12 @@ export interface OrderBookingItem {
|
|
|
213
213
|
[key: string]: unknown;
|
|
214
214
|
}[];
|
|
215
215
|
}
|
|
216
|
-
/** 支付记录 metadata
|
|
216
|
+
/** 支付记录 metadata */
|
|
217
217
|
export interface OrderPaymentMetadata {
|
|
218
|
-
/**
|
|
218
|
+
/** 三方支付交易流水号 */
|
|
219
219
|
unique_payment_number?: string;
|
|
220
|
+
/** 刷卡机设备快照;server 不解析内部字段,仅透传并持久化 */
|
|
221
|
+
card_reader_snapshot?: Record<string, unknown>;
|
|
220
222
|
[key: string]: unknown;
|
|
221
223
|
}
|
|
222
224
|
/**
|
|
@@ -225,6 +227,8 @@ export interface OrderPaymentMetadata {
|
|
|
225
227
|
export interface OrderPaymentItem {
|
|
226
228
|
/** 支付记录 ID;存量/更新时传。来源:OrderPayment.id */
|
|
227
229
|
order_payment_id?: number | null;
|
|
230
|
+
/** 支付项稳定唯一号;历史支付项允许缺失 */
|
|
231
|
+
payment_number?: string;
|
|
228
232
|
/** 支付方式 ID(设备端从本地支付方式配置取详情)。来源:OrderPayment.custom_payment_id */
|
|
229
233
|
custom_payment_id?: number;
|
|
230
234
|
/** 支付方式编码。来源:OrderPayment.payment_method */
|
|
@@ -249,11 +253,13 @@ export interface OrderPaymentItem {
|
|
|
249
253
|
created_at?: string | null;
|
|
250
254
|
/** 手续费配置。来源:OrderPayment.service_charge */
|
|
251
255
|
service_charge?: Record<string, unknown> | null;
|
|
256
|
+
/** 已计算的支付手续费。来源:OrderPayment.service_fee */
|
|
257
|
+
service_fee?: OrderMoneyString;
|
|
252
258
|
/** Wallet Pass 使用单位 */
|
|
253
259
|
wallet_pass_usage_unit?: unknown[] | null;
|
|
254
260
|
/** Wallet Pass 使用值 */
|
|
255
261
|
wallet_pass_use_value?: number | null;
|
|
256
|
-
/**
|
|
262
|
+
/** 元数据;三方支付成功后可含 unique_payment_number */
|
|
257
263
|
metadata?: OrderPaymentMetadata | null;
|
|
258
264
|
}
|
|
259
265
|
/**
|
|
@@ -413,6 +419,8 @@ export interface OrderData {
|
|
|
413
419
|
create_date?: string;
|
|
414
420
|
/** 本地待同步标记:1 表示需要后续同步到云端 */
|
|
415
421
|
need_sync?: 0 | 1 | number;
|
|
422
|
+
/** 本地草稿标记:1 表示仅为 POS 可恢复草稿,不代表已提交云端 */
|
|
423
|
+
is_draft_order?: 0 | 1 | number;
|
|
416
424
|
/** 兼容:部分场景仍使用顶层 total_amount */
|
|
417
425
|
total_amount?: OrderMoneyString | number;
|
|
418
426
|
/** 扩展字段(物流、标签等);使用 any 以便筛选与数据源扩展 */
|
|
@@ -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
|
/**
|
|
@@ -2,7 +2,7 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult } from './types';
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
|
-
import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from '../../modules/Order/types';
|
|
5
|
+
import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from '../../modules/Order/types';
|
|
6
6
|
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
7
7
|
import type { Discount } from '../../modules/Discount/types';
|
|
8
8
|
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
@@ -24,6 +24,19 @@ export interface BaseSalesState {
|
|
|
24
24
|
schedule?: ScheduleModule;
|
|
25
25
|
quotation?: QuotationModule;
|
|
26
26
|
}
|
|
27
|
+
export interface BaseSalesUpdateOrderPaymentOptions extends OrderPaymentUpdateOptions {
|
|
28
|
+
persistDraft?: boolean;
|
|
29
|
+
submitWhenPaid?: boolean;
|
|
30
|
+
forceSubmitIfPaid?: boolean;
|
|
31
|
+
/** 草稿恢复时,允许将新回调字段合并进已 paid 的支付项。 */
|
|
32
|
+
applyUpdatesWhenPaid?: boolean;
|
|
33
|
+
smallTicketDataFlag?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface BaseSalesUpdateOrderPaymentResult extends OrderPaymentUpdateResult {
|
|
36
|
+
draftResult?: unknown;
|
|
37
|
+
draftError?: unknown;
|
|
38
|
+
syncResult?: SyncPaymentsToOrderResult<any>;
|
|
39
|
+
}
|
|
27
40
|
export type BaseSalesPrintLocalOrderReceiptParams = string | number;
|
|
28
41
|
export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
29
42
|
protected defaultName: string;
|
|
@@ -128,6 +141,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
128
141
|
*/
|
|
129
142
|
protected readSessionCacheData(): Record<string, any>;
|
|
130
143
|
protected getAppData<T>(key: string): T | undefined;
|
|
144
|
+
private getPaymentNumberDevicePrefixSync;
|
|
145
|
+
private getPaymentNumberDevicePrefixAsync;
|
|
131
146
|
private syncAppDataToTempOrder;
|
|
132
147
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
133
148
|
destroy(): Promise<void>;
|
|
@@ -193,9 +208,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
193
208
|
}): Promise<{
|
|
194
209
|
productList: Record<string, any>[];
|
|
195
210
|
discountList: Discount[];
|
|
196
|
-
availableWalletIds: number[];
|
|
197
211
|
}>;
|
|
198
|
-
getAvailableWalletIds(): number[];
|
|
199
212
|
bestDiscount(cb?: (result: any) => void): Promise<{
|
|
200
213
|
productList: Record<string, any>[];
|
|
201
214
|
discountList: Discount[];
|
|
@@ -240,6 +253,13 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
240
253
|
confirmPendingVoucherPayments?: boolean;
|
|
241
254
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
242
255
|
}): Promise<T>;
|
|
256
|
+
saveSalesOrderDraft<T = any>(params?: {
|
|
257
|
+
platform?: string;
|
|
258
|
+
businessCode?: string;
|
|
259
|
+
channel?: string;
|
|
260
|
+
type?: string;
|
|
261
|
+
enhancePayload?: SubmitPayloadEnhancer;
|
|
262
|
+
}): Promise<T>;
|
|
243
263
|
submitTempOrderAsync<T = any>(params?: {
|
|
244
264
|
payments?: OrderPaymentSource[];
|
|
245
265
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
@@ -258,16 +278,24 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
258
278
|
private queueLatestAutoPaymentSync;
|
|
259
279
|
private scheduleQueuedAutoPaymentSyncFlush;
|
|
260
280
|
private flushQueuedAutoPaymentSync;
|
|
261
|
-
/**
|
|
281
|
+
/**
|
|
282
|
+
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
283
|
+
*/
|
|
262
284
|
addOrderPayment(payment: OrderPaymentSource): OrderPaymentData[];
|
|
285
|
+
/** 创建新支付项时读取最新设备短号,不缓存运行时设备信息。 */
|
|
286
|
+
addOrderPaymentAsync(payment: OrderPaymentSource): Promise<OrderPaymentData[]>;
|
|
287
|
+
private addOrderPaymentWithDevicePrefix;
|
|
263
288
|
/** 更新当前订单中的指定支付项。 */
|
|
264
|
-
updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any
|
|
289
|
+
updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>, options?: BaseSalesUpdateOrderPaymentOptions): Promise<BaseSalesUpdateOrderPaymentResult>;
|
|
265
290
|
/** 删除当前订单中的指定支付项。 */
|
|
266
291
|
deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
|
|
267
292
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
268
293
|
updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
|
|
269
294
|
status?: 'paid' | 'payment_pending';
|
|
270
295
|
}): OrderPaymentData[];
|
|
296
|
+
updateVoucherOrderPaymentsAsync(payments: OrderPaymentSource[], options?: {
|
|
297
|
+
status?: 'paid' | 'payment_pending';
|
|
298
|
+
}): Promise<OrderPaymentData[]>;
|
|
271
299
|
confirmPendingVoucherPayments(): OrderPaymentData[];
|
|
272
300
|
discardPendingVoucherPayments(): OrderPaymentData[];
|
|
273
301
|
private getWalletProductList;
|