@pisell/pisellos 2.2.278 → 2.2.280
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.
- package/dist/modules/BaseModule.d.ts +1 -0
- package/dist/modules/BaseModule.js +24 -28
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
- package/dist/modules/BookingContext/utils/productExtend.js +5 -9
- package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +32 -4
- package/dist/modules/Order/index.js +868 -675
- package/dist/modules/Order/types.d.ts +22 -1
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +71 -34
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +14 -4
- package/dist/modules/Payment/walletpass.js +21 -7
- package/dist/modules/Product/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +33 -13
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.js +153 -56
- package/dist/modules/SalesSummary/index.js +12 -13
- package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/index.js +15 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
- package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +3 -1
- package/dist/modules/Schedule/index.js +21 -16
- package/dist/modules/Summary/utils.js +38 -13
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/window.d.ts +1 -0
- package/dist/server/index.d.ts +20 -0
- package/dist/server/index.js +1101 -909
- package/dist/server/modules/order/index.d.ts +2 -0
- package/dist/server/modules/order/index.js +261 -96
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/solution/BaseSales/index.d.ts +20 -1
- package/dist/solution/BaseSales/index.js +989 -881
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +17 -2
- package/dist/solution/BookingByStep/index.js +294 -215
- package/dist/solution/BookingByStep/types.d.ts +2 -1
- package/dist/solution/BookingByStep/types.js +3 -1
- package/dist/solution/BookingByStep/utils/capacity.js +17 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/BookingTicket/index.d.ts +21 -3
- package/dist/solution/BookingTicket/index.js +312 -226
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +26 -14
- package/dist/solution/ScanOrder/index.js +1142 -739
- package/dist/solution/ScanOrder/types.d.ts +21 -1
- package/dist/solution/ScanOrder/utils.d.ts +8 -0
- package/dist/solution/ScanOrder/utils.js +97 -45
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +125 -87
- package/dist/solution/UnifiedBookingSales/index.d.ts +204 -0
- package/dist/solution/UnifiedBookingSales/index.js +2211 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +150 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +39 -11
- package/dist/solution/VenueBooking/index.js +1167 -841
- package/dist/solution/VenueBooking/types.d.ts +3 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BaseModule.d.ts +1 -0
- package/lib/modules/BaseModule.js +24 -37
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
- package/lib/modules/BookingContext/utils/productExtend.js +4 -3
- package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +32 -4
- package/lib/modules/Order/index.js +372 -156
- package/lib/modules/Order/types.d.ts +22 -1
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +39 -6
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +7 -0
- package/lib/modules/Payment/walletpass.js +12 -0
- package/lib/modules/Product/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +49 -31
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.js +117 -25
- package/lib/modules/SalesSummary/index.js +6 -7
- package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/index.js +13 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
- package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +3 -1
- package/lib/modules/Schedule/index.js +10 -8
- package/lib/modules/Summary/utils.js +21 -1
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/window.d.ts +1 -0
- package/lib/server/index.d.ts +20 -0
- package/lib/server/index.js +124 -19
- package/lib/server/modules/order/index.d.ts +2 -0
- package/lib/server/modules/order/index.js +75 -5
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/solution/BaseSales/index.d.ts +20 -1
- package/lib/solution/BaseSales/index.js +105 -31
- package/lib/solution/BaseSales/utils/cartPromotion.js +18 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -0
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +17 -2
- package/lib/solution/BookingByStep/index.js +60 -18
- package/lib/solution/BookingByStep/types.d.ts +2 -1
- package/lib/solution/BookingByStep/types.js +5 -0
- package/lib/solution/BookingByStep/utils/capacity.js +20 -1
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/BookingTicket/index.d.ts +21 -3
- package/lib/solution/BookingTicket/index.js +75 -16
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/ScanOrder/index.d.ts +26 -14
- package/lib/solution/ScanOrder/index.js +449 -182
- package/lib/solution/ScanOrder/types.d.ts +21 -1
- package/lib/solution/ScanOrder/utils.d.ts +8 -0
- package/lib/solution/ScanOrder/utils.js +60 -18
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +204 -0
- package/lib/solution/UnifiedBookingSales/index.js +1273 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +150 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +39 -11
- package/lib/solution/VenueBooking/index.js +322 -110
- package/lib/solution/VenueBooking/types.d.ts +3 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/lib/types/index.d.ts +1 -0
- 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 子商品
|
|
@@ -465,7 +466,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
465
466
|
origin_total: new Decimal(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
|
|
466
467
|
original_price: bundleItem.original_price,
|
|
467
468
|
// 继承主商品属性
|
|
468
|
-
booking_id:
|
|
469
|
+
booking_id: bundleItem.booking_id,
|
|
469
470
|
discount_list: bundleItem.discount_list || []
|
|
470
471
|
});
|
|
471
472
|
});
|
|
@@ -990,7 +991,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
990
991
|
discount_product_id: discount.product_id
|
|
991
992
|
},
|
|
992
993
|
metadata: {
|
|
993
|
-
num: num
|
|
994
|
+
num: num,
|
|
995
|
+
discount_rule_uncheck_flag: discount === null || discount === void 0 ? void 0 : discount.discount_rule_uncheck_flag
|
|
994
996
|
}
|
|
995
997
|
};
|
|
996
998
|
applicableProducts.push(productData);
|
|
@@ -1184,19 +1186,42 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1184
1186
|
return false;
|
|
1185
1187
|
});
|
|
1186
1188
|
|
|
1187
|
-
//
|
|
1189
|
+
// 用户显式点击某张卡券时,本次选择优先于自动排序和扫码默认选择。
|
|
1188
1190
|
// 目标仍必须在当前商品的 applicableDiscounts 中,因此不会绕过 Holder、时间或商品范围校验。
|
|
1189
|
-
var
|
|
1191
|
+
var explicitlySelectedDiscount = (options === null || options === void 0 ? void 0 : options.isSelected) === true && options.discountId !== undefined ? applicableDiscounts.find(function (discount) {
|
|
1190
1192
|
var discountType = discount.tag || discount.type;
|
|
1191
|
-
return String(discount.id) === String(options.discountId) && ['discount_card', 'product_discount_card'].includes(discountType);
|
|
1193
|
+
return String(discount.id) === String(options.discountId) && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
1192
1194
|
}) : undefined;
|
|
1195
|
+
// 折扣卡会复用于整条商品行;商品券必须继续按单张拆分,不能复用该分支。
|
|
1196
|
+
var explicitlySelectedDiscountCard = explicitlySelectedDiscount && (explicitlySelectedDiscount.tag || explicitlySelectedDiscount.type) !== 'good_pass' ? explicitlySelectedDiscount : undefined;
|
|
1197
|
+
|
|
1198
|
+
// 商品数量等变化会触发无 discountId 的重算。只要当前行已应用的折扣卡仍在
|
|
1199
|
+
// applicableDiscounts 中,就应保留该行选择,避免被自动排序中力度更大的卡替换。
|
|
1200
|
+
var appliedDiscountCardIds = new Set((product.discount_list || []).filter(function (item) {
|
|
1201
|
+
return ['discount_card', 'product_discount_card'].includes((item === null || item === void 0 ? void 0 : item.tag) || (item === null || item === void 0 ? void 0 : item.type));
|
|
1202
|
+
}).map(function (item) {
|
|
1203
|
+
var _ref12, _item$discount$resour, _item$discount;
|
|
1204
|
+
return (_ref12 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref12 !== void 0 ? _ref12 : item === null || item === void 0 ? void 0 : item.id;
|
|
1205
|
+
}).filter(function (id) {
|
|
1206
|
+
return id !== undefined && id !== null;
|
|
1207
|
+
}).map(String));
|
|
1208
|
+
var appliedDiscountCard = options !== null && options !== void 0 && options.scan ? undefined : applicableDiscounts.find(function (discount) {
|
|
1209
|
+
var discountType = discount.tag || discount.type;
|
|
1210
|
+
return discount.isSelected === true && ['discount_card', 'product_discount_card'].includes(discountType) && appliedDiscountCardIds.has(String(discount.id));
|
|
1211
|
+
});
|
|
1193
1212
|
|
|
1194
|
-
//
|
|
1213
|
+
// 优先级:本次显式选择 > 当前行既有选择 > 扫码选择 > 自动排序第一项。
|
|
1195
1214
|
var scannedSelectedDiscountCard = applicableDiscounts.find(function (n) {
|
|
1196
1215
|
return n.isScan && n.isSelected && (n.tag || n.type) !== 'good_pass';
|
|
1197
1216
|
});
|
|
1198
|
-
var selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
|
|
1199
|
-
var selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
1217
|
+
var selectedDiscountCard = explicitlySelectedDiscountCard || appliedDiscountCard || scannedSelectedDiscountCard;
|
|
1218
|
+
var selectedDiscount = explicitlySelectedDiscount || selectedDiscountCard || applicableDiscounts[0];
|
|
1219
|
+
var prioritizedApplicableDiscounts = explicitlySelectedDiscount && (explicitlySelectedDiscount.tag || explicitlySelectedDiscount.type) === 'good_pass' ? [explicitlySelectedDiscount].concat(_toConsumableArray(applicableDiscounts.filter(function (discount) {
|
|
1220
|
+
var discountType = discount.tag || discount.type;
|
|
1221
|
+
return discountType === 'good_pass' && String(discount.id) !== String(explicitlySelectedDiscount.id);
|
|
1222
|
+
})), _toConsumableArray(applicableDiscounts.filter(function (discount) {
|
|
1223
|
+
return (discount.tag || discount.type) !== 'good_pass';
|
|
1224
|
+
}))) : applicableDiscounts;
|
|
1200
1225
|
|
|
1201
1226
|
// 如果是手动折扣,则不适用优惠券
|
|
1202
1227
|
var isManualDiscount = false;
|
|
@@ -1207,8 +1232,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1207
1232
|
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
|
|
1208
1233
|
return item.type === 'product';
|
|
1209
1234
|
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1210
|
-
var
|
|
1211
|
-
return !((
|
|
1235
|
+
var _ref13;
|
|
1236
|
+
return !((_ref13 = item.discount_list || []) !== null && _ref13 !== void 0 && _ref13.length);
|
|
1212
1237
|
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 || (_product11$every = _product11.every) === null || _product11$every === void 0 ? void 0 : _product11$every.call(_product11, function (item) {
|
|
1213
1238
|
return item.type === 'product';
|
|
1214
1239
|
})));
|
|
@@ -1224,8 +1249,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1224
1249
|
isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : ((_parentProduct$discou = parentProduct.discount_list) === null || _parentProduct$discou === void 0 ? void 0 : _parentProduct$discou.some(function (item) {
|
|
1225
1250
|
return item.type === 'product';
|
|
1226
1251
|
})) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
|
|
1227
|
-
var
|
|
1228
|
-
return !((
|
|
1252
|
+
var _ref14;
|
|
1253
|
+
return !((_ref14 = item.discount_list || []) !== null && _ref14 !== void 0 && _ref14.length);
|
|
1229
1254
|
}) && (!((_parentProduct$discou2 = parentProduct.discount_list) !== null && _parentProduct$discou2 !== void 0 && _parentProduct$discou2.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou3 = parentProduct.discount_list) === null || _parentProduct$discou3 === void 0 || (_parentProduct$discou4 = _parentProduct$discou3.every) === null || _parentProduct$discou4 === void 0 ? void 0 : _parentProduct$discou4.call(_parentProduct$discou3, function (item) {
|
|
1230
1255
|
return item.type === 'product';
|
|
1231
1256
|
})));
|
|
@@ -1237,8 +1262,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1237
1262
|
var _product$discount_lis7;
|
|
1238
1263
|
// 主商品:检查自己的 discount_list
|
|
1239
1264
|
if (flatItem.type === 'main' && (_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
|
|
1240
|
-
var _item$
|
|
1241
|
-
return ((_item$
|
|
1265
|
+
var _item$discount2;
|
|
1266
|
+
return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
|
|
1242
1267
|
})) {
|
|
1243
1268
|
isManualDiscount = false;
|
|
1244
1269
|
}
|
|
@@ -1246,11 +1271,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1246
1271
|
if (flatItem.type === 'bundle') {
|
|
1247
1272
|
var _product$discount_lis8, _flatItem$parentProdu7;
|
|
1248
1273
|
if ((_product$discount_lis8 = product.discount_list) !== null && _product$discount_lis8 !== void 0 && _product$discount_lis8.some(function (item) {
|
|
1249
|
-
var _item$discount2;
|
|
1250
|
-
return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
|
|
1251
|
-
}) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
|
|
1252
1274
|
var _item$discount3;
|
|
1253
1275
|
return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
|
|
1276
|
+
}) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
|
|
1277
|
+
var _item$discount4;
|
|
1278
|
+
return ((_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.resource_id) === options.discountId;
|
|
1254
1279
|
})) {
|
|
1255
1280
|
isManualDiscount = false;
|
|
1256
1281
|
}
|
|
@@ -1262,8 +1287,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1262
1287
|
if (flatItem.type === 'main' && (_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
|
|
1263
1288
|
var _options$selectedList2;
|
|
1264
1289
|
return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
|
|
1265
|
-
var _item$
|
|
1266
|
-
return n.discountId === ((_item$
|
|
1290
|
+
var _item$discount5;
|
|
1291
|
+
return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
|
|
1267
1292
|
});
|
|
1268
1293
|
})) {
|
|
1269
1294
|
isManualDiscount = false;
|
|
@@ -1274,14 +1299,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1274
1299
|
if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
|
|
1275
1300
|
var _options$selectedList3;
|
|
1276
1301
|
return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
|
|
1277
|
-
var _item$
|
|
1278
|
-
return n.discountId === ((_item$
|
|
1302
|
+
var _item$discount6;
|
|
1303
|
+
return n.discountId === ((_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.resource_id);
|
|
1279
1304
|
});
|
|
1280
1305
|
}) || (_flatItem$parentProdu8 = flatItem.parentProduct) !== null && _flatItem$parentProdu8 !== void 0 && (_flatItem$parentProdu8 = _flatItem$parentProdu8.discount_list) !== null && _flatItem$parentProdu8 !== void 0 && _flatItem$parentProdu8.some(function (item) {
|
|
1281
1306
|
var _options$selectedList4;
|
|
1282
1307
|
return options === null || options === void 0 || (_options$selectedList4 = options.selectedList) === null || _options$selectedList4 === void 0 ? void 0 : _options$selectedList4.some(function (n) {
|
|
1283
|
-
var _item$
|
|
1284
|
-
return n.discountId === ((_item$
|
|
1308
|
+
var _item$discount7;
|
|
1309
|
+
return n.discountId === ((_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.resource_id);
|
|
1285
1310
|
});
|
|
1286
1311
|
})) {
|
|
1287
1312
|
isManualDiscount = false;
|
|
@@ -1318,8 +1343,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1318
1343
|
discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(product.discount_list) : _this4.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1319
1344
|
}))]);
|
|
1320
1345
|
} else {
|
|
1321
|
-
var
|
|
1322
|
-
var total = product.inPromotion ? (
|
|
1346
|
+
var _ref15, _product$_promotion$f, _product12, _product$origin_total;
|
|
1347
|
+
var total = product.inPromotion ? (_ref15 = (_product$_promotion$f = (_product12 = product) === null || _product12 === void 0 || (_product12 = _product12._promotion) === null || _product12 === void 0 ? void 0 : _product12.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref15 !== void 0 ? _ref15 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1323
1348
|
var main_product_selling_price = product.price;
|
|
1324
1349
|
if ((product.discount_list || []).some(function (item) {
|
|
1325
1350
|
return item.type === 'promotion';
|
|
@@ -1380,7 +1405,44 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1380
1405
|
if (flatItem.type === 'main') {
|
|
1381
1406
|
// 主商品:保持原有逻辑
|
|
1382
1407
|
if (splitCount < totalQuantity && isNeedSplit) {
|
|
1383
|
-
var _product$origin_total2;
|
|
1408
|
+
var _product$origin_total2, _product$main_product2;
|
|
1409
|
+
var remainingQuantity = totalQuantity - splitCount;
|
|
1410
|
+
var applicableNonGoodPassById = new Map(applicableDiscounts.filter(function (discount) {
|
|
1411
|
+
return (discount.tag || discount.type) !== 'good_pass';
|
|
1412
|
+
}).map(function (discount) {
|
|
1413
|
+
return [String(discount.id), discount];
|
|
1414
|
+
}));
|
|
1415
|
+
var remainderDiscountList = (product.discount_list || []).filter(function (discount) {
|
|
1416
|
+
var _discount$discount$re, _discount$discount5;
|
|
1417
|
+
var discountType = discount.tag || discount.type;
|
|
1418
|
+
if (discountType === 'promotion') return true;
|
|
1419
|
+
if (discountType === 'good_pass') return false;
|
|
1420
|
+
var resourceId = (_discount$discount$re = (_discount$discount5 = discount.discount) === null || _discount$discount5 === void 0 ? void 0 : _discount$discount5.resource_id) !== null && _discount$discount$re !== void 0 ? _discount$discount$re : discount.id;
|
|
1421
|
+
return resourceId !== undefined && resourceId !== null && applicableNonGoodPassById.has(String(resourceId));
|
|
1422
|
+
}).map(function (discount) {
|
|
1423
|
+
var _discount$discount$re2, _discount$discount6;
|
|
1424
|
+
if ((discount.tag || discount.type) === 'promotion') return discount;
|
|
1425
|
+
var resourceId = (_discount$discount$re2 = (_discount$discount6 = discount.discount) === null || _discount$discount6 === void 0 ? void 0 : _discount$discount6.resource_id) !== null && _discount$discount$re2 !== void 0 ? _discount$discount$re2 : discount.id;
|
|
1426
|
+
var matchedDiscount = applicableNonGoodPassById.get(String(resourceId));
|
|
1427
|
+
if (matchedDiscount) {
|
|
1428
|
+
// 实际场景:3 件折扣卡商品中拆出 1 件改用商品券后,
|
|
1429
|
+
// 剩余 2 件仍在使用原折扣卡;必须同步登记折扣卡的使用状态,
|
|
1430
|
+
// 否则 updatedDiscountList 会把它改成未选中并清空 savedAmount。
|
|
1431
|
+
usedDiscounts.set(matchedDiscount.id, true);
|
|
1432
|
+
var appliedProducts = appliedDiscountProducts.get(matchedDiscount.id) || [];
|
|
1433
|
+
appliedProducts.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
1434
|
+
_num: remainingQuantity
|
|
1435
|
+
}));
|
|
1436
|
+
appliedDiscountProducts.set(matchedDiscount.id, appliedProducts);
|
|
1437
|
+
}
|
|
1438
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1439
|
+
// _num 是 Rules 运行态的行数量;Order 写回 tempOrder 时会裁剪该字段。
|
|
1440
|
+
_num: remainingQuantity
|
|
1441
|
+
});
|
|
1442
|
+
});
|
|
1443
|
+
var hasRetainedWalletDiscount = remainderDiscountList.some(function (discount) {
|
|
1444
|
+
return !['promotion', 'good_pass'].includes(discount.tag || discount.type);
|
|
1445
|
+
});
|
|
1384
1446
|
var _total = (_product$origin_total2 = product.origin_total) !== null && _product$origin_total2 !== void 0 ? _product$origin_total2 : product.total;
|
|
1385
1447
|
if ((product.discount_list || []).some(function (item) {
|
|
1386
1448
|
return item.type === 'promotion';
|
|
@@ -1388,17 +1450,20 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1388
1450
|
var _product$total2;
|
|
1389
1451
|
_total = (_product$total2 = product.total) !== null && _product$total2 !== void 0 ? _product$total2 : product.origin_total;
|
|
1390
1452
|
}
|
|
1391
|
-
arr.push(_this4.hooks.setProduct(originProduct, {
|
|
1392
|
-
|
|
1393
|
-
|
|
1453
|
+
arr.push(_this4.hooks.setProduct(originProduct, _objectSpread({
|
|
1454
|
+
// 商品券只替换被拆出的 splitCount 件。余量行原本仍有效的折扣卡
|
|
1455
|
+
// 不能随 good_pass 拆分一起清除;已取消或已失效的折扣不会进入此列表。
|
|
1456
|
+
discount_list: remainderDiscountList,
|
|
1457
|
+
quantity: remainingQuantity,
|
|
1394
1458
|
_id: product._id.split('___')[0],
|
|
1395
1459
|
total: _total
|
|
1396
|
-
}
|
|
1460
|
+
}, hasRetainedWalletDiscount ? {
|
|
1461
|
+
main_product_selling_price: (_product$main_product2 = product.main_product_selling_price) !== null && _product$main_product2 !== void 0 ? _product$main_product2 : product.price
|
|
1462
|
+
} : {})));
|
|
1397
1463
|
}
|
|
1398
1464
|
for (var i = 0; i < splitCount; i++) {
|
|
1399
1465
|
var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2, _reapplyDiscountPerce;
|
|
1400
|
-
|
|
1401
|
-
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
|
|
1466
|
+
var _selectedDiscount = isNeedSplit ? prioritizedApplicableDiscounts[i] : selectedDiscountCard || applicableDiscounts[i];
|
|
1402
1467
|
// 标记优惠券为已使用
|
|
1403
1468
|
usedDiscounts.set(_selectedDiscount.id, true);
|
|
1404
1469
|
// 🔥 更新 product_id 使用计数
|
|
@@ -1485,7 +1550,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1485
1550
|
_num: isGoodPass ? 1 : product.num,
|
|
1486
1551
|
config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
|
|
1487
1552
|
metadata: _objectSpread(_objectSpread({
|
|
1488
|
-
num: 1
|
|
1553
|
+
num: 1,
|
|
1554
|
+
discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
|
|
1489
1555
|
}, productDiscountDifference !== undefined && {
|
|
1490
1556
|
product_discount_difference: productDiscountDifference
|
|
1491
1557
|
}), {}, {
|
|
@@ -1542,7 +1608,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1542
1608
|
// 生成有折扣的商品(每张商品券对应 num: 1)
|
|
1543
1609
|
for (var _i = 0; _i < discountNum; _i++) {
|
|
1544
1610
|
var _selectedDiscount2$me;
|
|
1545
|
-
var _selectedDiscount2 =
|
|
1611
|
+
var _selectedDiscount2 = prioritizedApplicableDiscounts[_i];
|
|
1546
1612
|
usedDiscounts.set(_selectedDiscount2.id, true);
|
|
1547
1613
|
// 🔥 更新 product_id 使用计数
|
|
1548
1614
|
if ((_selectedDiscount2.tag || _selectedDiscount2.type) === 'good_pass') {
|
|
@@ -1572,6 +1638,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1572
1638
|
metadata: {
|
|
1573
1639
|
// 🔥 使用拆分后的唯一 _id
|
|
1574
1640
|
custom_product_bundle_map_id: uniqueId,
|
|
1641
|
+
discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
|
|
1575
1642
|
num: 1
|
|
1576
1643
|
},
|
|
1577
1644
|
_num: 1,
|
|
@@ -1603,7 +1670,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1603
1670
|
_id: "".concat(flatItem._id, "_split_rest"),
|
|
1604
1671
|
num: normalNum,
|
|
1605
1672
|
quantity: normalNum,
|
|
1606
|
-
discount_list:
|
|
1673
|
+
discount_list: _this4.filterDiscountListByType(flatItem.discount_list, 'promotion'),
|
|
1607
1674
|
processed: true
|
|
1608
1675
|
}));
|
|
1609
1676
|
}
|
|
@@ -1665,6 +1732,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1665
1732
|
metadata: _objectSpread({
|
|
1666
1733
|
// 🔥 使用唯一的 _id
|
|
1667
1734
|
custom_product_bundle_map_id: _uniqueId,
|
|
1735
|
+
discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
|
|
1668
1736
|
num: product.num || 1
|
|
1669
1737
|
}, _productDiscountDifference !== undefined && {
|
|
1670
1738
|
product_discount_difference: _productDiscountDifference
|
|
@@ -1680,7 +1748,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1680
1748
|
processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1681
1749
|
total: targetProductTotal,
|
|
1682
1750
|
price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
|
|
1683
|
-
discount_list: [_discountDetail2],
|
|
1751
|
+
discount_list: _this4.filterDiscountListByType(flatItem.discount_list, 'promotion').concat([_discountDetail2]),
|
|
1684
1752
|
processed: true
|
|
1685
1753
|
}));
|
|
1686
1754
|
}
|
|
@@ -1974,7 +2042,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1974
2042
|
} else {
|
|
1975
2043
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
1976
2044
|
mainProductArr.forEach(function (mainProduct) {
|
|
1977
|
-
var
|
|
2045
|
+
var _ref17, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
1978
2046
|
var mainProductData = _this4.hooks.getProduct(mainProduct);
|
|
1979
2047
|
|
|
1980
2048
|
// 重组bundle
|
|
@@ -1989,9 +2057,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1989
2057
|
} else {
|
|
1990
2058
|
// 🔥 关键:拆分后的bundle item
|
|
1991
2059
|
processedBundleItems.forEach(function (item) {
|
|
1992
|
-
var _item$price,
|
|
2060
|
+
var _item$price, _ref16, _item$bundle_selling_;
|
|
1993
2061
|
var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
|
|
1994
|
-
var nextBundleSellingPrice = (
|
|
2062
|
+
var nextBundleSellingPrice = (_ref16 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref16 !== void 0 ? _ref16 : bundleItem.bundle_selling_price;
|
|
1995
2063
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1996
2064
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1997
2065
|
var _discount$metadata10;
|
|
@@ -2018,7 +2086,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2018
2086
|
|
|
2019
2087
|
// 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
|
|
2020
2088
|
// 避免把主商品 discount_list 再扣一次。
|
|
2021
|
-
var mainSellingPrice = (
|
|
2089
|
+
var mainSellingPrice = (_ref17 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref17 !== void 0 ? _ref17 : 0;
|
|
2022
2090
|
var newTotal = Number(mainSellingPrice || 0);
|
|
2023
2091
|
var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
2024
2092
|
|
|
@@ -2155,6 +2223,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2155
2223
|
}, {
|
|
2156
2224
|
key: "checkPackageSubItemUsageRules",
|
|
2157
2225
|
value: function checkPackageSubItemUsageRules(discount, flatItem) {
|
|
2226
|
+
var _flatItem$product;
|
|
2158
2227
|
var limitedData = discount.limited_relation_product_data;
|
|
2159
2228
|
var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
|
|
2160
2229
|
var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
|
|
@@ -2166,16 +2235,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2166
2235
|
var ruleType = usageRules.type;
|
|
2167
2236
|
// 套餐适用范围配置
|
|
2168
2237
|
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
2169
|
-
var
|
|
2170
|
-
scopeType =
|
|
2171
|
-
|
|
2172
|
-
exclude_bundle_product_ids =
|
|
2173
|
-
|
|
2174
|
-
include_bundle_product_ids =
|
|
2175
|
-
|
|
2176
|
-
filter =
|
|
2238
|
+
var _ref18 = packageScope || {},
|
|
2239
|
+
scopeType = _ref18.type,
|
|
2240
|
+
_ref18$exclude_bundle = _ref18.exclude_bundle_product_ids,
|
|
2241
|
+
exclude_bundle_product_ids = _ref18$exclude_bundle === void 0 ? [] : _ref18$exclude_bundle,
|
|
2242
|
+
_ref18$include_bundle = _ref18.include_bundle_product_ids,
|
|
2243
|
+
include_bundle_product_ids = _ref18$include_bundle === void 0 ? [] : _ref18$include_bundle,
|
|
2244
|
+
_ref18$filter = _ref18.filter,
|
|
2245
|
+
filter = _ref18$filter === void 0 ? 0 : _ref18$filter;
|
|
2177
2246
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2178
2247
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2248
|
+
var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
|
|
2179
2249
|
|
|
2180
2250
|
// 主商品直接可用
|
|
2181
2251
|
if (isMainProduct) {
|
|
@@ -2218,13 +2288,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2218
2288
|
if (!filter) {
|
|
2219
2289
|
isScopeValid = true;
|
|
2220
2290
|
} else {
|
|
2221
|
-
isScopeValid = !exclude_bundle_product_ids.includes(Number(
|
|
2291
|
+
isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2222
2292
|
}
|
|
2223
2293
|
}
|
|
2224
2294
|
|
|
2225
2295
|
// 包含套餐判断, products值兼容旧数据
|
|
2226
2296
|
if (scopeType === 'specific_packages' || scopeType === 'products') {
|
|
2227
|
-
isScopeValid = include_bundle_product_ids.includes(Number(
|
|
2297
|
+
isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2228
2298
|
}
|
|
2229
2299
|
|
|
2230
2300
|
// 价格和套餐适用范围都符合,则可用
|
|
@@ -2274,16 +2344,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2274
2344
|
|
|
2275
2345
|
// 检查 rules
|
|
2276
2346
|
if (rules.length > 0) {
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2347
|
+
var _isOriginalPrice3 = _isOriginalPrice2 && rules.includes('original_price');
|
|
2348
|
+
var _isMarkupPrice3 = _isMarkupPrice2 && rules.includes('markup_price');
|
|
2349
|
+
// 价格是否符合规则:原价或加价
|
|
2350
|
+
var _isPriceValid = _isOriginalPrice3 || _isMarkupPrice3;
|
|
2351
|
+
// 套餐适用范围校验
|
|
2352
|
+
var _isScopeValid = false;
|
|
2353
|
+
|
|
2354
|
+
// 排除套餐判断, product_all值兼容旧数据
|
|
2355
|
+
if (scopeType === 'all_packages' || scopeType === 'product_all') {
|
|
2356
|
+
// 所有套餐可用
|
|
2357
|
+
if (!filter) {
|
|
2358
|
+
_isScopeValid = true;
|
|
2359
|
+
} else {
|
|
2360
|
+
_isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2361
|
+
}
|
|
2280
2362
|
}
|
|
2281
2363
|
|
|
2282
|
-
//
|
|
2283
|
-
if (
|
|
2364
|
+
// 包含套餐判断, products值兼容旧数据
|
|
2365
|
+
if (scopeType === 'specific_packages' || scopeType === 'products') {
|
|
2366
|
+
_isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
// 价格和套餐适用范围都符合,则可用
|
|
2370
|
+
if (_isPriceValid && _isScopeValid) {
|
|
2284
2371
|
return true;
|
|
2285
2372
|
}
|
|
2286
2373
|
|
|
2374
|
+
// 检查原价
|
|
2375
|
+
// if (isOriginalPrice && rules.includes('original_price')) {
|
|
2376
|
+
// return true;
|
|
2377
|
+
// }
|
|
2378
|
+
|
|
2379
|
+
// 检查加价
|
|
2380
|
+
// if (isMarkupPrice && rules.includes('markup_price')) {
|
|
2381
|
+
// return true;
|
|
2382
|
+
// }
|
|
2383
|
+
|
|
2287
2384
|
// 如果都不匹配,则不可用
|
|
2288
2385
|
return false;
|
|
2289
2386
|
}
|