@pisell/pisellos 0.0.249 → 0.0.251

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.
@@ -110,21 +110,32 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
110
110
  key: "initializeWalletDataFromBusinessAsync",
111
111
  value: (function () {
112
112
  var _initializeWalletDataFromBusinessAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(businessData) {
113
+ var _businessData$amountI, _businessData$amountI2;
113
114
  var startTime, walletParams, result, endTime, duration, _endTime, _duration;
114
115
  return _regeneratorRuntime().wrap(function _callee$(_context) {
115
116
  while (1) switch (_context.prev = _context.next) {
116
117
  case 0:
117
- startTime = Date.now(); // 发送初始化开始事件
118
+ startTime = Date.now();
119
+ if (!(Number((businessData === null || businessData === void 0 || (_businessData$amountI = businessData.amountInfo) === null || _businessData$amountI === void 0 ? void 0 : _businessData$amountI.totalAmount) || 0) <= 0 || Number((businessData === null || businessData === void 0 || (_businessData$amountI2 = businessData.amountInfo) === null || _businessData$amountI2 === void 0 ? void 0 : _businessData$amountI2.subTotal) || 0) <= 0)) {
120
+ _context.next = 3;
121
+ break;
122
+ }
123
+ return _context.abrupt("return", {
124
+ walletRecommendList: [],
125
+ userIdentificationCodes: []
126
+ });
127
+ case 3:
128
+ // 发送初始化开始事件
118
129
  this.emitEvent(WalletPassHooks.OnWalletInitializationStarted, {
119
130
  businessData: businessData,
120
131
  startTime: startTime
121
132
  });
122
- _context.prev = 2;
133
+ _context.prev = 4;
123
134
  // 生成钱包API参数
124
135
  walletParams = this.generateWalletParams(businessData); // 调用标准的初始化流程
125
- _context.next = 6;
136
+ _context.next = 8;
126
137
  return this.initializeWalletDataAsync(walletParams);
127
- case 6:
138
+ case 8:
128
139
  result = _context.sent;
129
140
  endTime = Date.now();
130
141
  duration = endTime - startTime; // 发送初始化完成事件
@@ -137,9 +148,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
137
148
  });
138
149
  console.log("[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u6210\u529F\uFF0C\u8017\u65F6: ".concat(duration, "ms"));
139
150
  return _context.abrupt("return", result);
140
- case 14:
141
- _context.prev = 14;
142
- _context.t0 = _context["catch"](2);
151
+ case 16:
152
+ _context.prev = 16;
153
+ _context.t0 = _context["catch"](4);
143
154
  _endTime = Date.now();
144
155
  _duration = _endTime - startTime; // 发送初始化失败事件
145
156
  this.emitEvent(WalletPassHooks.OnWalletInitializationFailed, {
@@ -151,11 +162,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
151
162
  });
152
163
  console.error("[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u5931\u8D25\uFF0C\u8017\u65F6: ".concat(_duration, "ms"), _context.t0);
153
164
  throw _context.t0;
154
- case 21:
165
+ case 23:
155
166
  case "end":
156
167
  return _context.stop();
157
168
  }
158
- }, _callee, this, [[2, 14]]);
169
+ }, _callee, this, [[4, 16]]);
159
170
  }));
160
171
  function initializeWalletDataFromBusinessAsync(_x) {
161
172
  return _initializeWalletDataFromBusinessAsync.apply(this, arguments);
@@ -276,6 +276,7 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
276
276
  message?: string;
277
277
  orderId?: string;
278
278
  orderUuid?: string;
279
+ response?: any;
279
280
  }>;
280
281
  /**
281
282
  * 获取当前订单备注
@@ -319,6 +320,7 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
319
320
  message?: string;
320
321
  orderId?: string;
321
322
  orderUuid?: string;
323
+ response?: any;
322
324
  }>;
323
325
  /**
324
326
  * 获取当前商店折扣金额
@@ -440,7 +442,7 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
440
442
  *
441
443
  * @param isManual 是否为手动同步,默认为 false
442
444
  * @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
443
- * @returns 后端返回的真实订单ID
445
+ * @returns 包含订单ID、UUID和完整后端响应的对象
444
446
  */
