@pisell/pisellos 2.3.49 → 2.3.51

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 (144) hide show
  1. package/dist/modules/Discount/index.d.ts +1 -0
  2. package/dist/modules/Discount/index.js +40 -11
  3. package/dist/modules/Discount/types.d.ts +1 -0
  4. package/dist/modules/Holder/index.d.ts +48 -0
  5. package/dist/modules/Holder/index.js +640 -0
  6. package/dist/modules/Holder/types.d.ts +123 -0
  7. package/dist/modules/Holder/types.js +1 -0
  8. package/dist/modules/Holder/utils.d.ts +13 -0
  9. package/dist/modules/Holder/utils.js +34 -0
  10. package/dist/modules/OpenData/index.js +2 -2
  11. package/dist/modules/Order/index.d.ts +4 -2
  12. package/dist/modules/Order/index.js +54 -25
  13. package/dist/modules/Order/types.d.ts +9 -0
  14. package/dist/modules/Order/utils.d.ts +10 -0
  15. package/dist/modules/Order/utils.js +35 -3
  16. package/dist/modules/Product/types.d.ts +1 -0
  17. package/dist/modules/ProductList/index.js +33 -14
  18. package/dist/modules/Quotation/index.d.ts +1 -1
  19. package/dist/modules/Quotation/index.js +2 -2
  20. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  21. package/dist/modules/ResourcePlanner/index.js +181 -0
  22. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  23. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  24. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  25. package/dist/modules/ResourcePlanner/types.js +1 -0
  26. package/dist/modules/Rules/index.js +47 -13
  27. package/dist/modules/SalesSummary/index.js +12 -13
  28. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  29. package/dist/modules/ScanOrderLogger/index.js +15 -2
  30. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  31. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  32. package/dist/modules/Schedule/index.d.ts +3 -1
  33. package/dist/modules/Schedule/index.js +21 -16
  34. package/dist/modules/Summary/utils.js +38 -13
  35. package/dist/modules/index.d.ts +2 -0
  36. package/dist/modules/index.js +3 -1
  37. package/dist/plugins/window.d.ts +1 -0
  38. package/dist/server/index.d.ts +14 -0
  39. package/dist/server/index.js +907 -793
  40. package/dist/solution/BaseSales/index.d.ts +7 -0
  41. package/dist/solution/BaseSales/index.js +64 -42
  42. package/dist/solution/BookingByStep/index.d.ts +17 -2
  43. package/dist/solution/BookingByStep/index.js +294 -215
  44. package/dist/solution/BookingByStep/types.d.ts +2 -1
  45. package/dist/solution/BookingByStep/types.js +3 -1
  46. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  47. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  48. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  49. package/dist/solution/BookingTicket/index.js +2 -2
  50. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  51. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  52. package/dist/solution/ScanOrder/index.d.ts +26 -14
  53. package/dist/solution/ScanOrder/index.js +1142 -739
  54. package/dist/solution/ScanOrder/types.d.ts +21 -1
  55. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  56. package/dist/solution/ScanOrder/utils.js +66 -25
  57. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  58. package/dist/solution/ShopDiscount/index.js +125 -87
  59. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  60. package/dist/solution/UnifiedBookingSales/index.js +1891 -0
  61. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  62. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  63. package/dist/solution/VenueBooking/index.d.ts +39 -11
  64. package/dist/solution/VenueBooking/index.js +1167 -841
  65. package/dist/solution/VenueBooking/types.d.ts +3 -0
  66. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  67. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  68. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  69. package/dist/solution/index.d.ts +1 -0
  70. package/dist/solution/index.js +2 -1
  71. package/dist/types/index.d.ts +1 -0
  72. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  73. package/lib/modules/Discount/index.d.ts +1 -0
  74. package/lib/modules/Discount/index.js +9 -0
  75. package/lib/modules/Discount/types.d.ts +1 -0
  76. package/lib/modules/Holder/index.d.ts +48 -0
  77. package/lib/modules/Holder/index.js +402 -0
  78. package/lib/modules/Holder/types.d.ts +123 -0
  79. package/lib/modules/Holder/types.js +17 -0
  80. package/lib/modules/Holder/utils.d.ts +13 -0
  81. package/lib/modules/Holder/utils.js +71 -0
  82. package/lib/modules/OpenData/index.js +1 -1
  83. package/lib/modules/Order/index.d.ts +4 -2
  84. package/lib/modules/Order/index.js +26 -10
  85. package/lib/modules/Order/types.d.ts +9 -0
  86. package/lib/modules/Order/utils.d.ts +10 -0
  87. package/lib/modules/Order/utils.js +36 -5
  88. package/lib/modules/Product/types.d.ts +1 -0
  89. package/lib/modules/ProductList/index.js +40 -31
  90. package/lib/modules/Quotation/index.d.ts +1 -1
  91. package/lib/modules/Quotation/index.js +2 -2
  92. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  93. package/lib/modules/ResourcePlanner/index.js +148 -0
  94. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  95. package/lib/modules/ResourcePlanner/planner.js +933 -0
  96. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  97. package/lib/modules/ResourcePlanner/types.js +17 -0
  98. package/lib/modules/Rules/index.js +33 -16
  99. package/lib/modules/SalesSummary/index.js +6 -7
  100. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  101. package/lib/modules/ScanOrderLogger/index.js +13 -1
  102. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  103. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  104. package/lib/modules/Schedule/index.d.ts +3 -1
  105. package/lib/modules/Schedule/index.js +10 -8
  106. package/lib/modules/Summary/utils.js +21 -1
  107. package/lib/modules/index.d.ts +2 -0
  108. package/lib/modules/index.js +5 -1
  109. package/lib/plugins/window.d.ts +1 -0
  110. package/lib/server/index.d.ts +14 -0
  111. package/lib/server/index.js +72 -15
  112. package/lib/solution/BaseSales/index.d.ts +7 -0
  113. package/lib/solution/BaseSales/index.js +24 -8
  114. package/lib/solution/BookingByStep/index.d.ts +17 -2
  115. package/lib/solution/BookingByStep/index.js +60 -18
  116. package/lib/solution/BookingByStep/types.d.ts +2 -1
  117. package/lib/solution/BookingByStep/types.js +5 -0
  118. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  119. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  120. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  121. package/lib/solution/BookingTicket/index.js +10 -2
  122. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  123. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  124. package/lib/solution/ScanOrder/index.d.ts +26 -14
  125. package/lib/solution/ScanOrder/index.js +449 -182
  126. package/lib/solution/ScanOrder/types.d.ts +21 -1
  127. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  128. package/lib/solution/ScanOrder/utils.js +31 -0
  129. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  130. package/lib/solution/ShopDiscount/index.js +14 -0
  131. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  132. package/lib/solution/UnifiedBookingSales/index.js +1084 -0
  133. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  134. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  135. package/lib/solution/VenueBooking/index.d.ts +39 -11
  136. package/lib/solution/VenueBooking/index.js +322 -110
  137. package/lib/solution/VenueBooking/types.d.ts +3 -0
  138. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  139. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  140. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  141. package/lib/solution/index.d.ts +1 -0
  142. package/lib/solution/index.js +3 -1
  143. package/lib/types/index.d.ts +1 -0
  144. package/package.json +1 -1
