@pisell/pisellos 2.2.204 → 2.2.206
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/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 +237 -146
- package/dist/modules/Order/types.d.ts +10 -0
- package/dist/modules/Order/utils.js +7 -5
- package/dist/modules/Payment/index.d.ts +0 -13
- package/dist/modules/Payment/index.js +449 -833
- package/dist/plugins/request.d.ts +1 -0
- package/dist/server/index.d.ts +142 -0
- package/dist/server/index.js +2208 -824
- package/dist/server/modules/index.d.ts +2 -0
- package/dist/server/modules/index.js +2 -0
- 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/modules/payment/index.d.ts +28 -0
- package/dist/server/modules/payment/index.js +305 -0
- package/dist/server/modules/payment/types.d.ts +9 -0
- package/dist/server/modules/payment/types.js +1 -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 +10 -3
- package/dist/solution/BaseSales/index.js +307 -198
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +8 -1
- package/dist/solution/BookingTicket/index.js +444 -264
- package/dist/solution/BookingTicket/types.d.ts +2 -1
- package/dist/solution/BookingTicket/types.js +3 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +51 -52
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- 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 +64 -4
- package/lib/modules/Order/types.d.ts +10 -0
- package/lib/modules/Order/utils.js +4 -3
- package/lib/modules/Payment/index.d.ts +0 -13
- package/lib/modules/Payment/index.js +6 -149
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +142 -0
- package/lib/server/index.js +867 -49
- package/lib/server/modules/index.d.ts +2 -0
- package/lib/server/modules/index.js +3 -0
- 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/modules/payment/index.d.ts +28 -0
- package/lib/server/modules/payment/index.js +192 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/payment/types.js +17 -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 +10 -3
- package/lib/solution/BaseSales/index.js +98 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +8 -1
- package/lib/solution/BookingTicket/index.js +109 -2
- package/lib/solution/BookingTicket/types.d.ts +2 -1
- package/lib/solution/BookingTicket/types.js +5 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -2
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +17 -3
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ var import_BaseModule = require("../../modules/BaseModule");
|
|
|
37
37
|
var import_types = require("./types");
|
|
38
38
|
var import_Order = require("../../modules/Order");
|
|
39
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
40
|
+
var import_lodash_es = require("lodash-es");
|
|
40
41
|
var import_types2 = require("../BookingByStep/types");
|
|
41
42
|
var import_utils = require("../../modules/Order/utils");
|
|
42
43
|
var import_dayjs = __toESM(require("dayjs"));
|
|
@@ -69,6 +70,28 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
|
|
|
69
70
|
return previous && isBaseSalesManualProductDiscountProduct(previous) ? previous : product;
|
|
70
71
|
});
|
|
71
72
|
}
|
|
73
|
+
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
|
|
74
|
+
if (!currentTempOrder)
|
|
75
|
+
return loadedRecord;
|
|
76
|
+
return (0, import_lodash_es.mergeWith)(
|
|
77
|
+
(0, import_lodash_es.cloneDeep)(currentTempOrder),
|
|
78
|
+
(0, import_lodash_es.cloneDeep)(loadedRecord || {}),
|
|
79
|
+
(currentValue, loadedValue) => {
|
|
80
|
+
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
81
|
+
return [
|
|
82
|
+
...(0, import_lodash_es.cloneDeep)(currentValue),
|
|
83
|
+
...(0, import_lodash_es.cloneDeep)(loadedValue)
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
if (Array.isArray(loadedValue))
|
|
87
|
+
return (0, import_lodash_es.cloneDeep)(loadedValue);
|
|
88
|
+
if (Array.isArray(currentValue) && loadedValue === void 0) {
|
|
89
|
+
return (0, import_lodash_es.cloneDeep)(currentValue);
|
|
90
|
+
}
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
72
95
|
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
73
96
|
constructor(name, version) {
|
|
74
97
|
super(name, version);
|
|
@@ -84,6 +107,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
84
107
|
this.currentSalesDetail = null;
|
|
85
108
|
this.discountConfigCacheKey = null;
|
|
86
109
|
this.hasManualDiscountSelection = false;
|
|
110
|
+
this.paymentMethodsCache = [];
|
|
87
111
|
}
|
|
88
112
|
/**
|
|
89
113
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -131,6 +155,35 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
131
155
|
});
|
|
132
156
|
}
|
|
133
157
|
}
|
|
158
|
+
hydrateOrderPaymentNames(payments) {
|
|
159
|
+
if (!payments.length)
|
|
160
|
+
return [];
|
|
161
|
+
if (!this.paymentMethodsCache.length) {
|
|
162
|
+
return payments.map((payment) => ({ ...payment }));
|
|
163
|
+
}
|
|
164
|
+
const paymentMethodById = /* @__PURE__ */ new Map();
|
|
165
|
+
const paymentMethodByCode = /* @__PURE__ */ new Map();
|
|
166
|
+
this.paymentMethodsCache.forEach((method) => {
|
|
167
|
+
if ((method == null ? void 0 : method.id) !== void 0 && (method == null ? void 0 : method.id) !== null) {
|
|
168
|
+
paymentMethodById.set(String(method.id), method);
|
|
169
|
+
}
|
|
170
|
+
if (method == null ? void 0 : method.code) {
|
|
171
|
+
paymentMethodByCode.set(String(method.code), method);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return payments.map((payment) => {
|
|
175
|
+
const nextPayment = { ...payment };
|
|
176
|
+
if (nextPayment.name)
|
|
177
|
+
return nextPayment;
|
|
178
|
+
const paymentMethod = paymentMethodById.get(String(nextPayment.custom_payment_id)) || paymentMethodByCode.get(String(nextPayment.code));
|
|
179
|
+
if (!(paymentMethod == null ? void 0 : paymentMethod.name))
|
|
180
|
+
return nextPayment;
|
|
181
|
+
return {
|
|
182
|
+
...nextPayment,
|
|
183
|
+
name: paymentMethod.name
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
}
|
|
134
187
|
get payment() {
|
|
135
188
|
return this.store.payment;
|
|
136
189
|
}
|
|
@@ -435,6 +488,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
435
488
|
this.otherParams.enableTempOrderPersist
|
|
436
489
|
);
|
|
437
490
|
}
|
|
491
|
+
await this.getPaymentMethodsAsync();
|
|
438
492
|
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
439
493
|
}
|
|
440
494
|
async destroy() {
|
|
@@ -476,7 +530,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
476
530
|
const message = res && (res.message || res.msg) || `加载销售详情失败: ${lookup}`;
|
|
477
531
|
throw new Error(message);
|
|
478
532
|
}
|
|
479
|
-
const
|
|
533
|
+
const currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
534
|
+
const record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, res.data) : res.data;
|
|
535
|
+
const sales = await this.store.order.hydrateTempOrderFromRecord(record, { recalcOnHydrate: false });
|
|
480
536
|
this.currentSalesDetail = sales;
|
|
481
537
|
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales });
|
|
482
538
|
return sales;
|
|
@@ -1164,6 +1220,26 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1164
1220
|
};
|
|
1165
1221
|
return this.store.order.submitTempOrder(submitParams);
|
|
1166
1222
|
}
|
|
1223
|
+
async printLocalOrderReceipt() {
|
|
1224
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1225
|
+
if (!this.store.order) {
|
|
1226
|
+
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1227
|
+
}
|
|
1228
|
+
const payload = this.store.order.buildCurrentSubmitPayloadForLocalPrint({
|
|
1229
|
+
cacheId: this.cacheId,
|
|
1230
|
+
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
1231
|
+
businessCode: ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
1232
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
1233
|
+
type: (_d = this.otherParams) == null ? void 0 : _d.type
|
|
1234
|
+
});
|
|
1235
|
+
const response = await this.request.post("/local/print-order", payload, {
|
|
1236
|
+
osServer: true,
|
|
1237
|
+
customToast: () => {
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1240
|
+
await ((_g = (_f = this.store.order).applyLocalPrintOrderNumbers) == null ? void 0 : _g.call(_f, (_e = response == null ? void 0 : response.data) == null ? void 0 : _e.order));
|
|
1241
|
+
return response;
|
|
1242
|
+
}
|
|
1167
1243
|
getSubmitPaymentStatus(paymentStatus) {
|
|
1168
1244
|
var _a, _b;
|
|
1169
1245
|
if (paymentStatus !== void 0)
|
|
@@ -1226,7 +1302,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1226
1302
|
getOrderPayments() {
|
|
1227
1303
|
if (!this.store.order)
|
|
1228
1304
|
return [];
|
|
1229
|
-
|
|
1305
|
+
const payments = this.store.order.getOrderPayments();
|
|
1306
|
+
return this.hydrateOrderPaymentNames(payments);
|
|
1230
1307
|
}
|
|
1231
1308
|
/** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
|
|
1232
1309
|
setOrderPayments(payments) {
|
|
@@ -1273,6 +1350,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1273
1350
|
error: error instanceof Error ? error.message : String(error)
|
|
1274
1351
|
});
|
|
1275
1352
|
});
|
|
1353
|
+
} else {
|
|
1276
1354
|
}
|
|
1277
1355
|
return payments;
|
|
1278
1356
|
}
|
|
@@ -1408,11 +1486,25 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1408
1486
|
}
|
|
1409
1487
|
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
1410
1488
|
async getPaymentMethodsAsync() {
|
|
1411
|
-
|
|
1412
|
-
|
|
1489
|
+
try {
|
|
1490
|
+
const response = await this.request.get("/pay/custom-payment/all", {
|
|
1491
|
+
filterPaymentMethods: true
|
|
1492
|
+
}, {
|
|
1493
|
+
osServer: true
|
|
1494
|
+
});
|
|
1495
|
+
const paymentMethods = (response == null ? void 0 : response.data) || [];
|
|
1496
|
+
this.paymentMethodsCache = Array.isArray(paymentMethods) ? [...paymentMethods] : [];
|
|
1497
|
+
return this.getPaymentMethods();
|
|
1498
|
+
} catch (error) {
|
|
1499
|
+
this.logWarning("getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表", {
|
|
1500
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1501
|
+
});
|
|
1502
|
+
return this.getPaymentMethods();
|
|
1413
1503
|
}
|
|
1414
|
-
|
|
1415
|
-
|
|
1504
|
+
}
|
|
1505
|
+
/** 同步读取初始化时缓存的支付方式列表。 */
|
|
1506
|
+
getPaymentMethods() {
|
|
1507
|
+
return [...this.paymentMethodsCache];
|
|
1416
1508
|
}
|
|
1417
1509
|
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
1418
1510
|
roundAmount(params) {
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 5 | 3 | 6 | 4;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -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";
|
|
@@ -104,14 +107,118 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
104
107
|
}
|
|
105
108
|
async initialize(core, options = {}) {
|
|
106
109
|
var _a;
|
|
107
|
-
this.scan = new import_scan.default(this,
|
|
110
|
+
this.scan = new import_scan.default(this, `BOOKING_TICKET_SCAN:${this.name}`);
|
|
108
111
|
await super.initialize(core, options);
|
|
109
112
|
if (!this.request) {
|
|
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
|
}
|
|
@@ -91,7 +91,6 @@ async function runAddProductDecision(host, catalogItem, decision, ctx, bridge) {
|
|
|
91
91
|
async function applyGlobalScan(host, formatted, bridge) {
|
|
92
92
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
93
93
|
const { searchType, data, scanCode } = formatted;
|
|
94
|
-
debugger;
|
|
95
94
|
if (searchType === "wallet") {
|
|
96
95
|
if (!data) {
|
|
97
96
|
(_a = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _a.call(bridge, "fail", "pisell2.text.scan-global-failed");
|
|
@@ -157,7 +156,7 @@ async function applyGlobalScan(host, formatted, bridge) {
|
|
|
157
156
|
}
|
|
158
157
|
bridge.openOrder({
|
|
159
158
|
order_id: Number(orderId),
|
|
160
|
-
business_code: host.getBusinessCode()
|
|
159
|
+
business_code: (data == null ? void 0 : data.business_code) ?? host.getBusinessCode()
|
|
161
160
|
});
|
|
162
161
|
return { status: "pending", kind: "openOrder" };
|
|
163
162
|
}
|
|
@@ -14,12 +14,17 @@ declare enum ScanResultType {
|
|
|
14
14
|
NativeScanner = "nativeScanner"
|
|
15
15
|
}
|
|
16
16
|
export default class Scan {
|
|
17
|
+
private static scanInstances;
|
|
18
|
+
private static peripheralsListenerMounted;
|
|
17
19
|
private solution;
|
|
18
20
|
private watchKey;
|
|
19
21
|
private listenerConfig;
|
|
20
22
|
constructor(solution: BookingTicketImpl, watchKey: string);
|
|
21
23
|
/**
|
|
22
24
|
* 初始化外设扫码结果监听
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* scan.initPeripheralsListener();
|
|
23
28
|
*/
|
|
24
29
|
initPeripheralsListener(): void;
|
|
25
30
|
/**
|
|
@@ -34,17 +34,24 @@ __export(scan_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(scan_exports);
|
|
35
35
|
var import_watch = __toESM(require("../../../../utils/watch"));
|
|
36
36
|
var import_task = __toESM(require("../../../../utils/task"));
|
|
37
|
-
var
|
|
37
|
+
var _Scan = class {
|
|
38
38
|
constructor(solution, watchKey) {
|
|
39
39
|
this.listenerConfig = /* @__PURE__ */ new Map();
|
|
40
40
|
this.solution = solution;
|
|
41
41
|
this.watchKey = watchKey;
|
|
42
|
+
_Scan.scanInstances.add(this);
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* 初始化外设扫码结果监听
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* scan.initPeripheralsListener();
|
|
45
49
|
*/
|
|
46
50
|
initPeripheralsListener() {
|
|
47
51
|
var _a, _b, _c, _d, _e;
|
|
52
|
+
if (_Scan.peripheralsListenerMounted)
|
|
53
|
+
return;
|
|
54
|
+
_Scan.peripheralsListenerMounted = true;
|
|
48
55
|
(_e = (_d = (_c = (_b = (_a = this.solution) == null ? void 0 : _a.window) == null ? void 0 : _b.interaction) == null ? void 0 : _c.utils) == null ? void 0 : _d.mountFunction) == null ? void 0 : _e.call(
|
|
49
56
|
_d,
|
|
50
57
|
"global",
|
|
@@ -53,7 +60,9 @@ var Scan = class {
|
|
|
53
60
|
try {
|
|
54
61
|
const result = JSON.parse(strVal);
|
|
55
62
|
console.log("nativeScannerResult>>>>>>>", result);
|
|
56
|
-
|
|
63
|
+
_Scan.scanInstances.forEach((instance) => {
|
|
64
|
+
instance.handleScan(result);
|
|
65
|
+
});
|
|
57
66
|
} catch (err) {
|
|
58
67
|
console.error(err);
|
|
59
68
|
}
|
|
@@ -70,8 +79,9 @@ var Scan = class {
|
|
|
70
79
|
if (lastEnableEventKey) {
|
|
71
80
|
const listenerConfig = this.listenerConfig.get(lastEnableEventKey);
|
|
72
81
|
if (listenerConfig) {
|
|
82
|
+
const taskUuid = this.generateUuid();
|
|
73
83
|
listenerConfig.task.addTask({
|
|
74
|
-
uuid:
|
|
84
|
+
uuid: taskUuid,
|
|
75
85
|
type: lastEnableEventKey,
|
|
76
86
|
actionParams: {
|
|
77
87
|
scanResult: result
|
|
@@ -122,6 +132,7 @@ var Scan = class {
|
|
|
122
132
|
*/
|
|
123
133
|
removeAllListeners() {
|
|
124
134
|
var _a, _b, _c, _d;
|
|
135
|
+
_Scan.scanInstances.delete(this);
|
|
125
136
|
import_watch.default.clearEvent(this.watchKey);
|
|
126
137
|
(_b = (_a = this.listenerConfig) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (item) => {
|
|
127
138
|
var _a2;
|
|
@@ -213,3 +224,6 @@ var Scan = class {
|
|
|
213
224
|
}
|
|
214
225
|
}
|
|
215
226
|
};
|
|
227
|
+
var Scan = _Scan;
|
|
228
|
+
Scan.scanInstances = /* @__PURE__ */ new Set();
|
|
229
|
+
Scan.peripheralsListenerMounted = false;
|