@pisell/pisellos 0.0.256 → 0.0.257

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.
@@ -354,21 +354,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
354
354
  return this.request.post('/order/checkout', orderData);
355
355
  case 11:
356
356
  response = _context3.sent;
357
+ this.logInfo('Order API called successfully', {
358
+ response: response
359
+ });
357
360
  console.log('[Order] 订单创建成功,后端响应:', {
358
361
  success: !!response,
359
362
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
360
363
  });
361
364
  return _context3.abrupt("return", response);
362
- case 16:
363
- _context3.prev = 16;
365
+ case 17:
366
+ _context3.prev = 17;
364
367
  _context3.t0 = _context3["catch"](2);
365
368
  console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
369
+ this.logInfo('Order API called failed', {
370
+ error: _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0)
371
+ });
366
372
  throw _context3.t0;
367
- case 20:
373
+ case 22:
368
374
  case "end":
369
375
  return _context3.stop();
370
376
  }
371
- }, _callee3, this, [[2, 16]]);
377
+ }, _callee3, this, [[2, 17]]);
372
378
  }));
373
379
  function createOrderByCheckout(_x4) {
374
380
  return _createOrderByCheckout.apply(this, arguments);
@@ -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;
@@ -85,6 +85,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
85
85
  // IndexDBManager 实例
86
86
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
87
87
  // LoggerManager 实例
88
+ _defineProperty(_assertThisInitialized(_this), "otherParams", {});
88
89
  // 支付方式实例
89
90
  _defineProperty(_assertThisInitialized(_this), "cash", void 0);
90
91
  _defineProperty(_assertThisInitialized(_this), "eftpos", void 0);
@@ -104,34 +105,35 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
104
105
  case 0:
105
106
  this.core = core;
106
107
  this.store = options.store;
108
+ this.otherParams = options.otherParams || {};
107
109
 
108
110
  // 获取依赖的插件
109
111
  this.request = core.getPlugin('request');
110
112
  appPlugin = core.getPlugin('app');
111
113
  if (this.request) {
112
- _context.next = 6;
114
+ _context.next = 7;
113
115
  break;
114
116
  }
115
117
  throw new Error('支付模块需要 request 插件支持');
116
- case 6:
118
+ case 7:
117
119
  if (appPlugin) {
118
- _context.next = 8;
120
+ _context.next = 9;
119
121
  break;
120
122
  }
121
123
  throw new Error('支付模块需要 app 插件支持');
122
- case 8:
124
+ case 9:
123
125
  this.app = appPlugin.getApp();
124
126
  this.dbManager = this.app.dbManager;
125
127
  this.logger = this.app.logger;
126
128
 
127
129
  // 确保支付模块所需的对象存储已创建
128
- _context.next = 13;
130
+ _context.next = 14;
129
131
  return this.ensurePaymentTables();
130
- case 13:
132
+ case 14:
131
133
  this.registerNetworkHandlers();
132
134
  console.log('[PaymentModule] 初始化完成');
133
135
  this.logInfo('PaymentModule initialized successfully');
134
- case 16:
136
+ case 17:
135
137
  case "end":
136
138
  return _context.stop();
137
139
  }