@@ -0,0 +1,227 @@
1
+ export type ResourcePlannerMode = 'appointment' | 'scan_order' | 'venue_grid';
2
+ export type ResourcePlannerProductKind = 'normal' | 'duration' | 'session' | 'venue_slot';
3
+ export type ResourcePlannerResourceType = 'single' | 'multiple' | 'capacity';
4
+ export type ResourcePlannerStatus = 'available' | 'limited' | 'full' | 'conflict' | 'unavailable' | 'past';
5
+ export interface ResourcePlannerTimeRange {
6
+ start_at: string;
7
+ end_at: string;
8
+ }
9
+ export interface ResourcePlannerEvent extends ResourcePlannerTimeRange {
10
+ resourceId?: number | string;
11
+ resource_id?: number | string;
12
+ pax?: number;
13
+ product_uid?: string;
14
+ source?: 'remote' | 'cart' | 'selection';
15
+ [key: string]: any;
16
+ }
17
+ export interface ResourcePlannerResourceRequirement {
18
+ formId?: number | string;
19
+ resourceIds?: Array<number | string>;
20
+ resourceType?: ResourcePlannerResourceType;
21
+ capacityRequired?: number;
22
+ required?: boolean;
23
+ }
24
+ export interface ResourcePlannerProduct {
25
+ id: number | string;
26
+ title?: string;
27
+ kind: ResourcePlannerProductKind;
28
+ durationMinutes?: number;
29
+ schedule?: ResourcePlannerTimeRange[];
30
+ resourceRequirements?: ResourcePlannerResourceRequirement[];
31
+ capacityRequired?: number;
32
+ quantity?: number;
33
+ price?: string | number | null;
34
+ raw?: Record<string, any>;
35
+ }
36
+ export interface ResourcePlannerResource {
37
+ id: number | string;
38
+ formId?: number | string;
39
+ name?: string;
40
+ resourceType: ResourcePlannerResourceType;
41
+ capacity: number;
42
+ times: Array<ResourcePlannerTimeRange & {
43
+ event_list?: ResourcePlannerEvent[];
44
+ [key: string]: any;
45
+ }>;
46
+ childResourceIds?: Array<number | string>;
47
+ raw?: Record<string, any>;
48
+ }
49
+ export interface ResourcePlannerContextInput {
50
+ products?: ResourcePlannerProduct[];
51
+ resources?: ResourcePlannerResource[];
52
+ externalEvents?: ResourcePlannerEvent[];
53
+ slotDurationMinutes?: number;
54
+ businessStartTime?: string;
55
+ businessEndTime?: string;
56
+ }
57
+ export interface ResourcePlannerQuery {
58
+ mode?: ResourcePlannerMode;
59
+ productIds?: Array<number | string>;
60
+ date?: string;
61
+ dateRange?: {
62
+ start: string;
63
+ end: string;
64
+ };
65
+ startTime?: string;
66
+ endTime?: string;
67
+ resourceIds?: Array<number | string>;
68
+ serviceObjectIds?: Array<number | string>;
69
+ holderIds?: Array<number | string>;
70
+ pax?: number;
71
+ slotDurationMinutes?: number;
72
+ }
73
+ export interface ResourcePlannerSelection {
74
+ productIds: Array<number | string>;
75
+ date?: string;
76
+ startTime?: string;
77
+ endTime?: string;
78
+ resourceIds: Array<number | string>;
79
+ assignments: ResourcePlannerAssignment[];
80
+ mode?: ResourcePlannerMode;
81
+ }
82
+ export interface ResourcePlannerSelectionPatch extends Partial<ResourcePlannerSelection> {
83
+ replaceAssignments?: boolean;
84
+ }
85
+ export interface ResourcePlannerDemandInterval {
86
+ id: string;
87
+ productId: number | string;
88
+ source: Extract<ResourcePlannerProductKind, 'duration' | 'session' | 'venue_slot'>;
89
+ date: string;
90
+ start_at: string;
91
+ end_at: string;
92
+ durationMinutes: number;
93
+ quantity: number;
94
+ capacityRequired: number;
95
+ resourceRequirements: ResourcePlannerResourceRequirement[];
96
+ }
97
+ export interface ResourcePlannerConflict {
98
+ type: 'outside_resource_time' | 'remote_event_overlap' | 'cart_overlap' | 'capacity_full' | 'missing_time' | 'missing_resource' | 'missing_assignment' | 'past';
99
+ message: string;
100
+ event?: ResourcePlannerEvent;
101
+ resourceId?: number | string;
102
+ productId?: number | string;
103
+ }
104
+ export interface ResourcePlannerAvailabilityCell {
105
+ key: string;
106
+ productId: number | string;
107
+ resourceId?: number | string;
108
+ date?: string;
109
+ start_at: string;
110
+ end_at: string;
111
+ startTime?: string;
112
+ endTime?: string;
113
+ durationMinutes?: number;
114
+ cellType: 'availability_range' | 'fixed_interval' | 'unavailable';
115
+ status: ResourcePlannerStatus;
116
+ remainingCapacity?: number;
117
+ maxCapacity?: number;
118
+ reasonCodes: string[];
119
+ conflicts: ResourcePlannerConflict[];
120
+ }
121
+ export interface ResourcePlannerProductOption {
122
+ productId: number | string;
123
+ title?: string;
124
+ status: ResourcePlannerStatus;
125
+ reasonCodes: string[];
126
+ }
127
+ export interface ResourcePlannerResourceOption {
128
+ resourceId: number | string;
129
+ resourceName?: string;
130
+ resourceFormId?: number | string;
131
+ resourceType: ResourcePlannerResourceType;
132
+ status: ResourcePlannerStatus;
133
+ remainingCapacity?: number;
134
+ maxCapacity?: number;
135
+ reasonCodes: string[];
136
+ }
137
+ export interface ResourcePlannerDateSummary {
138
+ date: string;
139
+ status: ResourcePlannerStatus;
140
+ availableCount: number;
141
+ totalCount: number;
142
+ }
143
+ export interface ResourcePlannerTimeSlot {
144
+ startTime: string;
145
+ endTime: string;
146
+ status: ResourcePlannerStatus;
147
+ resourceId: number | string;
148
+ productId?: number | string;
149
+ remainingCapacity?: number;
150
+ maxCapacity?: number;
151
+ reasonCodes: string[];
152
+ }
153
+ export interface ResourcePlannerTimeGridRow {
154
+ resourceId: number | string;
155
+ resourceName?: string;
156
+ resourceFormId?: number | string;
157
+ slots: ResourcePlannerTimeSlot[];
158
+ }
159
+ export interface ResourcePlannerTimeGrid {
160
+ date?: string;
161
+ timeLabels: string[];
162
+ resources: ResourcePlannerTimeGridRow[];
163
+ }
164
+ export interface ResourcePlannerProjection {
165
+ query: ResourcePlannerQuery;
166
+ demandIntervals: ResourcePlannerDemandInterval[];
167
+ productOptions: ResourcePlannerProductOption[];
168
+ resourceOptions: ResourcePlannerResourceOption[];
169
+ dateSummary: ResourcePlannerDateSummary[];
170
+ timeGrid: ResourcePlannerTimeGrid;
171
+ cells: ResourcePlannerAvailabilityCell[];
172
+ }
173
+ export interface ResourcePlannerAssignment {
174
+ productId: number | string;
175
+ resourceId: number | string;
176
+ start_at: string;
177
+ end_at: string;
178
+ capacityRequired?: number;
179
+ }
180
+ export interface ResourcePlannerAssignableSlotResource {
181
+ resourceId: number | string;
182
+ resourceName?: string;
183
+ resourceFormId?: number | string;
184
+ resourceType?: ResourcePlannerResourceType;
185
+ capacityRequired?: number;
186
+ remainingCapacity?: number;
187
+ maxCapacity?: number;
188
+ }
189
+ export interface ResourcePlannerAssignableSlot {
190
+ key: string;
191
+ productId: number | string;
192
+ date: string;
193
+ start_at: string;
194
+ end_at: string;
195
+ startTime: string;
196
+ endTime: string;
197
+ durationMinutes: number;
198
+ status: ResourcePlannerStatus;
199
+ resources: ResourcePlannerAssignableSlotResource[];
200
+ assignments: ResourcePlannerAssignment[];
201
+ conflicts: ResourcePlannerConflict[];
202
+ }
203
+ export interface ResourcePlannerAssignableSlotResult {
204
+ projection: ResourcePlannerProjection;
205
+ slots: ResourcePlannerAssignableSlot[];
206
+ conflicts: ResourcePlannerConflict[];
207
+ }
208
+ export interface ResourcePlannerAssignmentResult {
209
+ assignments: ResourcePlannerAssignment[];
210
+ conflicts: ResourcePlannerConflict[];
211
+ }
212
+ export interface ResourcePlannerValidationResult {
213
+ ok: boolean;
214
+ conflicts: ResourcePlannerConflict[];
215
+ }
216
+ export interface ResourcePlannerSnapshot {
217
+ context: Required<ResourcePlannerContextInput>;
218
+ selection: ResourcePlannerSelection;
219
+ projection: ResourcePlannerProjection | null;
220
+ version: number;
221
+ }
222
+ export interface ResourcePlannerState {
223
+ context: Required<ResourcePlannerContextInput>;
224
+ selection: ResourcePlannerSelection;
225
+ projection: ResourcePlannerProjection | null;
226
+ version: number;
227
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -438,7 +438,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
438
438
  _id: product._id,
439
439
  parentId: product._id,
440
440
  quantity: product.quantity,
441
- num: product.num
441
+ num: product.num,
442
+ booking_id: product.booking_id
442
443
  });