445
447
  private syncOrderToBackendWithReturn;
446
448
  private syncOrderToBackend;
@@ -399,7 +399,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
399
399
  key: "createLocalOrderAsync",
400
400
  value: (function () {
401
401
  var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
402
- var _params$totalInfo, _params$totalInfo2, _params$totalInfo3, validation, localOrderId, amountInfo, customerInfo, paymentOrder;
402
+ var _params$totalInfo, _params$totalInfo2, _params$totalInfo3, _params$totalInfo4, validation, localOrderId, amountInfo, customerInfo, paymentOrder;
403
403
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
404
404
  while (1) switch (_context9.prev = _context9.next) {
405
405
  case 0:
@@ -429,6 +429,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
429
429
  params.orderData.surcharges = (_params$totalInfo2 = params.totalInfo) === null || _params$totalInfo2 === void 0 || (_params$totalInfo2 = _params$totalInfo2.total) === null || _params$totalInfo2 === void 0 ? void 0 : _params$totalInfo2.surcharge;
430
430
  // 补充订单折扣信息
431
431
  params.orderData.shop_discount = (_params$totalInfo3 = params.totalInfo) === null || _params$totalInfo3 === void 0 || (_params$totalInfo3 = _params$totalInfo3.total) === null || _params$totalInfo3 === void 0 ? void 0 : _params$totalInfo3.shopDiscount;
432
+ // 补充税费信息
433
+ params.orderData.tax = (_params$totalInfo4 = params.totalInfo) === null || _params$totalInfo4 === void 0 || (_params$totalInfo4 = _params$totalInfo4.total) === null || _params$totalInfo4 === void 0 ? void 0 : _params$totalInfo4.tax;
432
434
 
433
435
  // 保存原始订单数据和小计数据到状态中
434
436
  this.store.localOrderData = params.orderData;
@@ -448,7 +450,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
448
450
  }
449
451
 
450
452
  // 创建支付订单对象
451
- _context9.next = 21;
453
+ _context9.next = 22;
452
454
  return this.payment.createPaymentOrderAsync({
453
455
  order_id: localOrderId,
454
456
  total_amount: amountInfo.totalAmount,
@@ -465,32 +467,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
465
467
  amount_breakdown: amountInfo
466
468
  }
467
469
  });
468
- case 21:
470
+ case 22:
469
471
  paymentOrder = _context9.sent;
470
472
  this.store.currentOrder = paymentOrder;
471
473
  this.initWalletData();
472
- _context9.next = 26;
474
+ _context9.next = 27;
473
475
  return this.setStatus(CheckoutStatus.OrderCreated);
474
- case 26:
475
- _context9.next = 28;
476
+ case 27:
477
+ _context9.next = 29;
476
478
  return this.setStep(CheckoutStep.PaymentMethod);
477
- case 28:
479
+ case 29:
478
480
  if (!params.autoPayment) {
479
- _context9.next = 31;
481
+ _context9.next = 32;
480
482
  break;
481
483
  }
482
- _context9.next = 31;
484
+ _context9.next = 32;
483
485
  return this.setStep(CheckoutStep.PaymentProcessing);
484
- case 31:
486
+ case 32:
485
487
  this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
486
488
  order: paymentOrder,
487
489
  timestamp: Date.now()
488
490
  });
489
491
 
490
492
  // 自动设置 stateAmount 为剩余未支付金额
491
- _context9.next = 34;
493
+ _context9.next = 35;
492
494
  return this.updateStateAmountToRemaining();
493
- case 34:
495
+ case 35:
494
496
  console.log('[Checkout] 本地订单创建成功:', {
495
497
  localOrderId: localOrderId,
496
498
  uuid: paymentOrder.uuid,
@@ -500,22 +502,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
500
502
  stateAmount: this.store.stateAmount
501
503
  });
502
504
  return _context9.abrupt("return", paymentOrder);
503
- case 38:
504
- _context9.prev = 38;
505
+ case 39:
506
+ _context9.prev = 39;
505
507
  _context9.t0 = _context9["catch"](0);
506
- _context9.next = 42;
508
+ _context9.next = 43;
507
509
  return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
