@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.
Files changed (68) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/OpenData/index.d.ts +1 -0
  3. package/dist/modules/OpenData/index.js +21 -16
  4. package/dist/modules/Order/index.d.ts +9 -0
  5. package/dist/modules/Order/index.js +237 -146
  6. package/dist/modules/Order/types.d.ts +10 -0
  7. package/dist/modules/Order/utils.js +7 -5
  8. package/dist/modules/Payment/index.d.ts +0 -13
  9. package/dist/modules/Payment/index.js +449 -833
  10. package/dist/plugins/request.d.ts +1 -0
  11. package/dist/server/index.d.ts +142 -0
  12. package/dist/server/index.js +2208 -824
  13. package/dist/server/modules/index.d.ts +2 -0
  14. package/dist/server/modules/index.js +2 -0
  15. package/dist/server/modules/order/index.d.ts +7 -0
  16. package/dist/server/modules/order/index.js +375 -337
  17. package/dist/server/modules/order/types.d.ts +15 -0
  18. package/dist/server/modules/order/types.js +8 -0
  19. package/dist/server/modules/payment/index.d.ts +28 -0
  20. package/dist/server/modules/payment/index.js +305 -0
  21. package/dist/server/modules/payment/types.d.ts +9 -0
  22. package/dist/server/modules/payment/types.js +1 -0
  23. package/dist/server/utils/small-ticket.d.ts +69 -0
  24. package/dist/server/utils/small-ticket.js +528 -0
  25. package/dist/solution/BaseSales/index.d.ts +10 -3
  26. package/dist/solution/BaseSales/index.js +307 -198
  27. package/dist/solution/BookingByStep/index.d.ts +1 -1
  28. package/dist/solution/BookingTicket/index.d.ts +8 -1
  29. package/dist/solution/BookingTicket/index.js +444 -264
  30. package/dist/solution/BookingTicket/types.d.ts +2 -1
  31. package/dist/solution/BookingTicket/types.js +3 -1
  32. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +51 -52
  33. package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  34. package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
  35. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  36. package/lib/modules/OpenData/index.d.ts +1 -0
  37. package/lib/modules/OpenData/index.js +6 -4
  38. package/lib/modules/Order/index.d.ts +9 -0
  39. package/lib/modules/Order/index.js +64 -4
  40. package/lib/modules/Order/types.d.ts +10 -0
  41. package/lib/modules/Order/utils.js +4 -3
  42. package/lib/modules/Payment/index.d.ts +0 -13
  43. package/lib/modules/Payment/index.js +6 -149
  44. package/lib/plugins/request.d.ts +1 -0
  45. package/lib/server/index.d.ts +142 -0
  46. package/lib/server/index.js +867 -49
  47. package/lib/server/modules/index.d.ts +2 -0
  48. package/lib/server/modules/index.js +3 -0
  49. package/lib/server/modules/order/index.d.ts +7 -0
  50. package/lib/server/modules/order/index.js +21 -7
  51. package/lib/server/modules/order/types.d.ts +15 -0
  52. package/lib/server/modules/payment/index.d.ts +28 -0
  53. package/lib/server/modules/payment/index.js +192 -0
  54. package/lib/server/modules/payment/types.d.ts +9 -0
  55. package/lib/server/modules/payment/types.js +17 -0
  56. package/lib/server/utils/small-ticket.d.ts +69 -0
  57. package/lib/server/utils/small-ticket.js +555 -0
  58. package/lib/solution/BaseSales/index.d.ts +10 -3
  59. package/lib/solution/BaseSales/index.js +98 -6
  60. package/lib/solution/BookingByStep/index.d.ts +1 -1
  61. package/lib/solution/BookingTicket/index.d.ts +8 -1
  62. package/lib/solution/BookingTicket/index.js +109 -2
  63. package/lib/solution/BookingTicket/types.d.ts +2 -1
  64. package/lib/solution/BookingTicket/types.js +5 -0
  65. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -2
  66. package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  67. package/lib/solution/BookingTicket/utils/scan/index.js +17 -3
  68. package/package.json +1 -1
