@pisell/pisellos 2.2.205 → 2.2.207
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 +9 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +21 -16
- package/dist/modules/Order/index.d.ts +9 -0
- package/dist/modules/Order/index.js +230 -145
- package/dist/modules/Order/types.d.ts +10 -0
- package/dist/modules/Order/utils.js +7 -5
- package/dist/server/index.d.ts +136 -0
- package/dist/server/index.js +2055 -781
- package/dist/server/modules/order/index.d.ts +7 -0
- package/dist/server/modules/order/index.js +375 -337
- package/dist/server/modules/order/types.d.ts +15 -0
- package/dist/server/modules/order/types.js +8 -0
- package/dist/server/utils/small-ticket.d.ts +69 -0
- package/dist/server/utils/small-ticket.js +528 -0
- package/dist/solution/BaseSales/index.d.ts +4 -2
- package/dist/solution/BaseSales/index.js +248 -188
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +8 -1
- package/dist/solution/BookingTicket/index.js +443 -263
- package/dist/solution/BookingTicket/types.d.ts +2 -1
- package/dist/solution/BookingTicket/types.js +3 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +6 -4
- package/lib/modules/Order/index.d.ts +9 -0
- package/lib/modules/Order/index.js +59 -3
- package/lib/modules/Order/types.d.ts +10 -0
- package/lib/modules/Order/utils.js +4 -3
- package/lib/server/index.d.ts +136 -0
- package/lib/server/index.js +823 -50
- package/lib/server/modules/order/index.d.ts +7 -0
- package/lib/server/modules/order/index.js +21 -7
- package/lib/server/modules/order/types.d.ts +15 -0
- package/lib/server/utils/small-ticket.d.ts +69 -0
- package/lib/server/utils/small-ticket.js +555 -0
- package/lib/solution/BaseSales/index.d.ts +4 -2
- package/lib/solution/BaseSales/index.js +47 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +8 -1
- package/lib/solution/BookingTicket/index.js +108 -1
- package/lib/solution/BookingTicket/types.d.ts +2 -1
- package/lib/solution/BookingTicket/types.js +5 -0
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
27
27
|
private productCatalog;
|
|
28
28
|
private orderCustomerDiscountRefreshInFlight;
|
|
29
29
|
private orderCustomerDiscountRefreshCustomerId;
|
|
30
|
+
private loadOpenDataConfigInFlight;
|
|
30
31
|
/**
|
|
31
32
|
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
32
33
|
* bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
|
|
@@ -39,6 +40,12 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
39
40
|
*/
|
|
40
41
|
protected createSubModule(moduleName: string): Module | null;
|
|
41
42
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
43
|
+
private getBookingTicketBusinessCode;
|
|
44
|
+
private getIdGeneratorPlugin;
|
|
45
|
+
private loadOpenDataConfig;
|
|
46
|
+
private configureIdGeneratorFromOpenData;
|
|
47
|
+
private normalizePositiveInteger;
|
|
48
|
+
private normalizeIdPrefix;
|
|
42
49
|
/**
|
|
43
50
|
* 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
|
|
44
51
|
*
|
|
@@ -302,7 +309,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
302
309
|
* 获取当前的客户搜索条件
|
|
303
310
|
* @returns 当前搜索条件
|
|
304
311
|
*/
|
|
305
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
312
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
306
313
|
/**
|
|
307
314
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
308
315
|
* @returns 客户状态
|
|
@@ -51,6 +51,8 @@ var import_buildNormalProductCacheItemFromOrderLine = require("../../modules/Boo
|
|
|
51
51
|
var import_orderLineDisplay = require("../../modules/BookingContext/utils/orderLineDisplay");
|
|
52
52
|
var import_bookingStatus = require("./utils/bookingStatus");
|
|
53
53
|
__reExport(BookingTicket_exports, require("./types"), module.exports);
|
|
54
|
+
var OPEN_DATA_SECTION_CODES = ["sale", "reservation", "fulfillment", "menu", "workflow"];
|
|
55
|
+
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
54
56
|
function withProductOptionString(cacheItem) {
|
|
55
57
|
var _a;
|
|
56
58
|
const productOptionString = (0, import_orderLineDisplay.buildProductOptionStringFromOrderLine)(cacheItem);
|
|
@@ -78,13 +80,14 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
78
80
|
this.productCatalog = [];
|
|
79
81
|
this.orderCustomerDiscountRefreshInFlight = null;
|
|
80
82
|
this.orderCustomerDiscountRefreshCustomerId = null;
|
|
83
|
+
this.loadOpenDataConfigInFlight = null;
|
|
81
84
|
}
|
|
82
85
|
/**
|
|
83
86
|
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
84
87
|
* bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
|
|
85
88
|
*/
|
|
86
89
|
getRegisteredModuleNames() {
|
|
87
|
-
return [...super.getRegisteredModuleNames(), "customer", "bookingContext"];
|
|
90
|
+
return [...super.getRegisteredModuleNames(), "customer", "bookingContext", "openData"];
|
|
88
91
|
}
|
|
89
92
|
getSubmitOrderSalesChannel() {
|
|
90
93
|
return "pos";
|
|
@@ -110,8 +113,112 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
110
113
|
throw new Error("bookingTicket解决方案需要 request 插件支持");
|
|
111
114
|
}
|
|
112
115
|
this.platform = (_a = this.otherParams) == null ? void 0 : _a.platform;
|
|
116
|
+
await this.configureIdGeneratorFromOpenData();
|
|
113
117
|
console.log("[BookingTicket] 初始化完成");
|
|
114
118
|
}
|
|
119
|
+
getBookingTicketBusinessCode() {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
const businessCode = ((_a = this.otherParams) == null ? void 0 : _a.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.business_code);
|
|
122
|
+
if (businessCode === void 0 || businessCode === null)
|
|
123
|
+
return null;
|
|
124
|
+
const normalized = String(businessCode).trim();
|
|
125
|
+
return normalized || null;
|
|
126
|
+
}
|
|
127
|
+
getIdGeneratorPlugin() {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
const appPlugin = this.core.getPlugin("app");
|
|
130
|
+
const app = (_a = appPlugin == null ? void 0 : appPlugin.getApp) == null ? void 0 : _a.call(appPlugin);
|
|
131
|
+
return ((_b = app == null ? void 0 : app.getPlugin) == null ? void 0 : _b.call(app, "idGenerator")) || null;
|
|
132
|
+
}
|
|
133
|
+
async loadOpenDataConfig() {
|
|
134
|
+
if (!this.store.openData)
|
|
135
|
+
throw new Error("openData 模块未初始化");
|
|
136
|
+
const businessCode = this.getBookingTicketBusinessCode();
|
|
137
|
+
if (!businessCode) {
|
|
138
|
+
console.warn("[BookingTicket] businessCode 缺失,跳过 OpenData 配置加载");
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const lastFetchedAt = this.store.openData.getLastFetchedAt();
|
|
142
|
+
const cachedData = this.store.openData.getOpenData();
|
|
143
|
+
if (cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL) {
|
|
144
|
+
this.otherParams.openData = cachedData;
|
|
145
|
+
return cachedData;
|
|
146
|
+
}
|
|
147
|
+
if (this.loadOpenDataConfigInFlight)
|
|
148
|
+
return await this.loadOpenDataConfigInFlight;
|
|
149
|
+
this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
|
|
150
|
+
scope: "board",
|
|
151
|
+
target: `${businessCode}+pos`,
|
|
152
|
+
// target: `dine_in+pos`,
|
|
153
|
+
section_code: [...OPEN_DATA_SECTION_CODES]
|
|
154
|
+
});
|
|
155
|
+
try {
|
|
156
|
+
const openDataConfig = await this.loadOpenDataConfigInFlight;
|
|
157
|
+
this.otherParams.openData = openDataConfig;
|
|
158
|
+
return openDataConfig;
|
|
159
|
+
} finally {
|
|
160
|
+
this.loadOpenDataConfigInFlight = null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async configureIdGeneratorFromOpenData() {
|
|
164
|
+
let openDataConfig = null;
|
|
165
|
+
try {
|
|
166
|
+
openDataConfig = await this.loadOpenDataConfig();
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.warn("[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置", error);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (!openDataConfig)
|
|
172
|
+
return;
|
|
173
|
+
const idGenerator = this.getIdGeneratorPlugin();
|
|
174
|
+
if (!(idGenerator == null ? void 0 : idGenerator.configure)) {
|
|
175
|
+
console.warn("[BookingTicket] idGenerator 插件不可用,跳过配置");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const receiptSequenceLength = this.normalizePositiveInteger(
|
|
179
|
+
openDataConfig["sale.short_number_digits"],
|
|
180
|
+
5
|
|
181
|
+
);
|
|
182
|
+
const receiptSequenceStart = this.normalizePositiveInteger(
|
|
183
|
+
openDataConfig["sale.short_number_start_number"],
|
|
184
|
+
1
|
|
185
|
+
);
|
|
186
|
+
const prefix = this.normalizeIdPrefix(
|
|
187
|
+
openDataConfig["sale.short_number_prefix"],
|
|
188
|
+
"R"
|
|
189
|
+
);
|
|
190
|
+
const resetReceiptSequenceDaily = typeof openDataConfig["sale.short_number_daily_reset"] === "boolean" ? openDataConfig["sale.short_number_daily_reset"] : true;
|
|
191
|
+
const operatingDayBoundary = this.getAppData("operating_day_boundary");
|
|
192
|
+
try {
|
|
193
|
+
await idGenerator.configure({
|
|
194
|
+
biz: "ticket",
|
|
195
|
+
config: {
|
|
196
|
+
prefix,
|
|
197
|
+
deviceCode: this.getAppData("device_id") || 0,
|
|
198
|
+
// TODO 现在 picoding 没这个配置的 key
|
|
199
|
+
padReceiptSequence: true,
|
|
200
|
+
receiptSequenceLength,
|
|
201
|
+
resetReceiptSequenceDaily,
|
|
202
|
+
receiptSequenceResetTime: operatingDayBoundary.time,
|
|
203
|
+
receiptSequenceStart
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.warn("[BookingTicket] idGenerator 配置失败", error);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
normalizePositiveInteger(value, fallback) {
|
|
211
|
+
const numeric = Number(value);
|
|
212
|
+
if (!Number.isInteger(numeric) || numeric <= 0)
|
|
213
|
+
return fallback;
|
|
214
|
+
return numeric;
|
|
215
|
+
}
|
|
216
|
+
normalizeIdPrefix(value, fallback) {
|
|
217
|
+
if (value === void 0 || value === null)
|
|
218
|
+
return fallback;
|
|
219
|
+
const normalized = String(value).trim().toUpperCase();
|
|
220
|
+
return normalized || fallback;
|
|
221
|
+
}
|
|
115
222
|
/**
|
|
116
223
|
* 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
|
|
117
224
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductList, OrderModule } from '../../modules';
|
|
1
|
+
import { ProductList, OrderModule, OpenDataModule } from '../../modules';
|
|
2
2
|
import { BookingContextModule } from '../../modules/BookingContext';
|
|
3
3
|
import { CustomerModule } from '../../modules/Customer';
|
|
4
4
|
import { SalesSummaryModule } from '../../modules/SalesSummary';
|
|
@@ -18,6 +18,7 @@ export interface BookingTicketState extends BaseSalesState {
|
|
|
18
18
|
schedule: ScheduleModule;
|
|
19
19
|
customer: CustomerModule;
|
|
20
20
|
bookingContext: BookingContextModule;
|
|
21
|
+
openData: OpenDataModule;
|
|
21
22
|
}
|
|
22
23
|
export declare function createBookingTicketModule<T extends keyof BookingTicketState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingTicketState[T] | null;
|
|
23
24
|
export declare enum BookingTicketHooks {
|
|
@@ -60,6 +60,11 @@ function createBookingTicketModule(moduleName, solutionName, name, version) {
|
|
|
60
60
|
`${solutionName}_${name || moduleName}`,
|
|
61
61
|
version
|
|
62
62
|
);
|
|
63
|
+
case "openData":
|
|
64
|
+
return new import_modules.OpenDataModule(
|
|
65
|
+
`${solutionName}_${name || moduleName}`,
|
|
66
|
+
version
|
|
67
|
+
);
|
|
63
68
|
default:
|
|
64
69
|
return null;
|
|
65
70
|
}
|