@pisell/pisellos 2.2.238 → 2.2.240

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.
@@ -947,14 +947,19 @@ var Server = /*#__PURE__*/function () {
947
947
  });
948
948
  case 5:
949
949
  shouldLookup = _this.shouldLookupLocalPrintOrder(inputOrder) || _this.shouldLookupLocalPrintOrder(data);
950
+ _this.logInfo('handleLocalPrintOrder: 是否需要查找本地订单', {
951
+ shouldLookup: shouldLookup,
952
+ inputOrder: inputOrder,
953
+ data: data
954
+ });
950
955
  lookup = shouldLookup ? (_this$getLocalPrintOr = _this.getLocalPrintOrderLookup(inputOrder)) !== null && _this$getLocalPrintOr !== void 0 ? _this$getLocalPrintOr : _this.getLocalPrintOrderLookup(data) : undefined;
951
956
  sourceOrder = inputOrder;
952
957
  if (!shouldLookup) {
953
- _context16.next = 19;
958
+ _context16.next = 20;
954
959
  break;
955
960
  }
956
961
  if (!(lookup === undefined)) {
957
- _context16.next = 11;
962
+ _context16.next = 12;
958
963
  break;
959
964
  }
960
965
  return _context16.abrupt("return", {
@@ -966,9 +971,9 @@ var Server = /*#__PURE__*/function () {
966
971
  order: null
967
972
  }
968
973
  });
969
- case 11:
974
+ case 12:
970
975
  if ((_this$order = _this.order) !== null && _this$order !== void 0 && _this$order.getLocalOrderByLookup) {
971
- _context16.next = 13;
976
+ _context16.next = 14;
972
977
  break;
973
978
  }
974
979
  return _context16.abrupt("return", {
@@ -980,13 +985,13 @@ var Server = /*#__PURE__*/function () {
980
985
  order: null
981
986
  }
982
987
  });
983
- case 13:
984
- _context16.next = 15;
988
+ case 14:
989
+ _context16.next = 16;
985
990
  return _this.order.getLocalOrderByLookup(lookup);
986
- case 15:
991
+ case 16:
987
992
  localOrder = _context16.sent;
988
993
  if (localOrder) {
989
- _context16.next = 18;
994
+ _context16.next = 19;
990
995
  break;
991
996
  }
992
997
  return _context16.abrupt("return", {
@@ -998,29 +1003,33 @@ var Server = /*#__PURE__*/function () {
998
1003
  order: null
999
1004
  }
1000
1005
  });
1001
- case 18:
1006
+ case 19:
1002
1007
  sourceOrder = _objectSpread(_objectSpread(_objectSpread({}, localOrder), inputOrder), {}, {
1003
1008
  order_id: (_ref40 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : inputOrder.order_id) !== null && _ref40 !== void 0 ? _ref40 : inputOrder.orderId,
1004
1009
  external_sale_number: (_ref41 = (_external_sale_number = localOrder.external_sale_number) !== null && _external_sale_number !== void 0 ? _external_sale_number : inputOrder.external_sale_number) !== null && _ref41 !== void 0 ? _ref41 : inputOrder.externalSaleNumber
1005
1010
  });
1006
- case 19:
1007
- _context16.next = 21;
1011
+ case 20:
1012
+ _context16.next = 22;
1008
1013
  return _this.ensureCheckoutOrderNumbers(_objectSpread(_objectSpread({}, sourceOrder), {}, {
1009
1014
  small_ticket_data_flag: 1
1010
1015
  }), 'handleLocalPrintOrder');
1011
- case 21:
1016
+ case 22:
1012
1017
  checkoutData = _context16.sent;
1013
1018
  printableOrder = _objectSpread(_objectSpread({}, checkoutData), {}, {
1014
1019
  need_sync: (_need_sync = checkoutData.need_sync) !== null && _need_sync !== void 0 ? _need_sync : 1
1015
1020
  });
1016
- _context16.next = 25;
1021
+ _this.logInfo('handleLocalPrintOrder: 本地打印小票,构建触发任务前', {
1022
+ checkoutData: checkoutData,
1023
+ printableOrder: printableOrder
1024
+ });
1025
+ _context16.next = 27;
1017
1026
  return _this.dispatchLocalReceiptPrint({
1018
1027
  checkoutData: checkoutData,
1019
1028
  order: printableOrder,
1020
1029
  response: null,
1021
1030
  requireFullyPaid: false
1022
1031
  });
1023
- case 25:
1032
+ case 27:
1024
1033
  printResult = _context16.sent;
1025
1034
  return _context16.abrupt("return", {
1026
1035
  code: 200,
@@ -1031,8 +1040,8 @@ var Server = /*#__PURE__*/function () {
1031
1040
  order: printResult.order
1032
1041
  }
1033
1042
  });