@@ -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 {
@@ -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";
@@ -23,6 +23,8 @@ export function createBookingTicketModule(moduleName, solutionName, name, versio
23
23
  return new CustomerModule("".concat(solutionName, "_").concat(name || moduleName), version);
24
24
  case 'bookingContext':
25
25
  return new BookingContextModule("".concat(solutionName, "_").concat(name || moduleName), version);
26
+ case 'openData':
27
+ return new OpenDataModule("".concat(solutionName, "_").concat(name || moduleName), version);
26
28
  default:
27
29
  return null;
28
30
  }
@@ -192,18 +192,17 @@ export function applyGlobalScan(_x14, _x15, _x16) {
192
192
  }
193
193
  function _applyGlobalScan() {
194
194
  _applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(host, formatted, bridge) {
195
- var searchType, data, scanCode, _bridge$onNotify2, _bridge$onNotify, _bridge$onNotify4, _bridge$onNotify3, snapshot, result, list, _bridge$onNotify5, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify6, _data$order_id, orderId, _bridge$onNotify7;
195
+ var searchType, data, scanCode, _bridge$onNotify2, _bridge$onNotify, _bridge$onNotify4, _bridge$onNotify3, snapshot, result, list, _bridge$onNotify5, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify6, _data$order_id, _data$business_code, orderId, _bridge$onNotify7;
196
196
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
197
197
  while (1) switch (_context4.prev = _context4.next) {
198
198
  case 0:
199
199
  searchType = formatted.searchType, data = formatted.data, scanCode = formatted.scanCode;
200
- debugger;
201
200
  if (!(searchType === 'wallet')) {
202
- _context4.next = 9;
201
+ _context4.next = 8;
203
202
  break;
204
203
  }
205
204
  if (data) {
206
- _context4.next = 6;
205
+ _context4.next = 5;
207
206
  break;
208
207
  }
209
208
  bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
@@ -211,20 +210,20 @@ function _applyGlobalScan() {
211
210
  status: 'failed',
212
211
  reason: 'invalid_data'
213
212
  });
214
- case 6:
213
+ case 5:
215
214
  host.setOrderCustomer(data);
216
215
  bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'success', 'pisell2.text.add-client-success');
217
216
  return _context4.abrupt("return", {
218
217
  status: 'success',
219
218
  kind: 'customer'
220
219
  });
221
- case 9:
220
+ case 8:
222
221
  if (!(searchType === 'walletPass')) {
223
- _context4.next = 26;
222
+ _context4.next = 25;
224
223
  break;
225
224
  }
226
225
  if (data) {
227
- _context4.next = 13;
226
+ _context4.next = 12;
228
227
  break;
229
228
  }
230
229
  bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
@@ -232,53 +231,53 @@ function _applyGlobalScan() {
232
231
  status: 'failed',
233
232
  reason: 'invalid_data'
234
233
  });
235
- case 13:
234
+ case 12:
236
235
  snapshot = host.getOrderCustomerSnapshot();
237
236
  if (!isWalkInCustomer(snapshot)) {
238
- _context4.next = 23;
237
+ _context4.next = 22;
239
238
  break;
240
239
  }
241
240
  if (bridge !== null && bridge !== void 0 && bridge.applyPromotionCode) {
242
- _context4.next = 17;
241
+ _context4.next = 16;
243
242
  break;
244
243
  }
245
244
  return _context4.abrupt("return", {
246
245
  status: 'failed',
247
246
  reason: 'no_bridge'
248
247
  });
249
- case 17:
250
- _context4.next = 19;
248
+ case 16:
249
+ _context4.next = 18;
251
250
  return bridge.applyPromotionCode(scanCode);
252
- case 19:
251
+ case 18:
253
252
  result = _context4.sent;
254
253
  if (!(result !== null && result !== void 0 && result.isAvailable)) {
255
- _context4.next = 22;
254
+ _context4.next = 21;
256
255
  break;
257
256
  }
258
257
  return _context4.abrupt("return", {
259
258
  status: 'success',
260
259
  kind: 'promotion'
261
260
  });
262
- case 22:
261
+ case 21:
263
262
  return _context4.abrupt("return", {
264
263
  status: 'failed',
265
264
  reason: 'invalid_data'
266
265
  });
267
- case 23:
266
+ case 22:
268
267
  host.setOrderCustomer(data);
269
268
  bridge === null || bridge === void 0 || (_bridge$onNotify4 = bridge.onNotify) === null || _bridge$onNotify4 === void 0 || _bridge$onNotify4.call(bridge, 'success', 'pisell2.text.add-client-success');
270
269
  return _context4.abrupt("return", {
271
270
  status: 'success',
272
271
  kind: 'customer'
273
272
  });
274
- case 26:
273
+ case 25:
275
274
  if (!(searchType === 'product' || searchType === 'local_product')) {
276
- _context4.next = 59;
275
+ _context4.next = 58;
277
276
  break;
278
277
  }
279
278
  list = data === null || data === void 0 ? void 0 : data.list;
280
279
  if (!(!Array.isArray(list) || list.length === 0)) {
281
- _context4.next = 31;
280
+ _context4.next = 30;
282
281
  break;
283
282
  }
284
283
  bridge === null || bridge === void 0 || (_bridge$onNotify5 = bridge.onNotify) === null || _bridge$onNotify5 === void 0 || _bridge$onNotify5.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
@@ -286,57 +285,57 @@ function _applyGlobalScan() {
286
285
  status: 'failed',
287
286
  reason: 'invalid_data'
288
287
  });
