@pisell/pisellos 0.0.234 → 0.0.236

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 (33) hide show
  1. package/dist/modules/Order/index.d.ts +1 -1
  2. package/dist/modules/Payment/index.d.ts +3 -3
  3. package/dist/modules/Payment/index.js +74 -10
  4. package/dist/modules/Payment/types.d.ts +24 -3
  5. package/dist/modules/Payment/types.js +9 -1
  6. package/dist/modules/Payment/utils.js +1 -1
  7. package/dist/modules/Payment/walletpass.d.ts +5 -2
  8. package/dist/modules/Payment/walletpass.js +63 -11
  9. package/dist/solution/BookingTicket/index.d.ts +8 -0
  10. package/dist/solution/BookingTicket/index.js +27 -3
  11. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
  12. package/dist/solution/BookingTicket/utils/scan/handleScan.js +43 -28
  13. package/dist/solution/Checkout/index.d.ts +73 -8
  14. package/dist/solution/Checkout/index.js +1540 -926
  15. package/dist/solution/Checkout/types.d.ts +79 -3
  16. package/dist/solution/Checkout/types.js +6 -0
  17. package/lib/modules/Order/index.d.ts +1 -1
  18. package/lib/modules/Payment/index.d.ts +3 -3
  19. package/lib/modules/Payment/index.js +30 -5
  20. package/lib/modules/Payment/types.d.ts +24 -3
  21. package/lib/modules/Payment/types.js +1 -1
  22. package/lib/modules/Payment/utils.js +1 -1
  23. package/lib/modules/Payment/walletpass.d.ts +5 -2
  24. package/lib/modules/Payment/walletpass.js +30 -2
  25. package/lib/solution/BookingTicket/index.d.ts +8 -0
  26. package/lib/solution/BookingTicket/index.js +23 -2
  27. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
  28. package/lib/solution/BookingTicket/utils/scan/handleScan.js +21 -14
  29. package/lib/solution/Checkout/index.d.ts +73 -8
  30. package/lib/solution/Checkout/index.js +582 -200
  31. package/lib/solution/Checkout/types.d.ts +79 -3
  32. package/lib/solution/Checkout/types.js +2 -0
  33. package/package.json +1 -1
@@ -389,7 +389,11 @@ 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",
395
+ /** 订单状态已清理 */
396
+ OnOrderCleared = "checkout:onOrderCleared"
393
397
  }
394
398
  /**
395
399
  * 结账状态数据
@@ -610,11 +614,12 @@ export interface CheckoutModuleAPI extends Module {
610
614
  orderUuid?: string;
611
615
  }>;
612
616
  /**
613
- * 检查订单是否需要手动同步
617
+ * 检查订单是否需要手动同步(异步版本)
614
618
  *
615
619
  * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
620
+ * 从 Payment 模块获取最新的支付项数据
616
621
  */
617
- needsManualSync(): boolean;
622
+ needsManualSyncAsync(): Promise<boolean>;
618
623
  /**
619
624
  * 更新订单备注
620
625
  *
@@ -633,6 +638,25 @@ export interface CheckoutModuleAPI extends Module {
633
638
  * @returns 当前订单的ID,如果没有订单则返回null
634
639
  */
635
640
  getCurrentOrderId(): string | null;
