@pisell/pisellos 0.0.373 → 0.0.376

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 (92) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/model/strategy/adapter/walletPass/utils.js +7 -2
  3. package/dist/model/strategy/type.d.ts +1 -1
  4. package/dist/modules/Customer/types.d.ts +1 -1
  5. package/dist/modules/Payment/index.js +35 -7
  6. package/dist/modules/Payment/types.d.ts +9 -7
  7. package/dist/modules/Product/index.d.ts +1 -1
  8. package/dist/modules/Rules/types.d.ts +1 -1
  9. package/dist/modules/Schedule/type.d.ts +7 -7
  10. package/dist/modules/Schedule/types.d.ts +9 -9
  11. package/dist/solution/BookingByStep/index.d.ts +2 -2
  12. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  13. package/dist/solution/Checkout/index.js +31 -2
  14. package/dist/solution/Checkout/types.d.ts +2 -0
  15. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  16. package/dist/solution/ShopDiscount/utils.d.ts +2 -2
  17. package/dist/types/index.d.ts +1 -1
  18. package/dist/utils/task.d.ts +2 -2
  19. package/dist/utils/watch.d.ts +2 -2
  20. package/lib/core/index.js +28 -27
  21. package/lib/effects/index.d.ts +2 -2
  22. package/lib/effects/index.js +7 -3
  23. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -3
  24. package/lib/model/strategy/adapter/walletPass/example.js +21 -21
  25. package/lib/model/strategy/adapter/walletPass/index.js +4 -2
  26. package/lib/model/strategy/adapter/walletPass/locales.js +10 -10
  27. package/lib/model/strategy/adapter/walletPass/utils.js +9 -4
  28. package/lib/model/strategy/index.js +10 -7
  29. package/lib/model/strategy/strategy-example.js +19 -19
  30. package/lib/model/strategy/type.d.ts +1 -1
  31. package/lib/modules/Account/index.js +10 -9
  32. package/lib/modules/AccountList/index.js +11 -14
  33. package/lib/modules/BaseModule.js +3 -6
  34. package/lib/modules/Cart/index.js +9 -14
  35. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  36. package/lib/modules/Customer/constants.js +1 -1
  37. package/lib/modules/Customer/index.js +15 -18
  38. package/lib/modules/Customer/types.d.ts +1 -1
  39. package/lib/modules/Date/index.js +6 -10
  40. package/lib/modules/Date/types.js +0 -1
  41. package/lib/modules/Discount/index.js +6 -11
  42. package/lib/modules/Guests/index.js +15 -10
  43. package/lib/modules/Order/index.js +9 -11
  44. package/lib/modules/Payment/cash.js +1 -1
  45. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  46. package/lib/modules/Payment/eftpos.js +1 -1
  47. package/lib/modules/Payment/index.js +94 -86
  48. package/lib/modules/Payment/types.d.ts +9 -7
  49. package/lib/modules/Payment/utils.js +6 -3
  50. package/lib/modules/Payment/walletpass.js +33 -33
  51. package/lib/modules/Product/index.d.ts +1 -1
  52. package/lib/modules/Product/index.js +5 -6
  53. package/lib/modules/ProductList/index.js +3 -5
  54. package/lib/modules/Resource/index.js +12 -8
  55. package/lib/modules/Rules/index.js +21 -16
  56. package/lib/modules/Rules/types.d.ts +1 -1
  57. package/lib/modules/Schedule/index.js +5 -8
  58. package/lib/modules/Schedule/type.d.ts +7 -7
  59. package/lib/modules/Schedule/types.d.ts +9 -9
  60. package/lib/modules/Schedule/utils.js +4 -2
  61. package/lib/modules/Step/index.js +4 -7
  62. package/lib/modules/Summary/index.js +4 -9
  63. package/lib/plugins/request.js +33 -34
  64. package/lib/plugins/window.js +113 -101
  65. package/lib/solution/BookingByStep/index.d.ts +2 -2
  66. package/lib/solution/BookingByStep/index.js +129 -86
  67. package/lib/solution/BookingByStep/utils/capacity.js +15 -10
  68. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  69. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  70. package/lib/solution/BookingByStep/utils/stock.js +6 -3
  71. package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
  72. package/lib/solution/BookingTicket/index.js +14 -19
  73. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  74. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  75. package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
  76. package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
  77. package/lib/solution/BuyTickets/index.js +15 -15
  78. package/lib/solution/Checkout/index.js +233 -217
  79. package/lib/solution/Checkout/types.d.ts +2 -0
  80. package/lib/solution/Checkout/utils/index.js +22 -18
  81. package/lib/solution/RegisterAndLogin/config.js +2 -2
  82. package/lib/solution/RegisterAndLogin/index.js +110 -114
  83. package/lib/solution/RegisterAndLogin/utils.js +9 -9
  84. package/lib/solution/ShopDiscount/index.js +13 -16
  85. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  86. package/lib/solution/ShopDiscount/utils.d.ts +2 -2
  87. package/lib/types/index.d.ts +1 -1
  88. package/lib/utils/task.d.ts +2 -2
  89. package/lib/utils/task.js +3 -3
  90. package/lib/utils/watch.d.ts +2 -2
  91. package/lib/utils/watch.js +7 -5
  92. package/package.json +18 -17