289
- case 31:
288
+ case 30:
290
289
  addedCount = 0;
291
290
  _iterator = _createForOfIteratorHelper(list);
292
- _context4.prev = 33;
291
+ _context4.prev = 32;
293
292
  _iterator.s();
294
- case 35:
293
+ case 34:
295
294
  if ((_step = _iterator.n()).done) {
296
- _context4.next = 47;
295
+ _context4.next = 46;
297
296
  break;
298
297
  }
299
298
  _item = _step.value;
300
- _context4.next = 39;
299
+ _context4.next = 38;
301
300
  return processScannedProductItem(host, _item, scanCode, bridge);
302
- case 39:
301
+ case 38:
303
302
  outcome = _context4.sent;
304
303
  if (outcome === 'added') {
305
304
  addedCount += 1;
306
305
  }
307
306
  if (!(outcome === 'cancelled')) {
308
- _context4.next = 43;
307
+ _context4.next = 42;
309
308
  break;
310
309
  }
311
310
  return _context4.abrupt("return", {
312
311
  status: 'cancelled'
313
312
  });
314
- case 43:
313
+ case 42:
315
314
  if (!(outcome === 'pending')) {
316
- _context4.next = 45;
315
+ _context4.next = 44;
317
316
  break;
318
317
  }
319
318
  return _context4.abrupt("return", {
320
319
  status: 'pending',
321
320
  kind: 'requiresDetail'
322
321
  });
323
- case 45:
324
- _context4.next = 35;
322
+ case 44:
323
+ _context4.next = 34;
325
324
  break;
326
- case 47:
327
- _context4.next = 52;
325
+ case 46:
326
+ _context4.next = 51;
328
327
  break;
329
- case 49:
330
- _context4.prev = 49;
331
- _context4.t0 = _context4["catch"](33);
328
+ case 48:
329
+ _context4.prev = 48;
330
+ _context4.t0 = _context4["catch"](32);
332
331
  _iterator.e(_context4.t0);
333
- case 52:
334
- _context4.prev = 52;
332
+ case 51:
333
+ _context4.prev = 51;
335
334
  _iterator.f();
336
- return _context4.finish(52);
337
- case 55:
335
+ return _context4.finish(51);
336
+ case 54:
338
337
  if (!(addedCount > 0)) {
339
- _context4.next = 58;
338
+ _context4.next = 57;
340
339
  break;
341
340
  }
342
341
  bridge === null || bridge === void 0 || (_bridge$onNotify6 = bridge.onNotify) === null || _bridge$onNotify6 === void 0 || _bridge$onNotify6.call(bridge, 'success');
@@ -347,19 +346,19 @@ function _applyGlobalScan() {
347
346
  count: addedCount
348
347
  }
349
348
  });
350
- case 58:
349
+ case 57:
351
350
  return _context4.abrupt("return", {
352
351
  status: 'failed',
353
352
  reason: 'no_bridge'
354
353
  });
355
- case 59:
354
+ case 58:
356
355
  if (!(searchType === 'order')) {
357
- _context4.next = 68;
356
+ _context4.next = 67;
358
357
  break;
359
358
  }