443
444
 
444
445
  // 2. 展开 bundle 子商品
@@ -462,7 +463,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
462
463
  origin_total: new Decimal(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
463
464
  original_price: bundleItem.original_price,
464
465
  // 继承主商品属性
465
- booking_id: product.booking_id,
466
+ booking_id: bundleItem.booking_id,
466
467
  discount_list: bundleItem.discount_list || []
467
468
  });
468
469
  });
@@ -987,7 +988,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
987
988
  discount_product_id: discount.product_id
988
989
  },
989
990
  metadata: {
990
- num: num
991
+ num: num,
992
+ discount_rule_uncheck_flag: discount === null || discount === void 0 ? void 0 : discount.discount_rule_uncheck_flag
991
993
  }
992
994
  };
993
995
  applicableProducts.push(productData);
@@ -1483,7 +1485,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1483
1485
  _num: isGoodPass ? 1 : product.num,
1484
1486
  config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
1485
1487
  metadata: _objectSpread(_objectSpread({
1486
- num: 1
1488
+ num: 1,
1489
+ discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
1487
1490
  }, productDiscountDifference !== undefined && {
1488
1491
  product_discount_difference: productDiscountDifference
1489
1492
  }), {}, {
@@ -1570,6 +1573,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1570
1573
  metadata: {
1571
1574
  // 🔥 使用拆分后的唯一 _id
1572
1575
  custom_product_bundle_map_id: uniqueId,
1576
+ discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
1573
1577
  num: 1
1574
1578
  },
1575
1579
  _num: 1,
@@ -1601,7 +1605,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1601
1605
  _id: "".concat(flatItem._id, "_split_rest"),
1602
1606
  num: normalNum,
1603
1607
  quantity: normalNum,
1604
- discount_list: [],
1608
+ discount_list: _this4.filterDiscountListByType(flatItem.discount_list, 'promotion'),
1605
1609
  processed: true
1606
1610
  }));
