@pisell/pisellos 2.2.207 → 2.2.209

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.
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -381,7 +381,7 @@ declare class Server {
381
381
  private taskOk;
382
382
  private taskFail;
383
383
  private taskTimeout;
384
- private resolveCheckoutTaskDeviceId;
384
+ private getShortNumberOrDeviceId;
385
385
  private buildCheckoutTaskIdempotencyKey;
386
386
  private ensureCheckoutOrderNumbers;
387
387
  private dispatchCheckoutSyncTask;
@@ -2181,7 +2181,6 @@ var Server = class {
2181
2181
  }
2182
2182
  getSmallTicketShopInfo() {
2183
2183
  const shopInfo = this.getAppData("shop_info") || {};
2184
- debugger;
2185
2184
  return {
2186
2185
  ...shopInfo,
2187
2186
  currency_symbol: shopInfo.currency_symbol || this.getAppData("shop_symbol") || this.getAppData("currency_symbol"),
@@ -2207,7 +2206,14 @@ var Server = class {
2207
2206
  error: { code: "TIMEOUT", message }
2208
2207
  };
2209
2208
  }
2210
- resolveCheckoutTaskDeviceId(_data) {
2209
+ async getShortNumberOrDeviceId() {
2210
+ const getAsyncIotDeviceInfo = this.getAppData("async_iot_device_info");
2211
+ if (getAsyncIotDeviceInfo) {
2212
+ const res = await (getAsyncIotDeviceInfo == null ? void 0 : getAsyncIotDeviceInfo());
2213
+ if (res.short_number) {
2214
+ return res.short_number;
2215
+ }
2216
+ }
2211
2217
  return this.getAppData("device_id") || 0;
2212
2218
  }
2213
2219
  buildCheckoutTaskIdempotencyKey(data) {
@@ -2258,7 +2264,7 @@ var Server = class {
2258
2264
  var _a, _b, _c;
2259
2265
  this.registerDeviceTaskActions();
2260
2266
  const deviceTask = this.getDeviceTaskPlugin();
2261
- const debugDeviceId = this.resolveCheckoutTaskDeviceId(params.data);
2267
+ const debugDeviceId = await this.getShortNumberOrDeviceId();
2262
2268
  const debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
2263
2269
  if (!(deviceTask == null ? void 0 : deviceTask.dispatch)) {
2264
2270
  this.logError(`${params.title}: deviceTask.dispatch 不可用`);
@@ -2300,9 +2306,10 @@ var Server = class {
2300
2306
  }
2301
2307
  try {
2302
2308
  const printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
2309
+ const deviceId = await this.getShortNumberOrDeviceId();
2303
2310
  await deviceTask.dispatch({
2304
2311
  action: "print_all",
2305
- device_id: params.deviceId ?? this.resolveCheckoutTaskDeviceId(params.checkoutData),
2312
+ device_id: params.deviceId ?? deviceId,
2306
2313
  payload: {
2307
2314
  type: params.receiptOnly ? "0" : "99",
2308
2315
  data: params.receiptOnly ? {
@@ -43,6 +43,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
43
43
  private getBookingTicketBusinessCode;
44
44
  private getIdGeneratorPlugin;
45
45
  private loadOpenDataConfig;
46
+ private getShortNumberOrDeviceId;
46
47
  private configureIdGeneratorFromOpenData;
47
48
  private normalizePositiveInteger;
48
49
  private normalizeIdPrefix;
@@ -160,6 +160,16 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
160
160
  this.loadOpenDataConfigInFlight = null;
161
161
  }
162
162
  }
163
+ async getShortNumberOrDeviceId() {
164
+ const getAsyncIotDeviceInfo = this.getAppData("async_iot_device_info");
165
+ if (getAsyncIotDeviceInfo) {
166
+ const res = await (getAsyncIotDeviceInfo == null ? void 0 : getAsyncIotDeviceInfo());
167
+ if (res.short_number) {
168
+ return res.short_number;
169
+ }
170
+ }
171
+ return this.getAppData("device_id") || 0;
172
+ }
163
173
  async configureIdGeneratorFromOpenData() {
164
174
  let openDataConfig = null;
165
175
  try {
@@ -168,33 +178,32 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
168
178
  console.warn("[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置", error);
169
179
  return;
170
180
  }
171
- if (!openDataConfig)
172
- return;
173
181
  const idGenerator = this.getIdGeneratorPlugin();
174
182
  if (!(idGenerator == null ? void 0 : idGenerator.configure)) {
175
183
  console.warn("[BookingTicket] idGenerator 插件不可用,跳过配置");
176
184
  return;
177
185
  }
178
186
  const receiptSequenceLength = this.normalizePositiveInteger(
179
- openDataConfig["sale.short_number_digits"],
187
+ openDataConfig == null ? void 0 : openDataConfig["sale.short_number_digits"],
180
188
  5
181
189
  );
182
190
  const receiptSequenceStart = this.normalizePositiveInteger(
183
- openDataConfig["sale.short_number_start_number"],
191
+ openDataConfig == null ? void 0 : openDataConfig["sale.short_number_start_number"],
184
192
  1
185
193
  );
186
194
  const prefix = this.normalizeIdPrefix(
187
- openDataConfig["sale.short_number_prefix"],
195
+ openDataConfig == null ? void 0 : openDataConfig["sale.short_number_prefix"],
188
196
  "R"
189
197
  );
190
- const resetReceiptSequenceDaily = typeof openDataConfig["sale.short_number_daily_reset"] === "boolean" ? openDataConfig["sale.short_number_daily_reset"] : true;
198
+ const resetReceiptSequenceDaily = typeof (openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"]) === "boolean" ? openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"] : true;
191
199
  const operatingDayBoundary = this.getAppData("operating_day_boundary");
200
+ const deviceId = await this.getShortNumberOrDeviceId();
192
201
  try {
193
202
  await idGenerator.configure({
194
- biz: "ticket",
203
+ biz: this.getBookingTicketBusinessCode() || "ticket",
195
204
  config: {
196
205
  prefix,
197
- deviceCode: this.getAppData("device_id") || 0,
206
+ deviceCode: deviceId,
198
207
  // TODO 现在 picoding 没这个配置的 key
199
208
  padReceiptSequence: true,
200
209
  receiptSequenceLength,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.207",
4
+ "version": "2.2.209",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",