@pisell/pisellos 0.0.235 → 0.0.237

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.
@@ -96,6 +96,23 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
96
96
  await this.handlePaymentError(data);
97
97
  }
98
98
  });
99
+ this.core.effects.on(
100
+ import_types2.PaymentHooks.OnPaymentMethodsLoaded,
101
+ async (methods) => {
102
+ console.log("[Checkout] 收到支付方式加载完成事件:", methods.length);
103
+ this.store.paymentMethods = methods;
104
+ }
105
+ );
106
+ this.core.effects.on(
107
+ import_types2.PaymentHooks.OnPaymentMethodsChanged,
108
+ async (data) => {
109
+ console.log("[Checkout] 收到支付方式变更事件:", {
110
+ oldCount: data.oldMethods.length,
111
+ newCount: data.newMethods.length
112
+ });
113
+ this.store.paymentMethods = data.newMethods;
114
+ }
115
+ );
99
116
  }
100
117
  /**
101
118
  * 初始化结账流程
@@ -120,7 +137,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
120
137
  }
121
138
  }
122
139
  getProductListByOrder() {
123
- var _a;
140
+ var _a, _b, _c, _d, _e;
124
141
  if (!this.store.currentOrder) {
125
142
  return [];
126
143
  }
@@ -129,15 +146,21 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
129
146
  return pre + (item.amount || 0);
130
147
  }, 0);
131
148
  };
132
- const productList = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data.bookings.map(
149
+ const productList = ((_b = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data.bookings) == null ? void 0 : _b.map(
133
150
  (item) => ({
134
151
  product_id: item.product.product_id,
135
152
  product_variant_id: item.product.product_variant_id,
136
153
  quantity: item.product.num,
137
154
  selling_price: item.product.price - (item.product.discount_amount || 0) - getDiscountListAmount(item.product.discount_list)
138
155
  })
139
- );
140
- return productList;
156
+ )) || [];
157
+ const relationProducts = ((_e = (_d = (_c = this.store.currentOrder.order_info) == null ? void 0 : _c.original_order_data) == null ? void 0 : _d.relation_products) == null ? void 0 : _e.map((item) => ({
158
+ product_id: item.product_id,
159
+ product_variant_id: item.product_variant_id,
160
+ quantity: item.num,
161
+ selling_price: item.source_product_price
162
+ }))) || [];
163
+ return [...productList, ...relationProducts];
141
164
  }
142
165
  async initWalletData(params) {
143
166
  var _a, _b, _c;
@@ -160,7 +183,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
160
183
  }
161
184
  /**
162
185
  * 创建本地订单 (前端模拟下单流程)
163
- *
186
+ *
164
187
  * 此方法用于在前端模拟整个下单流程,创建一个本地的虚拟订单。
165
188
  * 用户在购物车点击下单时,会把购物车参数传递给此方法,
166
189
  * 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
@@ -168,6 +191,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
168
191
  async createLocalOrderAsync(params) {
169
192
  var _a, _b, _c, _d;
170
193
  try {
194
+ await this.resetStoreStateAsync();
171
195
  await this.setStatus(import_types.CheckoutStatus.CreatingOrder);
172
196
  const validation = await this.validateLocalOrderData(params.orderData);
173
197
  if (!validation.valid) {
@@ -233,7 +257,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
233
257
  });
234
258
  return paymentOrder;
235
259
  } catch (error) {
236
- await this.handleError(error, import_types.CheckoutErrorType.OrderCreationFailed);
260
+ await this.handleError(
261
+ error,
262
+ import_types.CheckoutErrorType.OrderCreationFailed
263
+ );
237
264
  await this.core.effects.emit(import_types.CheckoutHooks.OnOrderCreationFailed, {
238
265
  error: this.store.lastError,
239
266
  timestamp: Date.now()
@@ -243,7 +270,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
243
270
  }
244
271
  /**
245
272
  * 手动下单 (根据虚拟订单生成实际订单)
246
- *
273
+ *
247
274
  * 使用当前存储的本地订单数据调用 Order 模块创建真实订单
248
275
  */
249
276
  async placeOrderAsync(params = {}) {
@@ -310,7 +337,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
310
337
  errorMessage = error.message;
311
338
  }
312
339
  console.error("[Checkout] 手动下单失败:", errorMessage);