@@ -1,8 +1,8 @@
1
- declare type EffectCallback = (payload: any) => void | Promise<void | {
1
+ type EffectCallback = (payload: any) => void | Promise<void | {
2
2
  status: boolean;
3
3
  message?: string;
4
4
  }>;
5
- declare type UnsubscribeFunction = () => void;
5
+ type UnsubscribeFunction = () => void;
6
6
  declare class EffectsManager {
7
7
  private listeners;
8
8
  on(event: string, callback: EffectCallback): UnsubscribeFunction;
@@ -688,13 +688,18 @@ export var getMainProductPrice = function getMainProductPrice(product, isDeductT
688
688
  }
689
689
  }
690
690
 
691
- // 税费附加费总额
691
+ // 税费
692
692
  } catch (err) {
693
693
  _iterator3.e(err);
694
694
  } finally {
695
695
  _iterator3.f();
696
696
  }
697
- var taxAndFeeTotal = new Decimal(((product === null || product === void 0 ? void 0 : product.tax_fee) || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_attached_bundle_tax_fee) || 0) + ((product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.main_product_attached_bundle_surcharge_fee) || 0));
697
+ var taxFee = new Decimal((product === null || product === void 0 ? void 0 : product.tax_fee) || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_attached_bundle_tax_fee) || 0);
698
+ // 附加费
699
+ var surchargeFee = new Decimal((product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.main_product_attached_bundle_surcharge_fee) || 0);
700
+
701
+ // 税费附加费总额
702
+ var taxAndFeeTotal = taxFee.add(surchargeFee);
698
703
 
699
704
  // 如果需要抵扣税费与附加费,则加上税费附加费总额
700
705
  if (isDeductTaxAndFee) {
@@ -225,4 +225,4 @@ export interface EngineOptions {
225
225
  /**
226
226
  * 运算符处理器
227
227
  */
228
- export declare type OperatorHandler = (fieldValue: any, compareValue: any, rule: ConditionRule) => boolean;
228
+ export type OperatorHandler = (fieldValue: any, compareValue: any, rule: ConditionRule) => boolean;
@@ -33,7 +33,7 @@ export interface ShopCustomer extends ICustomer {
33
33
  * walletDetails.wallet: 用户所有wallet
34
34
  * latestWalletDetail.wallet: 用户最新wallet
35
35
  */
36
- declare type CustomerWith = 'formRecord' | 'walletDetails.wallet' | 'latestWalletDetail.wallet';
36
+ type CustomerWith = 'formRecord' | 'walletDetails.wallet' | 'latestWalletDetail.wallet';
37
37
  /**
38
38
  * 获取客户列表参数
39
39
  */
@@ -723,11 +723,39 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
723
723
  tax_fee: '0.00',
724
724
  is_deposit: params.is_deposit || 0,
725
725
  deposit_amount: params.deposit_amount || '0.00'
726
- }; // 🚀 性能监控:记录数据库添加操作耗时
726
+ }; // 🔧 新增: 处理云端已存在的支付项
727
+ if (params.existPayment && params.existPayment.length > 0) {
728
+ newOrder.payment = params.existPayment.map(function (payment) {
729
+ return _objectSpread(_objectSpread({}, payment), {}, {
730
+ isSynced: true,
731
+ // 标记为已同步
732
+ status: payment.status || 'active'
733
+ });
734
+ });
735
+
736
+ // 重新计算待付金额
737
+ this.recalculateOrderAmount(newOrder);
738
+ this.logInfo('创建订单时包含云端支付项', {
739
+ orderId: params.order_id,
740
+ existPaymentCount: params.existPayment.length,
741
+ totalAmount: newOrder.total_amount,
742
+ expectAmount: newOrder.expect_amount,
743
+ paymentDetails: params.existPayment.map(function (p) {
744
+ return {
745
+ uuid: p.uuid,
746
+ code: p.code,
747
+ amount: p.amount,
748
+ status: p.status
749
+ };
750
+ })
751
+ });
752
+ }
753
+
754
+ // 🚀 性能监控:记录数据库添加操作耗时
727
755
  dbAddStartTime = Date.now();
728
- _context7.next = 6;
756
+ _context7.next = 7;
729
757
  return this.dbManager.add('order', newOrder, true);
730
- case 6:
758
+ case 7:
731
759
  dbAddDuration = Date.now() - dbAddStartTime;
732
760
  this.logInfo('Database add operation completed', {
733
761
  operation: 'dbManager.add',
@@ -741,19 +769,19 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
741
769
  _this3.core.effects.emit("".concat(_this3.name, ":onOrderAdded"), newOrder);
742
770
  }, 0);
743
771
  return _context7.abrupt("return", newOrder);
744
- case 12:
745
- _context7.prev = 12;
772
+ case 13:
773
+ _context7.prev = 13;
746
774
  _context7.t0 = _context7["catch"](1);
747
775
  console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
748
776
  this.logError('createPaymentOrderAsync failed', _context7.t0, {
749
777
  orderId: params.order_id
750
778
  });
751
779
  throw _context7.t0;
752
- case 17:
780
+ case 18:
753
781
  case "end":
754
782
  return _context7.stop();
755
783
  }
