@pisell/pisellos 2.1.9 → 2.1.11

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.
@@ -670,12 +670,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
670
670
  return this.dbManager.get('order', params.order_id);
671
671
  case 4:
672
672
  existingOrder = _context7.sent;
673
+ this.logInfo('createPaymentOrderAsync existingOrder', {
674
+ existingOrder: existingOrder
675
+ });
676
+ // const existingOrder = existingOrders.find(
677
+ // (order: PaymentOrder) => String(order.id) === String(params.order_id),
678
+ // );
673
679
  if (!existingOrder) {
674
- _context7.next = 19;
680
+ _context7.next = 20;
675
681
  break;
676
682
  }
677
683
  // 如果存在相同 order_id 的订单,更新该订单信息
678
- console.log("[PaymentModule] \u53D1\u73B0\u91CD\u590D\u8BA2\u5355 ID: ".concat(params.order_id, "\uFF0C\u66F4\u65B0\u73B0\u6709\u652F\u4ED8\u8BA2\u5355"));
684
+ this.logInfo("createPaymentOrderAsync found duplicate order ID: ".concat(params.order_id, ", updating existing payment order"));
679
685
 
680
686
  // const originalOrder = { ...existingOrder };
681
687
  existingOrder.order_info = params.order_info;
@@ -687,14 +693,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
687
693
  this.recalculateOrderAmount(existingOrder);
688
694
 
689
695
  // 更新到数据库
690
- _context7.next = 14;
696
+ _context7.next = 15;
691
697
  return this.dbManager.update('order', existingOrder);
692
- case 14:
693
- _context7.next = 16;
698
+ case 15:
699
+ _context7.next = 17;
694
700
  return this.core.effects.emit(PaymentHooks.OnOrderUpdated, existingOrder);
695
- case 16:
701
+ case 17:
696
702
  return _context7.abrupt("return", existingOrder);
697
- case 19:
703
+ case 20:
698
704
  // 创建新的支付订单
699
705
  newOrder = {
700
706
  uuid: getUniqueId('pay_order_'),
@@ -710,31 +716,31 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
710
716
  is_deposit: params.is_deposit || 0,
711
717
  deposit_amount: params.deposit_amount || '0.00'
712
718
  };
713
- _context7.next = 22;
719
+ _context7.next = 23;
714
720
  return this.dbManager.add('order', newOrder);
715
- case 22:
721
+ case 23:
716
722
  this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
717
723
  this.logInfo('createPaymentOrderAsync completed - new payment order created', {
718
724
  orderUuid: newOrder.uuid,
719
725
  orderId: newOrder.id
720
726
  });
721
727
  return _context7.abrupt("return", newOrder);
722
- case 25:
723
- _context7.next = 32;
728
+ case 26:
729
+ _context7.next = 33;
724
730
  break;
725
- case 27:
726
- _context7.prev = 27;
731
+ case 28:
732
+ _context7.prev = 28;
727
733
  _context7.t0 = _context7["catch"](1);
728
734
  console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
729
735
  this.logError('createPaymentOrderAsync failed', _context7.t0, {
730
736
  orderId: params.order_id
731
737
  });
732
738
  throw _context7.t0;
733
- case 32:
739
+ case 33:
734
740
  case "end":
735
741
  return _context7.stop();
736
742
  }
737
- }, _callee7, this, [[1, 27]]);
743
+ }, _callee7, this, [[1, 28]]);
738
744
  }));
739
745
  function createPaymentOrderAsync(_x6) {
740
746
  return _createPaymentOrderAsync.apply(this, arguments);
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
314
314
  }[];
315
315
  setOtherData(key: string, value: any): void;
316
316
  getOtherData(key: string): any;
