@pisell/pisellos 0.0.233 → 0.0.235

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.
Files changed (37) hide show
  1. package/dist/modules/Order/index.d.ts +1 -1
  2. package/dist/modules/Order/index.js +1 -1
  3. package/dist/modules/Payment/index.d.ts +3 -3
  4. package/dist/modules/Payment/index.js +74 -10
  5. package/dist/modules/Payment/types.d.ts +24 -3
  6. package/dist/modules/Payment/types.js +9 -1
  7. package/dist/modules/Payment/utils.js +1 -1
  8. package/dist/modules/Payment/walletpass.d.ts +5 -2
  9. package/dist/modules/Payment/walletpass.js +63 -11
  10. package/dist/solution/BookingByStep/utils/timeslots.js +88 -38
  11. package/dist/solution/BookingTicket/index.d.ts +8 -0
  12. package/dist/solution/BookingTicket/index.js +27 -3
  13. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
  14. package/dist/solution/BookingTicket/utils/scan/handleScan.js +43 -28
  15. package/dist/solution/Checkout/index.d.ts +50 -7
  16. package/dist/solution/Checkout/index.js +890 -474
  17. package/dist/solution/Checkout/types.d.ts +69 -3
  18. package/dist/solution/Checkout/types.js +5 -0
  19. package/lib/modules/Order/index.d.ts +1 -1
  20. package/lib/modules/Order/index.js +1 -1
  21. package/lib/modules/Payment/index.d.ts +3 -3
  22. package/lib/modules/Payment/index.js +30 -5
  23. package/lib/modules/Payment/types.d.ts +24 -3
  24. package/lib/modules/Payment/types.js +1 -1
  25. package/lib/modules/Payment/utils.js +1 -1
  26. package/lib/modules/Payment/walletpass.d.ts +5 -2
  27. package/lib/modules/Payment/walletpass.js +30 -2
  28. package/lib/solution/BookingByStep/utils/timeslots.js +38 -3
  29. package/lib/solution/BookingTicket/index.d.ts +8 -0
  30. package/lib/solution/BookingTicket/index.js +23 -2
  31. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
  32. package/lib/solution/BookingTicket/utils/scan/handleScan.js +21 -14
  33. package/lib/solution/Checkout/index.d.ts +50 -7
  34. package/lib/solution/Checkout/index.js +267 -92
  35. package/lib/solution/Checkout/types.d.ts +69 -3
  36. package/lib/solution/Checkout/types.js +1 -0
  37. package/package.json +1 -1
@@ -508,8 +508,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
508
508
  async getCheckoutSummaryAsync() {
509
509
  var _a, _b;
510
510
  const totalAmount = ((_a = this.store.currentOrder) == null ? void 0 : _a.total_amount) || "0.00";
511
- const paidAmount = this.calculatePaidAmount();
512
- const remainingAmount = this.calculateRemainingAmount();
511
+ const paidAmount = await this.calculatePaidAmountAsync();
512
+ const remainingAmount = await this.calculateRemainingAmountAsync();
513
513
  return {
514
514
  order: this.store.currentOrder,
515
515
  totalAmount,
@@ -866,45 +866,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
866
866
  当前订单ID: currentOrderId,
867
867
  是否为真实ID: isCurrentOrderReal
868
868
  });