360
359
  orderId = (_data$order_id = data === null || data === void 0 ? void 0 : data.order_id) !== null && _data$order_id !== void 0 ? _data$order_id : data === null || data === void 0 ? void 0 : data.id;
361
360
  if (orderId) {
362
- _context4.next = 64;
361
+ _context4.next = 63;
363
362
  break;
364
363
  }
365
364
  bridge === null || bridge === void 0 || (_bridge$onNotify7 = bridge.onNotify) === null || _bridge$onNotify7 === void 0 || _bridge$onNotify7.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
@@ -367,34 +366,34 @@ function _applyGlobalScan() {
367
366
  status: 'failed',
368
367
  reason: 'invalid_data'
369
368
  });
370
- case 64:
369
+ case 63:
371
370
  if (bridge !== null && bridge !== void 0 && bridge.openOrder) {
372
- _context4.next = 66;
371
+ _context4.next = 65;
373
372
  break;
374
373
  }
375
374
  return _context4.abrupt("return", {
376
375
  status: 'pending',
377
376
  kind: 'openOrder'
378
377
  });
379
- case 66:
378
+ case 65:
380
379
  bridge.openOrder({
381
380
  order_id: Number(orderId),
382
- business_code: host.getBusinessCode()
381
+ business_code: (_data$business_code = data === null || data === void 0 ? void 0 : data.business_code) !== null && _data$business_code !== void 0 ? _data$business_code : host.getBusinessCode()
383
382
  });
384
383
  return _context4.abrupt("return", {
385
384
  status: 'pending',
386
385
  kind: 'openOrder'
387
386
  });
388
- case 68:
387
+ case 67:
389
388
  return _context4.abrupt("return", {
390
389
  status: 'failed',
391
390
  reason: 'invalid_data'
392
391
  });
393
- case 69:
392
+ case 68:
394
393
  case "end":
395
394
  return _context4.stop();
396
395
  }
397
- }, _callee4, null, [[33, 49, 52, 55]]);
396
+ }, _callee4, null, [[32, 48, 51, 54]]);
398
397
  }));
399
398
  return _applyGlobalScan.apply(this, arguments);
400
399
  }
