@pisell/pisellos 2.3.37 → 2.3.39

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 (169) 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 +11 -28
  12. package/dist/modules/Order/index.js +513 -747
  13. package/dist/modules/Order/types.d.ts +10 -33
  14. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  15. package/dist/modules/Order/utils.d.ts +10 -0
  16. package/dist/modules/Order/utils.js +40 -11
  17. package/dist/modules/Payment/index.d.ts +0 -2
  18. package/dist/modules/Payment/index.js +49 -78
  19. package/dist/modules/Payment/types.d.ts +24 -26
  20. package/dist/modules/Payment/types.js +0 -2
  21. package/dist/modules/Product/types.d.ts +1 -0
  22. package/dist/modules/ProductList/index.js +33 -14
  23. package/dist/modules/Quotation/index.d.ts +1 -1
  24. package/dist/modules/Quotation/index.js +2 -2
  25. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  26. package/dist/modules/ResourcePlanner/index.js +181 -0
  27. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  28. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  29. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  30. package/dist/modules/ResourcePlanner/types.js +1 -0
  31. package/dist/modules/Rules/index.js +48 -15
  32. package/dist/modules/SalesSummary/index.js +12 -13
  33. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  34. package/dist/modules/ScanOrderLogger/index.js +15 -2
  35. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  36. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  37. package/dist/modules/Schedule/index.d.ts +3 -1
  38. package/dist/modules/Schedule/index.js +21 -16
  39. package/dist/modules/Summary/utils.js +38 -13
  40. package/dist/modules/index.d.ts +2 -0
  41. package/dist/modules/index.js +3 -1
  42. package/dist/plugins/window.d.ts +1 -0
  43. package/dist/server/index.d.ts +14 -16
  44. package/dist/server/index.js +1162 -1943
  45. package/dist/server/modules/order/index.d.ts +4 -49
  46. package/dist/server/modules/order/index.js +695 -1574
  47. package/dist/server/modules/order/types.d.ts +3 -11
  48. package/dist/server/modules/order/types.js +1 -1
  49. package/dist/solution/BaseSales/index.d.ts +10 -33
  50. package/dist/solution/BaseSales/index.js +385 -676
  51. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  52. package/dist/solution/BookingByStep/index.d.ts +17 -2
  53. package/dist/solution/BookingByStep/index.js +294 -215
  54. package/dist/solution/BookingByStep/types.d.ts +2 -1
  55. package/dist/solution/BookingByStep/types.js +3 -1
  56. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  57. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  58. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  59. package/dist/solution/BookingTicket/index.js +1 -2
  60. package/dist/solution/Sales/index.d.ts +0 -1
  61. package/dist/solution/Sales/index.js +2 -10
  62. package/dist/solution/ScanOrder/index.d.ts +26 -14
  63. package/dist/solution/ScanOrder/index.js +1140 -737
  64. package/dist/solution/ScanOrder/types.d.ts +21 -1
  65. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  66. package/dist/solution/ScanOrder/utils.js +66 -25
  67. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  68. package/dist/solution/ShopDiscount/index.js +125 -87
  69. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  70. package/dist/solution/UnifiedBookingSales/index.js +1871 -0
  71. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  72. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  73. package/dist/solution/VenueBooking/index.d.ts +39 -11
  74. package/dist/solution/VenueBooking/index.js +1177 -850
  75. package/dist/solution/VenueBooking/types.d.ts +3 -0
  76. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  77. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  78. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  79. package/dist/solution/index.d.ts +1 -0
  80. package/dist/solution/index.js +2 -1
  81. package/dist/types/index.d.ts +1 -0
  82. package/lib/modules/Discount/index.d.ts +1 -0
  83. package/lib/modules/Discount/index.js +9 -0
  84. package/lib/modules/Discount/types.d.ts +1 -0
  85. package/lib/modules/Holder/index.d.ts +48 -0
  86. package/lib/modules/Holder/index.js +402 -0
  87. package/lib/modules/Holder/types.d.ts +123 -0
  88. package/lib/modules/Holder/types.js +17 -0
  89. package/lib/modules/Holder/utils.d.ts +13 -0
  90. package/lib/modules/Holder/utils.js +71 -0
  91. package/lib/modules/OpenData/index.js +1 -1
  92. package/lib/modules/Order/index.d.ts +11 -28
  93. package/lib/modules/Order/index.js +83 -187
  94. package/lib/modules/Order/types.d.ts +10 -33
  95. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  96. package/lib/modules/Order/utils.d.ts +10 -0
  97. package/lib/modules/Order/utils.js +39 -10
  98. package/lib/modules/Payment/index.d.ts +0 -2
  99. package/lib/modules/Payment/index.js +12 -33
  100. package/lib/modules/Payment/types.d.ts +24 -26
  101. package/lib/modules/Product/types.d.ts +1 -0
  102. package/lib/modules/ProductList/index.js +40 -31
  103. package/lib/modules/Quotation/index.d.ts +1 -1
  104. package/lib/modules/Quotation/index.js +2 -2
  105. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  106. package/lib/modules/ResourcePlanner/index.js +148 -0
  107. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  108. package/lib/modules/ResourcePlanner/planner.js +933 -0
  109. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  110. package/lib/modules/ResourcePlanner/types.js +17 -0
  111. package/lib/modules/Rules/index.js +34 -18
  112. package/lib/modules/SalesSummary/index.js +6 -7
  113. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  114. package/lib/modules/ScanOrderLogger/index.js +13 -1
  115. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  116. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  117. package/lib/modules/Schedule/index.d.ts +3 -1
  118. package/lib/modules/Schedule/index.js +10 -8
  119. package/lib/modules/Summary/utils.js +21 -1
  120. package/lib/modules/index.d.ts +2 -0
  121. package/lib/modules/index.js +5 -1
  122. package/lib/plugins/window.d.ts +1 -0
  123. package/lib/server/index.d.ts +14 -16
  124. package/lib/server/index.js +88 -678
  125. package/lib/server/modules/order/index.d.ts +4 -49
  126. package/lib/server/modules/order/index.js +66 -657
  127. package/lib/server/modules/order/types.d.ts +3 -11
  128. package/lib/solution/BaseSales/index.d.ts +10 -33
  129. package/lib/solution/BaseSales/index.js +33 -201
  130. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  131. package/lib/solution/BookingByStep/index.d.ts +17 -2
  132. package/lib/solution/BookingByStep/index.js +60 -18
  133. package/lib/solution/BookingByStep/types.d.ts +2 -1
  134. package/lib/solution/BookingByStep/types.js +5 -0
  135. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  136. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  137. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  138. package/lib/solution/BookingTicket/index.js +1 -2
  139. package/lib/solution/Sales/index.d.ts +0 -1
  140. package/lib/solution/Sales/index.js +3 -5
  141. package/lib/solution/ScanOrder/index.d.ts +26 -14
  142. package/lib/solution/ScanOrder/index.js +449 -182
  143. package/lib/solution/ScanOrder/types.d.ts +21 -1
  144. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  145. package/lib/solution/ScanOrder/utils.js +31 -0
  146. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  147. package/lib/solution/ShopDiscount/index.js +14 -0
  148. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  149. package/lib/solution/UnifiedBookingSales/index.js +1076 -0
  150. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  151. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  152. package/lib/solution/VenueBooking/index.d.ts +39 -11
  153. package/lib/solution/VenueBooking/index.js +328 -115
  154. package/lib/solution/VenueBooking/types.d.ts +3 -0
  155. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  156. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  157. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  158. package/lib/solution/index.d.ts +1 -0
  159. package/lib/solution/index.js +3 -1
  160. package/lib/types/index.d.ts +1 -0
  161. package/package.json +2 -2
  162. package/dist/modules/Order/payment-utils.d.ts +0 -26
  163. package/dist/modules/Order/payment-utils.js +0 -225
  164. package/dist/utils/payment-number.d.ts +0 -9
  165. package/dist/utils/payment-number.js +0 -69
  166. package/lib/modules/Order/payment-utils.d.ts +0 -26
  167. package/lib/modules/Order/payment-utils.js +0 -224
  168. package/lib/utils/payment-number.d.ts +0 -9
  169. package/lib/utils/payment-number.js +0 -64
