@pisell/pisellos 1.0.65 → 1.0.67

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 (43) hide show
  1. package/dist/modules/Date/index.js +4 -0
  2. package/dist/modules/Order/index.js +10 -4
  3. package/dist/modules/Payment/index.d.ts +1 -0
  4. package/dist/modules/Payment/index.js +75 -41
  5. package/dist/modules/Payment/walletpass.js +3 -4
  6. package/dist/modules/Rules/index.js +2 -0
  7. package/dist/modules/Schedule/index.d.ts +1 -1
  8. package/dist/modules/Schedule/index.js +9 -0
  9. package/dist/solution/BookingByStep/index.d.ts +16 -4
  10. package/dist/solution/BookingByStep/index.js +671 -109
  11. package/dist/solution/BookingByStep/utils/capacity.d.ts +23 -0
  12. package/dist/solution/BookingByStep/utils/capacity.js +219 -1
  13. package/dist/solution/BookingByStep/utils/stock.d.ts +29 -0
  14. package/dist/solution/BookingByStep/utils/stock.js +126 -0
  15. package/dist/solution/BookingTicket/index.d.ts +1 -1
  16. package/dist/solution/Checkout/index.d.ts +6 -148
  17. package/dist/solution/Checkout/index.js +1188 -2434
  18. package/dist/solution/Checkout/types.d.ts +7 -220
  19. package/dist/solution/Checkout/types.js +1 -49
  20. package/dist/solution/Checkout/utils/index.d.ts +9 -5
  21. package/dist/solution/Checkout/utils/index.js +18 -56
  22. package/lib/modules/Date/index.js +3 -0
  23. package/lib/modules/Order/index.js +6 -0
  24. package/lib/modules/Payment/index.d.ts +1 -0
  25. package/lib/modules/Payment/index.js +35 -8
  26. package/lib/modules/Payment/walletpass.js +2 -2
  27. package/lib/modules/Rules/index.js +2 -0
  28. package/lib/modules/Schedule/index.d.ts +1 -1
  29. package/lib/modules/Schedule/index.js +9 -0
  30. package/lib/solution/BookingByStep/index.d.ts +16 -4
  31. package/lib/solution/BookingByStep/index.js +363 -8
  32. package/lib/solution/BookingByStep/utils/capacity.d.ts +23 -0
  33. package/lib/solution/BookingByStep/utils/capacity.js +157 -0
  34. package/lib/solution/BookingByStep/utils/stock.d.ts +29 -0
  35. package/lib/solution/BookingByStep/utils/stock.js +89 -0
  36. package/lib/solution/BookingTicket/index.d.ts +1 -1
  37. package/lib/solution/Checkout/index.d.ts +6 -148
  38. package/lib/solution/Checkout/index.js +337 -1115
  39. package/lib/solution/Checkout/types.d.ts +7 -220
  40. package/lib/solution/Checkout/types.js +3 -27
  41. package/lib/solution/Checkout/utils/index.d.ts +9 -5
  42. package/lib/solution/Checkout/utils/index.js +12 -53
  43. package/package.json +1 -1
@@ -2,42 +2,6 @@ import { Module } from '../../types';
2
2
  import { OrderModule } from '../../modules/Order';
3
3
  import { PaymentModuleAPI, PaymentOrder, PaymentMethod, PaymentStatus, PaymentItem, PaymentItemInput } from '../../modules/Payment';
4
4
  import { CartItem } from '../../modules/Cart/types';
