@pisell/pisellos 2.2.190 → 2.2.191
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/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -7
- package/dist/modules/Cart/utils/cartProduct.js +13 -2
- package/dist/modules/Order/index.d.ts +1 -3
- package/dist/modules/Order/index.js +69 -95
- package/dist/modules/Order/types.d.ts +9 -6
- package/dist/modules/Order/utils.d.ts +9 -2
- package/dist/modules/Order/utils.js +36 -13
- package/dist/modules/SalesSummary/types.d.ts +3 -1
- package/dist/modules/SalesSummary/utils.js +7 -3
- package/dist/server/modules/order/index.d.ts +126 -6
- package/dist/server/modules/order/index.js +1204 -285
- package/dist/server/modules/order/types.d.ts +0 -2
- package/dist/server/modules/products/index.d.ts +90 -6
- package/dist/server/modules/products/index.js +1017 -361
- package/dist/solution/BaseSales/index.js +13 -7
- package/dist/solution/BaseSales/types.d.ts +8 -5
- package/dist/solution/BaseSales/types.js +2 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +7 -7
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -13
- package/dist/solution/BaseSales/utils.d.ts +1 -1
- package/dist/solution/BaseSales/utils.js +22 -19
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.js +7 -5
- package/dist/solution/ScanOrder/types.d.ts +8 -5
- package/dist/solution/ScanOrder/types.js +2 -3
- package/dist/solution/ScanOrder/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +26 -23
- package/dist/solution/VenueBooking/index.js +5 -3
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/Cart/utils/cartProduct.js +9 -2
- package/lib/modules/Order/index.d.ts +1 -3
- package/lib/modules/Order/index.js +45 -58
- package/lib/modules/Order/types.d.ts +9 -6
- package/lib/modules/Order/utils.d.ts +9 -2
- package/lib/modules/Order/utils.js +41 -10
- package/lib/modules/SalesSummary/types.d.ts +3 -1
- package/lib/modules/SalesSummary/utils.js +5 -3
- package/lib/server/modules/order/index.d.ts +126 -6
- package/lib/server/modules/order/index.js +722 -42
- package/lib/server/modules/order/types.d.ts +0 -2
- package/lib/server/modules/products/index.d.ts +90 -6
- package/lib/server/modules/products/index.js +492 -30
- package/lib/solution/BaseSales/index.js +14 -5
- package/lib/solution/BaseSales/types.d.ts +8 -5
- package/lib/solution/BaseSales/utils/cartPromotion.js +6 -6
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +21 -14
- package/lib/solution/BaseSales/utils.d.ts +1 -1
- package/lib/solution/BaseSales/utils.js +11 -7
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.js +4 -4
- package/lib/solution/ScanOrder/types.d.ts +8 -5
- package/lib/solution/ScanOrder/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +12 -8
- package/lib/solution/VenueBooking/index.js +2 -2
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/package.json +1 -1
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
|
@@ -38,12 +38,14 @@ __export(utils_exports, {
|
|
|
38
38
|
createEmptySummary: () => import_utils2.createEmptySummary,
|
|
39
39
|
createUuidV4: () => createUuidV4,
|
|
40
40
|
ensureManualProductDiscountList: () => import_manualProductDiscount.ensureManualProductDiscountList,
|
|
41
|
+
ensureProductSku: () => ensureProductSku,
|
|
41
42
|
findManualProductDiscountItem: () => import_manualProductDiscount.findManualProductDiscountItem,
|
|
42
43
|
formatDateTime: () => formatDateTime,
|
|
43
44
|
formatV1Product: () => formatV1Product,
|
|
44
45
|
generateDuration: () => generateDuration,
|
|
45
46
|
getAllDiscountList: () => getAllDiscountList,
|
|
46
47
|
getOrderProductLineUid: () => getOrderProductLineUid,
|
|
48
|
+
getProductSkuOptions: () => getProductSkuOptions,
|
|
47
49
|
hasAssignedHolderId: () => hasAssignedHolderId,
|
|
48
50
|
indexOrderProductsByUid: () => indexOrderProductsByUid,
|
|
49
51
|
isEmptyOrderProductDisplayValue: () => isEmptyOrderProductDisplayValue,
|
|
@@ -56,6 +58,7 @@ __export(utils_exports, {
|
|
|
56
58
|
normalizeBookingIsAll: () => normalizeBookingIsAll,
|
|
57
59
|
normalizeBookingSubType: () => normalizeBookingSubType,
|
|
58
60
|
normalizeOrderProductDiscountList: () => normalizeOrderProductDiscountList,
|
|
61
|
+
normalizeProductSkuOptions: () => normalizeProductSkuOptions,
|
|
59
62
|
normalizeSubmitBooking: () => normalizeSubmitBooking,
|
|
60
63
|
normalizeSubmitCollectPaxValue: () => normalizeSubmitCollectPaxValue,
|
|
61
64
|
resolveEffectivePerUnitDiscount: () => resolveEffectivePerUnitDiscount,
|
|
@@ -91,12 +94,36 @@ function composeLinePrice(params) {
|
|
|
91
94
|
}
|
|
92
95
|
return total.toDecimalPlaces(2).toFixed(2);
|
|
93
96
|
}
|
|
97
|
+
function normalizeProductSkuOptions(options) {
|
|
98
|
+
if (!Array.isArray(options))
|
|
99
|
+
return [];
|
|
100
|
+
return options.map((option) => {
|
|
101
|
+
const normalized = {
|
|
102
|
+
...option && typeof option === "object" ? option : {}
|
|
103
|
+
};
|
|
104
|
+
const addPrice = normalized.add_price ?? normalized.price;
|
|
105
|
+
if (addPrice !== void 0)
|
|
106
|
+
normalized.add_price = addPrice;
|
|
107
|
+
delete normalized.price;
|
|
108
|
+
return normalized;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function ensureProductSku(product) {
|
|
112
|
+
const rawSku = (product == null ? void 0 : product.product_sku) && typeof product.product_sku === "object" ? product.product_sku : {};
|
|
113
|
+
return {
|
|
114
|
+
...rawSku,
|
|
115
|
+
option: normalizeProductSkuOptions(rawSku.option)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function getProductSkuOptions(product) {
|
|
119
|
+
return ensureProductSku(product).option;
|
|
120
|
+
}
|
|
94
121
|
function sumOptionUnitPrice(options) {
|
|
95
122
|
let total = new import_decimal.default(0);
|
|
96
123
|
if (!Array.isArray(options))
|
|
97
124
|
return total;
|
|
98
125
|
for (const opt of options) {
|
|
99
|
-
const price = new import_decimal.default(Number(opt == null ? void 0 : opt.price) || 0);
|
|
126
|
+
const price = new import_decimal.default(Number((opt == null ? void 0 : opt.add_price) ?? (opt == null ? void 0 : opt.price)) || 0);
|
|
100
127
|
const num = new import_decimal.default(Number(opt == null ? void 0 : opt.num) || 0);
|
|
101
128
|
total = total.plus(price.times(num));
|
|
102
129
|
}
|
|
@@ -184,7 +211,7 @@ function resolveEffectivePerUnitDiscount(product) {
|
|
|
184
211
|
if (hasPromoDiscountItem)
|
|
185
212
|
return fromList;
|
|
186
213
|
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
187
|
-
const optionSum = sumOptionUnitPrice(product
|
|
214
|
+
const optionSum = sumOptionUnitPrice(getProductSkuOptions(product)).toNumber();
|
|
188
215
|
if (metadata.source_product_price != null && metadata.main_product_selling_price != null) {
|
|
189
216
|
const source = Number(metadata.source_product_price);
|
|
190
217
|
const selling = Number(metadata.main_product_selling_price) - optionSum;
|
|
@@ -246,7 +273,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
246
273
|
getProduct: (product) => {
|
|
247
274
|
var _a, _b, _c, _d, _e, _f;
|
|
248
275
|
const metadataAny = product.metadata || {};
|
|
249
|
-
const optionSum = sumOptionUnitPrice(product
|
|
276
|
+
const optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
250
277
|
let sourcePrice;
|
|
251
278
|
if (metadataAny.source_product_price !== void 0) {
|
|
252
279
|
sourcePrice = String(metadataAny.source_product_price);
|
|
@@ -274,7 +301,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
274
301
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
275
302
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
276
303
|
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, import_utils.buildProductLineFingerprint)(
|
|
277
|
-
product
|
|
304
|
+
getProductSkuOptions(product),
|
|
278
305
|
product.product_bundle
|
|
279
306
|
)}`,
|
|
280
307
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
@@ -306,7 +333,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
306
333
|
const nextNum = Number(values.quantity ?? product.num ?? 1) || 1;
|
|
307
334
|
const metadataAny = product.metadata || {};
|
|
308
335
|
const existedSource = metadataAny.source_product_price ?? product.selling_price ?? "0";
|
|
309
|
-
const nextOptions = product
|
|
336
|
+
const nextOptions = getProductSkuOptions(product);
|
|
310
337
|
const optionSum = sumOptionUnitPrice(nextOptions);
|
|
311
338
|
const nextSourceSellingPrice = values.main_product_selling_price !== void 0 ? String(values.main_product_selling_price) : values.price !== void 0 ? String(values.price) : values.total !== void 0 ? toUnitPriceString(values.total, nextNum) : String(existedSource);
|
|
312
339
|
const nextSourceOriginalPrice = values.original_price !== void 0 ? String(values.original_price) : String(existedSource);
|
|
@@ -415,6 +442,7 @@ function formatSubmitOptionItems(options) {
|
|
|
415
442
|
return [];
|
|
416
443
|
return options.map((d) => {
|
|
417
444
|
const option = {
|
|
445
|
+
...d && typeof d === "object" ? d : {},
|
|
418
446
|
num: d == null ? void 0 : d.num,
|
|
419
447
|
option_group_item_id: d == null ? void 0 : d.option_group_item_id,
|
|
420
448
|
option_group_id: d == null ? void 0 : d.option_group_id
|
|
@@ -422,6 +450,7 @@ function formatSubmitOptionItems(options) {
|
|
|
422
450
|
const addPrice = (d == null ? void 0 : d.add_price) ?? (d == null ? void 0 : d.price);
|
|
423
451
|
if (addPrice !== void 0)
|
|
424
452
|
option.add_price = String(addPrice);
|
|
453
|
+
delete option.price;
|
|
425
454
|
return option;
|
|
426
455
|
});
|
|
427
456
|
}
|
|
@@ -485,7 +514,6 @@ function normalizeSubmitProduct(product) {
|
|
|
485
514
|
const { unique_identification_number: _runtimeUid, ...submitProduct } = product;
|
|
486
515
|
const {
|
|
487
516
|
num,
|
|
488
|
-
product_option_item: productOptionItem,
|
|
489
517
|
surcharge_fee: _productSurchargeFee,
|
|
490
518
|
discount_amount: _deprecatedDiscountAmount,
|
|
491
519
|
discount_type: _deprecatedDiscountType,
|
|
@@ -494,6 +522,7 @@ function normalizeSubmitProduct(product) {
|
|
|
494
522
|
discount_per: _deprecatedDiscountPer,
|
|
495
523
|
...productRest
|
|
496
524
|
} = submitProduct;
|
|
525
|
+
delete productRest[`product_${"option"}_item`];
|
|
497
526
|
const rawMetadata = submitProduct.metadata || {};
|
|
498
527
|
const bookingUid = rawMetadata.booking_uid;
|
|
499
528
|
const cleanMetadata = {};
|
|
@@ -527,9 +556,7 @@ function normalizeSubmitProduct(product) {
|
|
|
527
556
|
}
|
|
528
557
|
const productSku = {
|
|
529
558
|
...submitProduct.product_sku && typeof submitProduct.product_sku === "object" ? submitProduct.product_sku : {},
|
|
530
|
-
option: formatSubmitOptionItems(
|
|
531
|
-
(productOptionItem == null ? void 0 : productOptionItem.length) ? productOptionItem : (_a = submitProduct.product_sku) == null ? void 0 : _a.option
|
|
532
|
-
)
|
|
559
|
+
option: formatSubmitOptionItems((_a = submitProduct.product_sku) == null ? void 0 : _a.option)
|
|
533
560
|
};
|
|
534
561
|
return {
|
|
535
562
|
...productRest,
|
|
@@ -872,7 +899,8 @@ function mergeOrderProductDisplayFields(previous, next) {
|
|
|
872
899
|
"product_cover",
|
|
873
900
|
"cover",
|
|
874
901
|
"variant_title",
|
|
875
|
-
"product_sku"
|
|
902
|
+
"product_sku",
|
|
903
|
+
"payment_price"
|
|
876
904
|
];
|
|
877
905
|
displayFields.forEach((field) => {
|
|
878
906
|
if (isEmptyOrderProductDisplayValue(merged[field]) && !isEmptyOrderProductDisplayValue(previous[field])) {
|
|
@@ -919,12 +947,14 @@ function indexOrderProductsByUid(products) {
|
|
|
919
947
|
createEmptySummary,
|
|
920
948
|
createUuidV4,
|
|
921
949
|
ensureManualProductDiscountList,
|
|
950
|
+
ensureProductSku,
|
|
922
951
|
findManualProductDiscountItem,
|
|
923
952
|
formatDateTime,
|
|
924
953
|
formatV1Product,
|
|
925
954
|
generateDuration,
|
|
926
955
|
getAllDiscountList,
|
|
927
956
|
getOrderProductLineUid,
|
|
957
|
+
getProductSkuOptions,
|
|
928
958
|
hasAssignedHolderId,
|
|
929
959
|
indexOrderProductsByUid,
|
|
930
960
|
isEmptyOrderProductDisplayValue,
|
|
@@ -937,6 +967,7 @@ function indexOrderProductsByUid(products) {
|
|
|
937
967
|
normalizeBookingIsAll,
|
|
938
968
|
normalizeBookingSubType,
|
|
939
969
|
normalizeOrderProductDiscountList,
|
|
970
|
+
normalizeProductSkuOptions,
|
|
940
971
|
normalizeSubmitBooking,
|
|
941
972
|
normalizeSubmitCollectPaxValue,
|
|
942
973
|
resolveEffectivePerUnitDiscount,
|
|
@@ -8,7 +8,9 @@ export interface SalesSummaryProduct {
|
|
|
8
8
|
original_price: string;
|
|
9
9
|
tax_fee: string;
|
|
10
10
|
is_charge_tax?: number;
|
|
11
|
-
|
|
11
|
+
product_sku?: Record<string, any> & {
|
|
12
|
+
option?: any[];
|
|
13
|
+
};
|
|
12
14
|
discount_list?: any[];
|
|
13
15
|
product_bundle?: any[];
|
|
14
16
|
metadata?: Record<string, any>;
|
|
@@ -35,6 +35,7 @@ __export(utils_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(utils_exports);
|
|
36
36
|
var import_decimal = __toESM(require("decimal.js"));
|
|
37
37
|
var import_utils = require("../Summary/utils");
|
|
38
|
+
var import_utils2 = require("../Order/utils");
|
|
38
39
|
function toDecimal(value) {
|
|
39
40
|
return new import_decimal.default(value || 0);
|
|
40
41
|
}
|
|
@@ -75,6 +76,7 @@ function buildSurchargeServiceItems(products) {
|
|
|
75
76
|
var _a, _b;
|
|
76
77
|
const quantity = getSafeNum(product.num);
|
|
77
78
|
const unitTotal = getUnitPaymentTotal(product);
|
|
79
|
+
const options = (0, import_utils2.getProductSkuOptions)(product);
|
|
78
80
|
return {
|
|
79
81
|
id: product.product_id,
|
|
80
82
|
num: quantity,
|
|
@@ -86,12 +88,12 @@ function buildSurchargeServiceItems(products) {
|
|
|
86
88
|
product: {
|
|
87
89
|
discount_list: product.discount_list || [],
|
|
88
90
|
product_bundle: product.product_bundle || [],
|
|
89
|
-
|
|
91
|
+
product_sku: product.product_sku || { option: options }
|
|
90
92
|
}
|
|
91
93
|
},
|
|
92
94
|
bundle: product.product_bundle || [],
|
|
93
|
-
option:
|
|
94
|
-
options
|
|
95
|
+
option: options,
|
|
96
|
+
options,
|
|
95
97
|
relation_details: [],
|
|
96
98
|
metadata: product.metadata || {},
|
|
97
99
|
start_date: ((_a = product.metadata) == null ? void 0 : _a.start_date) || "",
|
|
@@ -2,6 +2,44 @@ import { Module, ModuleOptions, PisellCore } from '../../../types';
|
|
|
2
2
|
import { BaseModule } from '../../../modules/BaseModule';
|
|
3
3
|
import type { RouteDefinition } from '../../types';
|
|
4
4
|
import { OrderData, OrderId } from './types';
|
|
5
|
+
/** 订单模块流程调试日志条目 */
|
|
6
|
+
interface OrderFlowLogEntry {
|
|
7
|
+
ts: string;
|
|
8
|
+
step: string;
|
|
9
|
+
metadata?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
/** 单笔订单 SQLite 写入记录 */
|
|
12
|
+
interface OrderWriteStatEntry {
|
|
13
|
+
ts: string;
|
|
14
|
+
writeSeq: number;
|
|
15
|
+
source: string;
|
|
16
|
+
writeMethod: string;
|
|
17
|
+
orderId: OrderId | null;
|
|
18
|
+
storageKey: string;
|
|
19
|
+
mergeAction?: 'insert' | 'update' | 'snapshot' | 'singleUpdate';
|
|
20
|
+
}
|
|
21
|
+
declare global {
|
|
22
|
+
interface Window {
|
|
23
|
+
/** 订单模块流程调试日志,可在 DevTools 直接查看 */
|
|
24
|
+
__orderModuleFlowLogs?: OrderFlowLogEntry[];
|
|
25
|
+
/** 按 storageKey 聚合的 SQLite 写入次数,便于排查重复写 */
|
|
26
|
+
__orderModuleWriteStats?: Record<string, OrderWriteStatEntry[]>;
|
|
27
|
+
/** 清空订单流程调试日志 */
|
|
28
|
+
clearOrderModuleFlowLogs?: () => void;
|
|
29
|
+
/** 导出订单流程调试日志 JSON 字符串 */
|
|
30
|
+
exportOrderModuleFlowLogs?: () => string;
|
|
31
|
+
/** 导出按订单聚合的写入统计 */
|
|
32
|
+
exportOrderModuleWriteStats?: () => string;
|
|
33
|
+
/** 汇总写入次数 Top N(默认 20) */
|
|
34
|
+
summarizeOrderModuleWrites?: (topN?: number) => Array<{
|
|
35
|
+
storageKey: string;
|
|
36
|
+
orderId: OrderId | null;
|
|
37
|
+
writeCount: number;
|
|
38
|
+
sources: string[];
|
|
39
|
+
lastWriteAt: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
5
43
|
/**
|
|
6
44
|
* Order 模块 - 基础框架
|
|
7
45
|
*/
|
|
@@ -19,6 +57,12 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
19
57
|
private logger;
|
|
20
58
|
private storage;
|
|
21
59
|
private orderSQLiteSaveQueue;
|
|
60
|
+
/** 全局递增的 SQLite 写入序号,便于日志关联同一次操作 */
|
|
61
|
+
private orderFlowWriteSeq;
|
|
62
|
+
/** 按 storageKey 记录最近一次 SQLite 写入来源与时间,用于去重 */
|
|
63
|
+
private recentSqliteWriteByStorageKey;
|
|
64
|
+
/** 最近一次 SSE 全量拉取完成时间 */
|
|
65
|
+
private lastServerFullFetchAtMs;
|
|
22
66
|
constructor(name?: string, version?: string);
|
|
23
67
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
24
68
|
/**
|
|
@@ -33,6 +77,60 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
33
77
|
* @param metadata 日志元数据
|
|
34
78
|
*/
|
|
35
79
|
private logError;
|
|
80
|
+
/**
|
|
81
|
+
* 初始化 window 上的订单流程调试日志数组及辅助方法。
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* window.clearOrderModuleFlowLogs()
|
|
85
|
+
* // 操作完成后:
|
|
86
|
+
* copy(window.exportOrderModuleFlowLogs?.() || '[]')
|
|
87
|
+
*/
|
|
88
|
+
private initOrderFlowLogs;
|
|
89
|
+
/**
|
|
90
|
+
* 写入 window 订单流程调试日志。
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* this.pushOrderFlowLog('mergeOrdersToStore.start', { count: 3 })
|
|
94
|
+
*/
|
|
95
|
+
private pushOrderFlowLog;
|
|
96
|
+
/** 当前内存 store 快照信息,供流程日志使用 */
|
|
97
|
+
private getOrderStoreSnapshot;
|
|
98
|
+
/**
|
|
99
|
+
* 记录一次 SQLite 写入到 window 统计,用于排查同一订单被多次写入的原因。
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* this.trackOrderWrite('upsertOrdersFromRemote', 'bulkUpdate', orders, 'insert')
|
|
103
|
+
*/
|
|
104
|
+
private trackOrderWrite;
|
|
105
|
+
/**
|
|
106
|
+
* 记录订单最近一次 SQLite 写入,供 pubsub 回声去重使用。
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* this.recordRecentSqliteWrite('upsertOrdersFromRemote', orders)
|
|
110
|
+
*/
|
|
111
|
+
private recordRecentSqliteWrite;
|
|
112
|
+
/**
|
|
113
|
+
* 过滤 pubsub 触发的冗余 SQLite patch(业务 API 刚写入过的 update 回声)。
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const { toWrite, skipped } = this.filterRedundantPatchOrders('pubsub.bodyUpsert', orders, mergeActions)
|
|
117
|
+
*/
|
|
118
|
+
private filterRedundantPatchOrders;
|
|
119
|
+
/**
|
|
120
|
+
* 过滤 pubsub HTTP 增量拉取 ids:本地刚由业务 API 写入的单可跳过 HTTP。
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* const ids = this.filterRedundantHttpRefreshIds([99331, 99332])
|
|
124
|
+
*/
|
|
125
|
+
private filterRedundantHttpRefreshIds;
|
|
126
|
+
/**
|
|
127
|
+
* 解析 pubsub 消息会走哪条同步分支,便于对照为何触发 HTTP 重拉或 body 直写。
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* this.resolveSyncMessageRoute(msg)
|
|
131
|
+
* // => { route: 'httpRefresh.batchIds', ... }
|
|
132
|
+
*/
|
|
133
|
+
private resolveSyncMessageRoute;
|
|
36
134
|
private getOrderSyncThrottleMs;
|
|
37
135
|
preload(): Promise<void>;
|
|
38
136
|
getOrders(): OrderData[];
|
|
@@ -120,6 +218,14 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
120
218
|
private normalizeOrderSyncPayload;
|
|
121
219
|
private uniqueOrderIds;
|
|
122
220
|
private getIdKey;
|
|
221
|
+
/**
|
|
222
|
+
* 解析订单 SQLite 主键,规则与宿主 OrderDataSource.getOrderStorageKey 一致。
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* const key = this.getOrderStorageKey({ order_id: 1001, external_sale_number: 'S-1001' })
|
|
226
|
+
* // => 'S-1001'
|
|
227
|
+
*/
|
|
228
|
+
private getOrderStorageKey;
|
|
123
229
|
/**
|
|
124
230
|
* 当前订单拉取窗口:
|
|
125
231
|
* - 优先使用 createdAtQuery.sales_time_between(已按营业日边界初始化)
|
|
@@ -132,22 +238,35 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
132
238
|
private setStorageItem;
|
|
133
239
|
private loadOrdersFromSQLite;
|
|
134
240
|
/**
|
|
135
|
-
* 串行执行订单 SQLite
|
|
241
|
+
* 串行执行订单 SQLite 写入任务,避免快照替换与增量 upsert 并发交错。
|
|
136
242
|
*
|
|
137
243
|
* @example
|
|
138
244
|
* await this.runInOrderSQLiteSaveQueue(async () => {
|
|
139
|
-
* await this.dbManager.
|
|
140
|
-
* await this.dbManager.bulkAdd(INDEXDB_STORE_NAME, orders)
|
|
245
|
+
* await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, orders)
|
|
141
246
|
* })
|
|
142
247
|
*/
|
|
143
248
|
private runInOrderSQLiteSaveQueue;
|
|
144
249
|
/**
|
|
145
|
-
*
|
|
250
|
+
* 批量增量 upsert 订单到 SQLite,不清空表;用于 pubsub / HTTP 增量合并。
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* await this.patchOrdersInSQLite(freshOrders)
|
|
254
|
+
*/
|
|
255
|
+
private patchOrdersInSQLite;
|
|
256
|
+
/**
|
|
257
|
+
* 单条 upsert 订单到 SQLite;用于 overwriteExistingOrder 等单条覆盖场景。
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* await this.updateOrderInSQLite(freshOrder)
|
|
261
|
+
*/
|
|
262
|
+
private updateOrderInSQLite;
|
|
263
|
+
/**
|
|
264
|
+
* 全量快照替换 orders 表(clear + bulkAdd),用于 SSE 全量拉取与营业日窗口裁剪。
|
|
146
265
|
*
|
|
147
266
|
* @example
|
|
148
|
-
* await this.
|
|
267
|
+
* await this.replaceOrdersSnapshotInSQLite(orderList)
|
|
149
268
|
*/
|
|
150
|
-
private
|
|
269
|
+
private replaceOrdersSnapshotInSQLite;
|
|
151
270
|
/**
|
|
152
271
|
* 清空订单模块的内存数据和本地 SQLite 订单表。
|
|
153
272
|
*
|
|
@@ -156,3 +275,4 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
156
275
|
*/
|
|
157
276
|
clear(): Promise<void>;
|
|
158
277
|
}
|
|
278
|
+
export {};
|