313
- await this.handleError(error, import_types.CheckoutErrorType.OrderCreationFailed);
340
+ await this.handleError(
341
+ error,
342
+ import_types.CheckoutErrorType.OrderCreationFailed
343
+ );
314
344
  return {
315
345
  success: false,
316
346
  error: errorMessage
@@ -359,7 +389,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
359
389
  console.log("[Checkout] 订单创建成功:", paymentOrder.id);
360
390
  return paymentOrder;
361
391
  } catch (error) {
362
- await this.handleError(error, import_types.CheckoutErrorType.OrderCreationFailed);
392
+ await this.handleError(
393
+ error,
394
+ import_types.CheckoutErrorType.OrderCreationFailed
395
+ );
363
396
  await this.core.effects.emit(import_types.CheckoutHooks.OnOrderCreationFailed, {
364
397
  error: this.store.lastError,
365
398
  timestamp: Date.now()
@@ -455,6 +488,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
455
488
  timestamp: Date.now()
456
489
  });
457
490
  console.log("[Checkout] 结账流程完成:", order.id);
491
+ await this.resetStoreStateAsync();
458
492
  return {
459
493
  success: true,
460
494
  orderId: String(order.id)
@@ -470,7 +504,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
470
504
  async cancelCheckoutAsync() {
471
505
  try {
472
506
  if (this.store.currentOrder) {
473
- await this.payment.deletePaymentOrderAsync(this.store.currentOrder.uuid);
507
+ await this.payment.deletePaymentOrderAsync(
508
+ this.store.currentOrder.uuid
509
+ );
474
510
  this.store.currentOrder = void 0;
475
511
  }
476
512
  this.store.localOrderData = void 0;
@@ -523,21 +559,26 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
523
559
  * 获取可用支付方式
524
560
  */
525
561
  async getAvailablePaymentMethodsAsync() {
526
- if (this.store.paymentMethods.length === 0) {
527
- console.log("[Checkout] 支付方式缓存为空,重新加载...");
528
- await this.preloadPaymentMethods();
529
- }
530
- return this.store.paymentMethods;
562
+ return await this.getPaymentMethodsAsync();
531
563
  }
532
564
  /**
533
565
  * 刷新支付方式缓存
534
- *
566
+ *
535
567
  * 强制重新从服务器获取支付方式列表,更新本地缓存
536
568
  */
537
569
  async refreshPaymentMethodsAsync() {
538
570
  console.log("[Checkout] 强制刷新支付方式缓存...");
539
- await this.preloadPaymentMethods();
540
- return this.store.paymentMethods;
571
+ try {
572
+ const methods = await this.payment.getPayMethodListAsync();
573
+ this.store.paymentMethods = methods;
574
+ console.log(
575
+ `[Checkout] 强制刷新完成,获取到 ${methods.length} 种支付方式`
576
+ );
577
+ return methods;
578
+ } catch (error) {
579
+ console.error("[Checkout] 强制刷新支付方式失败:", error);
580
+ return this.store.paymentMethods;
581
+ }
541
582
  }
542
583
  /**
543
584
  * 获取订单原始数据
@@ -548,7 +589,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
548
589
  }
549
590
  /**
550
591
  * 获取当前订单基础信息
551
- *
592
+ *
552
593
  * 返回当前订单的基础信息,包括订单状态、金额、支付状态等
553
594
  */
554
595
  getCurrentOrderInfo() {
@@ -593,7 +634,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
593
634
  }
594
635
  /**
595
636
  * 获取当前订单的支付项
596
- *
637
+ *
597
638
  * 返回当前订单的所有支付项,包括活跃和已撤销的支付项
598
639
  */
599
640
  async getCurrentOrderPaymentItemsAsync() {
@@ -607,7 +648,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
607
648
  orderUuid: currentOrder.uuid,
608
649
  orderId: currentOrder.order_id
609
650
  });
610
- const paymentItems = await this.payment.getPaymentItemsAsync(currentOrder.uuid);
651
+ const paymentItems = await this.payment.getPaymentItemsAsync(
652
+ currentOrder.uuid
653
+ );
611
654
  console.log("[Checkout] 成功获取支付项:", {
612
655
  orderUuid: currentOrder.uuid,
613
656
  paymentItemCount: paymentItems.length,
@@ -662,7 +705,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
662
705
  }
663
706
  break;
664
707
  default:
665
- console.warn("[Checkout] 无法重试此类型的错误:", this.store.lastError.type);
708
+ console.warn(
709
+ "[Checkout] 无法重试此类型的错误:",
710
+ this.store.lastError.type
711
+ );
666
712
  }
667
713
  }
668
714
  } catch (error) {
@@ -695,9 +741,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
695
741
  }
696
742
  /**
697
743
  * 替换本地订单ID为真实订单ID
698
- *
744
+ *
699
745
  * 当后端订单创建完成后,调用此方法将本地虚拟订单ID替换为真实订单ID
700
- *
746
+ *
701
747
  * @param newOrderId 后端返回的真实订单ID
702
748
  * @returns 更新后的订单对象,如果当前没有订单则返回null
703
749
  */
@@ -733,9 +779,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
733
779
  }
734
780
  /**
735
781
  * 设置自定义支付金额
736
- *
782
+ *
737
783
  * 允许UI自定义本次支付的金额,通常用于部分支付或调整支付金额场景
738
- *
784
+ *
739
785
  * @param amount 自定义支付金额,必须是有效的数字字符串
740
786
  */
741
787
  async setStateAmountAsync(amount) {
@@ -771,7 +817,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
771
817
  }
772
818
  /**
773
819
  * 获取当前自定义支付金额
774
- *
820
+ *
775
821
  * @returns 当前设置的自定义支付金额
776
822
  */
777
823
  getStateAmount() {
@@ -779,7 +825,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
779
825
  }
780
826
  /**
781
827
  * 刷新 stateAmount 为当前剩余未支付金额
782
- *
828
+ *
783
829
  * UI 可以调用此方法来主动刷新支付金额状态
784
830
  */
785
831
  async refreshStateAmountAsync() {
@@ -787,9 +833,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
787
833
  }
788
834
  /**
789
835
  * 获取购物车小计数据
790
- *
836
+ *
791
837
  * 返回当前结账流程中的购物车小计项数据,包含各种费用明细
792
- *
838
+ *
793
839
  * @returns 购物车小计数据数组,如果没有则返回 null
794
840
  */
795
841
  getCartSummary() {
@@ -799,15 +845,19 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
799
845
  }
800
846
  console.log("[Checkout] 获取购物车小计数据:", {
801
847
  itemCount: this.store.cartSummary.length,
802
- items: this.store.cartSummary.map((item) => ({ key: item.key, value: item.value, label: item.label }))
848
+ items: this.store.cartSummary.map((item) => ({
849
+ key: item.key,
850
+ value: item.value,
851
+ label: item.label
852
+ }))
803
853
  });
