@pisell/pisellos 2.1.8 → 2.1.9

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);
@@ -657,7 +657,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
657
657
  key: "createPaymentOrderAsync",
658
658
  value: (function () {
659
659
  var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
660
- var existingOrders, existingOrder, originalOrder, newOrder;
660
+ var existingOrder, newOrder;
661
661
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
662
662
  while (1) switch (_context7.prev = _context7.next) {
663
663
  case 0:
@@ -667,19 +667,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
667
667
  });
668
668
  _context7.prev = 1;
669
669
  _context7.next = 4;
670
- return this.dbManager.getAll('order');
670
+ return this.dbManager.get('order', params.order_id);
671
671
  case 4:
672
- existingOrders = _context7.sent;
673
- existingOrder = existingOrders.find(function (order) {
674
- return String(order.id) === String(params.order_id);
675
- });
672
+ existingOrder = _context7.sent;
676
673
  if (!existingOrder) {
677
- _context7.next = 21;
674
+ _context7.next = 19;
678
675
  break;
679
676
  }
680
677
  // 如果存在相同 order_id 的订单,更新该订单信息
681
678
  console.log("[PaymentModule] \u53D1\u73B0\u91CD\u590D\u8BA2\u5355 ID: ".concat(params.order_id, "\uFF0C\u66F4\u65B0\u73B0\u6709\u652F\u4ED8\u8BA2\u5355"));
682
- originalOrder = _objectSpread({}, existingOrder);
679
+
680
+ // const originalOrder = { ...existingOrder };
683
681
  existingOrder.order_info = params.order_info;
684
682
  existingOrder.total_amount = params.total_amount;
685
683
  existingOrder.is_deposit = params.is_deposit || 0;
@@ -689,14 +687,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
689
687
  this.recalculateOrderAmount(existingOrder);
690
688
 
691
689
  // 更新到数据库
692
- _context7.next = 16;
690
+ _context7.next = 14;
693
691
  return this.dbManager.update('order', existingOrder);
694
- case 16:
695
- _context7.next = 18;
692
+ case 14:
693
+ _context7.next = 16;
696
694
  return this.core.effects.emit(PaymentHooks.OnOrderUpdated, existingOrder);
697
- case 18:
695
+ case 16:
698
696
  return _context7.abrupt("return", existingOrder);
699
- case 21:
697
+ case 19:
700
698
  // 创建新的支付订单
701
699
  newOrder = {
702
700
  uuid: getUniqueId('pay_order_'),
@@ -712,33 +710,31 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
712
710
  is_deposit: params.is_deposit || 0,
713
711
  deposit_amount: params.deposit_amount || '0.00'
714
712
  };
715
- _context7.next = 24;
713
+ _context7.next = 22;
716
714
  return this.dbManager.add('order', newOrder);
717
- case 24:
718
- _context7.next = 26;
719
- return this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
720
- case 26:
715
+ case 22:
716
+ this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
721
717
  this.logInfo('createPaymentOrderAsync completed - new payment order created', {
722
718
  orderUuid: newOrder.uuid,
723
719
  orderId: newOrder.id
724
720
  });
725
721
  return _context7.abrupt("return", newOrder);
726
- case 28:
727
- _context7.next = 35;
722
+ case 25:
723
+ _context7.next = 32;
728
724
  break;
729
- case 30:
730
- _context7.prev = 30;
725
+ case 27:
726
+ _context7.prev = 27;
731
727
  _context7.t0 = _context7["catch"](1);
732
728
  console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
733
729
  this.logError('createPaymentOrderAsync failed', _context7.t0, {
734
730
  orderId: params.order_id
735
731
  });
736
732
  throw _context7.t0;
737
- case 35:
733
+ case 32:
738
734
  case "end":
739
735
  return _context7.stop();
740
736
  }
741
- }, _callee7, this, [[1, 30]]);
737
+ }, _callee7, this, [[1, 27]]);
742
738
  }));
743
739
  function createPaymentOrderAsync(_x6) {
744
740
  return _createPaymentOrderAsync.apply(this, arguments);
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
314
314
  }[];
315
315
  setOtherData(key: string, value: any): void;
316
316
  getOtherData(key: string): any;
317
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
317
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
318
318
  /**
319
319
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
320
320
  *
@@ -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
  }