@pisell/pisellos 0.10.97 → 0.10.99
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/walletPass/locales.js +9 -0
- package/dist/modules/Order/index.js +7 -0
- package/dist/modules/Order/types.d.ts +6 -0
- package/dist/modules/Payment/utils.d.ts +2 -0
- package/dist/modules/Payment/utils.js +6 -6
- package/dist/modules/Payment/walletpass.d.ts +2 -0
- package/dist/modules/Payment/walletpass.js +75 -34
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ResourcePlanner/planner.js +24 -5
- package/dist/server/index.js +26 -13
- package/dist/server/modules/products/index.d.ts +6 -2
- package/dist/server/modules/products/index.js +476 -400
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +6 -5
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +20 -20
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +34 -23
- package/lib/model/strategy/adapter/walletPass/locales.js +9 -0
- package/lib/modules/Order/index.js +5 -0
- package/lib/modules/Order/types.d.ts +6 -0
- package/lib/modules/Payment/utils.d.ts +2 -0
- package/lib/modules/Payment/utils.js +7 -7
- package/lib/modules/Payment/walletpass.d.ts +2 -0
- package/lib/modules/Payment/walletpass.js +42 -11
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ResourcePlanner/planner.js +24 -5
- package/lib/server/index.js +9 -4
- package/lib/server/modules/products/index.d.ts +6 -2
- package/lib/server/modules/products/index.js +40 -7
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +20 -20
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -1
- package/lib/solution/UnifiedBookingSales/index.js +3 -2
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ var _replication = require("./replication");
|
|
|
16
16
|
const INDEXDB_STORE_NAME = 'products';
|
|
17
17
|
/** 商品同步防抖时间(毫秒) */
|
|
18
18
|
const PRODUCT_SYNC_DEBOUNCE_MS = 10_000;
|
|
19
|
-
/** silentRefresh
|
|
19
|
+
/** silentRefresh 最小间隔,仅从成功的服务器全量刷新计时 */
|
|
20
20
|
const PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS = 30_000;
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -63,8 +63,10 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
63
63
|
syncTimer;
|
|
64
64
|
/** 最近一次 SSE 全量拉取完成时间 */
|
|
65
65
|
lastServerFullFetchAtMs = 0;
|
|
66
|
-
/** 最近一次 preload 完成时间(含 IndexDB
|
|
66
|
+
/** 最近一次 preload 完成时间(含 IndexDB 命中,仅用于日志) */
|
|
67
67
|
lastPreloadCompletedAtMs = 0;
|
|
68
|
+
serverFullFetchPromise;
|
|
69
|
+
silentRefreshPromise;
|
|
68
70
|
/** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
|
|
69
71
|
productIndexDBSaveQueue = Promise.resolve();
|
|
70
72
|
|
|
@@ -961,11 +963,20 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
961
963
|
*/
|
|
962
964
|
async loadProductsByServer(options = {}) {
|
|
963
965
|
if (this.isMemoryReplica()) return this.refreshFromReplica(options.trigger || 'loadProductsByServer');
|
|
966
|
+
if (this.serverFullFetchPromise) return this.serverFullFetchPromise;
|
|
967
|
+
const fetchPromise = this.fetchAndPersistProductsByServer(options.trigger || 'unknown');
|
|
968
|
+
this.serverFullFetchPromise = fetchPromise;
|
|
969
|
+
try {
|
|
970
|
+
return await fetchPromise;
|
|
971
|
+
} finally {
|
|
972
|
+
if (this.serverFullFetchPromise === fetchPromise) this.serverFullFetchPromise = undefined;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
async fetchAndPersistProductsByServer(trigger) {
|
|
964
976
|
if (!this.productDataSource) {
|
|
965
977
|
this.logWarning('loadProductsByServer: ProductDataSource 不可用');
|
|
966
978
|
return [];
|
|
967
979
|
}
|
|
968
|
-
const trigger = options.trigger || 'unknown';
|
|
969
980
|
this.logInfo('开始通过 DataSource SSE 加载商品列表', {
|
|
970
981
|
trigger
|
|
971
982
|
});
|
|
@@ -1415,6 +1426,8 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
1415
1426
|
await this.refreshFromReplica('preload');
|
|
1416
1427
|
return;
|
|
1417
1428
|
}
|
|
1429
|
+
const productsBeforePreload = this.store.list;
|
|
1430
|
+
const fullFetchBeforePreload = this.lastServerFullFetchAtMs;
|
|
1418
1431
|
const tTotal = performance.now();
|
|
1419
1432
|
this.logInfo('开始预加载数据');
|
|
1420
1433
|
try {
|
|
@@ -1423,6 +1436,11 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
1423
1436
|
(0, _product.perfMark)('preload.loadFromIndexDB', performance.now() - tIndexDB, {
|
|
1424
1437
|
count: cachedData?.length ?? 0
|
|
1425
1438
|
});
|
|
1439
|
+
|
|
1440
|
+
// PIN 刷新若先完成,不用随后读出的旧缓存覆盖服务器列表。
|
|
1441
|
+
if (this.lastServerFullFetchAtMs !== fullFetchBeforePreload && this.store.list !== productsBeforePreload) {
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1426
1444
|
if (cachedData && cachedData.length > 0) {
|
|
1427
1445
|
// IndexDB 反序列化的数据已经是全新的,无需 cloneDeep
|
|
1428
1446
|
this.store.list = cachedData;
|
|
@@ -1915,13 +1933,18 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
1915
1933
|
* @returns 刷新后的商品列表
|
|
1916
1934
|
*/
|
|
1917
1935
|
async silentRefresh(options = {}) {
|
|
1918
|
-
if (this.isMemoryReplica()) return this.refreshFromReplica(options.trigger || 'background');
|
|
1919
|
-
const t0 = performance.now();
|
|
1920
|
-
const now = Date.now();
|
|
1921
1936
|
const trigger = options.trigger || 'background';
|
|
1937
|
+
if (this.isMemoryReplica()) return this.refreshFromReplica(trigger);
|
|
1938
|
+
if (this.silentRefreshPromise) {
|
|
1939
|
+
this.logInfo('silentRefresh 复用进行中的全量刷新', {
|
|
1940
|
+
trigger
|
|
1941
|
+
});
|
|
1942
|
+
return this.silentRefreshPromise;
|
|
1943
|
+
}
|
|
1944
|
+
const now = Date.now();
|
|
1922
1945
|
const elapsedSincePreloadMs = now - this.lastPreloadCompletedAtMs;
|
|
1923
1946
|
const elapsedSinceFullFetchMs = now - this.lastServerFullFetchAtMs;
|
|
1924
|
-
if (this.
|
|
1947
|
+
if (!this.serverFullFetchPromise && this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetchMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS) {
|
|
1925
1948
|
this.logInfo('silentRefresh 跳过全量 SSE', {
|
|
1926
1949
|
trigger,
|
|
1927
1950
|
reason: 'within_min_interval',
|
|
@@ -1938,6 +1961,16 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
1938
1961
|
elapsedSinceFullFetchMs,
|
|
1939
1962
|
productCount: this.store.list.length
|
|
1940
1963
|
});
|
|
1964
|
+
const refreshPromise = this.runSilentRefresh(trigger);
|
|
1965
|
+
this.silentRefreshPromise = refreshPromise;
|
|
1966
|
+
try {
|
|
1967
|
+
return await refreshPromise;
|
|
1968
|
+
} finally {
|
|
1969
|
+
if (this.silentRefreshPromise === refreshPromise) this.silentRefreshPromise = undefined;
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
async runSilentRefresh(trigger) {
|
|
1973
|
+
const t0 = performance.now();
|
|
1941
1974
|
try {
|
|
1942
1975
|
const products = await this.loadProductsByServer({
|
|
1943
1976
|
trigger
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"
|
|
392
|
+
getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|
|
@@ -366,7 +366,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
366
366
|
* 获取当前的客户搜索条件
|
|
367
367
|
* @returns 当前搜索条件
|
|
368
368
|
*/
|
|
369
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
369
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
370
370
|
/**
|
|
371
371
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
372
372
|
* @returns 客户状态
|
|
@@ -386,6 +386,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
386
386
|
await idGenerator.configure({
|
|
387
387
|
biz: businessCode,
|
|
388
388
|
config: {
|
|
389
|
+
enableShortNumber: openDataConfig?.['sale.enable_short_number'] !== false,
|
|
389
390
|
prefix,
|
|
390
391
|
deviceCode: deviceId,
|
|
391
392
|
padReceiptSequence: openDataConfig?.['sale.pad_with_leading_zeros'] === true,
|
|
@@ -2078,7 +2079,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
2078
2079
|
if (invoiceContextChanged) {
|
|
2079
2080
|
await this.prepareInvoiceTemplateAtSolutionReady(Object.prototype.hasOwnProperty.call(params, 'openData') ? this.getInjectedOpenDataConfig() : undefined);
|
|
2080
2081
|
}
|
|
2081
|
-
if (params?.businessCode !== undefined || params?.business_code !== undefined) {
|
|
2082
|
+
if (params?.businessCode !== undefined || params?.business_code !== undefined || Object.prototype.hasOwnProperty.call(params ?? {}, 'openData')) {
|
|
2082
2083
|
await this.configureIdGeneratorFromOpenData();
|
|
2083
2084
|
}
|
|
2084
2085
|
}
|
|
@@ -24,23 +24,28 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
24
24
|
products: import("../../../modules/Order/types").OrderSubmitProduct[];
|
|
25
25
|
notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
|
|
26
26
|
summary?: import("../../../modules/Order/types").OrderSummary | undefined;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
status: string;
|
|
28
|
+
metadata: Record<string, any>;
|
|
29
|
+
business_code?: string | undefined;
|
|
30
30
|
customer_id: number | null;
|
|
31
|
+
type: string;
|
|
32
|
+
holder: Record<string, any> | null;
|
|
33
|
+
email: string;
|
|
34
|
+
phone: string;
|
|
35
|
+
note: string;
|
|
36
|
+
relation_forms: any[];
|
|
37
|
+
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
38
|
+
country_calling_code: string;
|
|
39
|
+
contacts_info: Record<string, any> | null;
|
|
31
40
|
order_id: number | null;
|
|
41
|
+
external_sale_number: string;
|
|
32
42
|
order_number: string | null;
|
|
33
43
|
shop_order_number: string | null;
|
|
34
|
-
|
|
35
|
-
business_code?: string | undefined;
|
|
44
|
+
shop_full_order_number: string | null;
|
|
36
45
|
sales_channel: string;
|
|
37
46
|
order_sales_channel: string;
|
|
38
|
-
status: string;
|
|
39
47
|
shipping_status: string;
|
|
40
48
|
customer_name: string;
|
|
41
|
-
country_calling_code: string;
|
|
42
|
-
phone: string;
|
|
43
|
-
email: string;
|
|
44
49
|
is_price_include_tax: number;
|
|
45
50
|
tax_title: string;
|
|
46
51
|
tax_country_code: string;
|
|
@@ -51,21 +56,16 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
51
56
|
deposit_amount: string;
|
|
52
57
|
shop_discount: string;
|
|
53
58
|
surcharge_fee: string;
|
|
54
|
-
|
|
59
|
+
buzzer?: string | undefined;
|
|
60
|
+
delivery_type?: string | undefined;
|
|
61
|
+
table_number?: Record<string, any> | undefined;
|
|
55
62
|
schedule_date: string;
|
|
63
|
+
bookings: any[];
|
|
64
|
+
payments: any[];
|
|
65
|
+
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
56
66
|
refunds?: any[] | undefined;
|
|
57
67
|
surcharges: any[];
|
|
58
|
-
relation_forms: any[];
|
|
59
68
|
contacts: any[];
|
|
60
|
-
contacts_info: Record<string, any> | null;
|
|
61
|
-
holder: Record<string, any> | null;
|
|
62
|
-
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
63
|
-
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
64
|
-
metadata: Record<string, any>;
|
|
65
|
-
buzzer?: string | undefined;
|
|
66
|
-
shop_full_order_number: string | null;
|
|
67
|
-
delivery_type?: string | undefined;
|
|
68
|
-
table_number?: Record<string, any> | undefined;
|
|
69
69
|
};
|
|
70
70
|
export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
|
|
71
71
|
schedule_event_id: any;
|
|
@@ -278,7 +278,7 @@ async function applyGlobalScan(host, formatted, bridge) {
|
|
|
278
278
|
}
|
|
279
279
|
// 已识别为 Wallet 支付资产但当前不可用:保留禁用展示,不回退优惠码。
|
|
280
280
|
if (!bindResult.resolveFailed) {
|
|
281
|
-
bridge?.onNotify?.('fail', 'pisell2.text.goodpass.code-invalid-cart');
|
|
281
|
+
bridge?.onNotify?.('fail', walletResult.asset.reasonCode === 'empty_cart' ? 'pisell2.sale-detail.promotion-panel.add-items-first' : 'pisell2.text.goodpass.code-invalid-cart');
|
|
282
282
|
}
|
|
283
283
|
return {
|
|
284
284
|
status: 'failed',
|
|
@@ -2029,7 +2029,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2029
2029
|
const biz = this.getBookingTicketBusinessCode();
|
|
2030
2030
|
if (!biz) throw new Error('当前订单缺少业务类型,无法生成订单编号');
|
|
2031
2031
|
const idGenerator = this.appPlugin?.getApp?.()?.getPlugin?.('idGenerator');
|
|
2032
|
-
|
|
2032
|
+
const useLongNumber = idGenerator?.getConfig?.(biz)?.enableShortNumber === false;
|
|
2033
|
+
if (!tempOrder.shop_order_number && typeof idGenerator?.generateShopOrderNumber !== 'function' || !tempOrder.shop_full_order_number && !useLongNumber && typeof idGenerator?.generateReceiptId !== 'function') {
|
|
2033
2034
|
throw new Error('订单编号生成器不可用,请重启应用后重试');
|
|
2034
2035
|
}
|
|
2035
2036
|
try {
|
|
@@ -2039,7 +2040,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2039
2040
|
});
|
|
2040
2041
|
}
|
|
2041
2042
|
if (!tempOrder.shop_full_order_number) {
|
|
2042
|
-
tempOrder.shop_full_order_number = await idGenerator.generateReceiptId({
|
|
2043
|
+
tempOrder.shop_full_order_number = useLongNumber ? tempOrder.shop_order_number : await idGenerator.generateReceiptId({
|
|
2043
2044
|
biz
|
|
2044
2045
|
});
|
|
2045
2046
|
}
|