804
854
  return [...this.store.cartSummary];
805
855
  }
806
856
  /**
807
857
  * 获取提取的金额详细信息
808
- *
858
+ *
809
859
  * 从当前的购物车小计数据中提取结构化的金额信息
810
- *
860
+ *
811
861
  * @returns 提取的金额信息对象,如果没有小计数据则返回 null
812
862
  */
813
863
  getExtractedAmountInfo() {
@@ -815,25 +865,45 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
815
865
  console.warn("[Checkout] 没有可用的购物车小计数据,无法提取金额信息");
816
866
  return null;
817
867
  }
818
- const extractedInfo = this.extractAmountFromCartSummary(this.store.cartSummary);
868
+ const extractedInfo = this.extractAmountFromCartSummary(
869
+ this.store.cartSummary
870
+ );
819
871
  console.log("[Checkout] 获取提取的金额信息:", extractedInfo);
820
872
  return extractedInfo;
821
873
  }
822
874
  /**
823
875
  * 获取支付方式列表
824
- *
825
- * 直接调用 Payment 模块的 getPayMethodListAsync 方法
826
- *
876
+ *
877
+ * 优先使用 store 中的缓存数据,避免重复接口调用。
878
+ * 如果 store 中没有数据,则调用 Payment 模块的方法获取。
879
+ *
827
880
  * @returns 支付方式列表
828
881
  */
829
882
  async getPaymentMethodsAsync() {
830
- return await this.payment.getPayMethodListAsync();
883
+ if (this.store.paymentMethods && this.store.paymentMethods.length > 0) {
884
+ console.log(
885
+ `[Checkout] 使用缓存的支付方式数据,共 ${this.store.paymentMethods.length} 种`
886
+ );
887
+ return this.store.paymentMethods;
888
+ }
889
+ console.log("[Checkout] store 中无缓存,从 Payment 模块获取支付方式...");
890
+ try {
891
+ const methods = await this.payment.getPayMethodListAsync();
892
+ this.store.paymentMethods = methods;
893
+ console.log(
894
+ `[Checkout] 从 Payment 模块获取到 ${methods.length} 种支付方式,已更新缓存`
895
+ );
896
+ return methods;
897
+ } catch (error) {
898
+ console.error("[Checkout] 获取支付方式失败:", error);
899
+ return [];
900
+ }
831
901
  }
832
902
  /**
833
903
  * 为当前订单添加支付项
834
- *
904
+ *
835
905
  * 向当前活跃订单添加一个支付项,支付项包含支付方式信息和金额
836
- *
906
+ *
837
907
  * @param paymentItem 支付项数据
838
908
  * @throws 当前没有活跃订单时抛出错误
839
909
  */
@@ -881,9 +951,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
881
951
  }
882
952
  /**
883
953
  * 删除当前订单的支付项
884
- *
954
+ *
885
955
  * 从当前活跃订单中删除指定的支付项,支付项将被标记为已撤销状态
886
- *
956
+ *
887
957
  * @param paymentUuid 要删除的支付项UUID
888
958
  * @throws 当前没有活跃订单时抛出错误
889
959
  * @throws 支付项不存在时抛出错误
@@ -925,17 +995,25 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
925
995
  console.log("[Checkout] Payment模块删除完成");
926
996
  const currentOrderId = this.store.currentOrder.order_id;
927
997
  const isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
928
- const updatedOrder = await this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
998
+ const updatedOrder = await this.payment.getPaymentOrderByUuidAsync(
999
+ this.store.currentOrder.uuid
1000
+ );
929
1001
  if (updatedOrder) {
930
1002
  if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
931
- console.warn("[Checkout] deletePaymentItemAsync: 检测到订单ID回退,保护真实订单ID:", {
932
- 当前真实ID: currentOrderId,
933
- 获取到的虚拟ID: updatedOrder.order_id
934
- });
1003
+ console.warn(
1004
+ "[Checkout] deletePaymentItemAsync: 检测到订单ID回退,保护真实订单ID:",
1005
+ {
1006
+ 当前真实ID: currentOrderId,
1007
+ 获取到的虚拟ID: updatedOrder.order_id
1008
+ }
1009
+ );
935
1010
  updatedOrder.order_id = currentOrderId;
936
1011
  }
937
1012
  this.store.currentOrder = updatedOrder;
938
- console.log("[Checkout] 订单数据已同步,当前支付项数量:", updatedOrder.payment.length);
1013
+ console.log(
1014
+ "[Checkout] 订单数据已同步,当前支付项数量:",
1015
+ updatedOrder.payment.length
1016
+ );
939
1017
  }
940
1018
  await this.updateStateAmountToRemaining();
941
1019
  await this.core.effects.emit(import_types.CheckoutHooks.OnPaymentStarted, {
@@ -954,10 +1032,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
954
1032
  }
955
1033
  /**
956
1034
  * 批量更新当前订单的代金券支付项(覆盖更新)
957
- *
1035
+ *
958
1036
  * 删除所有现有的代金券支付项,然后添加新的代金券支付项。
959
1037
  * 这是一个覆盖式更新操作,确保代金券支付项的一致性。
960
- *
1038
+ *
961
1039
  * @param voucherPaymentItems 新的代金券支付项列表,每个都必须包含 voucher_id
962
1040
  * @throws 当前没有活跃订单时抛出错误
963
1041
  * @throws 支付项缺少 voucher_id 时抛出错误
@@ -990,17 +1068,25 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
990
1068
  console.log("[Checkout] Payment模块批量更新完成");
991
1069
  const currentOrderId = this.store.currentOrder.order_id;
992
1070
  const isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
993
- const updatedOrder = await this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
1071
+ const updatedOrder = await this.payment.getPaymentOrderByUuidAsync(
1072
+ this.store.currentOrder.uuid
1073
+ );
994
1074
  if (updatedOrder) {
995
1075
  if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
996
- console.warn("[Checkout] updateVoucherPaymentItemsAsync: 检测到订单ID回退,保护真实订单ID:", {
997
- 当前真实ID: currentOrderId,
998
- 获取到的虚拟ID: updatedOrder.order_id
999
- });
1076
+ console.warn(
1077
+ "[Checkout] updateVoucherPaymentItemsAsync: 检测到订单ID回退,保护真实订单ID:",
1078
+ {
1079
+ 当前真实ID: currentOrderId,
1080
+ 获取到的虚拟ID: updatedOrder.order_id
1081
+ }
1082
+ );
1000
1083
  updatedOrder.order_id = currentOrderId;
1001
1084
  }
1002
1085
  this.store.currentOrder = updatedOrder;
1003
- console.log("[Checkout] 订单数据已同步,当前支付项数量:", updatedOrder.payment.length);
1086
+ console.log(
1087
+ "[Checkout] 订单数据已同步,当前支付项数量:",
1088
+ updatedOrder.payment.length
1089
+ );
1004
1090
  const voucherItems = updatedOrder.payment.filter(
1005
1091
  (payment) => payment.voucher_id && payment.status !== "voided"
1006
1092
  );
@@ -1030,9 +1116,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1030
1116
  }
1031
1117
  /**
1032
1118
  * 修改当前订单的定金状态
1033
- *
1119
+ *
1034
1120
  * 更新当前订单的 is_deposit 字段,用于标识订单是否为定金订单
1035
- *
1121
+ *
1036
1122
  * @param isDeposit 定金状态 (1: 定金订单, 0: 全款订单)
1037
1123
  * @throws 当前没有活跃订单时抛出错误
1038
1124
  */
