@pisell/pisellos 2.1.10 → 2.1.11

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.
@@ -670,12 +670,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
670
670
  return this.dbManager.get('order', params.order_id);
671
671
  case 4:
672
672
  existingOrder = _context7.sent;
673
+ this.logInfo('createPaymentOrderAsync existingOrder', {
674
+ existingOrder: existingOrder
675
+ });
676
+ // const existingOrder = existingOrders.find(
677
+ // (order: PaymentOrder) => String(order.id) === String(params.order_id),
678
+ // );
673
679
  if (!existingOrder) {
674
- _context7.next = 19;
680
+ _context7.next = 20;
675
681
  break;
676
682
  }
677
683
  // 如果存在相同 order_id 的订单,更新该订单信息
678
- console.log("[PaymentModule] \u53D1\u73B0\u91CD\u590D\u8BA2\u5355 ID: ".concat(params.order_id, "\uFF0C\u66F4\u65B0\u73B0\u6709\u652F\u4ED8\u8BA2\u5355"));
684
+ this.logInfo("createPaymentOrderAsync found duplicate order ID: ".concat(params.order_id, ", updating existing payment order"));
679
685
 
680
686
  // const originalOrder = { ...existingOrder };
681
687
  existingOrder.order_info = params.order_info;
@@ -687,14 +693,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
687
693
  this.recalculateOrderAmount(existingOrder);
688
694
 
689
695
  // 更新到数据库
690
- _context7.next = 14;
696
+ _context7.next = 15;
691
697
  return this.dbManager.update('order', existingOrder);
692
- case 14:
693
- _context7.next = 16;
698
+ case 15:
699
+ _context7.next = 17;
694
700
  return this.core.effects.emit(PaymentHooks.OnOrderUpdated, existingOrder);
695
- case 16:
701
+ case 17:
696
702
  return _context7.abrupt("return", existingOrder);
697
- case 19:
703
+ case 20:
698
704
  // 创建新的支付订单
699
705
  newOrder = {
700
706
  uuid: getUniqueId('pay_order_'),
@@ -710,31 +716,31 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
710
716
  is_deposit: params.is_deposit || 0,
711
717
  deposit_amount: params.deposit_amount || '0.00'
712
718
  };
713
- _context7.next = 22;
719
+ _context7.next = 23;
714
720
  return this.dbManager.add('order', newOrder);
715
- case 22:
721
+ case 23:
716
722
  this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
717
723
  this.logInfo('createPaymentOrderAsync completed - new payment order created', {
718
724
  orderUuid: newOrder.uuid,
719
725
  orderId: newOrder.id
720
726
  });
721
727
  return _context7.abrupt("return", newOrder);
722
- case 25:
723
- _context7.next = 32;
728
+ case 26:
729
+ _context7.next = 33;
724
730
  break;
725
- case 27:
726
- _context7.prev = 27;
731
+ case 28:
732
+ _context7.prev = 28;
727
733
  _context7.t0 = _context7["catch"](1);
728
734
  console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
729
735
  this.logError('createPaymentOrderAsync failed', _context7.t0, {
730
736
  orderId: params.order_id
731
737
  });
732
738
  throw _context7.t0;
733
- case 32:
739
+ case 33:
734
740
  case "end":
735
741
  return _context7.stop();
736
742
  }
737
- }, _callee7, this, [[1, 27]]);
743
+ }, _callee7, this, [[1, 28]]);
738
744
  }));
739
745
  function createPaymentOrderAsync(_x6) {
740
746
  return _createPaymentOrderAsync.apply(this, arguments);
@@ -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, "skip" | "num">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
@@ -403,13 +403,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
403
403
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
404
404
  while (1) switch (_context8.prev = _context8.next) {
405
405
  case 0:
406
+ this.logInfo('initWalletData called', {
407
+ params: params
408
+ });
406
409
  amountInfo = (_this$store$currentOr3 = this.store.currentOrder) === null || _this$store$currentOr3 === void 0 || (_this$store$currentOr3 = _this$store$currentOr3.order_info) === null || _this$store$currentOr3 === void 0 ? void 0 : _this$store$currentOr3.amount_breakdown;
407
410
  if (amountInfo) {
408
- _context8.next = 3;
411
+ _context8.next = 5;
409
412
  break;
410
413
  }
414
+ this.logInfo('initWalletData amountInfo not found', {
415
+ params: params
416
+ });
411
417
  return _context8.abrupt("return");
412
- case 3:
418
+ case 5:
413
419
  // 准备钱包初始化的业务数据
414
420
  walletBusinessData = _objectSpread({
415
421
  customer_id: (_this$store$currentCu = this.store.currentCustomer) !== null && _this$store$currentCu !== void 0 && _this$store$currentCu.customer_id ? Number(this.store.currentCustomer.customer_id) : undefined,
@@ -419,16 +425,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
419
425
  },
420
426
  products: this.getProductListByOrder()
421
427
  }, params);
422
- _context8.next = 6;
428
+ this.logInfo('开始拉取:initializeWalletDataFromBusinessAsync', {
429
+ walletBusinessData: walletBusinessData
430
+ });
431
+ _context8.next = 9;
423
432
  return this.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
424
- case 6:
433
+ case 9:
434
+ this.logInfo('调用结束:initializeWalletDataFromBusinessAsync', {
435
+ walletBusinessData: walletBusinessData
436
+ });
437
+
438
+ // 因为上面是接口 这里最好检查一下还有没有 currentOrder 了,如果没有,则不触发事件
425
439
  if (this.store.currentOrder) {
426
- _context8.next = 8;
440
+ _context8.next = 12;
427
441
  break;
428
442
  }
429
443
  return _context8.abrupt("return");
430
- case 8:
431
- _context8.next = 10;
444
+ case 12:
445
+ this.logInfo('initWalletData currentOrder found', {
446
+ currentOrder: this.store.currentOrder
447
+ });
448
+ // 触发钱包数据初始化完成事件
449
+ _context8.next = 15;
432
450
  return this.core.effects.emit(CheckoutHooks.OnWalletDataInitialized, {
433
451
  orderUuid: (_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.uuid,
434
452
  customerId: walletBusinessData.customer_id,
@@ -439,7 +457,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
439
457
  },
440
458
  timestamp: Date.now()
441
459
  });
442
- case 10:
460
+ case 15:
443
461
  case "end":
444
462
  return _context8.stop();
445
463
  }
