@pisell/pisellos 2.1.9 → 2.1.10

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.
@@ -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
  *
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
111
111
  * 获取当前的客户搜索条件
112
112
  * @returns 当前搜索条件
113
113
  */
114
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
@@ -1030,7 +1030,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1030
1030
  key: "addPaymentItemAsync",
1031
1031
  value: (function () {
1032
1032
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(paymentItem) {
1033
- var _paymentItem$type, _paymentItem$code, orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, isEftposPayment, syncResult;
1033
+ var orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type, _paymentItem$code, isEftposPayment, syncResult;
1034
1034
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1035
1035
  while (1) switch (_context15.prev = _context15.next) {
1036
1036
  case 0:
@@ -1062,6 +1062,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1062
1062
  case 12:
1063
1063
  this.logInfo('支付项添加成功');
1064
1064
 
1065
+ // 支付项添加后,更新 stateAmount 为剩余未支付金额
1066
+ _context15.next = 15;
1067
+ return this.updateStateAmountToRemaining();
1068
+ case 15:
1069
+ _context15.next = 17;
1070
+ return this.calculateRemainingAmountAsync();
1071
+ case 17:
1072
+ remainingAmount = _context15.sent;
1073
+ if (!(Number(remainingAmount) > 0)) {
1074
+ _context15.next = 36;
1075
+ break;
1076
+ }
1077
+ this.logInfo('订单金额还有待付的,同步 EFTPOS 支付');
1065
1078
  // 检查是否是 EFTPOS 支付,如果是则立即同步订单
1066
1079
  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
1080
  this.logInfo('EFTPOS 支付检查:', {
@@ -1071,56 +1084,54 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1071
1084
  currentOrderSynced: this.store.isOrderSynced
1072
1085
  });
1073
1086
  if (!isEftposPayment) {
1074
- _context15.next = 29;
1087
+ _context15.next = 36;
1075
1088
  break;
1076
1089
  }
1077
1090
  this.logInfo('检测到 EFTPOS 支付,立即同步订单到后端...');
1078
- _context15.prev = 17;
1079
- _context15.next = 20;
1091
+ _context15.prev = 24;
1092
+ _context15.next = 27;
1080
1093
  return this.syncOrderToBackendWithReturn(true);
1081
- case 20:
1094
+ case 27:
1082
1095
  syncResult = _context15.sent;
1083
1096
  this.logInfo('EFTPOS 支付后订单同步完成 (已标记为手动同步):', {
1084
1097
  orderId: syncResult.orderId,
1085
1098
  isOrderSynced: this.store.isOrderSynced,
1086
1099
  backendResponse: syncResult.response
1087
1100
  });
1088
- _context15.next = 29;
1101
+ _context15.next = 36;
1089
1102
  break;
1090
- case 24:
1091
- _context15.prev = 24;
1092
- _context15.t0 = _context15["catch"](17);
1103
+ case 31:
1104
+ _context15.prev = 31;
1105
+ _context15.t0 = _context15["catch"](24);
1093
1106
  this.logError('EFTPOS 支付后订单同步失败:', _context15.t0);
1094
1107
  // 不抛出错误,避免影响支付流程,但记录错误
1095
- _context15.next = 29;
1108
+ _context15.next = 36;
1096
1109
  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, {
1110
+ case 36:
1111
+ _context15.next = 38;
1112
+ return this.core.effects.emit(CheckoutHooks.OnPaymentItemAdded, {
1103
1113
  orderUuid: this.store.currentOrder.uuid,
1104
1114
  paymentMethodCode: paymentItem.code,
1115
+ paymentMethodName: paymentItem.name,
1105
1116
  amount: String(paymentItem.amount),
1106
1117
  timestamp: Date.now()
1107
1118
  });
1108
- case 33:
1109
- _context15.next = 41;
1119
+ case 38:
1120
+ _context15.next = 46;
1110
1121
  break;
1111
- case 35:
1112
- _context15.prev = 35;
1122
+ case 40:
1123
+ _context15.prev = 40;
1113
1124
  _context15.t1 = _context15["catch"](1);
1114
1125
  this.logError('添加支付项失败:', _context15.t1);
1115
- _context15.next = 40;
1126
+ _context15.next = 45;
1116
1127
  return this.handleError(_context15.t1, CheckoutErrorType.PaymentFailed);
1117
- case 40:
1128
+ case 45:
1118
1129
  throw _context15.t1;
1119
- case 41:
1130
+ case 46:
1120
1131
  case "end":
1121
1132
  return _context15.stop();
1122
1133
  }
1123
- }, _callee15, this, [[1, 35], [17, 24]]);
1134
+ }, _callee15, this, [[1, 40], [24, 31]]);
1124
1135
  }));