@@ -1069,7 +1155,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1069
1155
  updateParams.deposit_amount = "0.00";
1070
1156
  console.log("[Checkout] 订单从定金改为全款,清空定金金额");
1071
1157
  }
1072
- await this.payment.updateOrderAsync(this.store.currentOrder.uuid, updateParams);
1158
+ await this.payment.updateOrderAsync(
1159
+ this.store.currentOrder.uuid,
1160
+ updateParams
1161
+ );
1073
1162
  this.store.currentOrder = {
1074
1163
  ...this.store.currentOrder,
1075
1164
  ...updateParams
@@ -1087,15 +1176,18 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1087
1176
  });
1088
1177
  } catch (error) {
1089
1178
  console.error("[Checkout] 更新订单定金状态失败:", error);
1090
- await this.handleError(error, import_types.CheckoutErrorType.ValidationFailed);
1179
+ await this.handleError(
1180
+ error,
1181
+ import_types.CheckoutErrorType.ValidationFailed
1182
+ );
1091
1183
  throw error;
1092
1184
  }
1093
1185
  }
1094
1186
  /**
1095
1187
  * 更新当前订单的客户信息
1096
- *
1188
+ *
1097
1189
  * 更新当前订单关联的客户信息,用于标识订单的所属客户
1098
- *
1190
+ *
1099
1191
  * @param customer 客户信息 (customer_id 和/或 customer_name)
1100
1192
  * @throws 当前没有活跃订单时抛出错误
1101
1193
  */
@@ -1120,16 +1212,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1120
1212
  this.store.localOrderData.customer_id = customer.customer_id;
1121
1213
  this.store.localOrderData.customer_name = customer.customer_name;
1122
1214
  }
1123
- console.log("[Checkout] 订单客户信息更新成功:", this.store.currentCustomer);
1215
+ console.log(
1216
+ "[Checkout] 订单客户信息更新成功:",
1217
+ this.store.currentCustomer
1218
+ );
1124
1219
  } catch (error) {
1125
1220
  console.error("[Checkout] 更新订单客户信息失败:", error);
1126
- await this.handleError(error, import_types.CheckoutErrorType.ValidationFailed);
1221
+ await this.handleError(
1222
+ error,
1223
+ import_types.CheckoutErrorType.ValidationFailed
1224
+ );
1127
1225
  throw error;
1128
1226
  }
1129
1227
  }
1130
1228
  /**
1131
1229
  * 获取当前订单的客户信息
1132
- *
1230
+ *
1133
1231
  * @returns 当前客户信息,如果没有则返回 null
1134
1232
  */
1135
1233
  getCurrentCustomer() {
@@ -1137,7 +1235,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1137
1235
  }
1138
1236
  /**
1139
1237
  * 检查订单是否需要手动同步(异步版本)
1140
- *
1238
+ *
1141
1239
  * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
1142
1240
  * 从 Payment 模块获取最新的支付项数据
1143
1241
  */
@@ -1181,7 +1279,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1181
1279
  }
1182
1280
  /**
1183
1281
  * 手动同步订单到后端
1184
- *
1282
+ *
1185
1283
  * 用于强制同步订单到后端,特别适用于纯代金券支付完成的订单
1186
1284
  */
1187
1285
  async manualSyncOrderAsync() {
@@ -1224,7 +1322,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1224
1322
  console.error("[Checkout] 严重警告:手动同步完成后订单ID仍为虚拟ID!");
1225
1323
  }
1226
1324
  if (realOrderId !== finalOrderId) {
1227
- console.error("[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!");
1325
+ console.error(
1326
+ "[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!"
1327
+ );
1228
1328
  }
1229
1329
  return {
1230
1330
  success: true,
@@ -1245,7 +1345,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1245
1345
  }