5
- /**
6
- * 结账状态枚举
7
- */
8
- export declare enum CheckoutStatus {
9
- /** 初始化中 */
10
- Initializing = "initializing",
11
- /** 准备就绪 */
12
- Ready = "ready",
13
- /** 创建订单中 */
14
- CreatingOrder = "creating_order",
15
- /** 订单已创建 */
16
- OrderCreated = "order_created",
17
- /** 处理支付中 */
18
- ProcessingPayment = "processing_payment",
19
- /** 支付完成 */
20
- PaymentCompleted = "payment_completed",
21
- /** 结账完成 */
22
- Completed = "completed",
23
- /** 已取消 */
24
- Cancelled = "cancelled",
25
- /** 错误状态 */
26
- Error = "error"
27
- }
28
- /**
29
- * 结账步骤枚举
30
- */
31
- export declare enum CheckoutStep {
32
- /** 订单确认 */
33
- OrderConfirmation = "order_confirmation",
34
- /** 支付方式选择 */
35
- PaymentMethod = "payment_method",
36
- /** 支付处理 */
37
- PaymentProcessing = "payment_processing",
38
- /** 完成 */
39
- Complete = "complete"
40
- }
41
5
  /**
42
6
  * 结账错误类型
43
7
  */
@@ -127,15 +91,6 @@ export interface CreateLocalOrderParams {
127
91
  autoPayment?: boolean;
128
92
  totalInfo: any;
129
93
  }
130
- /**
131
- * 手动下单参数
132
- */
133
- export interface PlaceOrderParams {
134
- /** 订单提交的 URL (可选,默认使用 /order/appointment) */
135
- url?: string;
136
- /** 是否自动替换虚拟订单ID为真实订单ID */
137
- autoReplaceOrderId?: boolean;
138
- }
139
94
  /**
140
95
  * 本地订单数据结构 (基于 appointmentDemo.json)
141
96
  */
@@ -300,74 +255,12 @@ export interface LocalResourceItem {
300
255
  /** 资源类型 (可选) */
301
256
  resourceType?: string;
302
257
  }
303
- /**
304
- * 订单创建参数
305
- */
306
- export interface CreateOrderParams {
307
- /** 购物车商品 */
308
- cartItems: CartItem[];
309
- /** 订单类型 */
310
- type?: 'virtual' | 'appointment_booking';
311
- /** 平台类型 */
312
- platform?: 'pc' | 'h5';
313
- /** 额外参数 */
314
- extra?: Record<string, any>;
315
- }
316
- /**
317
- * 支付处理参数
318
- */
319
- export interface ProcessPaymentParams {
320
- /** 订单UUID */
321
- orderUuid: string;
322
- /** 支付方式代码 */
323
- paymentMethodCode: string;
324
- /** 支付金额 */
325
- amount: string | number;
326
- /** 支付元数据 */
327
- metadata?: Record<string, any>;
328
- }
329
- /**
330
- * 结账状态信息
331
- */
332
- export interface CheckoutStatusInfo {
333
- /** 当前状态 */
334
- status: CheckoutStatus;
335
- /** 当前步骤 */
336
- step: CheckoutStep;
337
- /** 进度百分比 (0-100) */
338
- progress: number;
339
- /** 状态消息 */
340
- message?: string;
341
- /** 错误信息 */
342
- error?: CheckoutError;
343
- }
344
- /**
345
- * 结账摘要信息
346
- */
347
- export interface CheckoutSummary {
348
- /** 订单信息 */
349
- order?: PaymentOrder;
350
- /** 总金额 */
351
- totalAmount: string;
352
- /** 已支付金额 */
353
- paidAmount: string;
354
- /** 待支付金额 */
355
- remainingAmount: string;
356
- /** 支付状态 */
357
- paymentStatus: PaymentStatus;
358
- /** 可用支付方式 */
359
- availablePaymentMethods: PaymentMethod[];
360
- }
361
258
  /**
362
259
  * 结账事件钩子
363
260
  */