1125
1136
  function addPaymentItemAsync(_x14) {
1126
1137
  return _addPaymentItemAsync.apply(this, arguments);
@@ -1743,7 +1754,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1743
1754
  case 8:
1744
1755
  allPaymentItems = _context21.sent;
1745
1756
  _context21.next = 11;
1746
- return this.syncOrderToBackendWithReturn(false, allPaymentItems);
1757
+ return this.syncOrderToBackendWithReturn(true, allPaymentItems);
1747
1758
  case 11:
1748
1759
  syncResult = _context21.sent;
1749
1760
  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
 
@@ -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
  *
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
111
111
  * 获取当前的客户搜索条件
112
112
  * @returns 当前搜索条件
113
113
  */
114
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
@@ -638,36 +638,41 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
638
638
  paymentItemWithType
639
639
  );
640
640
  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
- );
641
+ await this.updateStateAmountToRemaining();
642
+ const remainingAmount = await this.calculateRemainingAmountAsync();
643
+ if (Number(remainingAmount) > 0) {
644
+ this.logInfo("订单金额还有待付的,同步 EFTPOS 支付");
645
+ const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
646
+ this.logInfo("EFTPOS 支付检查:", {
647
+ paymentCode: paymentItem.code,
648
+ paymentType: paymentItem.type,
649
+ isEftposPayment,
650
+ currentOrderSynced: this.store.isOrderSynced
651
+ });
652
+ if (isEftposPayment) {
653
+ this.logInfo("检测到 EFTPOS 支付,立即同步订单到后端...");
654
+ try {
655
+ const syncResult = await this.syncOrderToBackendWithReturn(true);
656
+ this.logInfo("EFTPOS 支付后订单同步完成 (已标记为手动同步):", {
657
+ orderId: syncResult.orderId,
658
+ isOrderSynced: this.store.isOrderSynced,
659
+ backendResponse: syncResult.response
660
+ });
661
+ } catch (error) {
662
+ this.logError("EFTPOS 支付后订单同步失败:", error);
663
+ await this.handleError(
664
+ new Error(
665
+ `EFTPOS 支付后订单同步失败: ${error instanceof Error ? error.message : String(error)}`
666
+ ),
667
+ import_types.CheckoutErrorType.OrderCreationFailed
668
+ );
669
+ }
665
670
  }
666
671
  }
667
- await this.updateStateAmountToRemaining();
668
- await this.core.effects.emit(import_types.CheckoutHooks.OnPaymentStarted, {
672
+ await this.core.effects.emit(import_types.CheckoutHooks.OnPaymentItemAdded, {
669
673
  orderUuid: this.store.currentOrder.uuid,
670
674
  paymentMethodCode: paymentItem.code,
675
+ paymentMethodName: paymentItem.name,
671
676
  amount: String(paymentItem.amount),
672
677
  timestamp: Date.now()
673
678
  });
@@ -1103,7 +1108,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1103
1108
  this.store.currentOrder.uuid
1104
1109
  );
1105
1110
  const syncResult = await this.syncOrderToBackendWithReturn(
1106
- false,
1111
+ true,
1107
1112
  allPaymentItems
1108
1113
  );
1109
1114
  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.10",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",