@@ -540,7 +558,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
540
558
  case 21:
541
559
  paymentOrder = _context9.sent;
542
560
  this.store.currentOrder = paymentOrder;
543
- this.initWalletData();
544
561
 
545
562
  // 如果设置了自动支付,直接跳转到支付步骤
546
563
  if (params.autoPayment) {
@@ -552,9 +569,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
552
569
  });
553
570
 
554
571
  // 自动设置 stateAmount 为剩余未支付金额
555
- _context9.next = 28;
572
+ _context9.next = 27;
556
573
  return this.updateStateAmountToRemaining();
557
- case 28:
574
+ case 27:
558
575
  this.logInfo('本地订单创建成功:', {
559
576
  localOrderId: localOrderId,
560
577
  uuid: paymentOrder.uuid,
@@ -563,6 +580,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
563
580
  taxAmount: amountInfo.taxAmount,
564
581
  stateAmount: this.store.stateAmount
565
582
  });
583
+ this.initWalletData();
566
584
  return _context9.abrupt("return", paymentOrder);
567
585
  case 32:
568
586
  _context9.prev = 32;
@@ -570,12 +588,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
570
588
  _context9.next = 36;
571
589
  return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
572
590
  case 36:
591
+ this.logError('本地订单创建失败:', _context9.t0);
573
592
  this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
574
593
  error: this.store.lastError,
575
594
  timestamp: Date.now()
576
595
  });
577
596
  throw _context9.t0;
578
- case 38:
597
+ case 39:
579
598
  case "end":
580
599
  return _context9.stop();
581
600
  }
@@ -324,9 +324,12 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
324
324
  });
325
325
  try {
326
326
  const existingOrder = await this.dbManager.get("order", params.order_id);
327
+ this.logInfo("createPaymentOrderAsync existingOrder", {
328
+ existingOrder
329
+ });
327
330
  if (existingOrder) {
328
- console.log(
329
- `[PaymentModule] 发现重复订单 ID: ${params.order_id},更新现有支付订单`
331
+ this.logInfo(
332
+ `createPaymentOrderAsync found duplicate order ID: ${params.order_id}, updating existing payment order`
330
333
  );
331
334
  existingOrder.order_info = params.order_info;
332
335
  existingOrder.total_amount = params.total_amount;
@@ -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, "skip" | "num">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
@@ -222,8 +222,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
222
222
  }
223
223
  async initWalletData(params) {
224
224
  var _a, _b, _c, _d;
225
+ this.logInfo("initWalletData called", {
226
+ params
227
+ });
225
228
  const amountInfo = (_b = (_a = this.store.currentOrder) == null ? void 0 : _a.order_info) == null ? void 0 : _b.amount_breakdown;
226
229
  if (!amountInfo) {
230
+ this.logInfo("initWalletData amountInfo not found", {
231
+ params
232
+ });
227
233
  return;
228
234
  }
229
235
  const walletBusinessData = {
@@ -235,12 +241,21 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
235
241
  products: this.getProductListByOrder(),
236
242
  ...params
237
243
  };
244
+ this.logInfo("开始拉取:initializeWalletDataFromBusinessAsync", {
245
+ walletBusinessData
246
+ });
238
247
  await this.payment.wallet.initializeWalletDataFromBusinessAsync(
239
248
  walletBusinessData
240
249
  );
250
+ this.logInfo("调用结束:initializeWalletDataFromBusinessAsync", {
251
+ walletBusinessData
252
+ });
241
253
  if (!this.store.currentOrder) {
242
254
  return;
243
255
  }
256
+ this.logInfo("initWalletData currentOrder found", {
257
+ currentOrder: this.store.currentOrder
258
+ });
244
259
  await this.core.effects.emit(import_types.CheckoutHooks.OnWalletDataInitialized, {
245
260
  orderUuid: (_d = this.store.currentOrder) == null ? void 0 : _d.uuid,
246
261
  customerId: walletBusinessData.customer_id,
@@ -318,7 +333,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
318
333
  }
319
334
  });
320
335
  this.store.currentOrder = paymentOrder;
321
- this.initWalletData();
322
336
  if (params.autoPayment) {
323
337
  }
324
338
  this.core.effects.emit(import_types.CheckoutHooks.OnOrderCreated, {
@@ -334,12 +348,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
334
348
  taxAmount: amountInfo.taxAmount,
335
349
  stateAmount: this.store.stateAmount
336
350
  });
351
+ this.initWalletData();
337
352
  return paymentOrder;
338
353
  } catch (error) {
339
354
  await this.handleError(
340
355
  error,
341
356
  import_types.CheckoutErrorType.OrderCreationFailed
342
357
  );
358
+ this.logError("本地订单创建失败:", error);
343
359
  this.core.effects.emit(import_types.CheckoutHooks.OnOrderCreationFailed, {
344
360
  error: this.store.lastError,
345
361
  timestamp: Date.now()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.10",
4
+ "version": "2.1.11",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",