1246
1346
  /**
1247
1347
  * 获取当前订单备注
1248
- *
1348
+ *
1249
1349
  * @returns 当前订单的备注内容,如果没有则返回空字符串
1250
1350
  */
1251
1351
  getOrderNote() {
@@ -1257,7 +1357,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1257
1357
  }
1258
1358
  /**
1259
1359
  * 获取当前订单ID
1260
- *
1360
+ *
1261
1361
  * @returns 当前订单的ID,如果没有订单则返回null
1262
1362
  */
1263
1363
  getCurrentOrderId() {
@@ -1268,7 +1368,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1268
1368
  }
1269
1369
  /**
1270
1370
  * 获取当前订单是否已同步到后端
1271
- *
1371
+ *
1272
1372
  * @returns 当前订单是否已同步状态,如果没有订单则返回false
1273
1373
  */
1274
1374
  isCurrentOrderSynced() {
@@ -1286,9 +1386,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1286
1386
  }
1287
1387
  /**
1288
1388
  * 取消当前本地订单
1289
- *
1389
+ *
1290
1390
  * 只能取消未同步到后端的本地订单,如果订单已同步则不能取消
1291
- *
1391
+ *
1292
1392
  * @param cancelReason 取消原因(可选)
1293
1393
  * @returns 取消结果
1294
1394
  */
@@ -1368,7 +1468,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1368
1468
  }
1369
1469
  /**
1370
1470
  * 保存订单并稍后支付
1371
- *
1471
+ *
1372
1472
  * 将当前订单保存到后端,但排除代金券类支付项(voucher_id),
1373
1473
  * 适用于用户想要保存订单但稍后完成支付的场景
1374
1474
  */
@@ -1388,7 +1488,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1388
1488
  orderId: currentOrderId,
1389
1489
  totalAmount: this.store.currentOrder.total_amount
1390
1490
  });
1391
- const allPaymentItems = await this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
1491
+ const allPaymentItems = await this.payment.getPaymentItemsAsync(
1492
+ this.store.currentOrder.uuid
1493
+ );
1392
1494
  const filteredPaymentItems = allPaymentItems.filter(
1393
1495
  (payment) => !payment.voucher_id || payment.voucher_id.trim() === ""
1394
1496
  );
@@ -1411,7 +1513,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1411
1513
  amount: item.amount
1412
1514
  }))
1413
1515
  });
1414
- const realOrderId = await this.syncOrderToBackendWithReturn(false, filteredPaymentItems);
1516
+ const realOrderId = await this.syncOrderToBackendWithReturn(
1517
+ false,
1518
+ filteredPaymentItems
1519
+ );
1415
1520
  console.log("[Checkout] 保存订单完成:", {
1416
1521
  orderUuid,
1417
1522
  oldOrderId: currentOrderId,
@@ -1444,7 +1549,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1444
1549
  }
1445
1550
  /**
1446
1551
  * 获取当前商店折扣金额
1447
- *
1552
+ *
1448
1553
  * @returns 当前的商店折扣金额,如果没有则返回0
1449
1554
  */
1450
1555
  getShopDiscount() {
@@ -1453,7 +1558,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1453
1558
  return this.store.localOrderData.shop_discount;
1454
1559
  }
1455
1560
  if (this.store.cartSummary) {
1456
- const shopDiscountItem = this.store.cartSummary.find((item) => item.key === "shop_discount");
1561
+ const shopDiscountItem = this.store.cartSummary.find(
1562
+ (item) => item.key === "shop_discount"
1563
+ );
1457
1564
  if (shopDiscountItem) {
1458
1565
  return shopDiscountItem.value;
1459
1566
  }
@@ -1462,9 +1569,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1462
1569
  }
1463
1570
  /**
1464
1571
  * 更新订单商店折扣
1465
- *
1572
+ *
1466
1573
  * 同时更新cartSummary和localOrderData中的shop_discount值
1467
- *
1574
+ *
1468
1575
  * @param discountAmount 商店折扣金额
1469
1576
  */
1470
1577
  async updateShopDiscountAsync(discountAmount) {
@@ -1477,7 +1584,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1477
1584
  newDiscount: discountAmount
1478
1585
  });
1479
1586
  if (this.store.cartSummary) {
1480
- const shopDiscountItem = this.store.cartSummary.find((item) => item.key === "shop_discount");
1587
+ const shopDiscountItem = this.store.cartSummary.find(
1588
+ (item) => item.key === "shop_discount"
1589
+ );
1481
1590
  if (shopDiscountItem) {
1482
1591
  shopDiscountItem.value = discountAmount;
1483
1592
  console.log("[Checkout] cartSummary 中的商店折扣已更新");
@@ -1498,7 +1607,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1498
1607
  console.warn("[Checkout] localOrderData 不存在,无法更新商店折扣");
1499
1608
  }
1500
1609
  if (this.store.currentOrder && this.store.cartSummary) {
1501
- const updatedAmountInfo = this.extractAmountFromCartSummary(this.store.cartSummary);
1610
+ const updatedAmountInfo = this.extractAmountFromCartSummary(
1611
+ this.store.cartSummary
1612
+ );
1502
1613
  console.log("[Checkout] 重新计算订单金额:", updatedAmountInfo);
1503
1614
  this.store.currentOrder.total_amount = updatedAmountInfo.totalAmount;
1504
1615
  this.store.currentOrder.expect_amount = updatedAmountInfo.totalAmount;
@@ -1516,13 +1627,16 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1516
1627
  });