@@ -148,6 +150,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
148
150
  }, {
149
151
  key: "logInfo",
150
152
  value: function logInfo(title, metadata) {
153
+ var _this$otherParams;
154
+ if ((_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.fatherModule) {
155
+ var _this$otherParams2;
156
+ var fatherModule = this.core.getModule((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.fatherModule);
157
+ if (fatherModule) {
158
+ fatherModule.logInfo("".concat(title), metadata);
159
+ return;
160
+ }
161
+ }
151
162
  if (this.logger) {
152
163
  this.logger.addLog({
153
164
  type: 'info',
@@ -646,7 +657,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
646
657
  key: "createPaymentOrderAsync",
647
658
  value: (function () {
648
659
  var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
649
- var existingOrders, existingOrder, originalOrder, newOrder;
660
+ var existingOrder, newOrder;
650
661
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
651
662
  while (1) switch (_context7.prev = _context7.next) {
652
663
  case 0:
@@ -656,19 +667,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
656
667
  });
657
668
  _context7.prev = 1;
658
669
  _context7.next = 4;
659
- return this.dbManager.getAll('order');
670
+ return this.dbManager.get('order', params.order_id);
660
671
  case 4:
661
- existingOrders = _context7.sent;
662
- existingOrder = existingOrders.find(function (order) {
663
- return String(order.id) === String(params.order_id);
664
- });
672
+ existingOrder = _context7.sent;
665
673
  if (!existingOrder) {
666
- _context7.next = 21;
674
+ _context7.next = 19;
667
675
  break;
668
676
  }
669
677
  // 如果存在相同 order_id 的订单,更新该订单信息
670
678
  console.log("[PaymentModule] \u53D1\u73B0\u91CD\u590D\u8BA2\u5355 ID: ".concat(params.order_id, "\uFF0C\u66F4\u65B0\u73B0\u6709\u652F\u4ED8\u8BA2\u5355"));
671
- originalOrder = _objectSpread({}, existingOrder);
679
+
680
+ // const originalOrder = { ...existingOrder };
672
681
  existingOrder.order_info = params.order_info;
673
682
  existingOrder.total_amount = params.total_amount;
674
683
  existingOrder.is_deposit = params.is_deposit || 0;
@@ -678,14 +687,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
678
687
  this.recalculateOrderAmount(existingOrder);
679
688
 
680
689
  // 更新到数据库
681
- _context7.next = 16;
690
+ _context7.next = 14;
682
691
  return this.dbManager.update('order', existingOrder);
683
- case 16:
684
- _context7.next = 18;
692
+ case 14:
693
+ _context7.next = 16;
685
694
  return this.core.effects.emit(PaymentHooks.OnOrderUpdated, existingOrder);
686
- case 18:
695
+ case 16:
687
696
  return _context7.abrupt("return", existingOrder);
688
- case 21:
697
+ case 19:
689
698
  // 创建新的支付订单
690
699
  newOrder = {
691
700
  uuid: getUniqueId('pay_order_'),
@@ -701,33 +710,31 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
701
710
  is_deposit: params.is_deposit || 0,
702
711
  deposit_amount: params.deposit_amount || '0.00'
703
712
  };
704
- _context7.next = 24;
713
+ _context7.next = 22;
705
714
  return this.dbManager.add('order', newOrder);
706
- case 24:
707
- _context7.next = 26;
708
- return this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
709
- case 26:
715
+ case 22:
716
+ this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
710
717
  this.logInfo('createPaymentOrderAsync completed - new payment order created', {
711
718
  orderUuid: newOrder.uuid,
712
719
  orderId: newOrder.id
713
720
  });
714
721
  return _context7.abrupt("return", newOrder);
715
- case 28:
716
- _context7.next = 35;
722
+ case 25:
723
+ _context7.next = 32;
717
724
  break;
718
- case 30:
719
- _context7.prev = 30;
725
+ case 27:
726
+ _context7.prev = 27;
720
727
  _context7.t0 = _context7["catch"](1);
721
728
  console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
722
729
  this.logError('createPaymentOrderAsync failed', _context7.t0, {
723
730
  orderId: params.order_id
724
731
  });
725
732
  throw _context7.t0;
726
- case 35:
733
+ case 32:
727
734
  case "end":
728
735
  return _context7.stop();
729
736
  }
730
- }, _callee7, this, [[1, 30]]);
737
+ }, _callee7, this, [[1, 27]]);
731
738
  }));
732
739
  function createPaymentOrderAsync(_x6) {
733
740
  return _createPaymentOrderAsync.apply(this, arguments);
@@ -443,7 +443,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
443
443
  baseWalletParams = this.walletParams; // 构建完整的搜索参数,包含钱包扣款推荐的所有参数
444
444
  searchParams = {
445
445
  // 基础钱包参数
446
- sale_channel: params.sale_channel || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.sale_channel),
446
+ sale_channel: params.sale_channel || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.sale_channel) || "pos",
447
447
  customer_id: params.customer_id || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.customer_id),
448
448
  order_expect_amount: params.order_expect_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_expect_amount),
449
449
  order_product_amount: params.order_product_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_product_amount),
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -33,5 +33,5 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
33
33
  static isInScheduleByDate({ date, schedule, }: {
34
34
  date: string;
35
35
  schedule: any;
36
- }): true | undefined;
36
+ }): boolean | undefined;
37
37
  }
@@ -254,6 +254,15 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
254
254
  var _schedule$repeat_rule, _schedule$repeat_rule2;
255
255
  var date = _ref2.date,
256
256
  schedule = _ref2.schedule;