756
- }, _callee7, this, [[1, 12]]);
784
+ }, _callee7, this, [[1, 13]]);
757
785
  }));
758
786
  function createPaymentOrderAsync(_x6) {
759
787
  return _createPaymentOrderAsync.apply(this, arguments);
@@ -200,6 +200,8 @@ export interface PushOrderParams {
200
200
  deposit_amount?: string;
201
201
  /** 原始订单数据(可选,由 Checkout 模块传入) */
202
202
  order_info?: any;
203
+ /** 云端已存在的支付项(可选,用于处理订单在其他设备或云端生成的场景) */
204
+ existPayment?: PaymentItem[];
203
205
  }
204
206
  /**
205
207
  * 更新订单参数
@@ -581,12 +583,12 @@ export declare enum PaymentHooks {
581
583
  OnOrderAmountChanged = "payment:onOrderAmountChanged",
582
584
  OnPaymentSyncError = "payment:onPaymentSyncError",
583
585
  OnPaymentSyncSuccess = "payment:onPaymentSyncSuccess",
584
- OnWalletRecommendListUpdated = 0,
585
- OnWalletRecommendListCleared = 0,
586
- OnUserIdentificationCodesUpdated = 0,
587
- OnUserIdentificationCodesCleared = 0,
588
- OnWalletCacheCleared = 0,
589
- OnSearchIdentificationCodeCompleted = 0
586
+ OnWalletRecommendListUpdated = "wallet:onWalletRecommendListUpdated",
587
+ OnWalletRecommendListCleared = "wallet:onWalletRecommendListCleared",
588
+ OnUserIdentificationCodesUpdated = "wallet:onUserIdentificationCodesUpdated",
589
+ OnUserIdentificationCodesCleared = "wallet:onUserIdentificationCodesCleared",
590
+ OnWalletCacheCleared = "wallet:onWalletCacheCleared",
591
+ OnSearchIdentificationCodeCompleted = "wallet:onSearchIdentificationCodeCompleted"
590
592
  }
591
593
  /**
592
594
  * 钱包推荐扣款请求参数
@@ -749,7 +751,7 @@ export interface SearchIdentificationCodeResponse {
749
751
  /**
750
752
  * 搜索识别码结果类型
751
753
  */
752
- export declare type SearchIdentificationCodeResult = {
754
+ export type SearchIdentificationCodeResult = {
753
755
  type: 'walletCode';
754
756
  data: SearchIdentificationCodeItem[];
755
757
  } | {
@@ -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(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -28,7 +28,7 @@ export interface RulesModuleAPI {
28
28
  }[];
29
29
  }) => DiscountResult;
30
30
  }
31
- declare type ProductDetail = {
31
+ type ProductDetail = {
32
32
  isClient?: boolean;
33
33
  isManualDiscount?: boolean;
34
34
  booking_id: any;
@@ -1,4 +1,4 @@
1
- export declare type ScheduleItem = {
1
+ export type ScheduleItem = {
2
2
  /** 颜色 */
3
3
  color: string;
4
4
  /** 创建时间 */
@@ -65,7 +65,7 @@ export declare type ScheduleItem = {
65
65
  schedule_id: number;
66
66
  }[];
67
67
  };
68
- export declare type ScheduleFormOtherValue = {
68
+ export type ScheduleFormOtherValue = {
69
69
  /** 截止模式
70
70
  * 1: 永不截止
71
71
  * 2: 按日期截止
@@ -79,11 +79,11 @@ export declare type ScheduleFormOtherValue = {
79
79
  includeStatus: boolean;
80
80
  type: 'standard' | 'time-slots' | 'designation';
81
81
  };
82
- export declare type ExcIncDate = {
82
+ export type ExcIncDate = {
83
83
  start: string;
84
84
  end: string;
85
85
  };
86
- export declare type ScheduleFormData = {
86
+ export type ScheduleFormData = {
87
87
  /** 颜色 */
88
88
  color: string;
89
89
  /** 日程名称 */
@@ -131,20 +131,20 @@ export declare type ScheduleFormData = {
131
131
  start_time: any;
132
132
  end_time: any;
133
133
  };
134
- export declare type CalendarDataItem = {
134
+ export type CalendarDataItem = {
135
135
  date: string;
136
136
  color: string[];
137
137
  isExcluded: boolean;
138
138
  schedule_ids?: number[];
139
139
  [key: string]: any;
140
140
  };
141
- export declare type RequestData<Data> = {
141
+ export type RequestData<Data> = {
142
142
  data: Data;
143
143
  status: boolean;
144
144
  message: string;
145
145
  code: number;
146
146
  };
147
- export declare type ResponseListData<Data> = {
147
+ export type ResponseListData<Data> = {
148
148
  status: boolean;
149
149
  message: string;
150
150
  code: number;
@@ -4,7 +4,7 @@ export interface ScheduleState {
4
4
  availabilityDateList: ScheduleAvailabilityDateItem[];
5
5
  otherProductsIds: number[];
6
6
  }
7
- export declare type ScheduleAvailabilityDateItem = {
7
+ export type ScheduleAvailabilityDateItem = {
8
8
  date: string;
9
9
  schedule_id: number[];
10
10
  product_ids: number[];
@@ -24,7 +24,7 @@ export interface LoadScheduleAvailableDateParams {
24
24
  }
25
25
  export interface ScheduleModuleAPI {
26
26
  }
27
- export declare type ScheduleItem = {
27
+ export type ScheduleItem = {
28
28
  /** 颜色 */
29
29
  color: string;
30
30
  /** 创建时间 */
@@ -91,7 +91,7 @@ export declare type ScheduleItem = {
91
91
  schedule_id: number;
92
92
  }[];
93
93
  };
94
- export declare type ScheduleFormOtherValue = {
94
+ export type ScheduleFormOtherValue = {
95
95
  /** 截止模式
96
96
  * 1: 永不截止
97
97
  * 2: 按日期截止
@@ -105,11 +105,11 @@ export declare type ScheduleFormOtherValue = {
105
105
  includeStatus: boolean;
106
106
  type: 'standard' | 'time-slots' | 'designation';
107
107
  };
108
- export declare type ExcIncDate = {
108
+ export type ExcIncDate = {
109
109
  start: string;
110
110
  end: string;
111
111
  };
112
- export declare type ScheduleFormData = {
112
+ export type ScheduleFormData = {
113
113
  /** 颜色 */
114
114
  color: string;
115
115
  /** 日程名称 */
@@ -157,20 +157,20 @@ export declare type ScheduleFormData = {
157
157
  start_time: any;
158
158
  end_time: any;
159
159
  };
160
- export declare type CalendarDataItem = {
160
+ export type CalendarDataItem = {
161
161
  date: string;
162
162
  color: string[];
163
163
  isExcluded: boolean;
164
164
  schedule_ids?: number[];
165
165
  [key: string]: any;
166
166
  };
167
- export declare type RequestData<Data> = {
167
+ export type RequestData<Data> = {
168
168
  data: Data;
169
169
  status: boolean;
170
170
  message: string;
171
171
  code: number;
172
172
  };
173
- export declare type ResponseListData<Data> = {
173
+ export type ResponseListData<Data> = {
174
174
  status: boolean;
175
175
  message: string;
176
176
  code: number;
@@ -181,7 +181,7 @@ export declare type ResponseListData<Data> = {
181
181
  skip: number;
182
182
  };
183
183
  };
184
- export declare type ScheduleAllMap = Record<string, {
184
+ export type ScheduleAllMap = Record<string, {
185
185
  minTime: dayjs.Dayjs | null;
186
186
  maxTime: dayjs.Dayjs | null;
187
187
  minTimeStr: string | null;
@@ -308,7 +308,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
308
308
  date: string;
309
309
  status: string;
310
310
  week: string;
311
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
311
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
312
312
  }[]>;
313
313
  submitTimeSlot(timeSlots: TimeSliceItem): void;
314
314
  private getScheduleDataByIds;
@@ -353,7 +353,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
353
353
  };
354
354
  setOtherData(key: string, value: any): void;
355
355
  getOtherData(key: string): any;
356
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
356
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
357
357
  /**
358
358
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
359
359
  *
@@ -6,7 +6,7 @@ import { CartItem, ProductData } from '../../../modules';
6
6
  * 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
7
7
  *
8
8
  */
9
- declare type DateType = Dayjs;
9
+ type DateType = Dayjs;
10
10
  export interface TimeSliceItem {
11
11
  start_time: string;
12
12
  end_time: string;
@@ -752,7 +752,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
752
752
  value: (function () {
753
753
  var _updateLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
754
754
  var _params$orderData6, _params$orderData7, _params$cartSummary2, _params$totalInfo5, _params$totalInfo6, _params$totalInfo7, _params$totalInfo8;
755
- var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment, totalAmount, activePayments, paidAmount, remaining, _isNeedDeposit, updated, syncedAmount, remainingExpectAmount, depositDiffAmount, isNeedDeposit, created;
755
+ var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment, totalAmount, activePayments, paidAmount, remaining, _isNeedDeposit, updated, syncedAmount, remainingExpectAmount, depositDiffAmount, isNeedDeposit, created, syncedPayments, _syncedAmount;
756
756
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
757
757
  while (1) switch (_context10.prev = _context10.next) {
758
758
  case 0:
@@ -891,6 +891,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
891
891
  total_amount: amountInfo.totalAmount,
892
892
  is_deposit: isNeedDeposit.hasDeposit ? 1 : 0,
893
893
  deposit_amount: isNeedDeposit.total ? isNeedDeposit.total.toString() : '0.00',
894
+ existPayment: params.existPayment,
895
+ // 🔧 新增: 传递云端支付项
894
896
  order_info: {
895
897
  original_order_data: params.orderData,
896
898
  cart_summary: params.cartSummary,
@@ -905,7 +907,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
905
907
  case 47:
906
908
  created = _context10.sent;
907
909
  this.store.currentOrder = created;
908
- this.initWalletData();
910
+
911
+ // 🔧 新增: 如果有云端支付项,需要计算正确的待付金额
912
+ if (params.existPayment && params.existPayment.length > 0) {
913
+ // 计算已同步的支付金额
914
+ syncedPayments = created.payment.filter(function (p) {
915
+ return p.isSynced && p.status !== 'voided';
916
+ });
917
+ _syncedAmount = syncedPayments.reduce(function (sum, p) {
918
+ var amt = new Decimal(p.amount || '0');
919
+ var rounding = new Decimal(Number(p.rounding_amount) > 0 ? 0 : p.rounding_amount || '0').abs();
920
+ return sum.plus(amt).plus(rounding);
921
+ }, new Decimal(0));
922
+ this.logInfo('云端订单初始化钱包数据', {
923
+ orderId: params.orderId,
924
+ totalAmount: created.total_amount,
925
+ expectAmount: created.expect_amount,
926
+ syncedAmount: _syncedAmount.toFixed(2),
927
+ syncedPaymentCount: syncedPayments.length
928
+ });
929
+
930
+ // 初始化钱包数据,使用系统计算的待付金额
931
+ this.initWalletData({
932
+ order_wait_pay_amount: Number(created.expect_amount)
933
+ });
934
+ } else {
935
+ // 没有云端支付项,正常初始化
936
+ this.initWalletData();
937
+ }
909
938
  return _context10.abrupt("return", created);
910
939
  case 51:
911
940
  case "end":
@@ -103,6 +103,8 @@ export interface UpdateLocalOrderParams {
103
103
  cartSummary: CartSummaryItem[];
104
104
  /** total 信息(用于拆解金额) */
105
105
  totalInfo: any;
106
+ /** 云端已存在的支付项(可选,用于处理订单在其他设备或云端生成的场景) */
107
+ existPayment?: PaymentItem[];
106
108
  }
107
109
  /**
108
110
  * 本地订单数据结构 (基于 appointmentDemo.json)
@@ -11,7 +11,7 @@ export declare enum ShopDiscountHooks {
11
11
  onRulesListChange = "shopDiscount:onRulesListChange",
12
12
  onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
13
13
  }
14
- export declare type Customer = {
14
+ export type Customer = {
15
15
  id: string | number;
16
16
  name: string;
17
17
  email: string;
@@ -12,13 +12,13 @@ export declare const isAllNormalProduct: (items: any[]) => boolean;
12
12
  * @returns
13
13
  */
14
14
  export declare const getDiscountAmount: (discount: Discount, total: number, price: number) => number;
15
- export declare const getDiscountListAmountTotal: (discount: Discount[]) => Discount;
15
+ export declare const getDiscountListAmountTotal: (discount: Discount[]) => any;
16
16
  /**
17
17
  * 获取折扣金额 计算每个折扣的金额
18
18
  * @param discount
19
19
  * @returns
20
20
  */
21
- export declare const getDiscountListAmount: (discount: Discount[]) => Discount;
21
+ export declare const getDiscountListAmount: (discount: Discount[]) => any;
22
22
  export interface ScheduleItem {
23
23
  id: number;
24
24
  name: string | {
@@ -27,7 +27,7 @@ export interface ModuleOptions {
27
27
  initialState?: Record<string, any>;
28
28
  otherParams?: Record<string, any>;
29
29
  }
30
- export declare type EventHandler = (data?: any) => void;
30
+ export type EventHandler = (data?: any) => void;
31
31
  export interface PisellCore {
32
32
  registerPlugin: (plugin: Plugin, options?: PluginOptions) => void;
33
33
  getPlugin: <T extends Plugin>(name: string) => T | null;
@@ -1,5 +1,5 @@
1
- declare type Action = (...args: any[]) => Promise<any>;
2
- declare type Task = {
1
+ type Action = (...args: any[]) => Promise<any>;
2
+ type Task = {
3
3
  uuid: string;
4
4
  type: string;
5
5
  actionParams?: Record<string, any>;
@@ -2,8 +2,8 @@
2
2
  * 监听模块
3
3
  *
4
4
  */
5
- export declare type WatchEventCallback = (...args: any[]) => void;
6
- export declare type WatchEventItem = {
5
+ export type WatchEventCallback = (...args: any[]) => void;
6
+ export type WatchEventItem = {
7
7
  key: string;
8
8
  callback: WatchEventCallback;
9
9
  };
package/lib/core/index.js CHANGED
@@ -26,13 +26,13 @@ module.exports = __toCommonJS(core_exports);
26
26
  var import_createStore = require("../store/createStore");
27
27
  var import_effects = require("../effects");
28
28
  var PisellOSCore = class {
29
- plugins = /* @__PURE__ */ new Map();
30
- modules = /* @__PURE__ */ new Map();
31
- stores = /* @__PURE__ */ new Map();
32
- effects = new import_effects.EffectsManager();
33
- debug = false;
34
- context = {};
35
29
  constructor(options) {
30
+ this.plugins = /* @__PURE__ */ new Map();
31
+ this.modules = /* @__PURE__ */ new Map();
32
+ this.stores = /* @__PURE__ */ new Map();
33
+ this.effects = new import_effects.EffectsManager();
34
+ this.debug = false;
35
+ this.context = {};
36
36
  this.debug = (options == null ? void 0 : options.debug) || false;
37
37
  this.context = (options == null ? void 0 : options.context) || {};
38
38
  this.initialize(options);
@@ -48,7 +48,7 @@ var PisellOSCore = class {
48
48
  this.registerModule(item.module, item.options);
49
49
  });
50
50
  }
51
- this.log("PisellOS \u6838\u5FC3\u521D\u59CB\u5316\u5B8C\u6210");
51
+ this.log("PisellOS 核心初始化完成");
52
52
  }
53
53
  // 日志方法
54
54
  log(message, level = "info") {
@@ -71,12 +71,12 @@ var PisellOSCore = class {
71
71
  // 插件相关方法
72
72
  registerPlugin(plugin, options) {
73
73
  if (this.plugins.has(plugin.name)) {
74
- this.log(`\u63D2\u4EF6 ${plugin.name} \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6`, "warn");
74
+ this.log(`插件 ${plugin.name} 已经注册过,将被覆盖`, "warn");
75
75
  }
76
76
  if (options == null ? void 0 : options.dependencies) {
77
77
  for (const dep of options.dependencies) {
78
78
  if (!this.plugins.has(dep)) {
79
- throw new Error(`\u6CE8\u518C\u63D2\u4EF6 ${plugin.name} \u5931\u8D25\uFF1A\u7F3A\u5C11\u4F9D\u8D56\u63D2\u4EF6 ${dep}`);
79
+ throw new Error(`注册插件 ${plugin.name} 失败:缺少依赖插件 ${dep}`);
80
80
  }
81
81
  }
82
82
  }
@@ -84,14 +84,14 @@ var PisellOSCore = class {
84
84
  const result = plugin.initialize();
85
85
  if (result instanceof Promise) {
86
86
  result.catch((err) => {
87
- this.log(`\u63D2\u4EF6 ${plugin.name} \u521D\u59CB\u5316\u5931\u8D25: ${err.message}`, "error");
87
+ this.log(`插件 ${plugin.name} 初始化失败: ${err.message}`, "error");
88
88
  throw err;
89
89
  });
90
90
  }
91
91
  this.plugins.set(plugin.name, plugin);
92
- this.log(`\u63D2\u4EF6 ${plugin.name} v${plugin.version} \u6CE8\u518C\u6210\u529F`);
92
+ this.log(`插件 ${plugin.name} v${plugin.version} 注册成功`);
93
93
  } catch (error) {
94
- this.log(`\u63D2\u4EF6 ${plugin.name} \u521D\u59CB\u5316\u8FC7\u7A0B\u4E2D\u51FA\u9519: ${error}`, "error");
94
+ this.log(`插件 ${plugin.name} 初始化过程中出错: ${error}`, "error");
95
95
  throw error;
96
96
  }
97
97
  }
@@ -104,12 +104,12 @@ var PisellOSCore = class {
104
104
  // 模块相关方法
105
105
  registerModule(module2, options) {
106
106
  if (this.modules.has(module2.name)) {
107
- this.log(`\u6A21\u5757 ${module2.name} \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6`, "warn");
107
+ this.log(`模块 ${module2.name} 已经注册过,将被覆盖`, "warn");
108
108
  }
109
109
  if (options == null ? void 0 : options.dependencies) {
110
110
  for (const dep of options.dependencies) {
111
111
  if (!this.modules.has(dep)) {
112
- throw new Error(`\u6CE8\u518C\u6A21\u5757 ${module2.name} \u5931\u8D25\uFF1A\u7F3A\u5C11\u4F9D\u8D56\u6A21\u5757 ${dep}`);
112
+ throw new Error(`注册模块 ${module2.name} 失败:缺少依赖模块 ${dep}`);
113
113
  }
114
114
  }
115
115
  }
@@ -117,7 +117,7 @@ var PisellOSCore = class {
117
117
  for (const plugin of options.plugins) {
118
118
  if (!this.plugins.has(plugin)) {
119
119
  throw new Error(
120
- `\u6CE8\u518C\u6A21\u5757 ${module2.name} \u5931\u8D25\uFF1A\u7F3A\u5C11\u4F9D\u8D56\u63D2\u4EF6 ${plugin}`
120
+ `注册模块 ${module2.name} 失败:缺少依赖插件 ${plugin}`
121
121
  );
122
122
  }
123
123
  }
@@ -126,9 +126,10 @@ var PisellOSCore = class {
126
126
  (options == null ? void 0 : options.initialState) || {},
127
127
  module2.name,
128
128
  (path, value) => {
129
- console.log("core \u68C0\u6D4B\u5230\u6A21\u5757\u503C\u66F4\u65B0", module2.name, path, value);
129
+ console.log("core 检测到模块值更新", module2.name, path, value);
130
130
  this.effects.emit(`${module2.name}:changed`, { path, value });
131
- if (module2.storeChange) module2.storeChange(path, value);
131
+ if (module2.storeChange)
132
+ module2.storeChange(path, value);
132
133
  }
133
134
  );
134
135
  this.stores.set(module2.name, proxy);
@@ -136,14 +137,14 @@ var PisellOSCore = class {
136
137
  const result = module2.initialize(this, { store: proxy, ...options });
137
138
  if (result instanceof Promise) {
138
139
  result.catch((err) => {
139
- this.log(`\u6A21\u5757 ${module2.name} \u521D\u59CB\u5316\u5931\u8D25: ${err.message}`, "error");
140
+ this.log(`模块 ${module2.name} 初始化失败: ${err.message}`, "error");
140
141
  throw err;
141
142
  });
142
143
  }
143
144
  this.modules.set(module2.name, module2);
144
- this.log(`\u6A21\u5757 ${module2.name} v${module2.version} \u6CE8\u518C\u6210\u529F`);
145
+ this.log(`模块 ${module2.name} v${module2.version} 注册成功`);
145
146
  } catch (error) {
146
- this.log(`\u6A21\u5757 ${module2.name} \u521D\u59CB\u5316\u8FC7\u7A0B\u4E2D\u51FA\u9519: ${error}`, "error");
147
+ this.log(`模块 ${module2.name} 初始化过程中出错: ${error}`, "error");
147
148
  throw error;
148
149
  }
149
150
  }
@@ -167,9 +168,9 @@ var PisellOSCore = class {
167
168
  if (module2.destroy) {
168
169
  try {
169
170
  await Promise.resolve(module2.destroy());
170
- this.log(`\u6A21\u5757 ${name} \u5DF2\u9500\u6BC1`);
171
+ this.log(`模块 ${name} 已销毁`);
171
172
  } catch (error) {
172
- this.log(`\u9500\u6BC1\u6A21\u5757 ${name} \u65F6\u51FA\u9519: ${error}`, "error");
173
+ this.log(`销毁模块 ${name} 时出错: ${error}`, "error");
173
174
  }
174
175
  }
175
176
  }
@@ -178,14 +179,14 @@ var PisellOSCore = class {
178
179
  if (plugin.destroy) {
179
180
  try {
180
181
  await Promise.resolve(plugin.destroy());
181
- this.log(`\u63D2\u4EF6 ${name} \u5DF2\u9500\u6BC1`);
182
+ this.log(`插件 ${name} 已销毁`);
182
183
  } catch (error) {
183
- this.log(`\u9500\u6BC1\u63D2\u4EF6 ${name} \u65F6\u51FA\u9519: ${error}`, "error");
184
+ this.log(`销毁插件 ${name} 时出错: ${error}`, "error");
184
185
  }
185
186
  }
186
187
  }
187
188
  this.plugins.clear();
188
- this.log("PisellOS \u6838\u5FC3\u5DF2\u9500\u6BC1");
189
+ this.log("PisellOS 核心已销毁");
189
190
  }
190
191
  /**
191
192
  * 验证上下文参数
@@ -195,7 +196,7 @@ var PisellOSCore = class {
195
196
  const value = this.context[rule.name];
196
197
  if (rule.required && (value === void 0 || value === null)) {
197
198
  this.log(
198
- `\u6A21\u5757 ${config.name} \u7F3A\u5C11\u5FC5\u9700\u7684\u4E0A\u4E0B\u6587\u53C2\u6570: ${rule.name}`,
199
+ `模块 ${config.name} 缺少必需的上下文参数: ${rule.name}`,
199
200
  "error"
200
201
  );
201
202
  return false;
@@ -203,7 +204,7 @@ var PisellOSCore = class {
203
204
  if (rule.validate && value !== void 0 && value !== null) {
204
205
  if (!rule.validate(value)) {
205
206
  this.log(
206
- `\u6A21\u5757 ${config.name} \u4E0A\u4E0B\u6587\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ${rule.name} - ${rule.message || "\u9A8C\u8BC1\u5931\u8D25"}`,
207
+ `模块 ${config.name} 上下文参数验证失败: ${rule.name} - ${rule.message || "验证失败"}`,
207
208
  "error"
208
209
  );
209
210
  return false;
@@ -1,8 +1,8 @@
1
- declare type EffectCallback = (payload: any) => void | Promise<void | {
1
+ type EffectCallback = (payload: any) => void | Promise<void | {
2
2
  status: boolean;
3
3
  message?: string;
4
4
  }>;
5
- declare type UnsubscribeFunction = () => void;
5
+ type UnsubscribeFunction = () => void;
6
6
  declare class EffectsManager {
7
7
  private listeners;
8
8
  on(event: string, callback: EffectCallback): UnsubscribeFunction;
@@ -23,10 +23,13 @@ __export(effects_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(effects_exports);
25
25
  var EffectsManager = class {
26
- listeners = /* @__PURE__ */ new Map();
26
+ constructor() {
27
+ this.listeners = /* @__PURE__ */ new Map();
28
+ }
27
29
  on(event, callback) {
28
30
  var _a;
29
- if (!this.listeners.has(event)) this.listeners.set(event, /* @__PURE__ */ new Set());
31
+ if (!this.listeners.has(event))
32
+ this.listeners.set(event, /* @__PURE__ */ new Set());
30
33
  (_a = this.listeners.get(event)) == null ? void 0 : _a.add(callback);
31
34
  return () => {
32
35
  this.off(event, callback);
@@ -66,7 +69,8 @@ var EffectsManager = class {
66
69
  }
67
70
  async emit(event, payload) {
68
71
  const callbacks = this.listeners.get(event);
69
- if (!callbacks) return { status: true, data: [] };
72
+ if (!callbacks)
73
+ return { status: true, data: [] };
70
74
  return new Promise(async (resolve) => {
71
75
  const res = [];
72
76
  for (const cb of callbacks) {