1517
1628
  } catch (error) {
1518
1629
  console.error("[Checkout] 更新商店折扣失败:", error);
1519
- await this.handleError(error, import_types.CheckoutErrorType.ValidationFailed);
1630
+ await this.handleError(
1631
+ error,
1632
+ import_types.CheckoutErrorType.ValidationFailed
1633
+ );
1520
1634
  throw error;
1521
1635
  }
1522
1636
  }
1523
1637
  /**
1524
1638
  * 更新订单备注
1525
- *
1639
+ *
1526
1640
  * @param note 订单备注内容
1527
1641
  */
1528
1642
  async updateOrderNoteAsync(note) {
@@ -1543,12 +1657,17 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1543
1657
  this.store.localOrderData.shop_note = note;
1544
1658
  if (this.store.currentOrder) {
1545
1659
  try {
1546
- const orderInPayment = await this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
1660
+ const orderInPayment = await this.payment.getPaymentOrderByUuidAsync(
1661
+ this.store.currentOrder.uuid
1662
+ );
1547
1663
  if (orderInPayment && orderInPayment.note !== void 0) {
1548
1664
  console.log("[Checkout] 同步备注到Payment模块的订单数据中");
1549
1665
  }
1550
1666
  } catch (syncError) {
1551
- console.warn("[Checkout] 同步备注到Payment模块失败,但本地更新成功:", syncError);
1667
+ console.warn(
1668
+ "[Checkout] 同步备注到Payment模块失败,但本地更新成功:",
1669
+ syncError
1670
+ );
1552
1671
  }
1553
1672
  }
1554
1673
  await this.core.effects.emit(import_types.CheckoutHooks.OnOrderNoteChanged, {
@@ -1563,7 +1682,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1563
1682
  });
1564
1683
  } catch (error) {
1565
1684
  console.error("[Checkout] 更新订单备注失败:", error);
1566
- await this.handleError(error, import_types.CheckoutErrorType.ValidationFailed);
1685
+ await this.handleError(
1686
+ error,
1687
+ import_types.CheckoutErrorType.ValidationFailed
1688
+ );
1567
1689
  throw error;
1568
1690
  }
1569
1691
  }
@@ -1629,7 +1751,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1629
1751
  import_types.CheckoutErrorType.PaymentFailed,
1630
1752
  data.error || "支付同步失败"
1631
1753
  );