@@ -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 {};
@@ -423,7 +423,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
423
423
  _id: product._id,
424
424
  parentId: product._id,
425
425
  quantity: product.quantity,
426
- num: product.num
426
+ num: product.num,
427
+ booking_id: product.booking_id
427
428
  });
428
429
 
429
430
  // 2. 展开 bundle 子商品
@@ -447,7 +448,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
447
448
  origin_total: new Decimal(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
448
449
  original_price: bundleItem.original_price,
449
450
  // 继承主商品属性
450
- booking_id: product.booking_id,
451
+ booking_id: bundleItem.booking_id,
451
452
  discount_list: bundleItem.discount_list || []
452
453
  });
453
454
  });
@@ -968,7 +969,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
968
969
  discount_product_id: discount.product_id
969
970
  },
970
971
  metadata: {
971
- num: num
972
+ num: num,
973
+ discount_rule_uncheck_flag: discount === null || discount === void 0 ? void 0 : discount.discount_rule_uncheck_flag
972
974
  }
973
975
  };
974
976
  applicableProducts.push(productData);
@@ -1299,8 +1301,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1299
1301
  main_product_selling_price = (_product$main_product = product.main_product_selling_price) !== null && _product$main_product !== void 0 ? _product$main_product : main_product_selling_price;
1300
1302
  }
1301
1303
  processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