508
- case 42:
510
+ case 43:
509
511
  this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
510
512
  error: this.store.lastError,
511
513
  timestamp: Date.now()
512
514
  });
513
515
  throw _context9.t0;
514
- case 44:
516
+ case 45:
515
517
  case "end":
516
518
  return _context9.stop();
517
519
  }
518
- }, _callee9, this, [[0, 38]]);
520
+ }, _callee9, this, [[0, 39]]);
519
521
  }));
520
522
  function createLocalOrderAsync(_x11) {
521
523
  return _createLocalOrderAsync.apply(this, arguments);
@@ -1660,7 +1662,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1660
1662
  key: "addPaymentItemAsync",
1661
1663
  value: (function () {
1662
1664
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(paymentItem) {
1663
- var _paymentItem$type, _paymentItem$code, orderPaymentType, metadata, paymentItemWithType, isEftposPayment;
1665
+ var _paymentItem$type, _paymentItem$code, orderPaymentType, metadata, paymentItemWithType, isEftposPayment, syncResult;
1664
1666
  return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1665
1667
  while (1) switch (_context25.prev = _context25.next) {
1666
1668
  case 0:
@@ -1713,7 +1715,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1713
1715
  currentOrderSynced: this.store.isOrderSynced
1714
1716
  });
1715
1717
  if (!isEftposPayment) {
1716
- _context25.next = 25;
1718
+ _context25.next = 26;
1717
1719
  break;
1718
1720
  }
1719
1721
  console.log('[Checkout] 检测到 EFTPOS 支付,立即同步订单到后端...');
@@ -1721,46 +1723,48 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1721
1723
  _context25.next = 17;
1722
1724
  return this.syncOrderToBackendWithReturn(true);
1723
1725
  case 17:
1726
+ syncResult = _context25.sent;
1724
1727
  console.log('[Checkout] EFTPOS 支付后订单同步完成 (已标记为手动同步):', {
1725
- 订单ID: this.store.currentOrder.order_id,
1726
- 是否已同步: this.store.isOrderSynced
1728
+ 订单ID: syncResult.orderId,
1729
+ 是否已同步: this.store.isOrderSynced,
1730
+ 后端响应: syncResult.response
1727
1731
  });
1728
- _context25.next = 25;
1732
+ _context25.next = 26;
1729
1733
  break;
1730
- case 20:
1731
- _context25.prev = 20;
1734
+ case 21:
1735
+ _context25.prev = 21;
1732
1736
  _context25.t0 = _context25["catch"](14);
1733
1737
  console.error('[Checkout] EFTPOS 支付后订单同步失败:', _context25.t0);
1734
1738
  // 不抛出错误,避免影响支付流程,但记录错误
1735
- _context25.next = 25;
1739
+ _context25.next = 26;
1736
1740
  return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0))), CheckoutErrorType.OrderCreationFailed);
1737
- case 25:
1738
- _context25.next = 27;
1741
+ case 26:
1742
+ _context25.next = 28;
1739
1743
  return this.updateStateAmountToRemaining();
1740
- case 27:
1741
- _context25.next = 29;
1744
+ case 28:
1745
+ _context25.next = 30;
1742
1746
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1743
1747
  orderUuid: this.store.currentOrder.uuid,
1744
1748
  paymentMethodCode: paymentItem.code,
1745
1749
  amount: String(paymentItem.amount),
1746
1750
  timestamp: Date.now()
1747
1751
  });
1748
- case 29:
1749
- _context25.next = 37;
1752
+ case 30:
1753
+ _context25.next = 38;
1750
1754
  break;
1751
- case 31:
1752
- _context25.prev = 31;
1755
+ case 32:
1756
+ _context25.prev = 32;
1753
1757
  _context25.t1 = _context25["catch"](0);
1754
1758
  console.error('[Checkout] 添加支付项失败:', _context25.t1);
1755
- _context25.next = 36;
1759
+ _context25.next = 37;
1756
1760
  return this.handleError(_context25.t1, CheckoutErrorType.PaymentFailed);
1757
- case 36:
1758
- throw _context25.t1;
1759
1761
  case 37:
1762
+ throw _context25.t1;
1763
+ case 38:
1760
1764
  case "end":
1761
1765
  return _context25.stop();
1762
1766
  }
1763
- }, _callee25, this, [[0, 31], [14, 20]]);
1767
+ }, _callee25, this, [[0, 32], [14, 21]]);
1764
1768
  }));
1765
1769
  function addPaymentItemAsync(_x16) {
1766
1770
  return _addPaymentItemAsync.apply(this, arguments);
@@ -2270,7 +2274,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2270
2274
  key: "manualSyncOrderAsync",
2271
2275
  value: (function () {
2272
2276
  var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2273
- var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$currentOr8, errorMessage;
2277
+ var orderUuid, oldOrderId, syncResult, finalOrderId, finalIsVirtual, _this$store$currentOr8, errorMessage;
2274
2278
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2275
2279
  while (1) switch (_context31.prev = _context31.next) {
2276
2280
  case 0:
@@ -2307,11 +2311,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2307
2311
  _context31.next = 17;
2308
2312
  return this.syncOrderToBackendWithReturn(true);
2309
2313
  case 17:
2310
- realOrderId = _context31.sent;
2314
+ syncResult = _context31.sent;
2311
2315
  console.log('[Checkout] 手动同步订单完成:', {
2312
2316
  orderUuid: orderUuid,
2317
+ syncResult: syncResult,
2313
2318
  oldOrderId: oldOrderId,
2314
- realOrderId: realOrderId,
2319
+ realOrderId: syncResult.orderId,
2315
2320
  isOrderSynced: this.store.isOrderSynced
2316
2321
  });
2317
2322
 
@@ -2319,25 +2324,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2319
2324
  finalOrderId = this.store.currentOrder.order_id;
2320
2325
  finalIsVirtual = this.isVirtualOrderId(finalOrderId);
2321
2326
  console.log('[Checkout] manualSyncOrderAsync 最终状态验证:', {
2322
- 返回的订单ID: realOrderId,
2327
+ 返回的订单ID: syncResult.orderId,
2323
2328
  存储的订单ID: finalOrderId,
2324
2329
  存储的ID是否虚拟: finalIsVirtual,
2325
- 是否一致: realOrderId === finalOrderId,
2330
+ 是否一致: syncResult.orderId === finalOrderId,
2326
2331
  同步状态: this.store.isOrderSynced
2327
2332
  });
2328
2333
  if (finalIsVirtual) {
2329
2334
  console.error('[Checkout] 严重警告:手动同步完成后订单ID仍为虚拟ID!');
2330
2335
  }
2331
- if (realOrderId !== finalOrderId) {
2336
+ if (syncResult.orderId !== finalOrderId) {
2332
2337
  console.error('[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!');
2333
2338
  }
2334
- return _context31.abrupt("return", {
2335
- success: true,
2336
- message: '订单同步成功',
2337
- orderId: realOrderId,
2338
- // 直接返回从后端获取的真实订单ID
2339
- orderUuid: orderUuid
2340
- });
2339
+ return _context31.abrupt("return", syncResult);
2341
2340
  case 27:
2342
2341
  _context31.prev = 27;
2343
2342
  _context31.t6 = _context31["catch"](0);
@@ -2545,7 +2544,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2545
2544
  key: "saveForLaterPaymentAsync",
2546
2545
  value: (function () {
2547
2546
  var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2548
- var orderUuid, currentOrderId, allPaymentItems, realOrderId, finalOrderId, _this$store$currentOr11, errorMessage;
2547
+ var orderUuid, currentOrderId, allPaymentItems, syncResult, finalOrderId, _this$store$currentOr11, errorMessage;
2549
2548
  return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2550
2549
  while (1) switch (_context33.prev = _context33.next) {
2551
2550
  case 0:
@@ -2575,11 +2574,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2575
2574
  _context33.next = 11;
2576
2575
  return this.syncOrderToBackendWithReturn(false, allPaymentItems);
2577
2576
  case 11:
2578
- realOrderId = _context33.sent;
2577
+ syncResult = _context33.sent;
2579
2578
  console.log('[Checkout] 保存订单完成:', {
2580
2579
  orderUuid: orderUuid,
2581
2580
  oldOrderId: currentOrderId,
2582
- realOrderId: realOrderId,
2581
+ syncResult: syncResult,
2582
+ realOrderId: syncResult.orderId,
2583
2583
  isOrderSynced: this.store.isOrderSynced,
2584
2584
  filteredPaymentsCount: allPaymentItems.length
2585
2585
  });
@@ -2587,16 +2587,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2587
2587
  // 验证最终状态
2588
2588
  finalOrderId = this.store.currentOrder.order_id;
2589
2589
  console.log('[Checkout] saveForLaterPaymentAsync 最终状态验证:', {
2590
- 返回的订单ID: realOrderId,
2590
+ 返回的订单ID: syncResult.orderId,
2591
2591
  存储的订单ID: finalOrderId,
2592
- 是否一致: realOrderId === finalOrderId,
2592
+ 是否一致: syncResult.orderId === finalOrderId,
2593
2593
  同步状态: this.store.isOrderSynced
2594
2594
  });
2595
2595
  return _context33.abrupt("return", {
2596
2596
  success: true,
2597
2597
  message: '订单保存成功,可稍后继续支付',
2598
- orderId: realOrderId,
2599
- orderUuid: orderUuid
2598
+ orderId: syncResult.orderId,
2599
+ orderUuid: orderUuid,
2600
+ response: syncResult.response
2600
2601
  });
2601
2602
  case 18:
2602
2603
  _context33.prev = 18;
@@ -3646,7 +3647,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3646
3647
  *
3647
3648
  * @param isManual 是否为手动同步,默认为 false
3648
3649
  * @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
3649
- * @returns 后端返回的真实订单ID
3650
+ * @returns 包含订单ID、UUID和完整后端响应的对象
3650
3651
  */
3651
3652
  }, {
3652
3653
  key: "syncOrderToBackendWithReturn",
@@ -3822,6 +3823,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3822
3823
  deposit_amount: ((_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.deposit_amount) || '0.00',
3823
3824
  // surcharge_fee: this.otherParams.surcharge_fee,
3824
3825
  // surcharges: ,
3826
+ product_tax_fee: this.store.localOrderData.tax,
3825
3827
  note: this.store.localOrderData.shop_note
3826
3828
  // deposit_amount:
3827
3829
  }); // 如果是更新操作,需要在参数中包含真实的订单ID
@@ -4049,8 +4051,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4049
4051
  console.warn('[Checkout] 警告:订单创建后,当前订单ID仍然是虚拟ID,可能存在问题');
4050
4052
  }
4051
4053
 
4052
- // 返回真实订单ID
4053
- return _context47.abrupt("return", realOrderId);
4054
+ // 返回同步结果
4055
+ return _context47.abrupt("return", {
4056
+ success: true,
4057
+ message: "\u8BA2\u5355".concat(operation, "\u6210\u529F"),
4058
+ orderId: realOrderId,
4059
+ orderUuid: this.store.currentOrder.uuid,
4060
+ response: checkoutResponse
4061
+ });
4054
4062
  case 91:
4055
4063
  case "end":
4056
4064
  return _context47.stop();
@@ -4066,6 +4074,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4066
4074
  key: "syncOrderToBackend",
4067
4075
  value: function () {
4068
4076
  var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4077
+ var syncResult;
4069
4078
  return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4070
4079
  while (1) switch (_context48.prev = _context48.next) {
4071
4080
  case 0:
@@ -4073,19 +4082,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4073
4082
  _context48.next = 3;
4074
4083
  return this.syncOrderToBackendWithReturn(false);
4075
4084
  case 3:
4076
- _context48.next = 10;
4085
+ syncResult = _context48.sent;
4086
+ console.log('[Checkout] 自动同步订单完成:', syncResult);
4087
+ _context48.next = 12;
4077
4088
  break;
4078
- case 5:
4079
- _context48.prev = 5;
4089
+ case 7:
4090
+ _context48.prev = 7;
4080
4091
  _context48.t0 = _context48["catch"](0);
4081
4092
  console.error('[Checkout] 同步订单到后端失败:', _context48.t0);
4082
- _context48.next = 10;
4093
+ _context48.next = 12;
4083
4094
  return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0))), CheckoutErrorType.OrderCreationFailed);
4084
- case 10:
4095
+ case 12:
4085
4096
  case "end":
4086
4097
  return _context48.stop();
4087
4098
  }
4088
- }, _callee48, this, [[0, 5]]);
4099
+ }, _callee48, this, [[0, 7]]);
4089
4100
  }));