1632
- await this.handleError(error instanceof Error ? error : new Error(String(error)), import_types.CheckoutErrorType.PaymentFailed);
1754
+ await this.handleError(
1755
+ error instanceof Error ? error : new Error(String(error)),
1756
+ import_types.CheckoutErrorType.PaymentFailed
1757
+ );
1633
1758
  await this.core.effects.emit(import_types.CheckoutHooks.OnPaymentFailed, {
1634
1759
  orderUuid: data.orderUuid,
1635
1760
  paymentMethodCode: "",
@@ -1647,6 +1772,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1647
1772
  * 验证本地订单数据
1648
1773
  */
1649
1774
  async validateLocalOrderData(orderData) {
1775
+ var _a;
1650
1776
  const errors = [];
1651
1777
  if (!orderData.type) {
1652
1778
  errors.push("订单类型不能为空");
@@ -1654,7 +1780,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1654
1780
  if (!orderData.platform) {
1655
1781
  errors.push("平台信息不能为空");
1656
1782
  }
1657
- if (!orderData.bookings || orderData.bookings.length === 0) {
1783
+ if ((!orderData.bookings || orderData.bookings.length === 0) && !((_a = orderData == null ? void 0 : orderData.relation_products) == null ? void 0 : _a.length)) {
1658
1784
  errors.push("预订信息不能为空");
1659
1785
  }
1660
1786
  if (orderData.bookings) {
@@ -1685,7 +1811,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1685
1811
  }
1686
1812
  /**
1687
1813
  * 格式化日期时间为 YYYY-MM-DD hh:mm:ss 格式
1688
- *
1814
+ *
1689
1815
  * @param date 要格式化的日期对象
1690
1816
  * @returns 格式化后的日期时间字符串
1691
1817
  */
@@ -1871,7 +1997,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1871
1997
  }
1872
1998
  /**
1873
1999
  * 检查订单支付是否完成
1874
- *
2000
+ *
1875
2001
  * 当剩余待付款金额 <= 0 时,触发订单支付完成事件
1876
2002
  */
1877
2003
  async checkOrderPaymentCompletion() {
@@ -1932,18 +2058,20 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1932
2058
  }
1933
2059
  /**
1934
2060
  * 判断支付方式是否需要同步订单到后端
1935
- *
2061
+ *
1936
2062
  * 现金支付(CASHMANUAL)和自定义支付不需要同步,其他支付方式需要同步
1937
- *
2063
+ *
1938
2064
  * @param paymentCode 支付方式代码
1939
- * @param paymentType 支付方式类型
2065
+ * @param paymentType 支付方式类型
1940
2066
  * @returns 是否需要同步订单
1941
2067
  */
1942
2068
  shouldSyncOrderForPayment(paymentCode, paymentType) {
1943
2069
  const codeUpper = (paymentCode == null ? void 0 : paymentCode.toUpperCase()) || "";
1944
2070
  const typeUpper = (paymentType == null ? void 0 : paymentType.toUpperCase()) || "";
1945
2071
  const cashIdentifiers = ["CASHMANUAL", "CASH", "MANUAL"];
1946
- if (cashIdentifiers.some((id) => codeUpper.includes(id) || typeUpper.includes(id))) {
2072
+ if (cashIdentifiers.some(
2073
+ (id) => codeUpper.includes(id) || typeUpper.includes(id)
2074
+ )) {
1947
2075
  return false;
1948
2076
  }
1949
2077
  if (paymentCode === import_types2.PaymentMethodType.Cash || paymentType === import_types2.PaymentMethodType.Cash) {
@@ -1956,12 +2084,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1956
2084
  }
1957
2085
  /**
1958
2086
  * 同步订单到后端
1959
- *
2087
+ *
1960
2088
  * 调用后端 /order/checkout 接口创建真实订单
1961
2089
  */
1962
2090
  /**
1963
2091
  * 判断订单ID是否为本地生成的虚拟ID
1964
- *
2092
+ *
1965
2093
  * @param orderId 订单ID
1966
2094
  * @returns true 表示是虚拟ID,false 表示是真实的后端ID
1967
2095
  */
@@ -1970,7 +2098,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1970
2098
  }
1971
2099
  /**
1972
2100
  * 同步订单到后端并返回真实订单ID
1973
- *
2101
+ *
1974
2102
  * @param isManual 是否为手动同步,默认为 false
1975
2103
  * @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
1976
2104
  * @returns 后端返回的真实订单ID
@@ -2052,18 +2180,23 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2052
2180
  // surcharge_fee: this.otherParams.surcharge_fee,
2053
2181
  // surcharges: ,
2054
2182
  note: this.store.localOrderData.shop_note
2055
- // deposit_amount:
2183
+ // deposit_amount:
2056
2184
  };
2057
2185
  if (isUpdateOperation) {
2058
2186
  if (this.isVirtualOrderId(currentOrderId)) {
2059
- console.error("[Checkout] 数据不一致警告:更新操作但订单ID仍为虚拟ID!", {
2060
- currentOrderId,
2061
- isOrderSynced: this.store.isOrderSynced,
2062
- reason,
2063
- orderUuid: this.store.currentOrder.uuid
2064
- });
2187
+ console.error(
2188
+ "[Checkout] 数据不一致警告:更新操作但订单ID仍为虚拟ID!",
2189
+ {
2190
+ currentOrderId,
2191
+ isOrderSynced: this.store.isOrderSynced,
2192
+ reason,
2193
+ orderUuid: this.store.currentOrder.uuid
2194
+ }
2195
+ );
2065
2196
  console.log("[Checkout] 尝试数据修复:暂时不包含order_id,让后端处理");
2066
- console.log("[Checkout] 注意:这次调用将作为创建操作处理,但后续会修复数据一致性");
2197
+ console.log(
2198
+ "[Checkout] 注意:这次调用将作为创建操作处理,但后续会修复数据一致性"
2199
+ );
2067
2200
  } else {
2068
2201
  orderParams.order_id = currentOrderId;
2069
2202
  console.log(`[Checkout] 更新订单操作,包含订单ID: ${currentOrderId}`);
@@ -2117,9 +2250,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2117
2250
  totalAmount: updatedOrder.total_amount
2118
2251
  });
2119
2252
  this.store.currentOrder = updatedOrder;
2120
- console.log("[Checkout] 订单ID替换成功,当前订单ID:", this.store.currentOrder.order_id);
2253
+ console.log(
2254
+ "[Checkout] 订单ID替换成功,当前订单ID:",
2255
+ this.store.currentOrder.order_id
2256
+ );
2121
2257
  } else {
2122
- console.error("[Checkout] Payment模块返回空订单,订单ID替换失败,开始手动替换");
2258
+ console.error(
2259
+ "[Checkout] Payment模块返回空订单,订单ID替换失败,开始手动替换"
2260
+ );
2123
2261
  const beforeManualUpdate = this.store.currentOrder.order_id;
2124
2262
  this.store.currentOrder.order_id = realOrderId;
2125
2263
  console.log("[Checkout] 手动设置订单ID:", {
@@ -2152,7 +2290,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2152
2290
  是否同步: this.store.isOrderSynced
2153
2291
  });
2154
2292
  if (finalIsVirtual && !isUpdateOperation) {
2155
- console.warn("[Checkout] 警告:订单创建后,当前订单ID仍然是虚拟ID,可能存在问题");
2293
+ console.warn(
2294
+ "[Checkout] 警告:订单创建后,当前订单ID仍然是虚拟ID,可能存在问题"
2295
+ );
2156
2296
  }
2157
2297
  return realOrderId;
2158
2298
  }
@@ -2162,7 +2302,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2162
2302
  } catch (error) {
2163
2303
  console.error("[Checkout] 同步订单到后端失败:", error);
2164
2304
  await this.handleError(
2165
- new Error(`订单同步失败: ${error instanceof Error ? error.message : String(error)}`),
2305
+ new Error(
2306
+ `订单同步失败: ${error instanceof Error ? error.message : String(error)}`
2307
+ ),
2166
2308
  import_types.CheckoutErrorType.OrderCreationFailed
2167
2309
  );
2168
2310
  }
@@ -2204,9 +2346,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2204
2346
  }
2205
2347
  /**
2206
2348
  * 通过订单ID编辑订单备注
2207
- *
2349
+ *
2208
2350
  * 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
2209
- *
2351
+ *
2210
2352
  * @param orderId 后端订单ID
2211
2353
  * @param note 新的订单备注
2212
2354
  * @returns 修改结果
@@ -2225,9 +2367,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2225
2367
  orderId
2226
2368
  };
2227
2369
  }
2228
- const response = await this.request.put(`/shop/order/order/${orderId}/note`, {
2229
- note
2230
- });
2370
+ const response = await this.request.put(
2371
+ `/shop/order/order/${orderId}/note`,
2372
+ {
2373
+ note
2374
+ }
2375
+ );
2231
2376
  console.log("[Checkout] 订单备注编辑响应:", {
2232
2377
  orderId,
2233
2378
  status: response.status,
@@ -2275,9 +2420,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2275
2420
  }
2276
2421
  /**
2277
2422
  * 发送客户支付链接邮件
2278
- *
2423
+ *
2279
2424
  * 向指定邮箱发送订单支付提醒邮件
2280
- *
2425
+ *
2281
2426
  * @param params 发送参数
2282
2427
  * @returns 发送结果
2283
2428
  */
@@ -2301,7 +2446,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2301
2446
  };
2302
2447
  }
2303
2448
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
2304
- const invalidEmails = params.emails.filter((email) => !emailRegex.test(email));
2449
+ const invalidEmails = params.emails.filter(
2450
+ (email) => !emailRegex.test(email)
2451
+ );
2305
2452
  if (invalidEmails.length > 0) {
2306
2453
  return {
2307
2454
  success: false,
@@ -2314,7 +2461,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2314
2461
  emails: params.emails
2315
2462
  };
2316
2463
  console.log("[Checkout] 发送支付链接邮件请求参数:", requestBody);
2317
- const response = await this.request.post("/order/batch-email", requestBody);
2464
+ const response = await this.request.post(
2465
+ "/order/batch-email",
2466
+ requestBody
2467
+ );
2318
2468
  console.log("[Checkout] 支付链接邮件发送响应:", {
2319
2469
  status: response.status,
2320
2470
  message: response.message,
@@ -2346,7 +2496,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2346
2496
  }
2347
2497
  /**
2348
2498
  * 金额舍入
2349
- *
2499
+ *
2350
2500
  * @param amount 原始金额
2351
2501
  * @returns 舍入结果详情,包含原始金额、舍入后金额和舍入差额
2352
2502
  */
@@ -2357,7 +2507,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2357
2507
  (_a = this.otherParams.order_rounding_setting) == null ? void 0 : _a.interval,
2358
2508
  (_b = this.otherParams.order_rounding_setting) == null ? void 0 : _b.type
2359
2509
  );
2360
- console.log(`[Checkout] 金额舍入完成 - 原始: ${result.originalAmount}, 舍入后: ${result.roundedAmount}, 差额: ${result.roundingDifference}`);
2510
+ console.log(
2511
+ `[Checkout] 金额舍入完成 - 原始: ${result.originalAmount}, 舍入后: ${result.roundedAmount}, 差额: ${result.roundingDifference}`
2512
+ );
2361
2513
  return result;
2362
2514
  }
2363
2515
  async destroy() {
@@ -2369,6 +2521,67 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2369
2521
  this.core.unregisterModule(this);
2370
2522
  console.log("[Checkout] 已销毁");
2371
2523
  }
2524
+ /**
2525
+ * 重置 store 状态
2526
+ *
2527
+ * 在创建新订单前调用,确保状态完全干净
2528
+ */
2529
+ async resetStoreStateAsync() {
2530
+ try {
2531
+ const prevOrderInfo = this.store.currentOrder ? {
2532
+ uuid: this.store.currentOrder.uuid,
2533
+ orderId: this.store.currentOrder.order_id
2534
+ } : null;
2535
+ console.log("[Checkout] 重置 store 状态,准备创建新订单", prevOrderInfo);
2536
+ this.store.currentOrder = void 0;
2537
+ this.store.localOrderData = void 0;
2538
+ this.store.cartSummary = void 0;
2539
+ this.store.stateAmount = "0.00";
2540
+ this.store.isOrderSynced = false;
2541
+ this.store.currentCustomer = void 0;
2542
+ this.store.lastError = void 0;
2543
+ this.store.cartItems = [];
2544
+ this.payment.wallet.clearAllCache();
2545
+ await this.setStatus(import_types.CheckoutStatus.Ready);
2546
+ await this.setStep(import_types.CheckoutStep.OrderConfirmation);
2547
+ console.log("[Checkout] Store 状态重置完成");
2548
+ if (prevOrderInfo) {
2549
+ await this.core.effects.emit(import_types.CheckoutHooks.OnOrderCleared, {
2550
+ previousOrder: prevOrderInfo,
2551
+ timestamp: Date.now()
2552
+ });
2553
+ }
2554
+ } catch (error) {
2555
+ console.error("[Checkout] 重置 store 状态失败:", error);
2556
+ }
2557
+ }
2558
+ /**
2559
+ * 手动清理已完成的订单状态(公开方法)
2560
+ *
2561
+ * 供UI层调用的公开方法,用于手动清理订单状态
2562
+ *
2563
+ * @returns 清理结果
2564
+ */
2565
+ async clearCompletedOrderAsync() {
2566
+ try {
2567
+ const prevOrderInfo = this.store.currentOrder ? {
2568
+ uuid: this.store.currentOrder.uuid,
2569
+ orderId: this.store.currentOrder.order_id
2570
+ } : null;
2571
+ await this.resetStoreStateAsync();
2572
+ return {
2573
+ success: true,
2574
+ message: prevOrderInfo ? "订单状态已成功清理" : "没有需要清理的订单状态",
2575
+ clearedOrder: prevOrderInfo
2576
+ };
2577
+ } catch (error) {
2578
+ console.error("[Checkout] 手动清理订单状态失败:", error);
2579
+ return {
2580
+ success: false,
2581
+ message: error instanceof Error ? error.message : "清理失败"
2582
+ };
2583
+ }
2584
+ }
2372
2585
  };
2373
2586
  // Annotate the CommonJS export names for ESM import in node:
2374
2587
  0 && (module.exports = {