@pisell/pisellos 2.2.239 → 2.2.241

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.
@@ -416,7 +416,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
416
416
  generateIdempotencyToken(): string;
417
417
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
418
418
  createOrder(params: CommitOrderParams['query']): {
419
- type: "appointment_booking" | "virtual";
419
+ type: "virtual" | "appointment_booking";
420
420
  platform: string;
421
421
  sales_channel: string;
422
422
  order_sales_channel: string;
@@ -3911,7 +3911,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3911
3911
  value: function () {
3912
3912
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3913
3913
  var _params$cacheId2, _this$otherParams5, _ref70, _params$businessCode2, _this$otherParams6, _this$otherParams7;
3914
- var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
3914
+ var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _result, _data, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
3915
3915
  return _regeneratorRuntime().wrap(function _callee27$(_context29) {
3916
3916
  while (1) switch (_context29.prev = _context29.next) {
3917
3917
  case 0:
@@ -3989,20 +3989,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3989
3989
  });
3990
3990
  case 25:
3991
3991
  result = _context29.sent;
3992
- _context29.next = 38;
3992
+ // 如果成功需要把当前内存 tempOrder的一部分同步成 result 的
3993
+ if ((_result = result) !== null && _result !== void 0 && _result.success) {
3994
+ tempOrder.order_id = (_data = result.data) === null || _data === void 0 ? void 0 : _data.order_id;
3995
+ }
3996
+ _context29.next = 39;
3993
3997
  break;
3994
- case 28:
3995
- _context29.prev = 28;
3998
+ case 29:
3999
+ _context29.prev = 29;
3996
4000
  _context29.t2 = _context29["catch"](21);
3997
4001
  backendErrorResponse = this.extractSubmitErrorResponse(_context29.t2);
3998
4002
  if (!backendErrorResponse) {
3999
- _context29.next = 35;
4003
+ _context29.next = 36;
4000
4004
  break;
4001
4005
  }
4002
4006
  this.store.syncState = 'failed';
4003
4007
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4004
4008
  return _context29.abrupt("return", backendErrorResponse);
4005
- case 35:
4009
+ case 36:
4006
4010
  this.store.syncState = 'failed';
4007
4011
  this.logError('submitTempOrder failed', {
4008
4012
  error: _context29.t2 instanceof Error ? _context29.t2.message : String(_context29.t2),
@@ -4012,40 +4016,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4012
4016
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4013
4017
  });
4014
4018
  throw _context29.t2;
4015
- case 38:
4019
+ case 39:
4016
4020
  if (!this.isSubmitResponseRejected(result)) {
4017
- _context29.next = 42;
4021
+ _context29.next = 43;
4018
4022
  break;
4019
4023
  }
4020
4024
  this.store.syncState = 'failed';
4021
4025
  this.logSubmitBackendRejected(result, payload);
4022
4026
  return _context29.abrupt("return", result);
4023
- case 42:
4027
+ case 43:
4024
4028
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4025
4029
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4026
- _context29.next = 50;
4030
+ _context29.next = 51;
4027
4031
  break;
4028
4032
  }
4029
4033
  tempOrder.order_id = submittedOrderId;
4030
4034
  resultRecord = result;
4031
- _context29.next = 48;
4035
+ _context29.next = 49;
4032
4036
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4033
- case 48:
4034
- _context29.next = 51;
4037
+ case 49:
4038
+ _context29.next = 52;
4035
4039
  break;
4036
- case 50:
4040
+ case 51:
4037
4041
  if (this.isLocalPendingSubmitResult(result)) {
4038
4042
  this.store.syncState = 'local';
4039
4043
  } else {
4040
4044
  this.store.syncState = 'submitted';
4041
4045
  }
4042
- case 51:
4043
- return _context29.abrupt("return", result);
4044
4046
  case 52:
4047
+ return _context29.abrupt("return", result);
4048
+ case 53:
4045
4049
  case "end":
4046
4050
  return _context29.stop();
4047
4051
  }
4048
- }, _callee27, this, [[21, 28]]);
4052
+ }, _callee27, this, [[21, 29]]);
4049
4053
  }));
4050
4054
  function runSubmitTempOrder(_x31) {
4051
4055
  return _runSubmitTempOrder.apply(this, arguments);
@@ -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,
@@ -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 | 1 | 2 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -416,7 +416,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
416
416
  generateIdempotencyToken(): string;
417
417
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
418
418
  createOrder(params: CommitOrderParams['query']): {
419
- type: "appointment_booking" | "virtual";
419
+ type: "virtual" | "appointment_booking";
420
420
  platform: string;
421
421
  sales_channel: string;
422
422
  order_sales_channel: string;
@@ -2852,7 +2852,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2852
2852
  });
2853
2853
  }
2854
2854
  async runSubmitTempOrder(params) {
2855
- var _a, _b, _c, _d, _e;
2855
+ var _a, _b, _c, _d, _e, _f;
2856
2856
  const tempOrder = this.ensureTempOrder();
2857
2857
  this.persistTempOrder();
2858
2858
  const latestSummary = await this.recalculateSummary({ createIfMissing: true }) || this.store.summary || (0, import_utils.createEmptySummary)();
@@ -2906,6 +2906,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2906
2906
  result = await this.submitSalesOrder({
2907
2907
  query: payload
2908
2908
  });
2909
+ if (result == null ? void 0 : result.success) {
2910
+ tempOrder.order_id = (_e = result.data) == null ? void 0 : _e.order_id;
2911
+ }
2909
2912
  } catch (error) {
2910
2913
  const backendErrorResponse = this.extractSubmitErrorResponse(error);
2911
2914
  if (backendErrorResponse) {
@@ -2919,7 +2922,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2919
2922
  orderId: payload.order_id,
2920
2923
  externalSaleNumber: payload.external_sale_number,
2921
2924
  paymentStatus: payload.payment_status,
2922
- paymentsCount: ((_e = payload.payments) == null ? void 0 : _e.length) || 0
2925
+ paymentsCount: ((_f = payload.payments) == null ? void 0 : _f.length) || 0
2923
2926
  });
2924
2927
  throw error;
2925
2928
  }
@@ -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,
@@ -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 | 1 | 2 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.239",
4
+ "version": "2.2.241",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",