364
261
  export declare enum CheckoutHooks {
365
262
  /** 结账初始化完成 */
366
263
  OnCheckoutInitialized = "checkout:onInitialized",
367
- /** 状态变更 */
368
- OnStatusChanged = "checkout:onStatusChanged",
369
- /** 步骤变更 */
370
- OnStepChanged = "checkout:onStepChanged",
371
264
  /** 订单创建成功 */
372
265
  OnOrderCreated = "checkout:onOrderCreated",
373
266
  /** 订单创建失败 */
@@ -407,16 +300,14 @@ export declare enum CheckoutHooks {
407
300
  /** 下单接口请求完成 */
408
301
  OnOrderSubmitEnd = "checkout:onOrderSubmitEnd",
409
302
  /** 钱包数据初始化完成 */
410
- OnWalletDataInitialized = "checkout:onWalletDataInitialized"
303
+ OnWalletDataInitialized = "checkout:onWalletDataInitialized",
304
+ /** 支付项添加成功 */
305
+ OnPaymentItemAdded = "checkout:onPaymentItemAdded"
411
306
  }
412
307
  /**
413
308
  * 结账状态数据
414
309
  */
415
310
  export interface CheckoutState {
416
- /** 当前状态 */
417
- status: CheckoutStatus;
418
- /** 当前步骤 */
419
- step: CheckoutStep;
420
311
  /** 当前订单 */
421
312
  currentOrder?: PaymentOrder;
422
313
  /** 购物车商品 */
@@ -449,10 +340,6 @@ export interface CurrentOrderInfo {
449
340
  uuid?: string;
450
341
  /** 订单ID */
451
342
  orderId?: string;
452
- /** 订单状态 */
453
- status?: CheckoutStatus;
454
- /** 当前步骤 */
455
- step?: CheckoutStep;
456
343
  /** 订单总金额 */
457
344
  totalAmount?: string;
458
345
  /** 待付金额 */
@@ -486,22 +373,6 @@ export interface CheckoutModuleAPI extends Module {
486
373
  * 创建本地订单 (前端模拟下单流程)
487
374
  */
488
375
  createLocalOrderAsync(params: CreateLocalOrderParams): Promise<PaymentOrder>;
489
- /**
490
- * 手动下单 (根据虚拟订单生成实际订单)
491
- */
492
- placeOrderAsync(params?: PlaceOrderParams): Promise<{
493
- success: boolean;
494
- orderId?: string;
495
- error?: string;
496
- }>;
497
- /**
498
- * 创建订单
499
- */
500
- createOrderAsync(params: CreateOrderParams): Promise<PaymentOrder>;
501
- /**
502
- * 处理支付
503
- */
504
- processPaymentAsync(params: ProcessPaymentParams): Promise<void>;
505
376
  /**
506
377
  * 完成结账
507
378
  */
@@ -509,26 +380,6 @@ export interface CheckoutModuleAPI extends Module {
509
380
  success: boolean;
510
381
  orderId?: string;
511
382
  }>;
512
- /**
513
- * 取消结账
514
- */
515
- cancelCheckoutAsync(): Promise<void>;
516
- /**
517
- * 获取结账状态
518
- */
519
- getCheckoutStatus(): CheckoutStatusInfo;
520
- /**
521
- * 获取结账摘要
522
- */
523
- getCheckoutSummaryAsync(): Promise<CheckoutSummary>;
524
- /**
525
- * 获取可用支付方式
526
- */
527
- getAvailablePaymentMethodsAsync(): Promise<PaymentMethod[]>;
528
- /**
529
- * 刷新支付方式缓存
530
- */
531
- refreshPaymentMethodsAsync(): Promise<PaymentMethod[]>;
532
383
  /**
533
384
  * 获取当前订单基础信息
534
385
  */
@@ -537,21 +388,6 @@ export interface CheckoutModuleAPI extends Module {
537
388
  * 获取当前订单的支付项
538
389
  */
539
390
  getCurrentOrderPaymentItemsAsync(): Promise<PaymentItem[]>;
540
- /**
541
- * 验证结账前置条件
542
- */
543
- validateCheckoutAsync(): Promise<{
544
- valid: boolean;
545
- errors: string[];
546
- }>;
547
- /**
548
- * 重试失败的操作
549
- */
550
- retryFailedOperationAsync(): Promise<void>;
551
- /**
552
- * 设置当前步骤
553
- */
554
- setCurrentStep(step: CheckoutStep): void;
555
391
  /**
556
392
  * 获取订单模块
557
393
  */
@@ -578,18 +414,10 @@ export interface CheckoutModuleAPI extends Module {
578
414
  * @returns 当前系统计算的待付金额
579
415
  */
580
416
  getBalanceDueAmount(): string;
581
- /**
582
- * 刷新 stateAmount 为当前剩余未支付金额
583
- */
584
- refreshStateAmountAsync(): Promise<void>;
585
417
  /**
586
418
  * 获取购物车小计数据
587
419
  */
588
420
  getCartSummary(): CartSummaryItem[] | null;
589
- /**
590
- * 获取提取的金额详细信息
591
- */
592
- getExtractedAmountInfo(): ExtractedAmountInfo | null;
593
421
  /**
594
422
  * 获取支付方式列表(直接调用 Payment 模块)
595
423
  */
@@ -611,19 +439,11 @@ export interface CheckoutModuleAPI extends Module {
611
439
  */
612
440
  updateOrderDepositStatusAsync(isDeposit: number): Promise<void>;
613
441
  /**
614
- * 更新当前订单的客户信息
442
+ * 手动设置当前订单的定金金额
443
+ *
444
+ * @param depositAmount 定金金额,必须是有效的数字字符串,且不能超过订单总额
615
445
  */
616
- updateOrderCustomerAsync(customer: {
617
- customer_id?: string;
618
- customer_name?: string;
619
- }): Promise<void>;
620
- /**
621
- * 获取当前订单的客户信息
622
- */
623
- getCurrentCustomer(): {
624
- customer_id?: string;
625
- customer_name?: string;
626
- } | null;
446
+ setDepositAmountAsync(depositAmount: string): Promise<void>;
627
447
  /**
628
448
  * 手动同步订单到后端
629
449
  *
@@ -636,13 +456,6 @@ export interface CheckoutModuleAPI extends Module {
636
456
  orderUuid?: string;
637
457
  response?: any;
638
458
  }>;
639
- /**
640
- * 检查订单是否需要手动同步(异步版本)
641
- *
642
- * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
643
- * 从 Payment 模块获取最新的支付项数据
644
- */
645
- needsManualSyncAsync(): Promise<boolean>;
646
459
  /**
647
460
  * 更新订单备注
648
461
  *
@@ -680,20 +493,6 @@ export interface CheckoutModuleAPI extends Module {
680
493
  message?: string;
681
494
  orderId?: string;
682
495
  }>;
683
- /**
684
- * 更新订单商店折扣
685
- *
686
- * 同时更新cartSummary和localOrderData中的shop_discount值
687
- *
688
- * @param discountAmount 商店折扣金额
689
- */
690
- updateShopDiscountAsync(discountAmount: number): Promise<void>;
691
- /**
692
- * 获取当前商店折扣金额
693
- *
694
- * @returns 当前的商店折扣金额,如果没有则返回0
695
- */
696
- getShopDiscount(): number;
697
496
  /**
698
497
  * 保存订单并稍后支付
699
498
  *
@@ -764,18 +563,6 @@ export interface SendCustomerPayLinkParams {
764
563
  * 结账事件数据类型
765
564
  */
766
565
  export interface CheckoutEventData {
767
- /** 状态变更事件 */
768
- statusChanged: {
769
- oldStatus: CheckoutStatus;
770
- newStatus: CheckoutStatus;
771
- timestamp: number;
772
- };
773
- /** 步骤变更事件 */
774
- stepChanged: {
775
- oldStep: CheckoutStep;
776
- newStep: CheckoutStep;
777
- timestamp: number;
778
- };
779
566
  /** 订单创建事件 */
780
567
  orderCreated: {
781
568
  order: PaymentOrder;
@@ -1,30 +1,3 @@
1
- /**
2
- * 结账状态枚举
3
- */
4
- export var CheckoutStatus = /*#__PURE__*/function (CheckoutStatus) {
5
- CheckoutStatus["Initializing"] = "initializing";
6
- CheckoutStatus["Ready"] = "ready";
7
- CheckoutStatus["CreatingOrder"] = "creating_order";
8
- CheckoutStatus["OrderCreated"] = "order_created";
9
- CheckoutStatus["ProcessingPayment"] = "processing_payment";
10
- CheckoutStatus["PaymentCompleted"] = "payment_completed";
11
- CheckoutStatus["Completed"] = "completed";
12
- CheckoutStatus["Cancelled"] = "cancelled";
13
- CheckoutStatus["Error"] = "error";
14
- return CheckoutStatus;
15
- }({});
16
-
17
- /**
18
- * 结账步骤枚举
19
- */
20
- export var CheckoutStep = /*#__PURE__*/function (CheckoutStep) {
21
- CheckoutStep["OrderConfirmation"] = "order_confirmation";
22
- CheckoutStep["PaymentMethod"] = "payment_method";
23
- CheckoutStep["PaymentProcessing"] = "payment_processing";
24
- CheckoutStep["Complete"] = "complete";
25
- return CheckoutStep;
26
- }({});
27
-
28
1
  /**
29
2
  * 结账错误类型
30
3
  */
@@ -57,10 +30,6 @@ export var CheckoutErrorType = /*#__PURE__*/function (CheckoutErrorType) {
57
30
  * 本地订单创建参数
58
31
  */
59
32
 
60
- /**
61
- * 手动下单参数
62
- */
63
-
64
33
  /**
65
34
  * 本地订单数据结构 (基于 appointmentDemo.json)
66
35
  */
@@ -81,29 +50,11 @@ export var CheckoutErrorType = /*#__PURE__*/function (CheckoutErrorType) {
81
50
  * 本地资源项
82
51
  */
83
52
 
84
- /**
85
- * 订单创建参数
86
- */
87
-
88
- /**
89
- * 支付处理参数
90
- */
91
-
92
- /**
93
- * 结账状态信息
94
- */
95
-
96
- /**
97
- * 结账摘要信息
98
- */
99
-
100
53
  /**
101
54
  * 结账事件钩子
102
55
  */
103
56
  export var CheckoutHooks = /*#__PURE__*/function (CheckoutHooks) {
104
57
  CheckoutHooks["OnCheckoutInitialized"] = "checkout:onInitialized";
105
- CheckoutHooks["OnStatusChanged"] = "checkout:onStatusChanged";
106
- CheckoutHooks["OnStepChanged"] = "checkout:onStepChanged";
107
58
  CheckoutHooks["OnOrderCreated"] = "checkout:onOrderCreated";
108
59
  CheckoutHooks["OnOrderCreationFailed"] = "checkout:onOrderCreationFailed";
109
60
  CheckoutHooks["OnPaymentStarted"] = "checkout:onPaymentStarted";
@@ -124,6 +75,7 @@ export var CheckoutHooks = /*#__PURE__*/function (CheckoutHooks) {
124
75
  CheckoutHooks["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
125
76
  CheckoutHooks["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
126
77
  CheckoutHooks["OnWalletDataInitialized"] = "checkout:onWalletDataInitialized";
78
+ CheckoutHooks["OnPaymentItemAdded"] = "checkout:onPaymentItemAdded";
127
79
  return CheckoutHooks;
128
80
  }({});
129
81
 
@@ -1,4 +1,4 @@
1
- import { CheckoutInitParams, CheckoutError, CheckoutErrorType, CheckoutStatus, CheckoutStep, LocalOrderData, CartSummaryItem, ExtractedAmountInfo } from '../types';
1
+ import { CheckoutInitParams, CheckoutError, CheckoutErrorType, LocalOrderData, CartSummaryItem, ExtractedAmountInfo } from '../types';
2
2
  import { CartItem } from '../../../modules/Cart/types';
3
3
  /**
4
4
  * 验证结账数据
@@ -11,10 +11,6 @@ export declare function validateCheckoutData(params: CheckoutInitParams): {
11
11
  * 创建结账错误对象
12
12
  */
13
13
  export declare function createCheckoutError(type: CheckoutErrorType, message: string, details?: any): CheckoutError;
14
- /**
15
- * 计算结账进度
16
- */
17
- export declare function calculateProgress(status: CheckoutStatus, step: CheckoutStep): number;
18
14
  /**
19
15
  * 格式化金额
20
16
  */
@@ -115,3 +111,11 @@ export declare function isVirtualOrderId(orderId: string): boolean;
115
111
  * @returns 是否需要同步订单
116
112
  */
117
113
  export declare function shouldSyncOrderForPayment(paymentCode: string, paymentType: string): boolean;
114
+ /**
115
+ * 判断是否为现金支付
116
+ *
117
+ * @param paymentCode 支付方式代码
118
+ * @param paymentType 支付方式类型
119
+ * @returns 是否为现金支付
120
+ */
121
+ export declare function isCashPayment(paymentCode?: string, paymentType?: string): boolean;
@@ -2,7 +2,6 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
2
2
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
3
3
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
4
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
- import { CheckoutStatus, CheckoutStep } from "../types";
6
5
  import { PaymentMethodType } from "../../../modules/Payment/types";
7
6
 
8
7
  /**
@@ -58,61 +57,6 @@ export function createCheckoutError(type, message, details) {
58
57
  };
59
58
  }
60
59
 
61
- /**
62
- * 计算结账进度
63
- */
64
- export function calculateProgress(status, step) {
65
- // 基于状态的基础进度
66
- var baseProgress = 0;
67
- switch (status) {
68
- case CheckoutStatus.Initializing:
69
- baseProgress = 5;
70
- break;
71
- case CheckoutStatus.Ready:
72
- baseProgress = 10;
73
- break;
74
- case CheckoutStatus.CreatingOrder:
75
- baseProgress = 25;
76
- break;
77
- case CheckoutStatus.OrderCreated:
78
- baseProgress = 40;
79
- break;
80
- case CheckoutStatus.ProcessingPayment:
81
- baseProgress = 65;
82
- break;
83
- case CheckoutStatus.PaymentCompleted:
84
- baseProgress = 85;
85
- break;
86
- case CheckoutStatus.Completed:
87
- baseProgress = 100;
88
- break;
89
- case CheckoutStatus.Cancelled:
90
- case CheckoutStatus.Error:
91
- baseProgress = 0;
92
- break;
93
- default:
94
- baseProgress = 0;
95
- }
96
-
97
- // 基于步骤的额外进度
98
- var stepProgress = 0;
99
- switch (step) {
100
- case CheckoutStep.OrderConfirmation:
101
- stepProgress = 0;
102
- break;
103
- case CheckoutStep.PaymentMethod:
104
- stepProgress = 10;
105
- break;
106
- case CheckoutStep.PaymentProcessing:
107
- stepProgress = 15;
108
- break;
109
- case CheckoutStep.Complete:
110
- stepProgress = 0; // 已经在状态中体现
111
- break;
112
- }
113
- return Math.min(100, baseProgress + stepProgress);
114
- }
115
-
116
60
  /**
117
61
  * 格式化金额
118
62
  */
@@ -546,4 +490,22 @@ export function shouldSyncOrderForPayment(paymentCode, paymentType) {
546
490
 
547
491
  // 其他支付方式都需要同步
548
492
  return true;
493
+ }
494
+
495
+ /**
496
+ * 判断是否为现金支付
497
+ *
498
+ * @param paymentCode 支付方式代码
499
+ * @param paymentType 支付方式类型
500
+ * @returns 是否为现金支付
501
+ */
502
+ export function isCashPayment(paymentCode, paymentType) {
503
+ var codeUpper = (paymentCode === null || paymentCode === void 0 ? void 0 : paymentCode.toUpperCase()) || '';
504
+ var typeUpper = (paymentType === null || paymentType === void 0 ? void 0 : paymentType.toUpperCase()) || '';
505
+
506
+ // 现金支付识别规则
507
+ var cashIdentifiers = ['CASH', 'CASHMANUAL', 'MANUAL'];
508
+ return cashIdentifiers.some(function (identifier) {
509
+ return codeUpper.includes(identifier) || typeUpper.includes(identifier);
510
+ });
549
511
  }
@@ -178,6 +178,9 @@ var DateModule = class extends import_BaseModule.BaseModule {
178
178
  if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
179
179
  return resource;
180
180
  }
181
+ if (!resource.advanced || resource.advanced.unit === 0) {
182
+ return resource;
183
+ }
181
184
  const resourceStartTime = (0, import_dayjs.default)(resource.start_time);
182
185
  const correctedTimes = resource.times.map((timeSlot) => {
183
186
  if (!timeSlot.start_at || !timeSlot.end_at) {
@@ -273,6 +273,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
273
273
  smallTicketDataFlag: orderData.small_ticket_data_flag
274
274
  });
275
275
  const response = await this.request.post("/order/checkout", orderData);
276
+ this.logInfo("Order API called successfully", {
277
+ response
278
+ });
276
279
  console.log("[Order] 订单创建成功,后端响应:", {
277
280
  success: !!response,
278
281
  hasOrderId: !!(((_q = response == null ? void 0 : response.data) == null ? void 0 : _q.order_id) || (response == null ? void 0 : response.order_id))
@@ -280,6 +283,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
280
283
  return response;
281
284
  } catch (error) {
282
285
  console.error("[Order] createOrderByCheckout 创建订单失败:", error);
286
+ this.logInfo("Order API called failed", {
287
+ error: error instanceof Error ? error.message : String(error)
288
+ });
283
289
  throw error;
284
290
  }
285
291
  }
@@ -23,6 +23,7 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
23
23
  private store;
24
24
  private dbManager;
25
25
  private logger;
26
+ protected otherParams: any;
26
27
  cash: CashPayment;
27
28
  eftpos: EftposPayment;
28
29
  wallet: WalletPassPayment;
@@ -58,6 +58,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
58
58
  super(name, version);
59
59
  this.defaultName = "pay";
60
60
  this.defaultVersion = "1.0.0";
61
+ // LoggerManager 实例
62
+ this.otherParams = {};
61
63
  this.cash = new import_cash.CashPaymentImpl(this);
62
64
  this.eftpos = new import_eftpos.EftposPaymentImpl(this);
63
65
  this.wallet = new import_walletpass.WalletPassPaymentImpl(this);
@@ -65,6 +67,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
65
67
  async initialize(core, options) {
66
68
  this.core = core;
67
69
  this.store = options.store;
70
+ this.otherParams = options.otherParams || {};
68
71
  this.request = core.getPlugin("request");
69
72
  const appPlugin = core.getPlugin("app");
70
73
  if (!this.request) {
@@ -85,6 +88,14 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
85
88
  * 记录信息日志
86
89
  */
87
90
  logInfo(title, metadata) {
91
+ var _a, _b;
92
+ if ((_a = this.otherParams) == null ? void 0 : _a.fatherModule) {
93
+ const fatherModule = this.core.getModule((_b = this.otherParams) == null ? void 0 : _b.fatherModule);
94
+ if (fatherModule) {
95
+ fatherModule.logInfo(`${title}`, metadata);
96
+ return;
97
+ }
98
+ }
88
99
  if (this.logger) {
89
100
  this.logger.addLog({
90
101
  type: "info",
@@ -312,15 +323,14 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
312
323
  totalAmount: params.total_amount
313
324
  });
314
325
  try {
315
- const existingOrders = await this.dbManager.getAll("order");
316
- const existingOrder = existingOrders.find(
317
- (order) => String(order.id) === String(params.order_id)
318
- );
326
+ const existingOrder = await this.dbManager.get("order", params.order_id);
327
+ this.logInfo("createPaymentOrderAsync existingOrder", {
328
+ existingOrder
329
+ });
319
330
  if (existingOrder) {
320
- console.log(
321
- `[PaymentModule] 发现重复订单 ID: ${params.order_id},更新现有支付订单`
331
+ this.logInfo(
332
+ `createPaymentOrderAsync found duplicate order ID: ${params.order_id}, updating existing payment order`
322
333
  );
323
- const originalOrder = { ...existingOrder };
324
334
  existingOrder.order_info = params.order_info;
325
335
  existingOrder.total_amount = params.total_amount;
326
336
  existingOrder.is_deposit = params.is_deposit || 0;
@@ -348,7 +358,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
348
358
  deposit_amount: params.deposit_amount || "0.00"
349
359
  };
350
360
  await this.dbManager.add("order", newOrder);
351
- await this.core.effects.emit(import_types.PaymentHooks.OnOrderAdded, newOrder);
361
+ this.core.effects.emit(import_types.PaymentHooks.OnOrderAdded, newOrder);
352
362
  this.logInfo("createPaymentOrderAsync completed - new payment order created", {
353
363
  orderUuid: newOrder.uuid,
354
364
  orderId: newOrder.id
@@ -516,6 +526,23 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
516
526
  if (!order) {
517
527
  throw new Error(`Order not found: ${orderUuid}`);
518
528
  }
529
+ const expectAmount = new import_decimal.Decimal(order.expect_amount);
530
+ if (expectAmount.lte(0)) {
531
+ const warningMessage = `订单 ${orderUuid} 待付金额已为0,不允许添加新的支付项`;
532
+ console.warn("[PaymentModule] Payment lock triggered:", {
533
+ orderUuid,
534
+ expectAmount: order.expect_amount,
535
+ attemptedPaymentAmount: paymentItem.amount,
536
+ attemptedPaymentCode: paymentItem.code,
537
+ reason: "Order already fully paid"
538
+ });
539
+ this.logError("addPaymentItemAsync blocked by payment lock", new Error(warningMessage), {
540
+ orderUuid,
541
+ expectAmount: order.expect_amount,
542
+ paymentItem
543
+ });
544
+ throw new Error(warningMessage);
545
+ }
519
546
  const paymentUuid = (0, import_utils.getUniqueId)("payment_");
520
547
  const newPaymentItem = {
521
548
  uuid: paymentUuid,
@@ -268,7 +268,7 @@ var WalletPassPaymentImpl = class {
268
268
  code_length: code.length,
269
269
  noCache: config.noCache || false
270
270
  });
271
- const isWalletCode = code.startsWith("WL");
271
+ const isWalletCode = code.length === 9 && code.startsWith("000");
272
272
  if (isWalletCode) {
273
273
  const walletDetailParams = {
274
274
  code,
@@ -298,7 +298,7 @@ var WalletPassPaymentImpl = class {
298
298
  const baseWalletParams = this.walletParams;
299
299
  const searchParams = {
300
300
  // 基础钱包参数
301
- sale_channel: params.sale_channel || (baseWalletParams == null ? void 0 : baseWalletParams.sale_channel),
301
+ sale_channel: params.sale_channel || (baseWalletParams == null ? void 0 : baseWalletParams.sale_channel) || "pos",
302
302
  customer_id: params.customer_id || (baseWalletParams == null ? void 0 : baseWalletParams.customer_id),
303
303
  order_expect_amount: params.order_expect_amount || (baseWalletParams == null ? void 0 : baseWalletParams.order_expect_amount),
304
304
  order_product_amount: params.order_product_amount || (baseWalletParams == null ? void 0 : baseWalletParams.order_product_amount),
@@ -212,6 +212,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
212
212
  tag: discountType,
213
213
  discount: {
214
214
  discount_card_type: (_d = discount == null ? void 0 : discount.metadata) == null ? void 0 : _d.discount_card_type,
215
+ fixed_amount: product.price,
215
216
  resource_id: discount.id,
216
217
  title: discount.format_title,
217
218
  original_amount: product.origin_total,
@@ -346,6 +347,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
346
347
  type: discountType,
347
348
  discount: {
348
349
  discount_card_type: (_j = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _j.discount_card_type,
350
+ fixed_amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
349
351
  resource_id: selectedDiscount2.id,
350
352
  title: selectedDiscount2.format_title,
351
353
  original_amount: productOriginTotal,