@pisell/pisellos 2.2.153 → 2.2.154
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/core/index.js +1 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -1
- package/dist/modules/Order/index.d.ts +2 -0
- package/dist/modules/Order/index.js +231 -160
- package/dist/modules/Order/types.d.ts +19 -0
- package/dist/modules/Order/utils.js +7 -6
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +567 -505
- package/dist/modules/Payment/types.d.ts +29 -9
- package/dist/modules/SalesSummary/index.d.ts +7 -5
- package/dist/modules/SalesSummary/index.js +35 -11
- package/dist/plugins/app.d.ts +2 -0
- package/dist/server/index.d.ts +2 -5
- package/dist/server/index.js +58 -66
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/products/index.d.ts +12 -1
- package/dist/server/modules/products/index.js +169 -78
- package/dist/server/modules/products/types.d.ts +11 -0
- package/dist/server/modules/products/types.js +4 -0
- package/dist/server/utils/product.js +2 -2
- package/dist/solution/BaseSales/index.d.ts +26 -2
- package/dist/solution/BaseSales/index.js +342 -112
- package/dist/solution/BaseSales/types.d.ts +4 -4
- package/dist/solution/BaseSales/types.js +4 -4
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +116 -0
- package/dist/solution/BaseSales/utils.js +3 -3
- package/dist/solution/BookingTicket/index.d.ts +11 -13
- package/dist/solution/BookingTicket/index.js +23 -37
- package/dist/solution/BookingTicket/types.d.ts +9 -6
- package/dist/solution/BookingTicket/types.js +6 -3
- package/dist/solution/BookingTicket/utils/cartView.d.ts +7 -12
- package/dist/solution/BookingTicket/utils/cartView.js +52 -14
- package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
- package/dist/solution/Sales/index.d.ts +3 -0
- package/dist/solution/Sales/index.js +85 -43
- package/dist/solution/Sales/types.d.ts +3 -0
- package/dist/solution/ScanOrder/types.d.ts +4 -4
- package/dist/solution/ScanOrder/types.js +4 -4
- package/dist/solution/ScanOrder/utils.js +3 -3
- package/lib/core/index.js +1 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -1
- package/lib/modules/Order/index.d.ts +2 -0
- package/lib/modules/Order/index.js +39 -7
- package/lib/modules/Order/types.d.ts +19 -0
- package/lib/modules/Order/utils.js +4 -2
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +26 -2
- package/lib/modules/Payment/types.d.ts +29 -9
- package/lib/modules/SalesSummary/index.d.ts +7 -5
- package/lib/modules/SalesSummary/index.js +29 -9
- package/lib/plugins/app.d.ts +2 -0
- package/lib/server/index.d.ts +2 -5
- package/lib/server/index.js +38 -58
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/products/index.d.ts +12 -1
- package/lib/server/modules/products/index.js +69 -9
- package/lib/server/modules/products/types.d.ts +11 -0
- package/lib/server/utils/product.js +2 -2
- package/lib/solution/BaseSales/index.d.ts +26 -2
- package/lib/solution/BaseSales/index.js +169 -3
- package/lib/solution/BaseSales/types.d.ts +4 -4
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +155 -0
- package/lib/solution/BaseSales/utils.js +3 -3
- package/lib/solution/BookingTicket/index.d.ts +11 -13
- package/lib/solution/BookingTicket/index.js +17 -27
- package/lib/solution/BookingTicket/types.d.ts +9 -6
- package/lib/solution/BookingTicket/utils/cartView.d.ts +7 -12
- package/lib/solution/BookingTicket/utils/cartView.js +44 -18
- package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
- package/lib/solution/Sales/index.d.ts +3 -0
- package/lib/solution/Sales/index.js +50 -15
- package/lib/solution/Sales/types.d.ts +3 -0
- package/lib/solution/ScanOrder/types.d.ts +4 -4
- package/lib/solution/ScanOrder/utils.js +3 -3
- package/package.json +1 -1
|
@@ -349,6 +349,18 @@ export interface EftposPayment {
|
|
|
349
349
|
/**
|
|
350
350
|
* 钱包支付接口
|
|
351
351
|
*/
|
|
352
|
+
export interface WalletInitializationResult {
|
|
353
|
+
walletRecommendList: WalletRecommendItem[];
|
|
354
|
+
userIdentificationCodes: UserIdentificationCodeItem[];
|
|
355
|
+
transformList: any[];
|
|
356
|
+
noApplicableVoucher: any[];
|
|
357
|
+
products: any[];
|
|
358
|
+
}
|
|
359
|
+
export interface WalletStoredInitData {
|
|
360
|
+
transformList: any[];
|
|
361
|
+
noApplicableVoucher: any[];
|
|
362
|
+
products: any[];
|
|
363
|
+
}
|
|
352
364
|
export interface WalletPassPayment {
|
|
353
365
|
/** 生成钱包API默认参数 */
|
|
354
366
|
generateWalletParams: (businessData: WalletInitBusinessData) => WalletDeductionRecommendParams;
|
|
@@ -357,21 +369,25 @@ export interface WalletPassPayment {
|
|
|
357
369
|
/** 清理已存储的钱包参数 */
|
|
358
370
|
clearStoredWalletParams: () => void;
|
|
359
371
|
/** 初始化钱包数据(从业务数据开始,内部生成参数) */
|
|
360
|
-
initializeWalletDataFromBusinessAsync: (businessData: WalletInitBusinessData) => Promise<
|
|
361
|
-
walletRecommendList: WalletRecommendItem[];
|
|
362
|
-
userIdentificationCodes: UserIdentificationCodeItem[];
|
|
363
|
-
}>;
|
|
372
|
+
initializeWalletDataFromBusinessAsync: (businessData: WalletInitBusinessData) => Promise<WalletInitializationResult>;
|
|
364
373
|
/** 初始化钱包数据(先获取推荐列表,再获取用户识别码列表) */
|
|
365
|
-
initializeWalletDataAsync: (baseParams: WalletDeductionRecommendParams) => Promise<
|
|
366
|
-
walletRecommendList: WalletRecommendItem[];
|
|
367
|
-
userIdentificationCodes: UserIdentificationCodeItem[];
|
|
368
|
-
}>;
|
|
374
|
+
initializeWalletDataAsync: (baseParams: WalletDeductionRecommendParams) => Promise<WalletInitializationResult>;
|
|
369
375
|
/** 获取钱包推荐扣款列表(异步获取并缓存) */
|
|
370
376
|
getWalletPassRecommendListAsync: (params: WalletDeductionRecommendParams) => Promise<WalletRecommendItem[]>;
|
|
371
377
|
/** 查询用户识别码列表(异步获取并缓存) */
|
|
372
378
|
getUserIdentificationCodeListAsync: (params: UserIdentificationCodeParams) => Promise<UserIdentificationCodeItem[]>;
|
|
373
379
|
/** 搜索识别码信息 */
|
|
374
|
-
searchIdentificationCodeAsync: (params: SearchIdentificationCodeParams
|
|
380
|
+
searchIdentificationCodeAsync: (params: SearchIdentificationCodeParams, config?: {
|
|
381
|
+
noCache?: boolean;
|
|
382
|
+
}) => Promise<SearchIdentificationCodeResult>;
|
|
383
|
+
/** 将推荐钱包列表转换为 prepare_payments */
|
|
384
|
+
formatWalletPassList2PreparePayments: (list: WalletRecommendItem[]) => {
|
|
385
|
+
voucher_id: number;
|
|
386
|
+
amount: number;
|
|
387
|
+
tag: string;
|
|
388
|
+
wallet_pass_usage_unit?: unknown;
|
|
389
|
+
wallet_pass_use_value?: string | number | null;
|
|
390
|
+
}[];
|
|
375
391
|
/** 获取缓存的搜索结果列表 */
|
|
376
392
|
getSearchResults: () => SearchIdentificationCodeItem[];
|
|
377
393
|
/** 根据识别码查找搜索结果 */
|
|
@@ -384,6 +400,10 @@ export interface WalletPassPayment {
|
|
|
384
400
|
clearWalletRecommendList: () => void;
|
|
385
401
|
/** 清除用户识别码列表 */
|
|
386
402
|
clearUserIdentificationCodes: () => void;
|
|
403
|
+
/** 获取缓存的钱包初始化数据 */
|
|
404
|
+
getStoredWalletInitData: () => WalletStoredInitData | null;
|
|
405
|
+
/** 清除缓存的钱包初始化数据 */
|
|
406
|
+
clearStoredWalletInitData: () => void;
|
|
387
407
|
/** 清除搜索结果缓存 */
|
|
388
408
|
clearSearchResults: () => void;
|
|
389
409
|
/** 清除所有缓存数据 */
|
|
@@ -5,20 +5,22 @@ export * from './types';
|
|
|
5
5
|
export declare class SalesSummaryModule extends BaseModule implements Module, SalesSummaryModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
8
|
-
private
|
|
8
|
+
private appPlugin;
|
|
9
9
|
private store;
|
|
10
10
|
private request;
|
|
11
11
|
constructor(name?: string, version?: string);
|
|
12
12
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
13
|
getSurchargeList(): Promise<void>;
|
|
14
|
+
private getAppData;
|
|
15
|
+
private getTaxConfig;
|
|
14
16
|
getSummary(params: {
|
|
15
17
|
products: any[];
|
|
16
18
|
isPriceIncludeTax?: number;
|
|
17
19
|
taxRate?: number;
|
|
18
20
|
shopDiscount?: string | number;
|
|
19
21
|
}): Promise<{
|
|
20
|
-
tax_title:
|
|
21
|
-
tax_rate:
|
|
22
|
+
tax_title: string;
|
|
23
|
+
tax_rate: number | undefined;
|
|
22
24
|
product_quantity: number;
|
|
23
25
|
product_original_amount: string;
|
|
24
26
|
product_amount: string;
|
|
@@ -42,8 +44,8 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
42
44
|
pay_service_charge_amount: string;
|
|
43
45
|
is_price_include_tax?: number | undefined;
|
|
44
46
|
} | {
|
|
45
|
-
tax_title:
|
|
46
|
-
tax_rate:
|
|
47
|
+
tax_title: string;
|
|
48
|
+
tax_rate: number | undefined;
|
|
47
49
|
product_quantity: number;
|
|
48
50
|
product_original_amount: string;
|
|
49
51
|
product_amount: string;
|
|
@@ -24,6 +24,11 @@ import { BaseModule } from "../BaseModule";
|
|
|
24
24
|
import { ScheduleModule } from "../Schedule";
|
|
25
25
|
import { calculateSalesSummary, createEmptySalesSummary } from "./utils";
|
|
26
26
|
export * from "./types";
|
|
27
|
+
var salesSummaryDataKeys = {
|
|
28
|
+
isPriceIncludeTax: 'is_price_include_tax',
|
|
29
|
+
taxRate: 'tax_rate',
|
|
30
|
+
taxTitle: 'tax_title'
|
|
31
|
+
};
|
|
27
32
|
export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
28
33
|
_inherits(SalesSummaryModule, _BaseModule);
|
|
29
34
|
var _super = _createSuper(SalesSummaryModule);
|
|
@@ -33,7 +38,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
33
38
|
_this = _super.call(this, name, version);
|
|
34
39
|
_defineProperty(_assertThisInitialized(_this), "defaultName", 'salesSummary');
|
|
35
40
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
36
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
|
|
37
42
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
38
43
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
39
44
|
return _this;
|
|
@@ -48,15 +53,15 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
48
53
|
case 0:
|
|
49
54
|
this.core = core;
|
|
50
55
|
this.store = options.store;
|
|
51
|
-
this.
|
|
56
|
+
this.appPlugin = this.core.getPlugin('app');
|
|
52
57
|
this.request = this.core.getPlugin('request');
|
|
53
58
|
this.store.surchargeList = ((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList) || [];
|
|
54
59
|
this.store.summary = ((_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.summary) || createEmptySalesSummary();
|
|
55
|
-
if (this.
|
|
60
|
+
if (this.appPlugin) {
|
|
56
61
|
_context.next = 8;
|
|
57
62
|
break;
|
|
58
63
|
}
|
|
59
|
-
throw new Error('SalesSummaryModule 需要
|
|
64
|
+
throw new Error('SalesSummaryModule 需要 app 插件支持');
|
|
60
65
|
case 8:
|
|
61
66
|
if (this.request) {
|
|
62
67
|
_context.next = 10;
|
|
@@ -114,17 +119,36 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
114
119
|
}
|
|
115
120
|
return getSurchargeList;
|
|
116
121
|
}()
|
|
122
|
+
}, {
|
|
123
|
+
key: "getAppData",
|
|
124
|
+
value: function getAppData(key) {
|
|
125
|
+
var _this$appPlugin$getDa, _this$appPlugin, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
|
|
126
|
+
var getData = (_this$appPlugin$getDa = (_this$appPlugin = this.appPlugin).getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
|
|
127
|
+
if (typeof getData === 'function') return getData(key);
|
|
128
|
+
var app = this.appPlugin.getApp();
|
|
129
|
+
var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
|
|
130
|
+
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "getTaxConfig",
|
|
134
|
+
value: function getTaxConfig() {
|
|
135
|
+
return {
|
|
136
|
+
isPriceIncludeTax: this.getAppData(salesSummaryDataKeys.isPriceIncludeTax),
|
|
137
|
+
taxRate: this.getAppData(salesSummaryDataKeys.taxRate),
|
|
138
|
+
taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle)
|
|
139
|
+
};
|
|
140
|
+
}
|
|
117
141
|
}, {
|
|
118
142
|
key: "getSummary",
|
|
119
143
|
value: function () {
|
|
120
144
|
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
121
|
-
var
|
|
122
|
-
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount,
|
|
145
|
+
var _ref;
|
|
146
|
+
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, taxConfig, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
|
|
123
147
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
124
148
|
while (1) switch (_context3.prev = _context3.next) {
|
|
125
149
|
case 0:
|
|
126
150
|
_params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount;
|
|
127
|
-
|
|
151
|
+
taxConfig = this.getTaxConfig();
|
|
128
152
|
summarySchedule = this.core.getModule("".concat(this.name.split('_')[0], "_schedule"));
|
|
129
153
|
needScheduleIds = this.store.surchargeList.map(function (item) {
|
|
130
154
|
return item.available_schedule_ids;
|
|
@@ -146,16 +170,16 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
146
170
|
}
|
|
147
171
|
summary = calculateSalesSummary({
|
|
148
172
|
products: products,
|
|
149
|
-
isPriceIncludeTax: (_ref = isPriceIncludeTax !== null && isPriceIncludeTax !== void 0 ? isPriceIncludeTax :
|
|
150
|
-
taxRate: taxRate !== null && taxRate !== void 0 ? taxRate :
|
|
173
|
+
isPriceIncludeTax: (_ref = isPriceIncludeTax !== null && isPriceIncludeTax !== void 0 ? isPriceIncludeTax : taxConfig.isPriceIncludeTax) !== null && _ref !== void 0 ? _ref : 1,
|
|
174
|
+
taxRate: taxRate !== null && taxRate !== void 0 ? taxRate : taxConfig.taxRate,
|
|
151
175
|
surchargeList: this.store.surchargeList,
|
|
152
176
|
scheduleById: scheduleById,
|
|
153
177
|
isInScheduleByDate: ScheduleModule.isInScheduleByDate,
|
|
154
178
|
shopDiscount: shopDiscount
|
|
155
179
|
});
|
|
156
180
|
summaryWithTaxMeta = _objectSpread(_objectSpread({}, summary), {}, {
|
|
157
|
-
tax_title:
|
|
158
|
-
tax_rate: taxRate !== null && taxRate !== void 0 ? taxRate :
|
|
181
|
+
tax_title: taxConfig.taxTitle || '',
|
|
182
|
+
tax_rate: taxRate !== null && taxRate !== void 0 ? taxRate : taxConfig.taxRate
|
|
159
183
|
});
|
|
160
184
|
this.store.summary = summaryWithTaxMeta;
|
|
161
185
|
return _context3.abrupt("return", summaryWithTaxMeta);
|
package/dist/plugins/app.d.ts
CHANGED
package/dist/server/index.d.ts
CHANGED
|
@@ -372,13 +372,10 @@ declare class Server {
|
|
|
372
372
|
*/
|
|
373
373
|
private recomputeAndNotifyBookingQuery;
|
|
374
374
|
/**
|
|
375
|
-
*
|
|
376
|
-
* @param products 所有商品列表
|
|
377
|
-
* @param activeMenuList 生效的餐牌列表
|
|
378
|
-
* @returns 过滤后的商品列表
|
|
375
|
+
* 根据餐牌配置提取轻量商品范围。
|
|
379
376
|
* @private
|
|
380
377
|
*/
|
|
381
|
-
private
|
|
378
|
+
private getProductScopeByMenuConfig;
|
|
382
379
|
/**
|
|
383
380
|
* 记录信息日志
|
|
384
381
|
* @param title 日志标题
|
package/dist/server/index.js
CHANGED
|
@@ -3299,7 +3299,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3299
3299
|
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(context, options) {
|
|
3300
3300
|
var _menu_list_ids$length3,
|
|
3301
3301
|
_this6 = this;
|
|
3302
|
-
var tTotal, menu_list_ids, schedule_date, schedule_datetime, customer_id, product_id, _published$find, pid, _tPrice,
|
|
3302
|
+
var tTotal, menu_list_ids, schedule_date, schedule_datetime, customer_id, product_id, _published$find, pid, _tPrice, allProductsWithPrice, published, item, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tSort;
|
|
3303
3303
|
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3304
3304
|
while (1) switch (_context29.prev = _context29.next) {
|
|
3305
3305
|
case 0:
|
|
@@ -3339,12 +3339,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
3339
3339
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
3340
3340
|
});
|
|
3341
3341
|
case 11:
|
|
3342
|
-
|
|
3342
|
+
allProductsWithPrice = _context29.sent;
|
|
3343
3343
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice, {
|
|
3344
|
-
count:
|
|
3344
|
+
count: allProductsWithPrice.length,
|
|
3345
3345
|
productId: pid
|
|
3346
3346
|
});
|
|
3347
|
-
published =
|
|
3347
|
+
published = allProductsWithPrice.filter(function (p) {
|
|
3348
3348
|
return ((p === null || p === void 0 ? void 0 : p.status) || 'published') === 'published';
|
|
3349
3349
|
});
|
|
3350
3350
|
item = (_published$find = published.find(function (p) {
|
|
@@ -3405,25 +3405,39 @@ var Server = /*#__PURE__*/function () {
|
|
|
3405
3405
|
activeMenu: activeMenuList.length
|
|
3406
3406
|
});
|
|
3407
3407
|
}
|
|
3408
|
+
tFilter = performance.now();
|
|
3409
|
+
productScope = this.getProductScopeByMenuConfig(activeMenuList);
|
|
3410
|
+
scopedProductIds = this.products.getProductIdsByScope(productScope);
|
|
3411
|
+
perfMark('computeQuery.filterByMenu', performance.now() - tFilter, {
|
|
3412
|
+
scopedProductCount: scopedProductIds.length,
|
|
3413
|
+
activeMenuCount: activeMenuList.length,
|
|
3414
|
+
isAllProducts: !!productScope.isAllProducts
|
|
3415
|
+
});
|
|
3408
3416
|
tPrice = performance.now();
|
|
3409
|
-
|
|
3417
|
+
if (!(scopedProductIds.length > 0)) {
|
|
3418
|
+
_context29.next = 37;
|
|
3419
|
+
break;
|
|
3420
|
+
}
|
|
3421
|
+
_context29.next = 34;
|
|
3410
3422
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
3411
3423
|
scheduleModule: this.getSchedule(),
|
|
3412
3424
|
schedule_datetime: schedule_datetime,
|
|
3413
3425
|
customer_id: customer_id
|
|
3414
3426
|
}, {
|
|
3415
|
-
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
3427
|
+
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
3428
|
+
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
3416
3429
|
});
|
|
3417
|
-
case
|
|
3418
|
-
|
|
3430
|
+
case 34:
|
|
3431
|
+
_context29.t0 = _context29.sent;
|
|
3432
|
+
_context29.next = 38;
|
|
3433
|
+
break;
|
|
3434
|
+
case 37:
|
|
3435
|
+
_context29.t0 = [];
|
|
3436
|
+
case 38:
|
|
3437
|
+
filteredProducts = _context29.t0;
|
|
3419
3438
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
3420
|
-
count:
|
|
3421
|
-
|
|
3422
|
-
tFilter = performance.now();
|
|
3423
|
-
filteredProducts = this.filterProductsByMenuConfig(allProductsWithPrice, activeMenuList);
|
|
3424
|
-
perfMark('computeQuery.filterByMenu', performance.now() - tFilter, {
|
|
3425
|
-
before: allProductsWithPrice.length,
|
|
3426
|
-
after: filteredProducts.length
|
|
3439
|
+
count: filteredProducts.length,
|
|
3440
|
+
scopedProductCount: scopedProductIds.length
|
|
3427
3441
|
});
|
|
3428
3442
|
tStatus = performance.now();
|
|
3429
3443
|
beforeStatusCount = filteredProducts.length;
|
|
@@ -3444,12 +3458,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
3444
3458
|
count: filteredProducts.length
|
|
3445
3459
|
});
|
|
3446
3460
|
perfMark('computeProductQueryResult', performance.now() - tTotal, {
|
|
3447
|
-
|
|
3461
|
+
scopedProductCount: scopedProductIds.length,
|
|
3448
3462
|
filteredCount: filteredProducts.length,
|
|
3449
3463
|
activeMenuCount: activeMenuList.length
|
|
3450
3464
|
});
|
|
3451
3465
|
this.logInfo('computeProductQueryResult 完成', {
|
|
3452
|
-
|
|
3466
|
+
scopedProductCount: scopedProductIds.length,
|
|
3453
3467
|
filteredCount: filteredProducts.length,
|
|
3454
3468
|
activeMenuCount: activeMenuList.length
|
|
3455
3469
|
});
|
|
@@ -3462,7 +3476,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3462
3476
|
message: '',
|
|
3463
3477
|
status: true
|
|
3464
3478
|
});
|
|
3465
|
-
case
|
|
3479
|
+
case 50:
|
|
3466
3480
|
case "end":
|
|
3467
3481
|
return _context29.stop();
|
|
3468
3482
|
}
|
|
@@ -3717,24 +3731,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
3717
3731
|
return recomputeAndNotifyBookingQuery;
|
|
3718
3732
|
}()
|
|
3719
3733
|
/**
|
|
3720
|
-
*
|
|
3721
|
-
* @param products 所有商品列表
|
|
3722
|
-
* @param activeMenuList 生效的餐牌列表
|
|
3723
|
-
* @returns 过滤后的商品列表
|
|
3734
|
+
* 根据餐牌配置提取轻量商品范围。
|
|
3724
3735
|
* @private
|
|
3725
3736
|
*/
|
|
3726
3737
|
)
|
|
3727
3738
|
}, {
|
|
3728
|
-
key: "
|
|
3729
|
-
value: function
|
|
3730
|
-
// 如果没有生效的餐牌,返回空数组
|
|
3739
|
+
key: "getProductScopeByMenuConfig",
|
|
3740
|
+
value: function getProductScopeByMenuConfig(activeMenuList) {
|
|
3731
3741
|
if (!activeMenuList || activeMenuList.length === 0) {
|
|
3732
3742
|
console.log('[Server] 没有生效的餐牌,返回空数组');
|
|
3733
|
-
this.logInfo('
|
|
3734
|
-
productCount: products.length,
|
|
3743
|
+
this.logInfo('getProductScopeByMenuConfig: 没有生效的餐牌,返回空数组', {
|
|
3735
3744
|
activeMenuCount: 0
|
|
3736
3745
|
});
|
|
3737
|
-
return
|
|
3746
|
+
return {
|
|
3747
|
+
productIds: [],
|
|
3748
|
+
collectionIds: []
|
|
3749
|
+
};
|
|
3738
3750
|
}
|
|
3739
3751
|
|
|
3740
3752
|
// 收集允许的商品 IDs 和集合 IDs
|
|
@@ -3749,7 +3761,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3749
3761
|
var config = menu.partyroom_package;
|
|
3750
3762
|
if (!config) {
|
|
3751
3763
|
console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
|
|
3752
|
-
this.logWarning('
|
|
3764
|
+
this.logWarning('getProductScopeByMenuConfig: 餐牌缺少 partyroom_package 配置', {
|
|
3753
3765
|
menuId: menu.form_record_id,
|
|
3754
3766
|
menuName: menu.name
|
|
3755
3767
|
});
|
|
@@ -3759,7 +3771,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3759
3771
|
// 如果有任何一个餐牌是 product_all,则返回所有商品
|
|
3760
3772
|
if (config.type === 'product_all') {
|
|
3761
3773
|
console.log('[Server] 餐牌允许所有商品:', menu.name);
|
|
3762
|
-
this.logInfo('
|
|
3774
|
+
this.logInfo('getProductScopeByMenuConfig: 餐牌允许所有商品', {
|
|
3763
3775
|
menuId: menu.form_record_id,
|
|
3764
3776
|
menuName: menu.name,
|
|
3765
3777
|
configType: config.type
|
|
@@ -3777,7 +3789,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3777
3789
|
return id && allowedProductIds.add(id);
|
|
3778
3790
|
});
|
|
3779
3791
|
console.log('[Server] 餐牌允许指定商品 (product_ids):', menu.name, productIds);
|
|
3780
|
-
this.logInfo('
|
|
3792
|
+
this.logInfo('getProductScopeByMenuConfig: 餐牌允许指定商品', {
|
|
3781
3793
|
menuId: menu.form_record_id,
|
|
3782
3794
|
menuName: menu.name,
|
|
3783
3795
|
configType: config.type,
|
|
@@ -3794,7 +3806,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3794
3806
|
return id && allowedCollectionIds.add(id);
|
|
3795
3807
|
});
|
|
3796
3808
|
console.log('[Server] 餐牌允许商品集合 (product_collection):', menu.name, collectionIds);
|
|
3797
|
-
this.logInfo('
|
|
3809
|
+
this.logInfo('getProductScopeByMenuConfig: 餐牌允许商品集合', {
|
|
3798
3810
|
menuId: menu.form_record_id,
|
|
3799
3811
|
menuName: menu.name,
|
|
3800
3812
|
configType: config.type,
|
|
@@ -3810,55 +3822,35 @@ var Server = /*#__PURE__*/function () {
|
|
|
3810
3822
|
_iterator19.f();
|
|
3811
3823
|
}
|
|
3812
3824
|
if (hasProductAll) {
|
|
3813
|
-
this.logInfo('
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3825
|
+
this.logInfo('getProductScopeByMenuConfig: 返回所有商品 scope(product_all)');
|
|
3826
|
+
return {
|
|
3827
|
+
isAllProducts: true
|
|
3828
|
+
};
|
|
3817
3829
|
}
|
|
3818
3830
|
|
|
3819
3831
|
// 如果没有收集到任何商品 ID 和集合 ID,返回空数组
|
|
3820
3832
|
if (allowedProductIds.size === 0 && allowedCollectionIds.size === 0) {
|
|
3821
3833
|
console.log('[Server] 没有允许的商品和集合');
|
|
3822
|
-
this.logWarning('
|
|
3823
|
-
productCount: products.length,
|
|
3834
|
+
this.logWarning('getProductScopeByMenuConfig: 没有允许的商品和集合', {
|
|
3824
3835
|
activeMenuCount: activeMenuList.length
|
|
3825
3836
|
});
|
|
3826
|
-
return
|
|
3837
|
+
return {
|
|
3838
|
+
productIds: [],
|
|
3839
|
+
collectionIds: []
|
|
3840
|
+
};
|
|
3827
3841
|
}
|
|
3828
3842
|
var allowedProductIdsArray = Array.from(allowedProductIds);
|
|
3829
3843
|
var allowedCollectionIdsArray = Array.from(allowedCollectionIds);
|
|
3830
3844
|
console.log('[Server] 允许的商品 IDs:', allowedProductIdsArray);
|
|
3831
3845
|
console.log('[Server] 允许的集合 IDs:', allowedCollectionIdsArray);
|
|
3832
|
-
this.logInfo('
|
|
3846
|
+
this.logInfo('getProductScopeByMenuConfig: 收集到的允许规则', {
|
|
3833
3847
|
allowedProductCount: allowedProductIds.size,
|
|
3834
3848
|
allowedCollectionCount: allowedCollectionIds.size
|
|
3835
3849
|
});
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
if (allowedProductIds.has(product.id)) {
|
|
3841
|
-
return true;
|
|
3842
|
-
}
|
|
3843
|
-
|
|
3844
|
-
// 2. 检查商品是否属于允许的集合
|
|
3845
|
-
if (allowedCollectionIds.size > 0 && Array.isArray(product.collection)) {
|
|
3846
|
-
var hasMatchingCollection = product.collection.some(function (col) {
|
|
3847
|
-
return allowedCollectionIds.has(col.id);
|
|
3848
|
-
});
|
|
3849
|
-
if (hasMatchingCollection) {
|
|
3850
|
-
return true;
|
|
3851
|
-
}
|
|
3852
|
-
}
|
|
3853
|
-
return false;
|
|
3854
|
-
});
|
|
3855
|
-
console.log('[Server] 过滤结果: 原始 %d 个,过滤后 %d 个', products.length, filteredProducts.length);
|
|
3856
|
-
this.logInfo('filterProductsByMenuConfig: 过滤完成', {
|
|
3857
|
-
originalCount: products.length,
|
|
3858
|
-
filteredCount: filteredProducts.length,
|
|
3859
|
-
removedCount: products.length - filteredProducts.length
|
|
3860
|
-
});
|
|
3861
|
-
return filteredProducts;
|
|
3850
|
+
return {
|
|
3851
|
+
productIds: allowedProductIdsArray,
|
|
3852
|
+
collectionIds: allowedCollectionIdsArray
|
|
3853
|
+
};
|
|
3862
3854
|
}
|
|
3863
3855
|
|
|
3864
3856
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 包含新增的 Products、Menu、Quotation 和扩展的 Schedule 模块
|
|
4
4
|
*/
|
|
5
5
|
export { ProductsModule } from './products';
|
|
6
|
-
export type { ProductsState } from './products/types';
|
|
6
|
+
export type { ProductIdScope, ProductsState } from './products/types';
|
|
7
7
|
export { ProductsHooks } from './products/types';
|
|
8
8
|
export { MenuModule } from './menu';
|
|
9
9
|
export type { MenuState, MenuData } from './menu/types';
|
|
@@ -2,7 +2,7 @@ import { Module, PisellCore } from '../../../types';
|
|
|
2
2
|
import { BaseModule } from '../../../modules/BaseModule';
|
|
3
3
|
import { ProductData } from '../../../modules/Product/types';
|
|
4
4
|
import type { RouteDefinition } from '../../types';
|
|
5
|
-
import { ProductFormatter, ProductFormatterContext } from './types';
|
|
5
|
+
import { ProductIdScope, ProductFormatter, ProductFormatterContext } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* Products 模块 - 用于获取和管理完整的商品详细数据
|
|
8
8
|
* 相比 ProductList 模块,Products 会获取所有详细信息并缓存
|
|
@@ -80,10 +80,12 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
80
80
|
* @param extraContext 额外的上下文数据(可选,由 Server 层传入)
|
|
81
81
|
* @param options 可选参数
|
|
82
82
|
* @param options.changedIds 变更的商品 IDs,非空时仅对这些商品增量执行 prepare 并更新缓存
|
|
83
|
+
* @param options.productIds 指定商品 IDs,仅对这些商品执行价格计算;不传则处理全量
|
|
83
84
|
* @returns 应用了价格的商品列表
|
|
84
85
|
*/
|
|
85
86
|
getProductsWithPrice(schedule_date: string, extraContext?: Partial<ProductFormatterContext>, options?: {
|
|
86
87
|
changedIds?: number[];
|
|
88
|
+
productIds?: number[];
|
|
87
89
|
}): Promise<ProductData[]>;
|
|
88
90
|
/**
|
|
89
91
|
* 准备带价格的商品数据(通过格式化器流程处理)
|
|
@@ -96,6 +98,11 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
96
98
|
*/
|
|
97
99
|
private prepareProductsWithPrice;
|
|
98
100
|
private getProductsPriceCacheKey;
|
|
101
|
+
private normalizeProductIds;
|
|
102
|
+
/**
|
|
103
|
+
* 按轻量范围返回商品 ID,不做 structuredClone。
|
|
104
|
+
*/
|
|
105
|
+
getProductIdsByScope(scope: ProductIdScope): number[];
|
|
99
106
|
/**
|
|
100
107
|
* 应用所有已注册的格式化器
|
|
101
108
|
* @param products 商品列表
|
|
@@ -173,6 +180,10 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
173
180
|
* 仅供内部 formatter 流程使用,因为 formatter 会创建新对象
|
|
174
181
|
*/
|
|
175
182
|
private getProductsRef;
|
|
183
|
+
/**
|
|
184
|
+
* 按 ID 从 Map 取商品引用,供内部 formatter 流程使用。
|
|
185
|
+
*/
|
|
186
|
+
private getProductsRefByIds;
|
|
176
187
|
/**
|
|
177
188
|
* 根据ID获取单个商品(从内存缓存)
|
|
178
189
|
* 使用 Map 快速查询,时间复杂度 O(1)
|