869
- const updatedOrder = await this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
870
- if (updatedOrder) {
871
- if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
872
- console.warn("[Checkout] 检测到订单ID回退,保护真实订单ID:", {
873
- 当前真实ID: currentOrderId,
874
- 获取到的虚拟ID: updatedOrder.order_id
875
- });
876
- updatedOrder.order_id = currentOrderId;
877
- }
878
- this.store.currentOrder = updatedOrder;
879
- console.log("[Checkout] 订单数据已同步:", {
880
- 支付项数量: updatedOrder.payment.length,
881
- 最终订单ID: updatedOrder.order_id,
882
- 是否为虚拟ID: this.isVirtualOrderId(updatedOrder.order_id)
883
- });
884
- }
885
- const needsOrderSync = this.shouldSyncOrderForPayment(paymentItem.code, paymentItem.type);
886
- console.log("[Checkout] 支付项同步检查:", {
887
- paymentCode: paymentItem.code,
888
- paymentType: paymentItem.type,
889
- paymentAmount: paymentItem.amount,
890
- expectedCashCode: import_types2.PaymentMethodType.Cash,
891
- needsOrderSync,
892
- isOrderSynced: this.store.isOrderSynced
893
- });
894
- if (needsOrderSync) {
895
- console.log("[Checkout] 检测到非现金/自定义支付,开始同步订单到后端...", {
896
- 同步前订单ID: this.store.currentOrder.order_id,
897
- 是否为虚拟ID: this.isVirtualOrderId(this.store.currentOrder.order_id),
898
- 订单同步状态: this.store.isOrderSynced,
899
- 订单UUID: this.store.currentOrder.uuid
900
- });
901
- await this.syncOrderToBackend();
902
- console.log("[Checkout] addPaymentItemAsync 中的同步完成:", {
903
- 同步后订单ID: this.store.currentOrder.order_id,
904
- 是否为虚拟ID: this.isVirtualOrderId(this.store.currentOrder.order_id),
905
- 订单同步状态: this.store.isOrderSynced
906
- });
907
- }
908
869
  await this.updateStateAmountToRemaining();
909
870
  await this.core.effects.emit(import_types.CheckoutHooks.OnPaymentStarted, {
910
871
  orderUuid: this.store.currentOrder.uuid,
@@ -939,7 +900,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
939
900
  orderUuid: this.store.currentOrder.uuid,
940
901
  paymentUuid
941
902
  });