641
+ /**
642
+ * 获取当前订单是否已同步到后端
643
+ *
644
+ * @returns 当前订单是否已同步状态,如果没有订单则返回false
645
+ */
646
+ isCurrentOrderSynced(): boolean;
647
+ /**
648
+ * 取消当前本地订单
649
+ *
650
+ * 只能取消未同步到后端的本地订单,如果订单已同步则不能取消
651
+ *
652
+ * @param cancelReason 取消原因(可选)
653
+ * @returns 取消结果
654
+ */
655
+ cancelCurrentOrderAsync(cancelReason?: string): Promise<{
656
+ success: boolean;
657
+ message?: string;
658
+ orderId?: string;
659
+ }>;
636
660
  /**
637
661
  * 更新订单商店折扣
638
662
  *
@@ -675,6 +699,42 @@ export interface CheckoutModuleAPI extends Module {
675
699
  message?: string;
676
700
  orderId?: string | number;
677
701
  }>;
702
+ /**
703
+ * 发送客户支付链接邮件
704
+ *
705
+ * 向指定邮箱发送订单支付提醒邮件
706
+ *
707
+ * @param params 发送参数
708
+ * @returns 发送结果
709
+ */
710
+ sendCustomerPayLinkAsync(params: SendCustomerPayLinkParams): Promise<{
711
+ success: boolean;
712
+ message?: string;
713
+ }>;
714
+ /**
715
+ * 金额舍入
716
+ *
717
+ * 根据系统配置的舍入设置对金额进行舍入处理
718
+ *
719
+ * @param amount 原始金额
720
+ * @returns 舍入结果详情,包含原始金额、舍入后金额和舍入差额
721
+ */
722
+ roundAmountAsync(amount: number): Promise<{
723
+ originalAmount: string;
724
+ roundedAmount: string;
725
+ roundingDifference: string;
726
+ }>;
727
+ }
728
+ /**
729
+ * 发送客户支付链接参数
730
+ */
731
+ export interface SendCustomerPayLinkParams {
732
+ /** 订单ID列表 */
733
+ order_ids: string[];
734
+ /** 通知动作,固定为订单支付提醒 */
735
+ notify_action?: string;
736
+ /** 邮箱地址列表 */
737
+ emails: string[];
678
738
  }
679
739
  /**
680
740
  * 结账事件数据类型
@@ -748,4 +808,20 @@ export interface CheckoutEventData {
748
808
  newDiscount: number;
749
809
  timestamp: number;
750
810
  };
811
+ /** 订单取消事件 */
812
+ orderCancelled: {
813
+ orderUuid?: string;
814
+ orderId?: string;
815
+ cancelReason?: string;
816
+ wasSynced: boolean;
817
+ timestamp: number;
818
+ };
819
+ /** 订单状态清理事件 */
820
+ orderCleared: {
821
+ previousOrder?: {
822
+ uuid: string;
823
+ orderId: string;
824
+ } | null;
825
+ timestamp: number;
826
+ };
751
827
  }
@@ -117,6 +117,8 @@ export var CheckoutHooks = /*#__PURE__*/function (CheckoutHooks) {
117
117
  CheckoutHooks["OnOrderSynced"] = "checkout:onOrderSynced";
118
118
  CheckoutHooks["OnOrderNoteChanged"] = "checkout:onOrderNoteChanged";
119
119
  CheckoutHooks["OnShopDiscountChanged"] = "checkout:onShopDiscountChanged";
120
+ CheckoutHooks["OnOrderCancelled"] = "checkout:onOrderCancelled";
121
+ CheckoutHooks["OnOrderCleared"] = "checkout:onOrderCleared";
120
122
  return CheckoutHooks;
121
123
  }({});
122
124
 
@@ -132,6 +134,10 @@ export var CheckoutHooks = /*#__PURE__*/function (CheckoutHooks) {
132
134
  * 结账解决方案 API 接口
133
135
  */
134
136
 
137
+ /**
138
+ * 发送客户支付链接参数
139
+ */
140
+
135
141
  /**
136
142
  * 结账事件数据类型
137
143
  */
@@ -10,7 +10,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
10
10
  constructor(name?: string, version?: string);
11
11
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
12
12
  createOrder(params: CommitOrderParams['query']): {
13
- type: "virtual" | "appointment_booking";
13
+ type: "appointment_booking" | "virtual";
14
14
  platform: string;
15
15
  sales_channel: string;
16
16
  order_sales_channel: string;
@@ -1,7 +1,7 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { RequestPlugin } from '../../plugins';
3
3
  import { BaseModule } from '../BaseModule';
4
- import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval } from './types';
4
+ import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval, RoundingResult } from './types';
5
5
  export * from './types';