1034
- case 29:
1035
- _context16.prev = 29;
1043
+ case 31:
1044
+ _context16.prev = 31;
1036
1045
  _context16.t0 = _context16["catch"](1);
1037
1046
  message = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
1038
1047
  _this.logError('handleLocalPrintOrder: 本地打印小票失败', {
@@ -1047,11 +1056,11 @@ var Server = /*#__PURE__*/function () {
1047
1056
  order: null
1048
1057
  }
1049
1058
  });
1050
- case 34:
1059
+ case 36:
1051
1060
  case "end":
1052
1061
  return _context16.stop();
1053
1062
  }
1054
- }, _callee16, null, [[1, 29]]);
1063
+ }, _callee16, null, [[1, 31]]);
1055
1064
  }));
1056
1065
  return function (_x16) {
1057
1066
  return _ref39.apply(this, arguments);
@@ -4172,11 +4181,12 @@ var Server = /*#__PURE__*/function () {
4172
4181
  case 4:
4173
4182
  _context45.prev = 4;
4174
4183
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
4175
- _context45.next = 8;
4184
+ printIdentity = "".concat(printIdentity, "_").concat(Date.now());
4185
+ _context45.next = 9;
4176
4186
  return this.getShortNumberOrDeviceId();
4177
- case 8:
4187
+ case 9:
4178
4188
  deviceId = _context45.sent;
4179
- _context45.next = 11;
4189
+ _context45.next = 12;
4180
4190
  return deviceTask.dispatch({
4181
4191
  action: 'print_all',
4182
4192
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -4200,20 +4210,20 @@ var Server = /*#__PURE__*/function () {
4200
4210
  source_type: 'order',
4201
4211
  source_id: printIdentity
4202
4212
  });
4203
- case 11:
4204
- _context45.next = 16;
4213
+ case 12:
4214
+ _context45.next = 17;
4205
4215
  break;
4206
- case 13:
4207
- _context45.prev = 13;
4216
+ case 14:
4217
+ _context45.prev = 14;
4208
4218
  _context45.t0 = _context45["catch"](4);
4209
4219
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
4210
4220
  error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
4211
4221
  });
4212
- case 16:
4222
+ case 17:
4213
4223
  case "end":
4214
4224
  return _context45.stop();
4215
4225
  }
4216
- }, _callee45, this, [[4, 13]]);
4226
+ }, _callee45, this, [[4, 14]]);
4217
4227
  }));
4218
4228
  function dispatchPrintOtherReceiptTask(_x49) {
4219
4229
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
@@ -4265,7 +4275,11 @@ var Server = /*#__PURE__*/function () {
4265
4275
  order: printableOrder
4266
4276
  });
4267
4277
  case 7:
4268
- debugger;
4278
+ this.logInfo('dispatchLocalReceiptPrint: 构建触发任务前', {
4279
+ checkoutData: params.checkoutData,
4280
+ printableOrder: printableOrder,
4281
+ response: params.response
4282
+ });
4269
4283
  _context46.next = 10;
4270
4284
  return this.dispatchPrintOtherReceiptTask({
4271
4285
  checkoutData: params.checkoutData,
@@ -283,7 +283,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
283
283
  break;
284
284
  }
285
285
  console.warn('[BookingTicket] businessCode 缺失,跳过 OpenData 配置加载,当前 module name: ', this.name);
286
- return _context2.abrupt("return", new Error('businessCode 缺失'));
286
+ return _context2.abrupt("return", null);
287
287
  case 6:
288
288
  lastFetchedAt = this.store.openData.getLastFetchedAt();
289
289
  cachedData = this.store.openData.getOpenData();
@@ -392,7 +392,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
392
392
  value: function () {
393
393
  var _configureIdGeneratorFromOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
394
394
  var _openDataConfig, _openDataConfig2, _openDataConfig3, _openDataConfig4, _openDataConfig5, _openDataConfig6;
395
- var openDataConfig, idGenerator, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId;
395
+ var openDataConfig, idGenerator, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId, businessCode;
396
396
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
397
397
  while (1) switch (_context5.prev = _context5.next) {
398
398
  case 0:
@@ -429,10 +429,18 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
429
429
  return this.getShortNumberOrDeviceId();
430
430
  case 23:
431
431
  deviceId = _context5.sent;
432
- _context5.prev = 24;
433
- _context5.next = 27;
432
+ businessCode = this.getBookingTicketBusinessCode();
433
+ if (businessCode) {
434
+ _context5.next = 28;
435
+ break;
436
+ }
437
+ console.warn('[BookingTicket] businessCode 缺失,跳过 idGenerator 配置');
438
+ return _context5.abrupt("return");
439
+ case 28:
440
+ _context5.prev = 28;
441
+ _context5.next = 31;
434
442
  return idGenerator.configure({
435
- biz: this.getBookingTicketBusinessCode() || 'ticket',
443
+ biz: businessCode,
436
444
  config: {
437
445
  prefix: prefix,
438
446
  deviceCode: deviceId,
@@ -445,18 +453,18 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
445
453
  shopOrderPrefix: shopOrderPrefix
446
454
  }
447
455
  });
448
- case 27:
449
- _context5.next = 32;
456
+ case 31:
457
+ _context5.next = 36;
450
458
  break;
451
- case 29:
452
- _context5.prev = 29;
453
- _context5.t1 = _context5["catch"](24);
459
+ case 33:
460
+ _context5.prev = 33;
461
+ _context5.t1 = _context5["catch"](28);
454
462
  console.warn('[BookingTicket] idGenerator 配置失败', _context5.t1);
455
- case 32:
463
+ case 36:
456
464
  case "end":
457
465
  return _context5.stop();
458
466
  }
459
- }, _callee5, this, [[1, 7], [24, 29]]);
467
+ }, _callee5, this, [[1, 7], [28, 33]]);
460
468
  }));