1607
1611
  }
@@ -1655,6 +1659,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1655
1659
  metadata: _objectSpread({
1656
1660
  // 🔥 使用唯一的 _id
1657
1661
  custom_product_bundle_map_id: _uniqueId,
1662
+ discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
1658
1663
  num: product.num || 1
1659
1664
  }, _productDiscountDifference !== undefined && {
1660
1665
  product_discount_difference: _productDiscountDifference
@@ -1670,7 +1675,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1670
1675
  processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
1671
1676
  total: targetProductTotal,
1672
1677
  price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1673
- discount_list: [_discountDetail2],
1678
+ discount_list: _this4.filterDiscountListByType(flatItem.discount_list, 'promotion').concat([_discountDetail2]),
1674
1679
  processed: true
1675
1680
  }));
1676
1681
  }
@@ -2145,6 +2150,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2145
2150
  }, {
2146
2151
  key: "checkPackageSubItemUsageRules",
2147
2152
  value: function checkPackageSubItemUsageRules(discount, flatItem) {
2153
+ var _flatItem$product;
2148
2154
  var limitedData = discount.limited_relation_product_data;
2149
2155
  var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
2150
2156
  var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
@@ -2166,6 +2172,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2166
2172
  filter = _ref17$filter === void 0 ? 0 : _ref17$filter;
2167
2173
  var isMainProduct = flatItem.type === 'main'; // 单独购买
2168
2174
  var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
2175
+ var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
2169
2176
 
2170
2177
  // 主商品直接可用
2171
2178
  if (isMainProduct) {
@@ -2208,13 +2215,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2208
2215
  if (!filter) {
2209
2216
  isScopeValid = true;
2210
2217
  } else {
2211
- isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
2218
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2212
2219
  }
2213
2220
  }
2214
2221
 
2215
2222
  // 包含套餐判断, products值兼容旧数据
2216
2223
  if (scopeType === 'specific_packages' || scopeType === 'products') {
2217
- isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
2224
+ isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2218
2225
  }
2219
2226
 
2220
2227
  // 价格和套餐适用范围都符合,则可用
@@ -2264,16 +2271,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2264
2271
 
2265
2272
  // 检查 rules
2266
2273
  if (rules.length > 0) {
2267
- // 检查原价
2268
- if (_isOriginalPrice2 && rules.includes('original_price')) {
2269
- return true;
2274
+ var _isOriginalPrice3 = _isOriginalPrice2 && rules.includes('original_price');
2275
+ var _isMarkupPrice3 = _isMarkupPrice2 && rules.includes('markup_price');
2276
+ // 价格是否符合规则:原价或加价
2277
+ var _isPriceValid = _isOriginalPrice3 || _isMarkupPrice3;
2278
+ // 套餐适用范围校验
2279
+ var _isScopeValid = false;
2280
+
2281
+ // 排除套餐判断, product_all值兼容旧数据
2282
+ if (scopeType === 'all_packages' || scopeType === 'product_all') {
2283
+ // 所有套餐可用
2284
+ if (!filter) {
2285
+ _isScopeValid = true;
2286
+ } else {
2287
+ _isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2288
+ }
2270
2289
  }
2271
2290
 
2272
- // 检查加价
2273
- if (_isMarkupPrice2 && rules.includes('markup_price')) {
2291
+ // 包含套餐判断, products值兼容旧数据
2292
+ if (scopeType === 'specific_packages' || scopeType === 'products') {
2293
+ _isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2294
+ }
2295
+
2296
+ // 价格和套餐适用范围都符合,则可用
2297
+ if (_isPriceValid && _isScopeValid) {
2274
2298
  return true;
2275
2299
  }
2276
2300
 
2301
+ // 检查原价
2302
+ // if (isOriginalPrice && rules.includes('original_price')) {
2303
+ // return true;
2304
+ // }
2305
+
2306
+ // 检查加价
2307
+ // if (isMarkupPrice && rules.includes('markup_price')) {
2308
+ // return true;
2309
+ // }
2310
+
2277
2311
  // 如果都不匹配,则不可用
2278
2312
  return false;
2279
2313
  }
@@ -64,21 +64,19 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
64
64
  this.store.surchargeList = ((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList) || [];
65
65
  this.store.summary = ((_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.summary) || createEmptySalesSummary();
66
66
  this.surchargeListModuleName = ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.surchargeListModuleName) || 'surchargeList';
67
- if (this.appPlugin) {
68
- _context.next = 10;
69
- break;
70
- }
71
- throw new Error('SalesSummaryModule 需要 app 插件支持');
72
- case 10:
67
+
68
+ // if (!this.appPlugin) {
69
+ // throw new Error('SalesSummaryModule 需要 app 插件支持');
70
+ // }
73
71
  if (this.request) {
74
- _context.next = 12;
72
+ _context.next = 10;
75
73
  break;
76
74
  }
77
75
  throw new Error('SalesSummaryModule 需要 request 插件支持');
78
- case 12:
79
- _context.next = 14;
76
+ case 10:
77
+ _context.next = 12;
80
78
  return this.getSurchargeList();
81
- case 14:
79
+ case 12:
82
80
  case "end":
83
81
  return _context.stop();
84
82
  }
@@ -192,10 +190,11 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
192
190
  }, {
193
191
  key: "getAppData",
194
192
  value: function getAppData(key) {
195
- var _this$appPlugin$getDa, _this$appPlugin, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
196
- var getData = (_this$appPlugin$getDa = (_this$appPlugin = this.appPlugin).getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
193
+ var _this$appPlugin, _this$appPlugin$getDa, _this$appPlugin2, _this$appPlugin2$getA, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
194
+ var getData = (_this$appPlugin = this.appPlugin) === null || _this$appPlugin === void 0 || (_this$appPlugin$getDa = _this$appPlugin.getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
197
195
  if (typeof getData === 'function') return getData(key);
198
- var app = this.appPlugin.getApp();
196
+ var app = (_this$appPlugin2 = this.appPlugin) === null || _this$appPlugin2 === void 0 || (_this$appPlugin2$getA = _this$appPlugin2.getApp) === null || _this$appPlugin2$getA === void 0 ? void 0 : _this$appPlugin2$getA.call(_this$appPlugin2);
197
+ if (!app) return undefined;
199
198
  var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
200
199
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
201
200
  }
@@ -11,10 +11,12 @@ export declare class ScanOrderLoggerModule extends BaseModule implements Module,
11
11
  protected defaultName: string;
12
12
  protected defaultVersion: string;
13
13
  private store;
14
+ private window?;
14
15
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
15
16
  setContext(context: ScanOrderLoggerContext): void;
16
17
  setProvider(provider: ScanOrderLoggerProviderType): void;
17
18
  setProviderConfig(providerConfig: ScanOrderLoggerProviderConfig): void;
19
+ private getCurrentHost;
18
20
  private buildRecord;
19
21
  addLog(params: ScanOrderLogInput): Promise<void>;
20
22
  }
@@ -46,6 +46,7 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
46
46
  _defineProperty(_assertThisInitialized(_this), "defaultName", 'scanOrderLogger');
47
47
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
48
48
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
49
+ _defineProperty(_assertThisInitialized(_this), "window", void 0);
49
50
  return _this;
50
51
  }
51
52
  _createClass(ScanOrderLoggerModule, [{
@@ -64,6 +65,7 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
64
65
  options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
65
66
  this.core = core;
66
67
  this.store = options.store;
68
+ this.window = core.getPlugin('window') || undefined;
67
69
  provider = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.provider) || 'feishu';
68
70
  providerConfig = ((_options$otherParams2 = options.otherParams) === null || _options$otherParams2 === void 0 ? void 0 : _options$otherParams2.providerConfig) || {};
69
71
  context = ((_options$otherParams3 = options.otherParams) === null || _options$otherParams3 === void 0 ? void 0 : _options$otherParams3.context) || {};
@@ -73,7 +75,7 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
73
75
  grafana: _objectSpread(_objectSpread({}, defaultProviderConfig.grafana), providerConfig.grafana || {})
74
76
  });
75
77
  this.store.context = context;
76
- case 9:
78
+ case 10:
77
79
  case "end":
78
80
  return _context.stop();
79
81
  }
@@ -102,16 +104,27 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
102
104
  grafana: _objectSpread(_objectSpread({}, this.store.providerConfig.grafana || {}), providerConfig.grafana || {})
103
105
  });
104
106
  }