257
+ if (schedule.start_time && schedule.end_time) {
258
+ var isBeforeStartTime = dayjs(date).isBefore(dayjs(schedule.start_time));
259
+ var isAfterEndTime = dayjs(date).isAfter(dayjs(schedule.end_time));
260
+ // 如果不在 schedule 日期区间内直接返回false
261
+ if (isBeforeStartTime || isAfterEndTime) {
262
+ return false;
263
+ }
264
+ }
265
+
257
266
  // 节约性能, 强制将schedule的时间范围改为前后一天,避免大量计算.
258
267
  var _schedule = _objectSpread(_objectSpread({}, schedule), {}, {
259
268
  // 开始时间向前推一天
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
111
111
  * 获取当前的客户搜索条件
112
112
  * @returns 当前搜索条件
113
113
  */
114
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
@@ -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, SendCustomerPayLinkParams } from './types';
5
+ import { CheckoutModuleAPI, CheckoutInitParams, CreateLocalOrderParams, CurrentOrderInfo, CartSummaryItem, SendCustomerPayLinkParams } from './types';
6
6
  import { PaymentOrder, PaymentMethod, PaymentItem, PaymentItemInput } from '../../modules/Payment/types';
7
7
  export * from './types';
8
8
  /**
@@ -64,24 +64,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
64
64
  * 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
65
65
  */
66
66
  createLocalOrderAsync(params: CreateLocalOrderParams): Promise<PaymentOrder>;
67
- /**
68
- * 手动下单 (根据虚拟订单生成实际订单)
69
- *
70
- * 使用当前存储的本地订单数据调用 Order 模块创建真实订单
71
- */
72
- placeOrderAsync(params?: PlaceOrderParams): Promise<{
73
- success: boolean;
74
- orderId?: string;
75
- error?: string;
76
- }>;
77
- /**
78
- * 创建订单
79
- */
80
- createOrderAsync(params: CreateOrderParams): Promise<PaymentOrder>;
81
- /**
82
- * 处理支付
83
- */
84
- processPaymentAsync(params: ProcessPaymentParams): Promise<void>;
85
67
  /**
86
68
  * 完成结账
87
69
  */
@@ -89,28 +71,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
89
71
  success: boolean;
90
72
  orderId?: string;
91
73
  }>;
92
- /**
93
- * 取消结账
94
- */
95
- cancelCheckoutAsync(): Promise<void>;
96
- /**
97
- * 获取结账状态
98
- */
99
- getCheckoutStatus(): CheckoutStatusInfo;
100
- /**
101
- * 获取结账摘要
102
- */
103
- getCheckoutSummaryAsync(): Promise<CheckoutSummary>;
104
- /**
105
- * 获取可用支付方式
106
- */
107
- getAvailablePaymentMethodsAsync(): Promise<PaymentMethod[]>;
108
- /**
109
- * 刷新支付方式缓存
110
- *
111
- * 强制重新从服务器获取支付方式列表,更新本地缓存
112
- */
113
- refreshPaymentMethodsAsync(): Promise<PaymentMethod[]>;
114
74
  /**
115
75
  * 获取订单原始数据
116
76
  */
@@ -127,21 +87,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
127
87
  * 返回当前订单的所有支付项,包括活跃和已撤销的支付项
128
88
  */
129
89
  getCurrentOrderPaymentItemsAsync(): Promise<PaymentItem[]>;
130
- /**
131
- * 验证结账前置条件
132
- */
133
- validateCheckoutAsync(): Promise<{
134
- valid: boolean;
135
- errors: string[];
136
- }>;
137
- /**
138
- * 重试失败的操作
139
- */
140
- retryFailedOperationAsync(): Promise<void>;
141
- /**
142
- * 设置当前步骤
143
- */
144
- setCurrentStep(step: CheckoutStep): void;
145
90
  /**
146
91
  * 获取订单模块
147
92
  */
@@ -181,12 +126,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
181
126
  * @returns 当前系统计算的待付金额
182
127
  */
183
128
  getBalanceDueAmount(): string;
184
- /**
185
- * 刷新 stateAmount 为当前剩余未支付金额
186
- *
187
- * UI 可以调用此方法来主动刷新支付金额状态
188
- */
189
- refreshStateAmountAsync(): Promise<void>;
190
129
  /**
191
130
  * 获取购物车小计数据
192
131
  *
@@ -195,14 +134,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
195
134
  * @returns 购物车小计数据数组,如果没有则返回 null
196
135
  */
197
136
  getCartSummary(): CartSummaryItem[] | null;