317
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
317
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
318
318
  /**
319
319
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
320
320
  *
@@ -403,13 +403,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
403
403
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
404
404
  while (1) switch (_context8.prev = _context8.next) {
405
405
  case 0:
406
+ this.logInfo('initWalletData called', {
407
+ params: params
408
+ });
406
409
  amountInfo = (_this$store$currentOr3 = this.store.currentOrder) === null || _this$store$currentOr3 === void 0 || (_this$store$currentOr3 = _this$store$currentOr3.order_info) === null || _this$store$currentOr3 === void 0 ? void 0 : _this$store$currentOr3.amount_breakdown;
407
410
  if (amountInfo) {
408
- _context8.next = 3;
411
+ _context8.next = 5;
409
412
  break;
410
413
  }
414
+ this.logInfo('initWalletData amountInfo not found', {
415
+ params: params
416
+ });
411
417
  return _context8.abrupt("return");
412
- case 3:
418
+ case 5:
413
419
  // 准备钱包初始化的业务数据
414
420
  walletBusinessData = _objectSpread({
415
421
  customer_id: (_this$store$currentCu = this.store.currentCustomer) !== null && _this$store$currentCu !== void 0 && _this$store$currentCu.customer_id ? Number(this.store.currentCustomer.customer_id) : undefined,
@@ -419,16 +425,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
419
425
  },
420
426
  products: this.getProductListByOrder()
421
427
  }, params);
422
- _context8.next = 6;
428
+ this.logInfo('开始拉取:initializeWalletDataFromBusinessAsync', {
429
+ walletBusinessData: walletBusinessData
430
+ });
431
+ _context8.next = 9;
423
432
  return this.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
424
- case 6:
433
+ case 9:
434
+ this.logInfo('调用结束:initializeWalletDataFromBusinessAsync', {
435
+ walletBusinessData: walletBusinessData
436
+ });
437
+
438
+ // 因为上面是接口 这里最好检查一下还有没有 currentOrder 了,如果没有,则不触发事件
425
439
  if (this.store.currentOrder) {
426
- _context8.next = 8;
440
+ _context8.next = 12;
427
441
  break;
428
442
  }
429
443
  return _context8.abrupt("return");
430
- case 8:
431
- _context8.next = 10;
444
+ case 12:
445
+ this.logInfo('initWalletData currentOrder found', {
446
+ currentOrder: this.store.currentOrder
447
+ });
448
+ // 触发钱包数据初始化完成事件
449
+ _context8.next = 15;
432
450
  return this.core.effects.emit(CheckoutHooks.OnWalletDataInitialized, {
433
451
  orderUuid: (_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.uuid,
434
452
  customerId: walletBusinessData.customer_id,
@@ -439,7 +457,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
439
457
  },
440
458
  timestamp: Date.now()
441
459
  });
442
- case 10:
460
+ case 15:
443
461
  case "end":
444
462
  return _context8.stop();
445
463
  }
@@ -540,7 +558,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
540
558
  case 21:
541
559
  paymentOrder = _context9.sent;
542
560
  this.store.currentOrder = paymentOrder;
543
- this.initWalletData();
544
561
 
545
562
  // 如果设置了自动支付,直接跳转到支付步骤
546
563
  if (params.autoPayment) {
@@ -552,9 +569,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
552
569
  });
553
570
 
554
571
  // 自动设置 stateAmount 为剩余未支付金额
555
- _context9.next = 28;
572
+ _context9.next = 27;
556
573
  return this.updateStateAmountToRemaining();
557
- case 28:
574
+ case 27:
558
575
  this.logInfo('本地订单创建成功:', {
559
576
  localOrderId: localOrderId,
560
577
  uuid: paymentOrder.uuid,
@@ -563,6 +580,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
563
580
  taxAmount: amountInfo.taxAmount,
564
581
  stateAmount: this.store.stateAmount
565
582
  });
583
+ this.initWalletData();
566
584
  return _context9.abrupt("return", paymentOrder);
567
585
  case 32:
568
586
  _context9.prev = 32;
@@ -570,12 +588,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
570
588
  _context9.next = 36;
571
589
  return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
572
590
  case 36:
591
+ this.logError('本地订单创建失败:', _context9.t0);
573
592
  this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
574
593
  error: this.store.lastError,
575
594
  timestamp: Date.now()
576
595
  });
577
596
  throw _context9.t0;
578
- case 38:
597
+ case 39:
579
598
  case "end":
580
599
  return _context9.stop();
581
600
  }
@@ -1030,7 +1049,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1030
1049
  key: "addPaymentItemAsync",
1031
1050
  value: (function () {
1032
1051
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(paymentItem) {
1033
- var _paymentItem$type, _paymentItem$code, orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, isEftposPayment, syncResult;
1052
+ var orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type, _paymentItem$code, isEftposPayment, syncResult;
1034
1053
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1035
1054
  while (1) switch (_context15.prev = _context15.next) {
1036
1055
  case 0:
@@ -1062,6 +1081,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1062
1081
  case 12:
1063
1082
  this.logInfo('支付项添加成功');
1064
1083
 
1084
+ // 支付项添加后,更新 stateAmount 为剩余未支付金额
1085
+ _context15.next = 15;
1086
+ return this.updateStateAmountToRemaining();
1087
+ case 15:
1088
+ _context15.next = 17;
1089
+ return this.calculateRemainingAmountAsync();
1090
+ case 17:
1091
+ remainingAmount = _context15.sent;
1092
+ if (!(Number(remainingAmount) > 0)) {
1093
+ _context15.next = 36;
1094
+ break;
1095
+ }
1096
+ this.logInfo('订单金额还有待付的,同步 EFTPOS 支付');
1065
1097
  // 检查是否是 EFTPOS 支付,如果是则立即同步订单
1066
1098
  isEftposPayment = ((_paymentItem$type = paymentItem.type) === null || _paymentItem$type === void 0 ? void 0 : _paymentItem$type.toLowerCase()) === 'eftpos' || ((_paymentItem$code = paymentItem.code) === null || _paymentItem$code === void 0 ? void 0 : _paymentItem$code.toUpperCase().includes('EFTPOS'));
1067
1099
  this.logInfo('EFTPOS 支付检查:', {
@@ -1071,56 +1103,54 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1071
1103
  currentOrderSynced: this.store.isOrderSynced
1072
1104
  });
1073
1105
  if (!isEftposPayment) {
1074
- _context15.next = 29;
1106
+ _context15.next = 36;
1075
1107
  break;
1076
1108
  }
1077
1109
  this.logInfo('检测到 EFTPOS 支付,立即同步订单到后端...');
1078
- _context15.prev = 17;
1079
- _context15.next = 20;
1110
+ _context15.prev = 24;
1111
+ _context15.next = 27;
1080
1112
  return this.syncOrderToBackendWithReturn(true);
1081
- case 20:
1113
+ case 27:
1082
1114
  syncResult = _context15.sent;
1083
1115
  this.logInfo('EFTPOS 支付后订单同步完成 (已标记为手动同步):', {
1084
1116
  orderId: syncResult.orderId,
1085
1117
  isOrderSynced: this.store.isOrderSynced,
1086
1118
  backendResponse: syncResult.response
1087
1119
  });
1088
- _context15.next = 29;
1120
+ _context15.next = 36;
1089
1121
  break;
1090
- case 24:
1091
- _context15.prev = 24;
1092
- _context15.t0 = _context15["catch"](17);
1122
+ case 31:
1123
+ _context15.prev = 31;
1124
+ _context15.t0 = _context15["catch"](24);
1093
1125
  this.logError('EFTPOS 支付后订单同步失败:', _context15.t0);
1094
1126
  // 不抛出错误,避免影响支付流程,但记录错误
1095
- _context15.next = 29;
1127
+ _context15.next = 36;
1096
1128
  return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0))), CheckoutErrorType.OrderCreationFailed);
1097
- case 29:
1098
- _context15.next = 31;
1099
- return this.updateStateAmountToRemaining();
1100
- case 31:
1101
- _context15.next = 33;
1102
- return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1129
+ case 36:
1130
+ _context15.next = 38;
1131
+ return this.core.effects.emit(CheckoutHooks.OnPaymentItemAdded, {
1103
1132
  orderUuid: this.store.currentOrder.uuid,
1104
1133
  paymentMethodCode: paymentItem.code,
1134
+ paymentMethodName: paymentItem.name,
1105
1135
  amount: String(paymentItem.amount),
1106
1136
  timestamp: Date.now()
1107
1137
  });
1108
- case 33:
1109
- _context15.next = 41;
1138
+ case 38:
1139
+ _context15.next = 46;
1110
1140
  break;
1111
- case 35:
1112
- _context15.prev = 35;
1141
+ case 40:
1142
+ _context15.prev = 40;
1113
1143
  _context15.t1 = _context15["catch"](1);
1114
1144
  this.logError('添加支付项失败:', _context15.t1);
1115
- _context15.next = 40;
1145
+ _context15.next = 45;
1116
1146
  return this.handleError(_context15.t1, CheckoutErrorType.PaymentFailed);
1117
- case 40:
1147
+ case 45:
1118
1148
  throw _context15.t1;
1119
- case 41:
1149
+ case 46:
1120
1150
  case "end":
1121
1151
  return _context15.stop();
1122
1152
  }
1123
- }, _callee15, this, [[1, 35], [17, 24]]);
1153
+ }, _callee15, this, [[1, 40], [24, 31]]);
1124
1154
  }));
1125
1155
  function addPaymentItemAsync(_x14) {
1126
1156
  return _addPaymentItemAsync.apply(this, arguments);
@@ -1743,7 +1773,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1743
1773
  case 8:
1744
1774
  allPaymentItems = _context21.sent;
1745
1775
  _context21.next = 11;
1746
- return this.syncOrderToBackendWithReturn(false, allPaymentItems);
1776
+ return this.syncOrderToBackendWithReturn(true, allPaymentItems);
1747
1777
  case 11:
1748
1778
  syncResult = _context21.sent;
1749
1779
  this.logInfo('保存订单完成:', {
@@ -300,7 +300,9 @@ export declare enum CheckoutHooks {
300
300
  /** 下单接口请求完成 */