942
- const paymentItem = this.store.currentOrder.payment.find((p) => p.uuid === paymentUuid);
903
+ const currentPayments = await this.payment.getPaymentItemsAsync(
904
+ this.store.currentOrder.uuid,
905
+ true
906
+ // 包括已撤销的支付项,因为我们需要验证是否存在
907
+ );
908
+ const paymentItem = currentPayments.find((p) => p.uuid === paymentUuid);
943
909
  if (!paymentItem) {
944
910
  throw (0, import_utils.createCheckoutError)(
945
911
  import_types.CheckoutErrorType.ValidationFailed,
@@ -1170,35 +1136,46 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1170
1136
  return this.store.currentCustomer || null;
1171
1137
  }
1172
1138
  /**
1173
- * 检查订单是否需要手动同步
1139
+ * 检查订单是否需要手动同步(异步版本)
1174
1140
  *
1175
1141
  * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
1142
+ * 从 Payment 模块获取最新的支付项数据
1176
1143
  */
1177
- needsManualSync() {
1178
- var _a;
1144
+ async needsManualSyncAsync() {
1179
1145
  try {
1180
1146
  if (!this.store.currentOrder || this.store.isOrderSynced) {
1181
1147
  return false;
1182
1148
  }
1183
- const remainingAmount = this.calculateRemainingAmount();
1149
+ const remainingAmount = await this.calculateRemainingAmountAsync();
1184
1150
  const remainingValue = parseFloat(remainingAmount);
1185
1151
  if (remainingValue > 0) {
1186
1152
  return false;
1187
1153
  }
1188
- const allPaymentsHaveVoucherId = this.store.currentOrder.payment && this.store.currentOrder.payment.length > 0 && this.store.currentOrder.payment.every(
1154
+ const currentPayments = await this.payment.getPaymentItemsAsync(
1155
+ this.store.currentOrder.uuid,
1156
+ false
1157
+ // 不包括已撤销的支付项
1158
+ );
1159
+ const allPaymentsHaveVoucherId = currentPayments.length > 0 && currentPayments.every(
1189
1160
  (item) => item.status !== "voided" && item.voucher_id
1190
1161
  );
1191
- console.log("[Checkout] needsManualSync 检查结果:", {
1162
+ console.log("[Checkout] needsManualSyncAsync 检查结果:", {
1192
1163
  orderUuid: this.store.currentOrder.uuid,
1193
1164
  isOrderSynced: this.store.isOrderSynced,
1194
1165
  remainingAmount,
1195
- hasPayments: ((_a = this.store.currentOrder.payment) == null ? void 0 : _a.length) > 0,
1166
+ hasPayments: currentPayments.length > 0,
1196
1167
  allPaymentsHaveVoucherId,
1197
- needsManualSync: allPaymentsHaveVoucherId
1168
+ needsManualSync: allPaymentsHaveVoucherId,
1169
+ paymentItems: currentPayments.map((p) => ({
1170
+ code: p.code,
1171
+ amount: p.amount,
1172
+ status: p.status,
1173
+ hasVoucherId: !!p.voucher_id
1174
+ }))
1198
1175
  });
1199
1176
  return allPaymentsHaveVoucherId;
1200
1177
  } catch (error) {
1201
- console.error("[Checkout] needsManualSync 检查失败:", error);
1178
+ console.error("[Checkout] needsManualSyncAsync 检查失败:", error);
1202
1179
  return false;
1203
1180
  }
1204
1181
  }
@@ -1225,7 +1202,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1225
1202
  orderUuid,
1226
1203
  orderId: oldOrderId,
1227
1204
  totalAmount: this.store.currentOrder.total_amount,
1228
- remainingAmount: this.calculateRemainingAmount()
1205
+ remainingAmount: await this.calculateRemainingAmountAsync()
1229
1206
  });
1230
1207
  const realOrderId = await this.syncOrderToBackendWithReturn(true);
1231
1208
  console.log("[Checkout] 手动同步订单完成:", {
@@ -1289,6 +1266,106 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1289
1266
  }
1290
1267
  return this.store.currentOrder.order_id;
1291
1268
  }
1269
+ /**
1270
+ * 获取当前订单是否已同步到后端
1271
+ *
1272
+ * @returns 当前订单是否已同步状态,如果没有订单则返回false
1273
+ */
1274
+ isCurrentOrderSynced() {
1275
+ if (!this.store.currentOrder) {
1276
+ console.log("[Checkout] 没有当前订单,同步状态为false");
1277
+ return false;
1278
+ }
1279
+ const syncStatus = this.store.isOrderSynced;
1280
+ console.log("[Checkout] 当前订单同步状态:", {
1281
+ orderUuid: this.store.currentOrder.uuid,
1282
+ orderId: this.store.currentOrder.order_id,
1283
+ isOrderSynced: syncStatus
1284
+ });
1285
+ return syncStatus;
1286
+ }
1287
+ /**
1288
+ * 取消当前本地订单
1289
+ *
1290
+ * 只能取消未同步到后端的本地订单,如果订单已同步则不能取消
1291
+ *
1292
+ * @param cancelReason 取消原因(可选)
1293
+ * @returns 取消结果
1294
+ */
1295
+ async cancelCurrentOrderAsync(cancelReason) {
1296
+ var _a, _b;
1297
+ try {
1298
+ console.log("[Checkout] 开始取消当前本地订单:", {
1299
+ hasCurrentOrder: !!this.store.currentOrder,
1300
+ orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid,
1301
+ orderId: (_b = this.store.currentOrder) == null ? void 0 : _b.order_id,
1302
+ isOrderSynced: this.store.isOrderSynced,
1303
+ cancelReason
1304
+ });
1305
+ if (!this.store.currentOrder) {
1306
+ console.log("[Checkout] 没有当前订单,无需取消");
1307
+ return {
1308
+ success: false,
1309
+ message: "没有当前订单可取消"
1310
+ };
1311
+ }
1312
+ const currentOrderUuid = this.store.currentOrder.uuid;
1313
+ const currentOrderId = this.store.currentOrder.order_id;
1314
+ const isOrderSynced = this.store.isOrderSynced;
1315
+ if (isOrderSynced) {
1316
+ console.log("[Checkout] 订单已同步到后端,不能取消:", {
1317
+ orderId: currentOrderId,
1318
+ orderUuid: currentOrderUuid
1319
+ });
1320
+ return {
1321
+ success: false,
1322
+ message: "订单已同步到后端,无法取消",
1323
+ orderId: currentOrderId
1324
+ };
1325
+ }
1326
+ console.log("[Checkout] 订单尚未同步,可以取消");
1327
+ try {
1328
+ console.log("[Checkout] 删除本地订单数据");
1329
+ await this.payment.deletePaymentOrderAsync(currentOrderUuid);
1330
+ console.log("[Checkout] 本地订单数据删除成功");
1331
+ } catch (error) {
1332
+ console.warn("[Checkout] 删除本地订单数据失败,但继续执行:", error);
1333
+ }
1334
+ console.log("[Checkout] 清理订单相关状态");
1335
+ this.store.currentOrder = void 0;
1336
+ this.store.localOrderData = void 0;
1337
+ this.store.stateAmount = "0.00";
1338
+ this.store.isOrderSynced = false;
1339
+ this.store.currentCustomer = void 0;
1340
+ this.payment.wallet.clearAllCache();
1341
+ console.log("[Checkout] 订单状态清理完成,currentOrder已释放");
1342
+ await this.core.effects.emit(import_types.CheckoutHooks.OnOrderCancelled, {
1343
+ orderUuid: currentOrderUuid,
1344
+ orderId: currentOrderId,
1345
+ cancelReason,
1346
+ wasSynced: false,
1347
+ // 只有未同步订单可以被取消
1348
+ timestamp: Date.now()
1349
+ });
1350
+ console.log("[Checkout] 本地订单取消完成:", {
1351
+ orderUuid: currentOrderUuid,
1352
+ orderId: currentOrderId,
1353
+ cancelReason
1354
+ });
1355
+ return {
1356
+ success: true,
1357
+ message: "本地订单已成功取消",
1358
+ orderId: currentOrderId
1359
+ };
1360
+ } catch (error) {
1361
+ console.error("[Checkout] 取消本地订单失败:", error);
1362
+ const errorMessage = error instanceof Error ? error.message : "未知错误";
1363
+ return {
1364
+ success: false,
1365
+ message: `取消订单失败: ${errorMessage}`
1366
+ };
1367
+ }
1368
+ }
1292
1369
  /**
1293
1370
  * 保存订单并稍后支付
1294
1371
  *
@@ -1700,45 +1777,54 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1700
1777
  return total.toFixed(2);
1701
1778
  }
1702
1779
  /**
1703
- * 计算已支付金额
1780
+ * 计算已支付金额(从 Payment 模块获取最新数据)
1704
1781
  */
1705
- calculatePaidAmount() {
1782
+ async calculatePaidAmountAsync() {
1706
1783
  if (!this.store.currentOrder) {
1707
- console.log("[Checkout] calculatePaidAmount: 没有当前订单");
1784
+ console.log("[Checkout] calculatePaidAmountAsync: 没有当前订单");
1785
+ return "0.00";
1786
+ }
1787
+ try {
1788
+ const payments = await this.payment.getPaymentItemsAsync(
1789
+ this.store.currentOrder.uuid,
1790
+ false
1791
+ // 不包括已撤销的支付项
1792
+ );
1793
+ console.log("[Checkout] calculatePaidAmountAsync: 支付项详情:", {
1794
+ paymentCount: payments.length,
1795
+ payments: payments.map((p) => ({
1796
+ uuid: p.uuid,
1797
+ amount: p.amount,
1798
+ code: p.code,
1799
+ status: p.status
1800
+ }))
1801
+ });
1802
+ const paidAmount = payments.filter((payment) => payment.status !== "voided").reduce((sum, payment) => {
1803
+ const amount = parseFloat(payment.amount || "0");
1804
+ console.log(`[Checkout] 计算支付项: ${payment.code} = ${amount}`);
1805
+ return sum + amount;
1806
+ }, 0);
1807
+ const result = paidAmount.toFixed(2);
1808
+ console.log("[Checkout] calculatePaidAmountAsync: 计算结果 =", result);
1809
+ return result;
1810
+ } catch (error) {
1811
+ console.error("[Checkout] calculatePaidAmountAsync 失败:", error);
1708
1812
  return "0.00";
1709
1813
  }
1710
- const payments = this.store.currentOrder.payment || [];
1711
- console.log("[Checkout] calculatePaidAmount: 支付项详情:", {
1712
- paymentCount: payments.length,
1713
- payments: payments.map((p) => ({
1714
- uuid: p.uuid,
1715
- amount: p.amount,
1716
- code: p.code,
1717
- status: p.status
1718
- }))
1719
- });
1720
- const paidAmount = payments.filter((payment) => payment.status !== "voided").reduce((sum, payment) => {
1721
- const amount = parseFloat(payment.amount || "0");
1722
- console.log(`[Checkout] 计算支付项: ${payment.code} = ${amount}`);
1723
- return sum + amount;
1724
- }, 0);
1725
- const result = paidAmount.toFixed(2);
1726
- console.log("[Checkout] calculatePaidAmount: 计算结果 =", result);
1727
- return result;
1728
1814
  }
1729
1815
  /**
1730
- * 计算剩余未支付金额
1816
+ * 计算剩余未支付金额(从 Payment 模块获取最新数据)
1731
1817
  */
1732
- calculateRemainingAmount() {
1818
+ async calculateRemainingAmountAsync() {
1733
1819
  if (!this.store.currentOrder) {
1734
- console.log("[Checkout] calculateRemainingAmount: 没有当前订单");
1820
+ console.log("[Checkout] calculateRemainingAmountAsync: 没有当前订单");
1735
1821
  return "0.00";
1736
1822
  }
1737
1823
  const totalAmount = parseFloat(this.store.currentOrder.total_amount || "0");
1738
- const paidAmount = parseFloat(this.calculatePaidAmount());
1824
+ const paidAmount = parseFloat(await this.calculatePaidAmountAsync());
1739
1825
  const remainingAmount = totalAmount - paidAmount;
1740
1826
  const result = Math.max(0, remainingAmount).toFixed(2);
1741
- console.log("[Checkout] calculateRemainingAmount: 计算详情:", {
1827
+ console.log("[Checkout] calculateRemainingAmountAsync: 计算详情:", {
1742
1828
  orderUuid: this.store.currentOrder.uuid,
1743
1829
  totalAmount: totalAmount.toFixed(2),
1744
1830
  paidAmount: paidAmount.toFixed(2),
@@ -1753,7 +1839,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1753
1839
  async updateStateAmountToRemaining() {
1754
1840
  var _a;
1755
1841
  try {
1756
- const remainingAmount = this.calculateRemainingAmount();
1842
+ const remainingAmount = await this.calculateRemainingAmountAsync();
1757
1843
  const currentStateAmount = this.store.stateAmount;
1758
1844
  console.log("[Checkout] updateStateAmountToRemaining: 状态检查:", {
1759
1845
  calculatedRemainingAmount: remainingAmount,
@@ -1789,16 +1875,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1789
1875
  * 当剩余待付款金额 <= 0 时,触发订单支付完成事件
1790
1876
  */
1791
1877
  async checkOrderPaymentCompletion() {
1792
- var _a, _b;
1793
1878
  try {
1794
1879
  if (!this.store.currentOrder) {
1795
1880
  return;
1796
1881
  }
1797
- const remainingAmount = this.calculateRemainingAmount();
1882
+ const remainingAmount = await this.calculateRemainingAmountAsync();
1798
1883
  const remainingValue = parseFloat(remainingAmount);
1799
1884
  if (remainingValue <= 0) {
1800
1885
  const totalAmount = this.store.currentOrder.total_amount;
1801
- const paidAmount = this.calculatePaidAmount();
1886
+ const paidAmount = await this.calculatePaidAmountAsync();
1802
1887
  console.log("[Checkout] 检测到订单支付完成:", {
1803
1888
  orderUuid: this.store.currentOrder.uuid,
1804
1889
  orderId: this.store.currentOrder.order_id,
@@ -1807,13 +1892,18 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1807
1892
  remainingAmount,
1808
1893
  isOrderSynced: this.store.isOrderSynced
1809
1894
  });
1810
- const allPaymentsHaveVoucherId = this.store.currentOrder.payment && this.store.currentOrder.payment.length > 0 && this.store.currentOrder.payment.every(
1895
+ const currentPayments = await this.payment.getPaymentItemsAsync(
1896
+ this.store.currentOrder.uuid,
1897
+ false
1898
+ // 不包括已撤销的支付项
1899
+ );
1900
+ const allPaymentsHaveVoucherId = currentPayments.length > 0 && currentPayments.every(
1811
1901
  (item) => item.status !== "voided" && item.voucher_id
1812
1902
  );
1813
1903
  console.log("[Checkout] 支付项voucher_id检查:", {
1814
- paymentCount: ((_a = this.store.currentOrder.payment) == null ? void 0 : _a.length) || 0,
1904
+ paymentCount: currentPayments.length,
1815
1905
  allHaveVoucherId: allPaymentsHaveVoucherId,
1816
- paymentItems: (_b = this.store.currentOrder.payment) == null ? void 0 : _b.map((p) => ({
1906
+ paymentItems: currentPayments.map((p) => ({
1817
1907
  uuid: p.uuid,
1818
1908
  code: p.code,
1819
1909
  amount: p.amount,
@@ -1821,13 +1911,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1821
1911
  status: p.status
1822
1912
  }))
1823
1913
  });
1824
- if (!this.store.isOrderSynced) {
1825
- if (allPaymentsHaveVoucherId) {
1826
- console.log("[Checkout] 所有支付项均为代金券类型,跳过订单同步");
1827
- } else {
1828
- console.log("[Checkout] 支付完成但订单未同步,开始同步订单到后端...");
1829
- await this.syncOrderToBackend();
1830
- }
1914
+ if (allPaymentsHaveVoucherId) {
1915
+ console.log("[Checkout] 所有支付项均为代金券类型,跳过订单同步");
1916
+ } else {
1917
+ console.log("[Checkout] 支付完成但订单未同步,开始同步订单到后端...");
1918
+ await this.syncOrderToBackend();
1831
1919
  }
1832
1920
  await this.core.effects.emit(import_types.CheckoutHooks.OnOrderPaymentCompleted, {
1833
1921
  orderUuid: this.store.currentOrder.uuid,
@@ -2185,6 +2273,93 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2185
2273
  };
2186
2274
  }
2187
2275
  }
2276
+ /**
2277
+ * 发送客户支付链接邮件
2278
+ *
2279
+ * 向指定邮箱发送订单支付提醒邮件
2280
+ *
2281
+ * @param params 发送参数
2282
+ * @returns 发送结果
2283
+ */
2284
+ async sendCustomerPayLinkAsync(params) {
2285
+ try {
2286
+ console.log("[Checkout] 开始发送客户支付链接邮件:", {
2287
+ orderIds: params.order_ids,
2288
+ emails: params.emails,
2289
+ notifyAction: params.notify_action || "order_payment_reminder"
2290
+ });
2291
+ if (!params.order_ids || params.order_ids.length === 0) {
2292
+ return {
2293
+ success: false,
2294
+ message: "订单ID列表不能为空"
2295
+ };
2296
+ }
2297
+ if (!params.emails || params.emails.length === 0) {
2298
+ return {
2299
+ success: false,
2300
+ message: "邮箱地址列表不能为空"
2301
+ };
2302
+ }
2303
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
2304
+ const invalidEmails = params.emails.filter((email) => !emailRegex.test(email));
2305
+ if (invalidEmails.length > 0) {
2306
+ return {
2307
+ success: false,
2308
+ message: `邮箱格式无效: ${invalidEmails.join(", ")}`
2309
+ };
2310
+ }
2311
+ const requestBody = {
2312
+ order_ids: params.order_ids,
2313
+ notify_action: params.notify_action || "order_payment_reminder",
2314
+ emails: params.emails
2315
+ };
2316
+ console.log("[Checkout] 发送支付链接邮件请求参数:", requestBody);
2317
+ const response = await this.request.post("/order/batch-email", requestBody);
2318
+ console.log("[Checkout] 支付链接邮件发送响应:", {
2319
+ status: response.status,
2320
+ message: response.message,
2321
+ data: response.data,
2322
+ response
2323
+ });
2324
+ if (response.status === true || response.status === 200) {
2325
+ console.log("[Checkout] 支付链接邮件发送成功");
2326
+ return {
2327
+ success: true,
2328
+ message: response.message || "支付链接邮件发送成功"
2329
+ };
2330
+ } else {
2331
+ const errorMessage = response.message || "支付链接邮件发送失败";
2332
+ console.error("[Checkout] 支付链接邮件发送失败:", errorMessage);
2333
+ return {
2334
+ success: false,
2335
+ message: errorMessage
2336
+ };
2337
+ }
2338
+ } catch (error) {
2339
+ console.error("[Checkout] 发送客户支付链接邮件失败:", error);
2340
+ const errorMessage = error instanceof Error ? error.message : "网络错误或服务器异常";
2341
+ return {
2342
+ success: false,
2343
+ message: `发送支付链接邮件失败: ${errorMessage}`
2344
+ };
2345
+ }
2346
+ }
2347
+ /**
2348
+ * 金额舍入
2349
+ *
2350
+ * @param amount 原始金额
2351
+ * @returns 舍入结果详情,包含原始金额、舍入后金额和舍入差额
2352
+ */
2353
+ async roundAmountAsync(amount) {
2354
+ var _a, _b;
2355
+ const result = await this.payment.roundAmountAsync(
2356
+ amount,
2357
+ (_a = this.otherParams.order_rounding_setting) == null ? void 0 : _a.interval,
2358
+ (_b = this.otherParams.order_rounding_setting) == null ? void 0 : _b.type
2359
+ );
2360
+ console.log(`[Checkout] 金额舍入完成 - 原始: ${result.originalAmount}, 舍入后: ${result.roundedAmount}, 差额: ${result.roundingDifference}`);
2361
+ return result;
2362
+ }
2188
2363
  async destroy() {
2189
2364
  var _a, _b, _c, _d;
2190
2365
  this.payment.wallet.clearAllCache();
@@ -389,7 +389,9 @@ export declare enum CheckoutHooks {
389
389
  /** 订单备注变更 */
390
390
  OnOrderNoteChanged = "checkout:onOrderNoteChanged",
391
391
  /** 商店折扣变更 */
392
- OnShopDiscountChanged = "checkout:onShopDiscountChanged"
392
+ OnShopDiscountChanged = "checkout:onShopDiscountChanged",
393
+ /** 订单取消 */
394
+ OnOrderCancelled = "checkout:onOrderCancelled"
393
395
  }
394
396
  /**
395
397
  * 结账状态数据
@@ -610,11 +612,12 @@ export interface CheckoutModuleAPI extends Module {
610
612
  orderUuid?: string;
611
613
  }>;
612
614
  /**
613
- * 检查订单是否需要手动同步
615
+ * 检查订单是否需要手动同步(异步版本)
614
616
  *
615
617
  * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
618
+ * 从 Payment 模块获取最新的支付项数据
616
619
  */
617
- needsManualSync(): boolean;
620
+ needsManualSyncAsync(): Promise<boolean>;
618
621
  /**
619
622
  * 更新订单备注
620
623
  *
@@ -633,6 +636,25 @@ export interface CheckoutModuleAPI extends Module {
633
636
  * @returns 当前订单的ID,如果没有订单则返回null
634
637
  */
635
638
  getCurrentOrderId(): string | null;
639
+ /**
640
+ * 获取当前订单是否已同步到后端
641
+ *
642
+ * @returns 当前订单是否已同步状态,如果没有订单则返回false
643
+ */
644
+ isCurrentOrderSynced(): boolean;
645
+ /**
646
+ * 取消当前本地订单
647
+ *
648
+ * 只能取消未同步到后端的本地订单,如果订单已同步则不能取消
649
+ *
650
+ * @param cancelReason 取消原因(可选)
651
+ * @returns 取消结果
652
+ */
653
+ cancelCurrentOrderAsync(cancelReason?: string): Promise<{
654
+ success: boolean;
655
+ message?: string;
656
+ orderId?: string;
657
+ }>;
636
658
  /**
637
659
  * 更新订单商店折扣
638
660
  *
@@ -675,6 +697,42 @@ export interface CheckoutModuleAPI extends Module {
675
697
  message?: string;
676
698
  orderId?: string | number;
677
699
  }>;
700
+ /**
701
+ * 发送客户支付链接邮件
702
+ *
703
+ * 向指定邮箱发送订单支付提醒邮件
704
+ *
705
+ * @param params 发送参数
706
+ * @returns 发送结果
707
+ */
708
+ sendCustomerPayLinkAsync(params: SendCustomerPayLinkParams): Promise<{
709
+ success: boolean;
710
+ message?: string;
711
+ }>;
712
+ /**
713
+ * 金额舍入
714
+ *
715
+ * 根据系统配置的舍入设置对金额进行舍入处理
716
+ *
717
+ * @param amount 原始金额
718
+ * @returns 舍入结果详情,包含原始金额、舍入后金额和舍入差额
719
+ */
720
+ roundAmountAsync(amount: number): Promise<{
721
+ originalAmount: string;
722
+ roundedAmount: string;
723
+ roundingDifference: string;
724
+ }>;
725
+ }
726
+ /**
727
+ * 发送客户支付链接参数
728
+ */
729
+ export interface SendCustomerPayLinkParams {
730
+ /** 订单ID列表 */
731
+ order_ids: string[];
732
+ /** 通知动作,固定为订单支付提醒 */
733
+ notify_action?: string;
734
+ /** 邮箱地址列表 */
735
+ emails: string[];
678
736
  }
679
737
  /**
680
738
  * 结账事件数据类型
@@ -748,4 +806,12 @@ export interface CheckoutEventData {
748
806
  newDiscount: number;
749
807
  timestamp: number;
750
808
  };
809
+ /** 订单取消事件 */
810
+ orderCancelled: {
811
+ orderUuid?: string;
812
+ orderId?: string;
813
+ cancelReason?: string;
814
+ wasSynced: boolean;
815
+ timestamp: number;
816
+ };
751
817
  }
@@ -69,6 +69,7 @@ var CheckoutHooks = /* @__PURE__ */ ((CheckoutHooks2) => {
69
69
  CheckoutHooks2["OnOrderSynced"] = "checkout:onOrderSynced";
70
70
  CheckoutHooks2["OnOrderNoteChanged"] = "checkout:onOrderNoteChanged";
71
71
  CheckoutHooks2["OnShopDiscountChanged"] = "checkout:onShopDiscountChanged";
72
+ CheckoutHooks2["OnOrderCancelled"] = "checkout:onOrderCancelled";
72
73
  return CheckoutHooks2;
73
74
  })(CheckoutHooks || {});
74
75
  // 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": "0.0.233",
4
+ "version": "0.0.235",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",