198
- /**
199
- * 获取提取的金额详细信息
200
- *
201
- * 从当前的购物车小计数据中提取结构化的金额信息
202
- *
203
- * @returns 提取的金额信息对象,如果没有小计数据则返回 null
204
- */
205
- getExtractedAmountInfo(): ExtractedAmountInfo | null;
206
137
  /**
207
138
  * 获取支付方式列表
208
139
  *
@@ -251,34 +182,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
251
182
  * @throws 当前没有活跃订单时抛出错误
252
183
  */
253
184
  updateOrderDepositStatusAsync(isDeposit: number): Promise<void>;
254
- /**
255
- * 更新当前订单的客户信息
256
- *
257
- * 更新当前订单关联的客户信息,用于标识订单的所属客户
258
- *
259
- * @param customer 客户信息 (customer_id 和/或 customer_name)
260
- * @throws 当前没有活跃订单时抛出错误
261
- */
262
- updateOrderCustomerAsync(customer: {
263
- customer_id?: string;
264
- customer_name?: string;
265
- }): Promise<void>;
266
- /**
267
- * 获取当前订单的客户信息
268
- *
269
- * @returns 当前客户信息,如果没有则返回 null
270
- */
271
- getCurrentCustomer(): {
272
- customer_id?: string;
273
- customer_name?: string;
274
- } | null;
275
- /**
276
- * 检查订单是否需要手动同步(异步版本)
277
- *
278
- * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
279
- * 从 Payment 模块获取最新的支付项数据
280
- */
281
- needsManualSyncAsync(): Promise<boolean>;
282
185
  /**
283
186
  * 手动同步订单到后端
284
187
  *
@@ -335,34 +238,12 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
335
238
  orderUuid?: string;
336
239
  response?: any;
337
240
  }>;
338
- /**
339
- * 获取当前商店折扣金额
340
- *
341
- * @returns 当前的商店折扣金额,如果没有则返回0
342
- */
343
- getShopDiscount(): number;
344
- /**
345
- * 更新订单商店折扣
346
- *
347
- * 同时更新cartSummary和localOrderData中的shop_discount值
348
- *
349
- * @param discountAmount 商店折扣金额
350
- */
351
- updateShopDiscountAsync(discountAmount: number): Promise<void>;
352
241
  /**
353
242
  * 更新订单备注
354
243
  *
355
244
  * @param note 订单备注内容
356
245
  */
357
246
  updateOrderNoteAsync(note: string): Promise<void>;
358
- /**
359
- * 设置状态
360
- */
361
- private setStatus;
362
- /**
363
- * 设置步骤
364
- */
365
- private setStep;
366
247
  /**
367
248
  * 处理错误
368
249
  */
@@ -386,14 +267,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
386
267
  * @returns 处理后的支付项(包含找零信息)
387
268
  */
388
269
  private processCashPaymentItem;
389
- /**
390
- * 判断是否为现金支付
391
- *
392
- * @param paymentCode 支付代码
393
- * @param paymentType 支付类型
394
- * @returns 是否为现金支付
395
- */
396
- private isCashPayment;
397
270
  /**
398
271
  * 预加载支付方式(在初始化时调用)
399
272
  */
@@ -426,11 +299,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
426
299
  * 当剩余待付款金额 <= 0 时,触发订单支付完成事件
427
300
  */
428
301
  private checkOrderPaymentCompletion;
429
- /**
430
- * 同步订单到后端
431
- *
432
- * 调用后端 /order/checkout 接口创建真实订单
433
- */
434
302
  /**
435
303
  * 同步订单到后端并返回真实订单ID
436
304
  *
@@ -439,11 +307,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
439
307
  * @returns 包含订单ID、UUID和完整后端响应的对象
440
308
  */
441
309
  private syncOrderToBackendWithReturn;
442
- private syncOrderToBackend;
443
- /**
444
- * 获取状态消息
445
- */
446
- private getStatusMessage;
447
310
  setOtherParams(params: Record<string, any>, { cover }?: {
448
311
  cover?: boolean;
449
312
  }): Promise<void>;
@@ -491,19 +354,4 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
491
354
  * 在创建新订单前调用,确保状态完全干净
492
355
  */
493
356
  private resetStoreStateAsync;
494
- /**
495
- * 手动清理已完成的订单状态(公开方法)
496
- *
497
- * 供UI层调用的公开方法,用于手动清理订单状态
498
- *
499
- * @returns 清理结果
500
- */
501
- clearCompletedOrderAsync(): Promise<{
502
- success: boolean;
503
- message?: string;
504
- clearedOrder?: {
505
- uuid: string;
506
- orderId: string;
507
- } | null;
508
- }>;
509
357
  }