461
469
  function configureIdGeneratorFromOpenData() {
462
470
  return _configureIdGeneratorFromOpenData.apply(this, arguments);
@@ -580,6 +580,11 @@ var Server = class {
580
580
  };
581
581
  }
582
582
  const shouldLookup = this.shouldLookupLocalPrintOrder(inputOrder) || this.shouldLookupLocalPrintOrder(data);
583
+ this.logInfo("handleLocalPrintOrder: 是否需要查找本地订单", {
584
+ shouldLookup,
585
+ inputOrder,
586
+ data
587
+ });
583
588
  const lookup = shouldLookup ? this.getLocalPrintOrderLookup(inputOrder) ?? this.getLocalPrintOrderLookup(data) : void 0;
584
589
  let sourceOrder = inputOrder;
585
590
  if (shouldLookup) {
@@ -626,6 +631,10 @@ var Server = class {
626
631
  ...checkoutData,
627
632
  need_sync: checkoutData.need_sync ?? 1
628
633
  };
634
+ this.logInfo("handleLocalPrintOrder: 本地打印小票,构建触发任务前", {
635
+ checkoutData,
636
+ printableOrder
637
+ });
629
638
  const printResult = await this.dispatchLocalReceiptPrint({
630
639
  checkoutData,
631
640
  order: printableOrder,
@@ -2605,7 +2614,8 @@ var Server = class {
2605
2614
  return;
2606
2615
  }
2607
2616
  try {
2608
- const printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
2617
+ let printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
2618
+ printIdentity = `${printIdentity}_${Date.now()}`;
2609
2619
  const deviceId = await this.getShortNumberOrDeviceId();
2610
2620
  await deviceTask.dispatch({
2611
2621
  action: "print_all",
@@ -2656,7 +2666,11 @@ var Server = class {
2656
2666
  if (!(0, import_small_ticket.hasSmallTicketData)((_a = printableOrder.payment_info) == null ? void 0 : _a.small_ticket_data)) {
2657
2667
  return { printed: false, order: printableOrder };
2658
2668
  }
2659
- debugger;
2669
+ this.logInfo("dispatchLocalReceiptPrint: 构建触发任务前", {
2670
+ checkoutData: params.checkoutData,
2671
+ printableOrder,
2672
+ response: params.response
2673
+ });
2660
2674
  await this.dispatchPrintOtherReceiptTask({
2661
2675
  checkoutData: params.checkoutData,
2662
2676
  syncedOrder: printableOrder,
@@ -192,7 +192,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
192
192
  const businessCode = this.getBookingTicketBusinessCode();
193
193
  if (!businessCode) {
194
194
  console.warn("[BookingTicket] businessCode 缺失,跳过 OpenData 配置加载,当前 module name: ", this.name);
195
- return new Error("businessCode 缺失");
195
+ return null;
196
196
  }
197
197
  const lastFetchedAt = this.store.openData.getLastFetchedAt();
198
198
  const cachedData = this.store.openData.getOpenData();
@@ -263,9 +263,14 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
263
263
  const resetReceiptSequenceDaily = typeof (openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"]) === "boolean" ? openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"] : false;
264
264
  const operatingDayBoundary = this.getAppData("operating_day_boundary");
265
265
  const deviceId = await this.getShortNumberOrDeviceId();
266
+ const businessCode = this.getBookingTicketBusinessCode();
267
+ if (!businessCode) {
268
+ console.warn("[BookingTicket] businessCode 缺失,跳过 idGenerator 配置");
269
+ return;
270
+ }
266
271
  try {
267
272
  await idGenerator.configure({
268
- biz: this.getBookingTicketBusinessCode() || "ticket",
273
+ biz: businessCode,
269
274
  config: {
270
275
  prefix,
271
276
  deviceCode: deviceId,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.238",
4
+ "version": "2.2.240",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",