107
+ }, {
108
+ key: "getCurrentHost",
109
+ value: function getCurrentHost() {
110
+ var _this$window;
111
+ var host = (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.location) === null || _this$window === void 0 ? void 0 : _this$window.host;
112
+ if (typeof host === 'string' && host.length > 0) return host;
113
+ return undefined;
114
+ }
105
115
  }, {
106
116
  key: "buildRecord",
107
117
  value: function buildRecord(params) {
118
+ var host = this.getCurrentHost();
108
119
  return {
109
120
  level: params.level || 'info',
110
121
  title: params.title,
111
122
  timestamp: params.timestamp || dayjs().format('YYYY-MM-DD HH:mm:ss'),
112
123
  payload: params.payload || {},
113
124
  extra: params.extra || {},
114
- context: this.store.context || {}
125
+ context: _objectSpread(_objectSpread({}, this.store.context || {}), host ? {
126
+ host: host
127
+ } : {})
115
128
  };
116
129
  }
117
130
  }, {
@@ -142,62 +142,80 @@ function _flushQueue() {
142
142
  export var feishuLoggerProvider = {
143
143
  send: function send(payload) {
144
144
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
145
- var _payload$providerConf, _payload$providerConf2, _payload$providerConf3;
146
- var webhook, throttleMs;
145
+ var _payload$providerConf, _payload$providerConf2, _payload$providerConf3, _payload$providerConf4;
146
+ var webhook, errorHook, throttleMs;
147
147
  return _regeneratorRuntime().wrap(function _callee$(_context) {
148
148
  while (1) switch (_context.prev = _context.next) {
149
149
  case 0:
150
150
  cachedProviderConfig = payload.providerConfig;
151
151
  webhook = (_payload$providerConf = payload.providerConfig) === null || _payload$providerConf === void 0 || (_payload$providerConf = _payload$providerConf.feishu) === null || _payload$providerConf === void 0 ? void 0 : _payload$providerConf.webhook;
152
- if (webhook) {
153
- _context.next = 5;
152
+ errorHook = (_payload$providerConf2 = payload.providerConfig) === null || _payload$providerConf2 === void 0 || (_payload$providerConf2 = _payload$providerConf2.feishu) === null || _payload$providerConf2 === void 0 ? void 0 : _payload$providerConf2.errorHook;
153
+ if (!(typeof fetch !== 'function')) {
154
+ _context.next = 6;
154
155
  break;
155
156
  }
156
- console.warn('[ScanOrderLogger] Feishu webhook 未配置,跳过日志上报');
157
+ console.warn('[ScanOrderLogger] 当前环境不支持 fetch,跳过 Feishu 日志上报');
157
158
  return _context.abrupt("return");
158
- case 5:
159
- if (isWebhookUsable(webhook)) {
160
- _context.next = 7;
159
+ case 6:
160
+ if (!(payload.record.level === 'error' && isWebhookUsable(errorHook))) {
161
+ _context.next = 16;
161
162
  break;
162
163
  }
164
+ _context.prev = 7;
165
+ _context.next = 10;
166
+ return postToFeishu(errorHook, buildFeishuBody([payload.record]));
167
+ case 10:
168
+ _context.next = 15;
169
+ break;
170
+ case 12:
171
+ _context.prev = 12;
172
+ _context.t0 = _context["catch"](7);
173
+ console.warn('[ScanOrderLogger] Feishu errorHook 上报失败', _context.t0);
174
+ case 15:
163
175
  return _context.abrupt("return");
164
- case 7:
165
- if (!(typeof fetch !== 'function')) {
166
- _context.next = 10;
176
+ case 16:
177
+ if (webhook) {
178
+ _context.next = 19;
167
179
  break;
168
180
  }
169
- console.warn('[ScanOrderLogger] 当前环境不支持 fetch,跳过 Feishu 日志上报');
181
+ console.warn('[ScanOrderLogger] Feishu webhook 未配置,跳过日志上报');
170
182
  return _context.abrupt("return");
171
- case 10:
172
- throttleMs = (_payload$providerConf2 = (_payload$providerConf3 = payload.providerConfig) === null || _payload$providerConf3 === void 0 || (_payload$providerConf3 = _payload$providerConf3.feishu) === null || _payload$providerConf3 === void 0 ? void 0 : _payload$providerConf3.throttleMs) !== null && _payload$providerConf2 !== void 0 ? _payload$providerConf2 : DEFAULT_THROTTLE_MS;
173
- if (!(throttleMs <= 0)) {
183
+ case 19:
184
+ if (isWebhookUsable(webhook)) {
174
185
  _context.next = 21;
175
186
  break;
176
187
  }
177
- _context.prev = 12;
178
- _context.next = 15;
188
+ return _context.abrupt("return");
189
+ case 21:
190
+ throttleMs = (_payload$providerConf3 = (_payload$providerConf4 = payload.providerConfig) === null || _payload$providerConf4 === void 0 || (_payload$providerConf4 = _payload$providerConf4.feishu) === null || _payload$providerConf4 === void 0 ? void 0 : _payload$providerConf4.throttleMs) !== null && _payload$providerConf3 !== void 0 ? _payload$providerConf3 : DEFAULT_THROTTLE_MS;
191
+ if (!(throttleMs <= 0)) {
192
+ _context.next = 32;
193
+ break;
194
+ }
195
+ _context.prev = 23;
196
+ _context.next = 26;
179
197
  return postToFeishu(webhook, buildFeishuBody([payload.record]));
180
- case 15:
181
- _context.next = 20;
198
+ case 26:
199
+ _context.next = 31;
182
200
  break;
183
- case 17:
184
- _context.prev = 17;
185
- _context.t0 = _context["catch"](12);
186
- console.warn('[ScanOrderLogger] Feishu 日志上报失败', _context.t0);
187
- case 20:
201
+ case 28:
202
+ _context.prev = 28;
203
+ _context.t1 = _context["catch"](23);
204
+ console.warn('[ScanOrderLogger] Feishu 日志上报失败', _context.t1);
205
+ case 31:
188
206
  return _context.abrupt("return");
189
- case 21:
207
+ case 32:
190
208
  pendingQueue.push(payload.record);
191
209
  if (!flushTimer) {
192
210
  flushTimer = setTimeout(function () {
193
211
  void flushQueue();
194
212
  }, throttleMs);
195
213
  }
196
- case 23:
214
+ case 34:
197
215
  case "end":
198
216
  return _context.stop();
199
217
  }
200
- }, _callee, null, [[12, 17]]);
218
+ }, _callee, null, [[7, 12], [23, 28]]);
201
219
  }))();
202
220
  }
203
221
  };
@@ -2,6 +2,7 @@ export type ScanOrderLogLevel = 'info' | 'warning' | 'error' | 'debug';
2
2
  export type ScanOrderLoggerProviderType = 'feishu' | 'grafana';
3
3
  export interface ScanOrderLoggerProviderFeishuConfig {
4
4
  webhook?: string;
5
+ errorHook?: string;
5
6
  /**
6
7
  * 节流窗口毫秒数,默认 3000ms
7
8
  * - >0:首条日志进入队列并启动定时器,窗口结束后合并成一条 Feishu post 统一发送
@@ -24,7 +24,9 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
24
24
  *
25
25
  * @memberof ScheduleModule
26
26
  */
27
- loadAllSchedule(): Promise<void>;
27
+ loadAllSchedule(options?: {
28
+ useCache?: boolean;
29
+ }): Promise<void>;
28
30
  setScheduleList(list: ScheduleItem[]): void;
29
31
  private syncScheduleMap;
30
32
  getScheduleList(): ScheduleItem[];