4090
4101
  function syncOrderToBackend() {
4091
4102
  return _syncOrderToBackend.apply(this, arguments);
@@ -172,6 +172,8 @@ export interface LocalOrderData {
172
172
  surcharges?: any[];
173
173
  /** 商店折扣金额 */
174
174
  shop_discount?: number;
175
+ /** 税费金额 */
176
+ tax?: number;
175
177
  }
176
178
  /**
177
179
  * 本地预订项
@@ -632,6 +634,7 @@ export interface CheckoutModuleAPI extends Module {
632
634
  message?: string;
633
635
  orderId?: string;
634
636
  orderUuid?: string;
637
+ response?: any;
635
638
  }>;
636
639
  /**
637
640
  * 检查订单是否需要手动同步(异步版本)
@@ -704,6 +707,7 @@ export interface CheckoutModuleAPI extends Module {
704
707
  message?: string;
705
708
  orderId?: string;
706
709
  orderUuid?: string;
710
+ response?: any;
707
711
  }>;
708
712
  /**
709
713
  * 通过订单ID编辑订单备注
@@ -88,7 +88,14 @@ var WalletPassPaymentImpl = class {
88
88
  * 内部生成参数,然后调用标准的初始化流程
89
89
  */
90
90
  async initializeWalletDataFromBusinessAsync(businessData) {
91
+ var _a, _b;
91
92
  const startTime = Date.now();
93
+ if (Number(((_a = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _a.totalAmount) || 0) <= 0 || Number(((_b = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _b.subTotal) || 0) <= 0) {
94
+ return {
95
+ walletRecommendList: [],
96
+ userIdentificationCodes: []
97
+ };
98
+ }
92
99
  this.emitEvent(import_types.WalletPassHooks.OnWalletInitializationStarted, {
93
100
  businessData,
94
101
  startTime
@@ -276,6 +276,7 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
276
276
  message?: string;
277
277
  orderId?: string;
278
278
  orderUuid?: string;
279
+ response?: any;
279
280
  }>;
280
281
  /**
281
282
  * 获取当前订单备注
@@ -319,6 +320,7 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
319
320
  message?: string;
320
321
  orderId?: string;
321
322
  orderUuid?: string;
323
+ response?: any;
322
324
  }>;
323
325
  /**
324
326
  * 获取当前商店折扣金额
@@ -440,7 +442,7 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
440
442
  *
441
443
  * @param isManual 是否为手动同步,默认为 false
442
444
  * @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
443
- * @returns 后端返回的真实订单ID
445
+ * @returns 包含订单ID、UUID和完整后端响应的对象
444
446
  */
445
447
  private syncOrderToBackendWithReturn;
446
448
  private syncOrderToBackend;
@@ -200,7 +200,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
200
200
  * 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
201
201
  */
202
202
  async createLocalOrderAsync(params) {
203
- var _a, _b, _c, _d, _e, _f;
203
+ var _a, _b, _c, _d, _e, _f, _g, _h;
204
204
  try {
205
205
  await this.resetStoreStateAsync();
206
206
  await this.setStatus(import_types.CheckoutStatus.CreatingOrder);
@@ -218,6 +218,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
218
218
  params.orderData.surcharge_fee = (_b = (_a = params.totalInfo) == null ? void 0 : _a.total) == null ? void 0 : _b.otherAmount;
219
219
  params.orderData.surcharges = (_d = (_c = params.totalInfo) == null ? void 0 : _c.total) == null ? void 0 : _d.surcharge;
220
220
  params.orderData.shop_discount = (_f = (_e = params.totalInfo) == null ? void 0 : _e.total) == null ? void 0 : _f.shopDiscount;
221
+ params.orderData.tax = (_h = (_g = params.totalInfo) == null ? void 0 : _g.total) == null ? void 0 : _h.tax;
221
222
  this.store.localOrderData = params.orderData;
222
223
  this.store.cartSummary = params.cartSummary;
223
224
  const customerInfo = {
@@ -981,10 +982,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
981
982
  if (isEftposPayment) {
982
983
  console.log("[Checkout] 检测到 EFTPOS 支付,立即同步订单到后端...");
983
984
  try {
984
- await this.syncOrderToBackendWithReturn(true);
985
+ const syncResult = await this.syncOrderToBackendWithReturn(true);
985
986
  console.log("[Checkout] EFTPOS 支付后订单同步完成 (已标记为手动同步):", {
986
- 订单ID: this.store.currentOrder.order_id,
987
- 是否已同步: this.store.isOrderSynced
987
+ 订单ID: syncResult.orderId,
988
+ 是否已同步: this.store.isOrderSynced,
989
+ 后端响应: syncResult.response
988
990
  });
989
991
  } catch (error) {
990
992
  console.error("[Checkout] EFTPOS 支付后订单同步失败:", error);
@@ -1376,37 +1378,32 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1376
1378
  totalAmount: this.store.currentOrder.total_amount,
1377
1379
  remainingAmount: await this.calculateRemainingAmountAsync()
1378
1380
  });
1379
- const realOrderId = await this.syncOrderToBackendWithReturn(true);
1381
+ const syncResult = await this.syncOrderToBackendWithReturn(true);
1380
1382
  console.log("[Checkout] 手动同步订单完成:", {
1381
1383
  orderUuid,
1384
+ syncResult,
1382
1385
  oldOrderId,
1383
- realOrderId,
1386
+ realOrderId: syncResult.orderId,
1384
1387
  isOrderSynced: this.store.isOrderSynced
1385
1388
  });
1386
1389
  const finalOrderId = this.store.currentOrder.order_id;
1387
1390
  const finalIsVirtual = this.isVirtualOrderId(finalOrderId);
1388
1391
  console.log("[Checkout] manualSyncOrderAsync 最终状态验证:", {
1389
- 返回的订单ID: realOrderId,
1392
+ 返回的订单ID: syncResult.orderId,
1390
1393
  存储的订单ID: finalOrderId,
1391
1394
  存储的ID是否虚拟: finalIsVirtual,
1392
- 是否一致: realOrderId === finalOrderId,
1395
+ 是否一致: syncResult.orderId === finalOrderId,
1393
1396
  同步状态: this.store.isOrderSynced
1394
1397
  });
1395
1398
  if (finalIsVirtual) {
1396
1399
  console.error("[Checkout] 严重警告:手动同步完成后订单ID仍为虚拟ID!");
1397
1400
  }
1398
- if (realOrderId !== finalOrderId) {
1401
+ if (syncResult.orderId !== finalOrderId) {
1399
1402
  console.error(
1400
1403
  "[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!"
1401
1404
  );
1402
1405
  }
1403
- return {
1404
- success: true,
1405
- message: "订单同步成功",
1406
- orderId: realOrderId,
1407
- // 直接返回从后端获取的真实订单ID
1408
- orderUuid
1409
- };
1406
+ return syncResult;
1410
1407
  } catch (error) {
1411
1408
  console.error("[Checkout] 手动同步订单失败:", error);
1412
1409
  const errorMessage = error instanceof Error ? error.message : "同步失败";
@@ -1566,29 +1563,31 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1566
1563
  const allPaymentItems = await this.payment.getPaymentItemsAsync(
1567
1564
  this.store.currentOrder.uuid
1568
1565
  );
1569
- const realOrderId = await this.syncOrderToBackendWithReturn(
1566
+ const syncResult = await this.syncOrderToBackendWithReturn(
1570
1567
  false,
1571
1568
  allPaymentItems
1572
1569
  );
1573
1570
  console.log("[Checkout] 保存订单完成:", {
1574
1571
  orderUuid,
1575
1572
  oldOrderId: currentOrderId,
1576
- realOrderId,
1573
+ syncResult,
1574
+ realOrderId: syncResult.orderId,
1577
1575
  isOrderSynced: this.store.isOrderSynced,
1578
1576
  filteredPaymentsCount: allPaymentItems.length
1579
1577
  });
1580
1578
  const finalOrderId = this.store.currentOrder.order_id;
1581
1579
  console.log("[Checkout] saveForLaterPaymentAsync 最终状态验证:", {
1582
- 返回的订单ID: realOrderId,
1580
+ 返回的订单ID: syncResult.orderId,
1583
1581
  存储的订单ID: finalOrderId,
1584
- 是否一致: realOrderId === finalOrderId,
1582
+ 是否一致: syncResult.orderId === finalOrderId,
1585
1583
  同步状态: this.store.isOrderSynced
1586
1584
  });
1587
1585
  return {
1588
1586
  success: true,
1589
1587
  message: "订单保存成功,可稍后继续支付",
1590
- orderId: realOrderId,
1591
- orderUuid
1588
+ orderId: syncResult.orderId,
1589
+ orderUuid,
1590
+ response: syncResult.response
1592
1591
  };
1593
1592
  } catch (error) {
1594
1593
  console.error("[Checkout] 保存订单失败:", error);
@@ -2211,7 +2210,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2211
2210
  *
2212
2211
  * @param isManual 是否为手动同步,默认为 false
2213
2212
  * @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
2214
- * @returns 后端返回的真实订单ID
2213
+ * @returns 包含订单ID、UUID和完整后端响应的对象
2215
2214
  */
2216
2215
  async syncOrderToBackendWithReturn(isManual = false, customPaymentItems) {
2217
2216
  var _a, _b, _c, _d, _e, _f;
@@ -2312,6 +2311,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2312
2311
  deposit_amount: ((_d = this.store.currentOrder) == null ? void 0 : _d.deposit_amount) || "0.00",
2313
2312
  // surcharge_fee: this.otherParams.surcharge_fee,
2314
2313
  // surcharges: ,
2314
+ product_tax_fee: this.store.localOrderData.tax,
2315
2315
  note: this.store.localOrderData.shop_note
2316
2316
  // deposit_amount:
2317
2317
  };
@@ -2490,11 +2490,18 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2490
2490
  "[Checkout] 警告:订单创建后,当前订单ID仍然是虚拟ID,可能存在问题"
2491
2491
  );
2492
2492
  }
2493
- return realOrderId;
2493
+ return {
2494
+ success: true,
2495
+ message: `订单${operation}成功`,
2496
+ orderId: realOrderId,
2497
+ orderUuid: this.store.currentOrder.uuid,
2498
+ response: checkoutResponse
2499
+ };
2494
2500
  }
2495
2501
  async syncOrderToBackend() {
2496
2502
  try {
2497
- await this.syncOrderToBackendWithReturn(false);
2503
+ const syncResult = await this.syncOrderToBackendWithReturn(false);
2504
+ console.log("[Checkout] 自动同步订单完成:", syncResult);
2498
2505
  } catch (error) {
2499
2506
  console.error("[Checkout] 同步订单到后端失败:", error);
2500
2507
  await this.handleError(
@@ -172,6 +172,8 @@ export interface LocalOrderData {
172
172
  surcharges?: any[];
173
173
  /** 商店折扣金额 */
174
174
  shop_discount?: number;
175
+ /** 税费金额 */
176
+ tax?: number;
175
177
  }
176
178
  /**
177
179
  * 本地预订项
@@ -632,6 +634,7 @@ export interface CheckoutModuleAPI extends Module {
632
634
  message?: string;
633
635
  orderId?: string;
634
636
  orderUuid?: string;
637
+ response?: any;
635
638
  }>;
636
639
  /**
637
640
  * 检查订单是否需要手动同步(异步版本)
@@ -704,6 +707,7 @@ export interface CheckoutModuleAPI extends Module {
704
707
  message?: string;
705
708
  orderId?: string;
706
709
  orderUuid?: string;
710
+ response?: any;
707
711
  }>;
708
712
  /**
709
713
  * 通过订单ID编辑订单备注
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.249",
4
+ "version": "0.0.251",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",