6
6
  export { generateRequestUniqueId };
7
7
  /**
@@ -176,9 +176,9 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
176
176
  * @param originalAmount 原始金额
177
177
  * @param interval 舍入间隔 (0.05, 0.1, 0.5, 1)
178
178
  * @param rule 舍入规则 (standard, standard_down, always_up, always_down)
179
- * @returns 舍入后的金额(保留两位小数的字符串)
179
+ * @returns 舍入结果详情(包含原始金额、舍入后金额和舍入差额)
180
180
  */
181
- roundAmountAsync(originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string): Promise<string>;
181
+ roundAmountAsync(originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string): Promise<RoundingResult>;
182
182
  /**
183
183
  * 标准舍入处理(处理中点情况)
184
184
  *
@@ -257,7 +257,25 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
257
257
  if (!oldMethod) {
258
258
  return true;
259
259
  }
260
- if (oldMethod.code !== newMethod.code || oldMethod.name !== newMethod.name || oldMethod.type !== newMethod.type || oldMethod.enabled !== newMethod.enabled) {
260
+ if (oldMethod.code !== newMethod.code || oldMethod.name !== newMethod.name || oldMethod.type !== newMethod.type || oldMethod.description !== newMethod.description || oldMethod.status !== newMethod.status || oldMethod.disable !== newMethod.disable || oldMethod.is_surcharge !== newMethod.is_surcharge || oldMethod.fixed !== newMethod.fixed || oldMethod.percentage !== newMethod.percentage || oldMethod.enabled !== newMethod.enabled || JSON.stringify(oldMethod.channel_application || []) !== JSON.stringify(newMethod.channel_application || []) || JSON.stringify(oldMethod.companies || []) !== JSON.stringify(newMethod.companies || []) || JSON.stringify(oldMethod.metadata || {}) !== JSON.stringify(newMethod.metadata || {})) {
261
+ console.log(`[PaymentModule] 支付方式 ${newMethod.id} (${newMethod.code}) 发生变化:`, {
262
+ id: newMethod.id,
263
+ changes: {
264
+ code: oldMethod.code !== newMethod.code ? { old: oldMethod.code, new: newMethod.code } : void 0,
265
+ name: oldMethod.name !== newMethod.name ? { old: oldMethod.name, new: newMethod.name } : void 0,
266
+ type: oldMethod.type !== newMethod.type ? { old: oldMethod.type, new: newMethod.type } : void 0,
267
+ description: oldMethod.description !== newMethod.description ? { old: oldMethod.description, new: newMethod.description } : void 0,
268
+ status: oldMethod.status !== newMethod.status ? { old: oldMethod.status, new: newMethod.status } : void 0,
269
+ disable: oldMethod.disable !== newMethod.disable ? { old: oldMethod.disable, new: newMethod.disable } : void 0,
270
+ is_surcharge: oldMethod.is_surcharge !== newMethod.is_surcharge ? { old: oldMethod.is_surcharge, new: newMethod.is_surcharge } : void 0,
271
+ fixed: oldMethod.fixed !== newMethod.fixed ? { old: oldMethod.fixed, new: newMethod.fixed } : void 0,
272
+ percentage: oldMethod.percentage !== newMethod.percentage ? { old: oldMethod.percentage, new: newMethod.percentage } : void 0,
273
+ enabled: oldMethod.enabled !== newMethod.enabled ? { old: oldMethod.enabled, new: newMethod.enabled } : void 0,
274
+ channel_application: JSON.stringify(oldMethod.channel_application || []) !== JSON.stringify(newMethod.channel_application || []) ? { old: oldMethod.channel_application, new: newMethod.channel_application } : void 0,
275
+ companies: JSON.stringify(oldMethod.companies || []) !== JSON.stringify(newMethod.companies || []) ? { old: oldMethod.companies, new: newMethod.companies } : void 0,
276
+ metadata: JSON.stringify(oldMethod.metadata || {}) !== JSON.stringify(newMethod.metadata || {}) ? { old: oldMethod.metadata, new: newMethod.metadata } : void 0
277
+ }
278
+ });
261
279
  return true;
262
280
  }
263
281
  }
@@ -948,7 +966,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
948
966
  * @param originalAmount 原始金额
949
967
  * @param interval 舍入间隔 (0.05, 0.1, 0.5, 1)
950
968
  * @param rule 舍入规则 (standard, standard_down, always_up, always_down)
951
- * @returns 舍入后的金额(保留两位小数的字符串)
969
+ * @returns 舍入结果详情(包含原始金额、舍入后金额和舍入差额)
952
970
  */