@@ -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
  /**
@@ -1,3 +1,4 @@
1
+ var _class;
1
2
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
3
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
4
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
@@ -24,6 +25,7 @@ var Scan = /*#__PURE__*/function () {
24
25
  _defineProperty(this, "listenerConfig", new Map());
25
26
  this.solution = solution;
26
27
  this.watchKey = watchKey;
28
+ Scan.scanInstances.add(this);
27
29
 
28
30
  // 初始化扫码监听
29
31
  // this.initPeripheralsListener();
@@ -31,18 +33,23 @@ var Scan = /*#__PURE__*/function () {
31
33
 
32
34
  /**
33
35
  * 初始化外设扫码结果监听
36
+ *
37
+ * @example
38
+ * scan.initPeripheralsListener();
34
39
  */
35
40
  _createClass(Scan, [{
36
41
  key: "initPeripheralsListener",
37
42
  value: function initPeripheralsListener() {
38
- var _this$solution,
39
- _this$solution$mountF,
40
- _this = this;
43
+ var _this$solution, _this$solution$mountF;
44
+ if (Scan.peripheralsListenerMounted) return;
45
+ Scan.peripheralsListenerMounted = true;
41
46
  (_this$solution = this.solution) === null || _this$solution === void 0 || (_this$solution = _this$solution.window) === null || _this$solution === void 0 || (_this$solution = _this$solution.interaction) === null || _this$solution === void 0 || (_this$solution = _this$solution.utils) === null || _this$solution === void 0 || (_this$solution$mountF = _this$solution.mountFunction) === null || _this$solution$mountF === void 0 || _this$solution$mountF.call(_this$solution, 'global', 'peripheralsResult', function (strVal) {
42
47
  try {
43
48
  var _result = JSON.parse(strVal);
44
49
  console.log('nativeScannerResult>>>>>>>', _result);
45
- _this.handleScan(_result);
50
+ Scan.scanInstances.forEach(function (instance) {
51
+ instance.handleScan(_result);
52
+ });
46
53
  } catch (err) {
47
54
  console.error(err);
48
55
  }
@@ -61,8 +68,9 @@ var Scan = /*#__PURE__*/function () {
61
68
  if (lastEnableEventKey) {
62
69
  var listenerConfig = this.listenerConfig.get(lastEnableEventKey);
63
70
  if (listenerConfig) {
71
+ var taskUuid = this.generateUuid();
64
72
  listenerConfig.task.addTask({
65
- uuid: this.generateUuid(),
73
+ uuid: taskUuid,
66
74
  type: lastEnableEventKey,
67
75
  actionParams: {
68
76
  scanResult: result
@@ -91,7 +99,7 @@ var Scan = /*#__PURE__*/function () {
91
99
  }, {
92
100
  key: "addListener",
93
101
  value: function addListener(event, scanCallback) {
94
- var _this2 = this;
102
+ var _this = this;
95
103
  // 订阅事件
96
104
  watch.subscribe(this.watchKey, event);
97
105
  // 创建任务
@@ -100,7 +108,7 @@ var Scan = /*#__PURE__*/function () {
100
108
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
101
109
  args[_key] = arguments[_key];
102
110
  }
103
- return _this2.scanTaskAction.apply(_this2, [event.key].concat(args));
111
+ return _this.scanTaskAction.apply(_this, [event.key].concat(args));
104
112
  });
105
113
 
106
114
  // 创建监听配置
@@ -110,7 +118,7 @@ var Scan = /*#__PURE__*/function () {
110
118
  });
111
119
  return {
112
120
  remove: function remove() {
113
- _this2.removeListener(event);
121
+ _this.removeListener(event);
114
122
  }
115
123
  };
116
124
  }
@@ -136,6 +144,7 @@ var Scan = /*#__PURE__*/function () {
136
144
  key: "removeAllListeners",
137
145
  value: function removeAllListeners() {
138
146
  var _this$listenerConfig, _this$listenerConfig$2, _this$listenerConfig2, _this$listenerConfig3;
147
+ Scan.scanInstances.delete(this);
139
148
  watch.clearEvent(this.watchKey);
140
149
  (_this$listenerConfig = this.listenerConfig) === null || _this$listenerConfig === void 0 || (_this$listenerConfig$2 = _this$listenerConfig.forEach) === null || _this$listenerConfig$2 === void 0 || _this$listenerConfig$2.call(_this$listenerConfig, function (item) {
141
150
  var _item$task;
@@ -291,4 +300,7 @@ var Scan = /*#__PURE__*/function () {
291
300
  }]);
292
301
  return Scan;
293
302
  }();
303
+ _class = Scan;
304
+ _defineProperty(Scan, "scanInstances", new Set());
305
+ _defineProperty(Scan, "peripheralsListenerMounted", false);
294
306
  export { Scan as default };
@@ -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
+ });
@@ -9,6 +9,7 @@ export declare class OpenDataModule extends BaseModule implements Module {
9
9
  protected defaultVersion: string;
10
10
  private request;
11
11
  private window;
12
+ private appPlugin;
12
13
  private store;
13
14
  private cacheId;
14
15
  private openCache;
@@ -52,6 +52,7 @@ var OpenDataModule = class extends import_BaseModule.BaseModule {
52
52
  }
53
53
  this.request = core.getPlugin("request");
54
54
  this.window = core.getPlugin("window");
55
+ this.appPlugin = core.getPlugin("app");
55
56
  if (!this.request)
56
57
  throw new Error("OpenDataModule 需要 request 插件支持");
57
58
  if (!this.window)
@@ -59,11 +60,12 @@ var OpenDataModule = class extends import_BaseModule.BaseModule {
59
60
  console.log("[OpenDataModule] 初始化完成");
60
61
  }
61
62
  async fetchOpenData(params) {
62
- var _a, _b, _c, _d;
63
- const shopId = (_b = (_a = this.otherParams) == null ? void 0 : _a.getStateData) == null ? void 0 : _b.call(_a, "shop_id");
63
+ var _a, _b;
64
+ const getData = (_b = (_a = this.appPlugin).getData) == null ? void 0 : _b.call(_a);
65
+ const shopId = getData == null ? void 0 : getData("shop_id");
64
66
  if (!shopId)
65
67
  throw new Error("[OpenDataModule] 无法获取 shop_id");
66
- const tenantId = (_d = (_c = this.otherParams) == null ? void 0 : _c.getStateData) == null ? void 0 : _d.call(_c, "tenant_id");
68
+ const tenantId = getData == null ? void 0 : getData("tenant_id");
67
69
  const headers = {};
68
70
  if (tenantId)
69
71
  headers["Tenant-Id"] = String(tenantId);
@@ -74,7 +76,7 @@ var OpenDataModule = class extends import_BaseModule.BaseModule {
74
76
  target: params.target,
75
77
  section_code: params.section_code
76
78
  },
77
- { pisell2: true, headers }
79
+ { pisell2: true, isPisell2: true, prefix: false, headers }
78
80
  );
79
81
  if ((response == null ? void 0 : response.status) === false) {
80
82
  throw new Error((response == null ? void 0 : response.message) || "获取 OpenData 配置失败");
@@ -149,6 +149,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
149
149
  private updateTempOrderPaymentStatus;
150
150
  private shouldKeepPaymentStatusAfterAmountRecalc;
151
151
  private resolveWalletPassUseValue;
152
+ private adjustVoucherFundRecord;
152
153
  private capVoucherPaymentsByRemainingAmount;
153
154
  private calculatePaidPaymentSummary;
154
155
  private calculatePaymentServiceFee;
@@ -300,6 +301,14 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
300
301
  * 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
301
302
  */
302
303
  clearOrderCartLines(): Promise<OrderTempOrder>;
304
+ buildCurrentSubmitPayloadForLocalPrint(params?: {
305
+ cacheId?: string;
306
+ platform?: string;
307
+ businessCode?: string;
308
+ channel?: string;
309
+ type?: string;
310
+ }): import("./types").OrderSubmitPayload;
311
+ applyLocalPrintOrderNumbers(order?: Record<string, any> | null): Promise<OrderTempOrder>;
303
312
  /**
304
313
  * 提交当前 Sales tempOrder。
305
314
  *
@@ -826,6 +826,18 @@ var OrderModule = class extends import_BaseModule.BaseModule {
826
826
  return payment.wallet_pass_use_value;
827
827
  return amount.div(price).times(points).toDecimalPlaces(2).toFixed(2);
828
828
  }
829
+ adjustVoucherFundRecord(params) {
830
+ var _a;
831
+ const fundRecord = params.voucher.fund_record && typeof params.voucher.fund_record === "object" && !Array.isArray(params.voucher.fund_record) ? { ...params.voucher.fund_record } : null;
832
+ if (!fundRecord || fundRecord.using_before_value === void 0 || fundRecord.using_before_value === null) {
833
+ return fundRecord || void 0;
834
+ }
835
+ const code = String(params.voucher.code || "").toUpperCase();
836
+ const isPointCard = code === "POINTCARD" || String(((_a = params.voucher.fund_record) == null ? void 0 : _a.tag) || "").toLowerCase() === "point_card";
837
+ const usingValue = isPointCard ? new import_decimal.default(params.walletPassUseValue || 0) : params.amount;
838
+ fundRecord.using_after_value = new import_decimal.default(fundRecord.using_before_value || 0).minus(usingValue).toDecimalPlaces(2).toFixed(2);
839
+ return fundRecord;
840
+ }
829
841
  capVoucherPaymentsByRemainingAmount(params) {
830
842
  const targetAmount = this.getPaymentTargetAmount();
831
843
  const nonVoucherTotal = this.calculatePaymentTotal(params.nonVoucherPayments);
@@ -844,14 +856,20 @@ var OrderModule = class extends import_BaseModule.BaseModule {
844
856
  continue;
845
857
  const cappedAmount = import_decimal.default.min(voucherAmount, remainingAmount);
846
858
  const amountText = cappedAmount.toDecimalPlaces(2).toFixed(2);
859
+ const walletPassUseValue = this.resolveWalletPassUseValue(
860
+ voucher,
861
+ cappedAmount
862
+ );
847
863
  cappedVouchers.push({
848
864
  ...voucher,
849
865
  amount: amountText,
850
866
  origin_amount: amountText,
851
- wallet_pass_use_value: this.resolveWalletPassUseValue(
867
+ wallet_pass_use_value: walletPassUseValue,
868
+ fund_record: this.adjustVoucherFundRecord({
852
869
  voucher,
853
- cappedAmount
854
- )
870
+ amount: cappedAmount,
871
+ walletPassUseValue
872
+ })
855
873
  });
856
874
  remainingAmount = remainingAmount.minus(cappedAmount);
857
875
  }
@@ -2014,6 +2032,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2014
2032
  const matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex((item) => {
2015
2033
  if (this.hasGoodPassDiscount(item))
2016
2034
  return false;
2035
+ if (item.order_detail_id !== void 0 && item.order_detail_id !== null)
2036
+ return false;
2017
2037
  if (item.product_id !== productToAdd.product_id)
2018
2038
  return false;
2019
2039
  if (item.product_variant_id !== productToAdd.product_variant_id)
@@ -2507,6 +2527,44 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2507
2527
  return tempOrder;
2508
2528
  }
2509
2529
  // ─── TempOrder: 提交 ───
2530
+ buildCurrentSubmitPayloadForLocalPrint(params) {
2531
+ var _a, _b, _c;
2532
+ const tempOrder = this.ensureTempOrder();
2533
+ this.persistTempOrder();
2534
+ const payload = (0, import_utils.buildSubmitPayload)({
2535
+ tempOrder,
2536
+ cacheId: (params == null ? void 0 : params.cacheId) ?? this.cacheId,
2537
+ platform: (params == null ? void 0 : params.platform) || ((_a = this.otherParams) == null ? void 0 : _a.platform),
2538
+ businessCode: (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
2539
+ channel: params == null ? void 0 : params.channel,
2540
+ type: params == null ? void 0 : params.type,
2541
+ enhance: (nextPayload) => ({
2542
+ ...nextPayload,
2543
+ order_number: tempOrder.order_number ?? nextPayload.order_number ?? null,
2544
+ shop_order_number: tempOrder.shop_order_number ?? nextPayload.shop_order_number ?? null,
2545
+ shop_full_order_number: tempOrder.shop_full_order_number ?? nextPayload.shop_full_order_number ?? null,
2546
+ small_ticket_data_flag: 1
2547
+ })
2548
+ });
2549
+ payload.created_at = void 0;
2550
+ return payload;
2551
+ }
2552
+ async applyLocalPrintOrderNumbers(order) {
2553
+ const tempOrder = this.ensureTempOrder();
2554
+ if (!order || typeof order !== "object")
2555
+ return tempOrder;
2556
+ const shopOrderNumber = order.shop_order_number;
2557
+ const shopFullOrderNumber = order.shop_full_order_number;
2558
+ if (shopOrderNumber !== void 0 && shopOrderNumber !== null && shopOrderNumber !== "") {
2559
+ tempOrder.shop_order_number = String(shopOrderNumber);
2560
+ }
2561
+ if (shopFullOrderNumber !== void 0 && shopFullOrderNumber !== null && shopFullOrderNumber !== "") {
2562
+ tempOrder.shop_full_order_number = String(shopFullOrderNumber);
2563
+ }
2564
+ this.persistTempOrder();
2565
+ await this.saveDraft();
2566
+ return tempOrder;
2567
+ }
2510
2568
  /**
2511
2569
  * 提交当前 Sales tempOrder。
2512
2570
  *
@@ -2589,6 +2647,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2589
2647
  submittedOrderId,
2590
2648
  (resultRecord == null ? void 0 : resultRecord.data) || resultRecord || {}
2591
2649
  );
2650
+ } else {
2651
+ this.store.syncState = "submitted";
2592
2652
  }
2593
2653
  return result;
2594
2654
  }
@@ -2907,7 +2967,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2907
2967
  hasOrderId: !!orderData.order_id,
2908
2968
  smallTicketDataFlag: orderData.small_ticket_data_flag
2909
2969
  });
2910
- const response = await this.request.post("/shop/order/checkout", orderData, {
2970
+ const response = await this.request.post("/order/checkout", orderData, {
2911
2971
  osServer: true,
2912
2972
  customToast: () => {
2913
2973
  }