1302
- price: product.price,
1303
- main_product_selling_price: product.price
1304
+ price: product.price
1304
1305
  } : {
1305
1306
  _id: product._id.split('___')[0] + '___' + index,
1306
1307
  total: total,
@@ -1453,7 +1454,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1453
1454
  _num: isGoodPass ? 1 : product.num,
1454
1455
  config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
1455
1456
  metadata: _objectSpread(_objectSpread({
1456
- num: 1
1457
+ num: 1,
1458
+ discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
1457
1459
  }, productDiscountDifference !== undefined && {
1458
1460
  product_discount_difference: productDiscountDifference
1459
1461
  }), {}, {
@@ -1540,6 +1542,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1540
1542
  metadata: {
1541
1543
  // 🔥 使用拆分后的唯一 _id
1542
1544
  custom_product_bundle_map_id: uniqueId,
1545
+ discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
1543
1546
  num: 1
1544
1547
  },
1545
1548
  _num: 1,
@@ -1571,7 +1574,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1571
1574
  _id: "".concat(flatItem._id, "_split_rest"),
1572
1575
  num: normalNum,
1573
1576
  quantity: normalNum,
1574
- discount_list: [],
1577
+ discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion'),
1575
1578
  processed: true
1576
1579
  }));
1577
1580
  }
@@ -1625,6 +1628,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1625
1628
  metadata: _objectSpread({
1626
1629
  // 🔥 使用唯一的 _id
1627
1630
  custom_product_bundle_map_id: _uniqueId,
1631
+ discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
1628
1632
  num: product.num || 1
1629
1633
  }, _productDiscountDifference !== undefined && {
1630
1634
  product_discount_difference: _productDiscountDifference
@@ -1640,7 +1644,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1640
1644
  processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
1641
1645
  total: targetProductTotal,
1642
1646
  price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1643
- discount_list: [_discountDetail2],
1647
+ discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion').concat([_discountDetail2]),
1644
1648
  processed: true
1645
1649
  }));
1646
1650
  }
@@ -2115,6 +2119,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2115
2119
  }, {
2116
2120
  key: "checkPackageSubItemUsageRules",
2117
2121
  value: function checkPackageSubItemUsageRules(discount, flatItem) {
2122
+ var _flatItem$product;
2118
2123
  var limitedData = discount.limited_relation_product_data;
2119
2124
  var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
2120
2125
  var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
@@ -2136,6 +2141,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2136
2141
  filter = _ref16$filter === void 0 ? 0 : _ref16$filter;
2137
2142
  var isMainProduct = flatItem.type === 'main'; // 单独购买
2138
2143
  var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
2144
+ var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
2139
2145
 
2140
2146
  // 主商品直接可用
2141
2147
  if (isMainProduct) {
@@ -2178,13 +2184,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2178
2184
  if (!filter) {
2179
2185
  isScopeValid = true;
2180
2186
  } else {
2181
- isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
2187
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2182
2188
  }
2183
2189
  }
2184
2190
 
2185
2191
  // 包含套餐判断, products值兼容旧数据
2186
2192
  if (scopeType === 'specific_packages' || scopeType === 'products') {
2187
- isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
2193
+ isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2188
2194
  }
2189
2195
 
2190
2196
  // 价格和套餐适用范围都符合,则可用
@@ -2234,16 +2240,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2234
2240
 
2235
2241
  // 检查 rules
2236
2242
  if (rules.length > 0) {
2237
- // 检查原价
2238
- if (_isOriginalPrice2 && rules.includes('original_price')) {
2239
- return true;
2243
+ var _isOriginalPrice3 = _isOriginalPrice2 && rules.includes('original_price');
2244
+ var _isMarkupPrice3 = _isMarkupPrice2 && rules.includes('markup_price');
2245
+ // 价格是否符合规则:原价或加价
2246
+ var _isPriceValid = _isOriginalPrice3 || _isMarkupPrice3;
2247
+ // 套餐适用范围校验
2248
+ var _isScopeValid = false;
2249
+
2250
+ // 排除套餐判断, product_all值兼容旧数据
2251
+ if (scopeType === 'all_packages' || scopeType === 'product_all') {
2252
+ // 所有套餐可用
2253
+ if (!filter) {
2254
+ _isScopeValid = true;
2255
+ } else {
2256
+ _isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2257
+ }
2240
2258
  }
2241
2259
 
2242
- // 检查加价
2243
- if (_isMarkupPrice2 && rules.includes('markup_price')) {
2260
+ // 包含套餐判断, products值兼容旧数据
2261
+ if (scopeType === 'specific_packages' || scopeType === 'products') {
2262
+ _isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2263
+ }
2264
+
2265
+ // 价格和套餐适用范围都符合,则可用
2266
+ if (_isPriceValid && _isScopeValid) {
2244
2267
  return true;
2245
2268
  }
2246
2269
 
2270
+ // 检查原价
2271
+ // if (isOriginalPrice && rules.includes('original_price')) {
2272
+ // return true;
2273
+ // }
2274
+
2275
+ // 检查加价
2276
+ // if (isMarkupPrice && rules.includes('markup_price')) {
2277
+ // return true;
2278
+ // }
2279
+
2247
2280
  // 如果都不匹配,则不可用
2248
2281
  return false;
2249
2282
  }
@@ -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[];