301
301
  OnOrderSubmitEnd = "checkout:onOrderSubmitEnd",
302
302
  /** 钱包数据初始化完成 */
303
- OnWalletDataInitialized = "checkout:onWalletDataInitialized"
303
+ OnWalletDataInitialized = "checkout:onWalletDataInitialized",
304
+ /** 支付项添加成功 */
305
+ OnPaymentItemAdded = "checkout:onPaymentItemAdded"
304
306
  }
305
307
  /**
306
308
  * 结账状态数据
@@ -75,6 +75,7 @@ export var CheckoutHooks = /*#__PURE__*/function (CheckoutHooks) {
75
75
  CheckoutHooks["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
76
76
  CheckoutHooks["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
77
77
  CheckoutHooks["OnWalletDataInitialized"] = "checkout:onWalletDataInitialized";
78
+ CheckoutHooks["OnPaymentItemAdded"] = "checkout:onPaymentItemAdded";
78
79
  return CheckoutHooks;
79
80
  }({});
80
81
 
@@ -324,9 +324,12 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
324
324
  });
325
325
  try {
326
326
  const existingOrder = await this.dbManager.get("order", params.order_id);
327
+ this.logInfo("createPaymentOrderAsync existingOrder", {
328
+ existingOrder
329
+ });
327
330
  if (existingOrder) {
328
- console.log(
329
- `[PaymentModule] 发现重复订单 ID: ${params.order_id},更新现有支付订单`
331
+ this.logInfo(
332
+ `createPaymentOrderAsync found duplicate order ID: ${params.order_id}, updating existing payment order`
330
333
  );
331
334
  existingOrder.order_info = params.order_info;
332
335
  existingOrder.total_amount = params.total_amount;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
314
314
  }[];
315
315
  setOtherData(key: string, value: any): void;
316
316
  getOtherData(key: string): any;
317
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
317
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
318
318
  /**
319
319
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
320
320
  *
@@ -222,8 +222,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
222
222
  }
223
223
  async initWalletData(params) {
224
224
  var _a, _b, _c, _d;
225
+ this.logInfo("initWalletData called", {
226
+ params
227
+ });
225
228
  const amountInfo = (_b = (_a = this.store.currentOrder) == null ? void 0 : _a.order_info) == null ? void 0 : _b.amount_breakdown;
226
229
  if (!amountInfo) {
230
+ this.logInfo("initWalletData amountInfo not found", {
231
+ params
232
+ });
227
233
  return;
228
234
  }
229
235
  const walletBusinessData = {
@@ -235,12 +241,21 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
235
241
  products: this.getProductListByOrder(),
236
242
  ...params
237
243
  };
244
+ this.logInfo("开始拉取:initializeWalletDataFromBusinessAsync", {
245
+ walletBusinessData
246
+ });
238
247
  await this.payment.wallet.initializeWalletDataFromBusinessAsync(
239
248
  walletBusinessData
240
249
  );
250
+ this.logInfo("调用结束:initializeWalletDataFromBusinessAsync", {
251
+ walletBusinessData
252
+ });
241
253
  if (!this.store.currentOrder) {
242
254
  return;
243
255
  }
256
+ this.logInfo("initWalletData currentOrder found", {
257
+ currentOrder: this.store.currentOrder
258
+ });
244
259
  await this.core.effects.emit(import_types.CheckoutHooks.OnWalletDataInitialized, {
245
260
  orderUuid: (_d = this.store.currentOrder) == null ? void 0 : _d.uuid,
246
261
  customerId: walletBusinessData.customer_id,
@@ -318,7 +333,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
318
333
  }
319
334
  });
320
335
  this.store.currentOrder = paymentOrder;
321
- this.initWalletData();
322
336
  if (params.autoPayment) {
323
337
  }
324
338
  this.core.effects.emit(import_types.CheckoutHooks.OnOrderCreated, {
@@ -334,12 +348,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
334
348
  taxAmount: amountInfo.taxAmount,
335
349
  stateAmount: this.store.stateAmount
336
350
  });
351
+ this.initWalletData();
337
352
  return paymentOrder;
338
353
  } catch (error) {
339
354
  await this.handleError(
340
355
  error,
341
356
  import_types.CheckoutErrorType.OrderCreationFailed
342
357
  );
358
+ this.logError("本地订单创建失败:", error);
343
359
  this.core.effects.emit(import_types.CheckoutHooks.OnOrderCreationFailed, {
344
360
  error: this.store.lastError,
345
361
  timestamp: Date.now()
@@ -638,36 +654,41 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
638
654
  paymentItemWithType
639
655
  );
640
656
  this.logInfo("支付项添加成功");
641
- const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
642
- this.logInfo("EFTPOS 支付检查:", {
643
- paymentCode: paymentItem.code,
644
- paymentType: paymentItem.type,
645
- isEftposPayment,
646
- currentOrderSynced: this.store.isOrderSynced
647
- });
648
- if (isEftposPayment) {
649
- this.logInfo("检测到 EFTPOS 支付,立即同步订单到后端...");
650
- try {
651
- const syncResult = await this.syncOrderToBackendWithReturn(true);
652
- this.logInfo("EFTPOS 支付后订单同步完成 (已标记为手动同步):", {
653
- orderId: syncResult.orderId,
654
- isOrderSynced: this.store.isOrderSynced,
655
- backendResponse: syncResult.response
656
- });
657
- } catch (error) {
658
- this.logError("EFTPOS 支付后订单同步失败:", error);
659
- await this.handleError(
660
- new Error(
661
- `EFTPOS 支付后订单同步失败: ${error instanceof Error ? error.message : String(error)}`
662
- ),
663
- import_types.CheckoutErrorType.OrderCreationFailed
664
- );
657
+ await this.updateStateAmountToRemaining();
658
+ const remainingAmount = await this.calculateRemainingAmountAsync();
659
+ if (Number(remainingAmount) > 0) {
660
+ this.logInfo("订单金额还有待付的,同步 EFTPOS 支付");
661
+ const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
662
+ this.logInfo("EFTPOS 支付检查:", {
663
+ paymentCode: paymentItem.code,
664
+ paymentType: paymentItem.type,
665
+ isEftposPayment,
666
+ currentOrderSynced: this.store.isOrderSynced
667
+ });
668
+ if (isEftposPayment) {
669
+ this.logInfo("检测到 EFTPOS 支付,立即同步订单到后端...");
670
+ try {
671
+ const syncResult = await this.syncOrderToBackendWithReturn(true);
672
+ this.logInfo("EFTPOS 支付后订单同步完成 (已标记为手动同步):", {
673
+ orderId: syncResult.orderId,
674
+ isOrderSynced: this.store.isOrderSynced,
675
+ backendResponse: syncResult.response
676
+ });
677
+ } catch (error) {
678
+ this.logError("EFTPOS 支付后订单同步失败:", error);
679
+ await this.handleError(
680
+ new Error(
681
+ `EFTPOS 支付后订单同步失败: ${error instanceof Error ? error.message : String(error)}`
682
+ ),
683
+ import_types.CheckoutErrorType.OrderCreationFailed
684
+ );
685
+ }
665
686
  }
666
687
  }
667
- await this.updateStateAmountToRemaining();
668
- await this.core.effects.emit(import_types.CheckoutHooks.OnPaymentStarted, {
688
+ await this.core.effects.emit(import_types.CheckoutHooks.OnPaymentItemAdded, {
669
689
  orderUuid: this.store.currentOrder.uuid,
670
690
  paymentMethodCode: paymentItem.code,
691
+ paymentMethodName: paymentItem.name,
671
692
  amount: String(paymentItem.amount),
672
693
  timestamp: Date.now()
673
694
  });
@@ -1103,7 +1124,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1103
1124
  this.store.currentOrder.uuid
1104
1125
  );
1105
1126
  const syncResult = await this.syncOrderToBackendWithReturn(
1106
- false,
1127
+ true,
1107
1128
  allPaymentItems
1108
1129
  );
1109
1130
  this.logInfo("保存订单完成:", {
@@ -300,7 +300,9 @@ export declare enum CheckoutHooks {
300
300
  /** 下单接口请求完成 */
301
301
  OnOrderSubmitEnd = "checkout:onOrderSubmitEnd",
302
302
  /** 钱包数据初始化完成 */
303
- OnWalletDataInitialized = "checkout:onWalletDataInitialized"
303
+ OnWalletDataInitialized = "checkout:onWalletDataInitialized",
304
+ /** 支付项添加成功 */
305
+ OnPaymentItemAdded = "checkout:onPaymentItemAdded"
304
306
  }
305
307
  /**
306
308
  * 结账状态数据
@@ -53,6 +53,7 @@ var CheckoutHooks = /* @__PURE__ */ ((CheckoutHooks2) => {
53
53
  CheckoutHooks2["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
54
54
  CheckoutHooks2["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
55
55
  CheckoutHooks2["OnWalletDataInitialized"] = "checkout:onWalletDataInitialized";
56
+ CheckoutHooks2["OnPaymentItemAdded"] = "checkout:onPaymentItemAdded";
56
57
  return CheckoutHooks2;
57
58
  })(CheckoutHooks || {});
58
59
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.9",
4
+ "version": "2.1.11",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",