953
971
  async roundAmountAsync(originalAmount, interval, rule) {
954
972
  try {
@@ -986,9 +1004,16 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
986
1004
  throw new Error(`不支持的舍入规则: ${rule}`);
987
1005
  }
988
1006
  const finalAmount = roundedValue.mul(roundingInterval);
989
- const result = finalAmount.toFixed(2);
990
- console.log(`[PaymentModule] 舍入结果 - 舍入值: ${roundedValue.toString()}, 最终金额: ${result}`);
991
- return result;
1007
+ const roundedAmountStr = finalAmount.toFixed(2);
1008
+ const originalAmountStr = amount.toFixed(2);
1009
+ const roundingDifference = finalAmount.sub(amount);
1010
+ const roundingDifferenceStr = roundingDifference.toFixed(2);
1011
+ console.log(`[PaymentModule] 舍入结果 - 原始金额: ${originalAmountStr}, 舍入后金额: ${roundedAmountStr}, 舍入差额: ${roundingDifferenceStr}`);
1012
+ return {
1013
+ originalAmount: originalAmountStr,
1014
+ roundedAmount: roundedAmountStr,
1015
+ roundingDifference: roundingDifferenceStr
1016
+ };
992
1017
  } catch (error) {
993
1018
  console.error("[PaymentModule] 金额舍入失败:", error);
994
1019
  throw new Error(`金额舍入失败: ${error instanceof Error ? error.message : String(error)}`);
@@ -36,7 +36,7 @@ export declare enum TaskRunStatus {
36
36
  */
37
37
  export declare enum RoundingRule {
38
38
  /** 标准舍入(中点向上) */
39
- Standard = "standard",
39
+ Standard = "standard_rounding",
40
40
  /** 标准舍入(中点向下) */
41
41
  StandardDown = "standard_down",
42
42
  /** 总是向上舍入 */
@@ -44,6 +44,17 @@ export declare enum RoundingRule {
44
44
  /** 总是向下舍入 */
45
45
  AlwaysDown = "always_down"
46
46
  }
47
+ /**
48
+ * 舍入结果
49
+ */
50
+ export interface RoundingResult {
51
+ /** 原始金额 */
52
+ originalAmount: string;
53
+ /** 舍入后的金额 */
54
+ roundedAmount: string;
55
+ /** 舍入差额(舍入后金额 - 原始金额) */
56
+ roundingDifference: string;
57
+ }
47
58
  /**
48
59
  * 舍入间隔枚举
49
60
  */
@@ -306,7 +317,7 @@ export interface WalletPassPayment {
306
317
  /** 查询用户识别码列表(异步获取并缓存) */
307
318
  getUserIdentificationCodeListAsync: (params: UserIdentificationCodeParams) => Promise<UserIdentificationCodeItem[]>;
308
319
  /** 搜索识别码信息 */
309
- searchIdentificationCodeAsync: (params: SearchIdentificationCodeParams) => Promise<SearchIdentificationCodeItem[]>;
320
+ searchIdentificationCodeAsync: (params: SearchIdentificationCodeParams) => Promise<SearchIdentificationCodeResult>;
310
321
  /** 获取缓存的搜索结果列表 */
311
322
  getSearchResults: () => SearchIdentificationCodeItem[];
312
323
  /** 根据识别码查找搜索结果 */
@@ -371,7 +382,7 @@ export interface PaymentModuleAPI {
371
382
  * @param rule 舍入规则 (standard, standard_down, always_up, always_down)
372
383
  * @returns 舍入后的金额
373
384
  */
374
- roundAmountAsync: (originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string) => Promise<string>;
385
+ roundAmountAsync: (originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string) => Promise<RoundingResult>;
375
386
  /** 提交支付 */
376
387
  submitPayAsync: (orderUuid?: string) => Promise<{
377
388
  status: 'success' | 'failed';
@@ -636,6 +647,16 @@ export interface SearchIdentificationCodeResponse {
636
647
  /** 响应数据 */
637
648
  data?: SearchIdentificationCodeItem[];
638
649
  }
650
+ /**
651
+ * 搜索识别码结果类型
652
+ */
653
+ export type SearchIdentificationCodeResult = {
654
+ type: 'walletCode';
655
+ data: SearchIdentificationCodeItem[];
656
+ } | {
657
+ type: 'normalCode';
658
+ data: SearchIdentificationCodeItem[];
659
+ };
639
660
  /**
640
661
  * 搜索识别码项目
641
662
  */
@@ -49,7 +49,7 @@ var TaskRunStatus = /* @__PURE__ */ ((TaskRunStatus2) => {
49
49
  return TaskRunStatus2;
50
50
  })(TaskRunStatus || {});
51
51
  var RoundingRule = /* @__PURE__ */ ((RoundingRule2) => {
52
- RoundingRule2["Standard"] = "standard";
52
+ RoundingRule2["Standard"] = "standard_rounding";
53
53
  RoundingRule2["StandardDown"] = "standard_down";
54
54
  RoundingRule2["AlwaysUp"] = "always_up";
55
55
  RoundingRule2["AlwaysDown"] = "always_down";
@@ -31,7 +31,7 @@ var formatWalletPassList2PreparePayments = (list) => {
31
31
  return (list || []).map((item) => {
32
32
  return {
33
33
  voucher_id: item.id || 0,
34
- amount: Number(getAvailableMaxAmount(item)) || 0,
34
+ amount: Number(item.edit_current_amount || getAvailableMaxAmount(item)) || 0,
35
35
  tag: item.tag || ""
36
36
  };
37
37
  });
@@ -1,4 +1,4 @@
1
- import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, WalletInitBusinessData } from './types';
1
+ import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, SearchIdentificationCodeResult, WalletInitBusinessData } from './types';
2
2
  import type { PaymentModule } from './index';
3
3
  /**
4
4
  * 钱包支付实现
@@ -57,8 +57,11 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
57
57
  * 搜索识别码信息
58
58
  * 通过识别码搜索相关的钱包通行证信息
59
59
  * 基于 WalletDeductionRecommendParams 参数结构
60
+ * 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
60
61
  */
61
- searchIdentificationCodeAsync(params: SearchIdentificationCodeParams): Promise<SearchIdentificationCodeItem[]>;
62
+ searchIdentificationCodeAsync(params: SearchIdentificationCodeParams, config?: {
63
+ noCache?: boolean;
64
+ }): Promise<SearchIdentificationCodeResult>;
62
65
  processWalletPayment(amount: number, orderUuid: string, voucherId?: string): Promise<void>;
63
66
  getWalletBalance(voucherId: string): Promise<number>;
64
67
  /**
@@ -175,9 +175,28 @@ var WalletPassPaymentImpl = class {
175
175
  * 搜索识别码信息
176
176
  * 通过识别码搜索相关的钱包通行证信息
177
177
  * 基于 WalletDeductionRecommendParams 参数结构
178
+ * 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
178
179
  */
179
- async searchIdentificationCodeAsync(params) {
180
+ async searchIdentificationCodeAsync(params, config = {}) {
180
181
  try {
182
+ const { code } = params;
183
+ const isWalletCode = code.startsWith("WL");
184
+ if (isWalletCode) {
185
+ const walletDetailParams = {
186
+ code,
187
+ with_customer: 1,
188
+ with: ["wallet"]
189
+ };
190
+ const response2 = await this.paymentModule.request.post(
191
+ "/wallet/detail/search",
192
+ walletDetailParams
193
+ );
194
+ const searchResults2 = (response2 == null ? void 0 : response2.data) || [];
195
+ return {
196
+ type: "walletCode",
197
+ data: searchResults2
198
+ };
199
+ }
181
200
  const baseWalletParams = this.walletParams;
182
201
  const searchParams = {
183
202
  // 基础钱包参数
@@ -198,6 +217,12 @@ var WalletPassPaymentImpl = class {
198
217
  searchParams
199
218
  );
200
219
  const searchResults = (response == null ? void 0 : response.data) || [];
220
+ if (config.noCache) {
221
+ return {
222
+ type: "normalCode",
223
+ data: searchResults
224
+ };
225
+ }
201
226
  if (searchResults.length > 0) {
202
227
  const existingCodes = new Set(
203
228
  this.searchResults.map((item) => item.code)
@@ -213,7 +238,10 @@ var WalletPassPaymentImpl = class {
213
238
  cachedSearchResults: [...this.searchResults],
214
239
  searchParams: params
215
240
  });
216
- return searchResults;
241
+ return {
242
+ type: "normalCode",
243
+ data: searchResults
244
+ };
217
245
  } catch (error) {
218
246
  console.error("[WalletPass] 搜索识别码信息失败:", error);
219
247
  throw error;
@@ -131,6 +131,14 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  scanCustomerListener(callback: (data: IScanResult) => void): {
132
132
  remove: () => void;
133
133
  };
134
+ /**
135
+ * @title 通用扫描监听
136
+ * @description 直接将扫描结果返回给调用方
137
+ * @param callback 回调
138
+ */
139
+ scanUniversalListener(callback: (data: IScanResult) => void, key: string): {
140
+ remove: () => void;
141
+ };
134
142
  /**
135
143
  * 调用摄像头
136
144
  * @param data 用户自定义数据
@@ -302,7 +302,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
302
302
  try {
303
303
  callback(d);
304
304
  } catch (error) {
305
- console.error("scanGlobalListener回掉函数异常", error);
305
+ console.error("scanGlobalListener传入的回调函数异常", error);
306
306
  }
307
307
  };
308
308
  const listener = { key: "global", callback: safeCallback };
@@ -319,13 +319,34 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
319
319
  try {
320
320
  callback(d);
321
321
  } catch (error) {
322
- console.error("scanCustomerListener回掉函数异常", error);
322
+ console.error("scanCustomerListener传入的回调函数异常", error);
323
323
  }
324
324
  };
325
325
  const listener = { key: "customer", callback: safeCallback };
326
326
  const removeListener = this.scan.addListener(listener, scanCallback);
327
327
  return removeListener;
328
328
  }
329
+ /**
330
+ * @title 通用扫描监听
331
+ * @description 直接将扫描结果返回给调用方
332
+ * @param callback 回调
333
+ */
334
+ scanUniversalListener(callback, key) {
335
+ const scanCallback = (0, import_handleScan.handleUniversalScan)();
336
+ const safeCallback = (d) => {
337
+ try {
338
+ callback(d);
339
+ } catch (error) {
340
+ console.error(
341
+ `scanUniversalListener传入的回调函数异常, key: ${key}`,
342
+ error
343
+ );
344
+ }
345
+ };
346
+ const listener = { key, callback: safeCallback };
347
+ const removeListener = this.scan.addListener(listener, scanCallback);
348
+ return removeListener;
349
+ }
329
350
  /**
330
351
  * 调用摄像头
331
352
  * @param data 用户自定义数据
@@ -14,3 +14,9 @@ export declare const handleGlobalScan: (request: RequestPlugin, localSearch: (v:
14
14
  * @returns 处理结果
15
15
  */
16
16
  export declare const handleCustomerScan: () => () => Promise<{}>;
17
+ /**
18
+ * 处理钱包扫码
19
+ * @param request 请求插件
20
+ * @returns 处理结果
21
+ */
22
+ export declare const handleUniversalScan: () => () => Promise<{}>;
@@ -30,7 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var handleScan_exports = {};
31
31
  __export(handleScan_exports, {
32
32
  handleCustomerScan: () => handleCustomerScan,
33
- handleGlobalScan: () => handleGlobalScan
33
+ handleGlobalScan: () => handleGlobalScan,
34
+ handleUniversalScan: () => handleUniversalScan
34
35
  });
35
36
  module.exports = __toCommonJS(handleScan_exports);
36
37
  var import_cloudSearch = require("./cloudSearch");
@@ -61,19 +62,21 @@ var promiseAny = async (promises) => {
61
62
  var handleScanFn = (getRequestList, localSearch) => {
62
63
  return async (scanResult) => {
63
64
  const { value } = scanResult || {};
64
- try {
65
- const localResult = localSearch == null ? void 0 : localSearch(value);
66
- if ((localResult == null ? void 0 : localResult.length) > 0) {
67
- console.log("本地搜索到数据>>>>>>>", localResult);
68
- return {
69
- searchType: "local_product",
70
- response: { data: { list: localResult } }
71
- };
72
- } else {
73
- console.log("本地搜索无数据>>>>>>>");
65
+ if (localSearch) {
66
+ try {
67
+ const localResult = localSearch == null ? void 0 : localSearch(value);
68
+ if ((localResult == null ? void 0 : localResult.length) > 0) {
69
+ console.log("本地搜索到数据>>>>>>>", localResult);
70
+ return {
71
+ searchType: "local_product",
72
+ response: { data: { list: localResult } }
73
+ };
74
+ } else {
75
+ console.log("本地搜索无数据>>>>>>>");
76
+ }
77
+ } catch (error) {
78
+ console.error("本地搜索到数据失败>>>>>>>", error);
74
79
  }
75
- } catch (error) {
76
- console.error("本地搜索到数据失败>>>>>>>", error);
77
80
  }
78
81
  try {
79
82
  if (import_scanCache.default.has(value)) {
@@ -118,8 +121,12 @@ var handleGlobalScan = (request, localSearch) => {
118
121
  var handleCustomerScan = () => {
119
122
  return () => Promise.resolve({});
120
123
  };
124
+ var handleUniversalScan = () => {
125
+ return () => Promise.resolve({});
126
+ };
121
127
  // Annotate the CommonJS export names for ESM import in node:
122
128
  0 && (module.exports = {
123
129
  handleCustomerScan,
124
- handleGlobalScan
130
+ handleGlobalScan,
131
+ handleUniversalScan
125
132
  });
@@ -2,7 +2,7 @@ import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { OrderModule } from '../../modules/Order';
4
4
  import { PaymentModule } from '../../modules/Payment';
5
- import { CheckoutModuleAPI, CheckoutStep, CheckoutInitParams, CreateLocalOrderParams, PlaceOrderParams, CreateOrderParams, ProcessPaymentParams, CheckoutStatusInfo, CheckoutSummary, CurrentOrderInfo, CartSummaryItem, ExtractedAmountInfo } from './types';
5
+ import { CheckoutModuleAPI, CheckoutStep, CheckoutInitParams, CreateLocalOrderParams, PlaceOrderParams, CreateOrderParams, ProcessPaymentParams, CheckoutStatusInfo, CheckoutSummary, CurrentOrderInfo, CartSummaryItem, ExtractedAmountInfo, SendCustomerPayLinkParams } from './types';
6
6
  import { PaymentOrder, PaymentMethod, PaymentItem, PaymentItemInput } from '../../modules/Payment/types';
7
7
  export * from './types';
8
8
  /**
@@ -185,7 +185,8 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
185
185
  /**
186
186
  * 获取支付方式列表
187
187
  *
188
- * 直接调用 Payment 模块的 getPayMethodListAsync 方法
188
+ * 优先使用 store 中的缓存数据,避免重复接口调用。
189
+ * 如果 store 中没有数据,则调用 Payment 模块的方法获取。
189
190
  *
190
191
  * @returns 支付方式列表
191
192
  */
@@ -251,11 +252,12 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
251
252
  customer_name?: string;
252
253
  } | null;
253
254
  /**
254
- * 检查订单是否需要手动同步
255
+ * 检查订单是否需要手动同步(异步版本)
255
256
  *
256
257
  * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
258
+ * 从 Payment 模块获取最新的支付项数据
257
259
  */
258
- needsManualSync(): boolean;
260
+ needsManualSyncAsync(): Promise<boolean>;
259
261
  /**
260
262
  * 手动同步订单到后端
261
263
  *
@@ -279,6 +281,25 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
279
281
  * @returns 当前订单的ID,如果没有订单则返回null
280
282
  */
281
283
  getCurrentOrderId(): string | null;
284
+ /**
285
+ * 获取当前订单是否已同步到后端
286
+ *
287
+ * @returns 当前订单是否已同步状态,如果没有订单则返回false
288
+ */
289
+ isCurrentOrderSynced(): boolean;
290
+ /**
291
+ * 取消当前本地订单
292
+ *
293
+ * 只能取消未同步到后端的本地订单,如果订单已同步则不能取消
294
+ *
295
+ * @param cancelReason 取消原因(可选)
296
+ * @returns 取消结果
297
+ */
298
+ cancelCurrentOrderAsync(cancelReason?: string): Promise<{
299
+ success: boolean;
300
+ message?: string;
301
+ orderId?: string;
302
+ }>;
282
303
  /**
283
304
  * 保存订单并稍后支付
284
305
  *
@@ -363,13 +384,13 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
363
384
  */
364
385
  private calculateTotalAmount;
365
386
  /**
366
- * 计算已支付金额
387
+ * 计算已支付金额(从 Payment 模块获取最新数据)
367
388
  */
368
- private calculatePaidAmount;
389
+ private calculatePaidAmountAsync;
369
390
  /**
370
- * 计算剩余未支付金额
391
+ * 计算剩余未支付金额(从 Payment 模块获取最新数据)
371
392
  */
372
- private calculateRemainingAmount;
393
+ private calculateRemainingAmountAsync;
373
394
  /**
374
395
  * 更新 stateAmount 为当前剩余未支付金额
375
396
  */
@@ -432,5 +453,49 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
432
453
  message?: string;
433
454
  orderId?: string | number;
434
455
  }>;
456
+ /**
457
+ * 发送客户支付链接邮件
458
+ *
459
+ * 向指定邮箱发送订单支付提醒邮件
460
+ *
461
+ * @param params 发送参数
462
+ * @returns 发送结果
463
+ */
464
+ sendCustomerPayLinkAsync(params: SendCustomerPayLinkParams): Promise<{
465
+ success: boolean;
466
+ message?: string;
467
+ }>;
468
+ /**
469
+ * 金额舍入
470
+ *
471
+ * @param amount 原始金额
472
+ * @returns 舍入结果详情,包含原始金额、舍入后金额和舍入差额
473
+ */
474
+ roundAmountAsync(amount: number): Promise<{
475
+ originalAmount: string;
476
+ roundedAmount: string;
477
+ roundingDifference: string;
478
+ }>;
435
479
  destroy(): Promise<void>;
480
+ /**
481
+ * 重置 store 状态
482
+ *
483
+ * 在创建新订单前调用,确保状态完全干净
484
+ */
485
+ private resetStoreStateAsync;
486
+ /**
487
+ * 手动清理已完成的订单状态(公开方法)
488
+ *
489
+ * 供UI层调用的公开方法,用于手动清理订单状态
490
+ *
491
+ * @returns 清理结果
492
+ */
493
+ clearCompletedOrderAsync(): Promise<{
494
+ success: boolean;
495
+ message?: string;
496
+ clearedOrder?: {
497
+ uuid: string;
498
+ orderId: string;
499
+ } | null;
500
+ }>;
436
501
  }