@pisell/pisellos 2.3.40 → 2.3.41
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/core/index.d.ts +2 -0
- package/dist/core/index.js +7 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +11 -40
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.d.ts +2 -0
- package/dist/modules/OpenData/index.js +10 -2
- package/dist/modules/Order/index.d.ts +29 -12
- package/dist/modules/Order/index.js +750 -509
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +33 -10
- package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
- package/dist/modules/Order/utils.d.ts +0 -10
- package/dist/modules/Order/utils.js +13 -41
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +79 -50
- package/dist/modules/Payment/types.d.ts +99 -28
- package/dist/modules/Payment/types.js +20 -3
- package/dist/modules/Payment/walletpass.d.ts +25 -1
- package/dist/modules/Payment/walletpass.js +707 -157
- package/dist/modules/Product/types.d.ts +0 -1
- package/dist/modules/ProductList/index.js +14 -33
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/Rules/index.d.ts +1 -0
- package/dist/modules/Rules/index.js +89 -96
- package/dist/modules/SalesSummary/index.js +13 -12
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/index.js +2 -15
- package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
- package/dist/modules/Schedule/index.d.ts +1 -3
- package/dist/modules/Schedule/index.js +16 -21
- package/dist/modules/Summary/utils.js +13 -38
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +1 -3
- package/dist/plugins/window.d.ts +0 -1
- package/dist/server/index.d.ts +16 -14
- package/dist/server/index.js +1925 -1143
- package/dist/server/modules/order/index.d.ts +54 -4
- package/dist/server/modules/order/index.js +1600 -700
- package/dist/server/modules/order/types.d.ts +11 -3
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +109 -20
- package/dist/solution/BaseSales/index.js +1800 -480
- package/dist/solution/BaseSales/types.d.ts +52 -0
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -17
- package/dist/solution/BookingByStep/index.js +215 -294
- package/dist/solution/BookingByStep/types.d.ts +1 -2
- package/dist/solution/BookingByStep/types.js +1 -3
- package/dist/solution/BookingByStep/utils/capacity.js +1 -17
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/BookingTicket/index.d.ts +8 -4
- package/dist/solution/BookingTicket/index.js +134 -51
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -10
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +14 -26
- package/dist/solution/ScanOrder/index.js +756 -1148
- package/dist/solution/ScanOrder/types.d.ts +1 -21
- package/dist/solution/ScanOrder/utils.d.ts +0 -8
- package/dist/solution/ScanOrder/utils.js +25 -66
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +87 -125
- package/dist/solution/VenueBooking/index.d.ts +11 -39
- package/dist/solution/VenueBooking/index.js +860 -1176
- package/dist/solution/VenueBooking/types.d.ts +0 -3
- package/dist/solution/VenueBooking/utils/resource.js +0 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
- package/dist/solution/index.d.ts +0 -1
- package/dist/solution/index.js +1 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +2 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +0 -9
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/OpenData/index.d.ts +2 -0
- package/lib/modules/OpenData/index.js +6 -1
- package/lib/modules/Order/index.d.ts +29 -12
- package/lib/modules/Order/index.js +196 -86
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +33 -10
- package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
- package/lib/modules/Order/utils.d.ts +0 -10
- package/lib/modules/Order/utils.js +16 -40
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +34 -13
- package/lib/modules/Payment/types.d.ts +99 -28
- package/lib/modules/Payment/types.js +4 -3
- package/lib/modules/Payment/walletpass.d.ts +25 -1
- package/lib/modules/Payment/walletpass.js +470 -21
- package/lib/modules/Product/types.d.ts +0 -1
- package/lib/modules/ProductList/index.js +31 -40
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/Rules/index.d.ts +1 -0
- package/lib/modules/Rules/index.js +47 -40
- package/lib/modules/SalesSummary/index.js +7 -6
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/index.js +1 -13
- package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
- package/lib/modules/Schedule/index.d.ts +1 -3
- package/lib/modules/Schedule/index.js +8 -10
- package/lib/modules/Summary/utils.js +1 -21
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/index.js +1 -5
- package/lib/plugins/window.d.ts +0 -1
- package/lib/server/index.d.ts +16 -14
- package/lib/server/index.js +675 -83
- package/lib/server/modules/order/index.d.ts +54 -4
- package/lib/server/modules/order/index.js +679 -66
- package/lib/server/modules/order/types.d.ts +11 -3
- package/lib/solution/BaseSales/index.d.ts +109 -20
- package/lib/solution/BaseSales/index.js +883 -70
- package/lib/solution/BaseSales/types.d.ts +52 -0
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -17
- package/lib/solution/BookingByStep/index.js +18 -60
- package/lib/solution/BookingByStep/types.d.ts +1 -2
- package/lib/solution/BookingByStep/types.js +0 -5
- package/lib/solution/BookingByStep/utils/capacity.js +1 -20
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/BookingTicket/index.d.ts +8 -4
- package/lib/solution/BookingTicket/index.js +64 -19
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +5 -3
- package/lib/solution/ScanOrder/index.d.ts +14 -26
- package/lib/solution/ScanOrder/index.js +190 -449
- package/lib/solution/ScanOrder/types.d.ts +1 -21
- package/lib/solution/ScanOrder/utils.d.ts +0 -8
- package/lib/solution/ScanOrder/utils.js +0 -31
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +0 -14
- package/lib/solution/VenueBooking/index.d.ts +11 -39
- package/lib/solution/VenueBooking/index.js +123 -328
- package/lib/solution/VenueBooking/types.d.ts +0 -3
- package/lib/solution/VenueBooking/utils/resource.js +0 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
- package/lib/solution/index.d.ts +0 -1
- package/lib/solution/index.js +1 -3
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
- package/dist/modules/Holder/index.d.ts +0 -48
- package/dist/modules/Holder/index.js +0 -640
- package/dist/modules/Holder/types.d.ts +0 -123
- package/dist/modules/Holder/types.js +0 -1
- package/dist/modules/Holder/utils.d.ts +0 -13
- package/dist/modules/Holder/utils.js +0 -34
- package/dist/modules/ResourcePlanner/index.d.ts +0 -24
- package/dist/modules/ResourcePlanner/index.js +0 -181
- package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
- package/dist/modules/ResourcePlanner/planner.js +0 -1069
- package/dist/modules/ResourcePlanner/types.d.ts +0 -227
- package/dist/modules/ResourcePlanner/types.js +0 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/dist/solution/UnifiedBookingSales/index.js +0 -1871
- package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/dist/solution/UnifiedBookingSales/types.js +0 -11
- package/lib/modules/Holder/index.d.ts +0 -48
- package/lib/modules/Holder/index.js +0 -402
- package/lib/modules/Holder/types.d.ts +0 -123
- package/lib/modules/Holder/types.js +0 -17
- package/lib/modules/Holder/utils.d.ts +0 -13
- package/lib/modules/Holder/utils.js +0 -71
- package/lib/modules/ResourcePlanner/index.d.ts +0 -24
- package/lib/modules/ResourcePlanner/index.js +0 -148
- package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
- package/lib/modules/ResourcePlanner/planner.js +0 -933
- package/lib/modules/ResourcePlanner/types.d.ts +0 -227
- package/lib/modules/ResourcePlanner/types.js +0 -17
- package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/lib/solution/UnifiedBookingSales/index.js +0 -1076
- package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/lib/solution/UnifiedBookingSales/types.js +0 -33
|
@@ -157,10 +157,6 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
157
157
|
userPlugin,
|
|
158
158
|
customer_id,
|
|
159
159
|
_userPlugin$get,
|
|
160
|
-
channelMap,
|
|
161
|
-
rawApplicationCode,
|
|
162
|
-
mappedApplicationCode,
|
|
163
|
-
queryPayload,
|
|
164
160
|
productsData,
|
|
165
161
|
sortedList,
|
|
166
162
|
_args4 = arguments;
|
|
@@ -189,16 +185,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
189
185
|
console.error(error);
|
|
190
186
|
}
|
|
191
187
|
// 如果没传schedule_date,则从
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
scan_to_order: 'online-store',
|
|
195
|
-
'scan-to-order': 'online-store',
|
|
196
|
-
scan_to_order_2: 'mobile_order',
|
|
197
|
-
scan_to_order_3: 'scantoorder3'
|
|
198
|
-
};
|
|
199
|
-
rawApplicationCode = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel;
|
|
200
|
-
mappedApplicationCode = typeof rawApplicationCode === 'string' ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
|
|
201
|
-
queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
188
|
+
_context4.next = 7;
|
|
189
|
+
return this.request.post("/product/query", {
|
|
202
190
|
open_quotation: 1,
|
|
203
191
|
open_bundle: 0,
|
|
204
192
|
exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
|
|
@@ -206,35 +194,28 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
206
194
|
status: status,
|
|
207
195
|
num: 500,
|
|
208
196
|
skip: 1,
|
|
209
|
-
customer_id: customer_id
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
collection: collection
|
|
216
|
-
} : {}), {}, {
|
|
217
|
-
front_end_cache_id: cacheId
|
|
218
|
-
}, Array.isArray(menu_list_ids) && menu_list_ids.length ? {
|
|
219
|
-
menu_list_ids: menu_list_ids
|
|
220
|
-
} : {}), {}, {
|
|
197
|
+
customer_id: customer_id,
|
|
198
|
+
category_ids: category_ids,
|
|
199
|
+
ids: product_ids,
|
|
200
|
+
collection: collection,
|
|
201
|
+
front_end_cache_id: cacheId,
|
|
202
|
+
menu_list_ids: menu_list_ids,
|
|
221
203
|
with_count: with_count,
|
|
222
204
|
// client_schedule_ids: schedule_ids,
|
|
223
205
|
schedule_date: schedule_date,
|
|
224
|
-
application_code:
|
|
206
|
+
application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel,
|
|
225
207
|
is_eject: 1,
|
|
226
208
|
with_schedule: with_schedule,
|
|
227
209
|
schedule_datetime: schedule_datetime,
|
|
228
|
-
extension_type: extension_type
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return this.request.post("/product/query", queryPayload, {
|
|
210
|
+
extension_type: extension_type,
|
|
211
|
+
strategy_context: strategy_context
|
|
212
|
+
}, {
|
|
232
213
|
osServer: true,
|
|
233
214
|
callback: options === null || options === void 0 ? void 0 : options.callback,
|
|
234
215
|
subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
|
|
235
216
|
customToast: function customToast() {}
|
|
236
217
|
});
|
|
237
|
-
case
|
|
218
|
+
case 7:
|
|
238
219
|
productsData = _context4.sent;
|
|
239
220
|
sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
|
|
240
221
|
return Number(b.sort) - Number(a.sort);
|
|
@@ -247,7 +228,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
247
228
|
// }
|
|
248
229
|
this.addProduct(sortedList);
|
|
249
230
|
return _context4.abrupt("return", sortedList);
|
|
250
|
-
case
|
|
231
|
+
case 11:
|
|
251
232
|
case "end":
|
|
252
233
|
return _context4.stop();
|
|
253
234
|
}
|
|
@@ -21,7 +21,7 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
21
21
|
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
22
22
|
* Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
|
|
23
23
|
*
|
|
24
|
-
* Priority: iterates quotations already sorted by `sort`
|
|
24
|
+
* Priority: iterates quotations already sorted by `sort` ascending (lowest = highest priority).
|
|
25
25
|
* First matching quotation whose schedule covers `datetime` and whose product_data contains
|
|
26
26
|
* the requested productId wins.
|
|
27
27
|
*/
|
|
@@ -90,7 +90,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
90
90
|
res = _context2.sent;
|
|
91
91
|
list = (res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [];
|
|
92
92
|
list.sort(function (a, b) {
|
|
93
|
-
return
|
|
93
|
+
return a.sort - b.sort;
|
|
94
94
|
});
|
|
95
95
|
this.store.list = list;
|
|
96
96
|
case 9:
|
|
@@ -151,7 +151,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
151
151
|
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
152
152
|
* Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
|
|
153
153
|
*
|
|
154
|
-
* Priority: iterates quotations already sorted by `sort`
|
|
154
|
+
* Priority: iterates quotations already sorted by `sort` ascending (lowest = highest priority).
|
|
155
155
|
* First matching quotation whose schedule covers `datetime` and whose product_data contains
|
|
156
156
|
* the requested productId wins.
|
|
157
157
|
*/
|
|
@@ -35,6 +35,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
35
35
|
excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
36
36
|
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
37
37
|
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
38
|
+
private isItemRewardProductDiscount;
|
|
38
39
|
private getUnavailableReason;
|
|
39
40
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
40
41
|
discountList: Discount[];
|
|
@@ -241,6 +241,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
241
241
|
value: function resolveDiscountListForManualOverride(discountList) {
|
|
242
242
|
return this.excludeDiscountListByType(discountList, 'promotion');
|
|
243
243
|
}
|
|
244
|
+
}, {
|
|
245
|
+
key: "isItemRewardProductDiscount",
|
|
246
|
+
value: function isItemRewardProductDiscount(product) {
|
|
247
|
+
var _product$_promotion;
|
|
248
|
+
var discountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? product.discount_list : [];
|
|
249
|
+
return (product === null || product === void 0 || (_product$_promotion = product._promotion) === null || _product$_promotion === void 0 ? void 0 : _product$_promotion.actionType) === 'ITEM_REWARD' && discountList.some(function (item) {
|
|
250
|
+
var _item$metadata, _item$metadata2;
|
|
251
|
+
return (item === null || item === void 0 ? void 0 : item.type) === 'product' && (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.source) === 'promotion' && (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.actionType) === 'ITEM_REWARD';
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
244
255
|
// 获取券不可用的原因
|
|
245
256
|
}, {
|
|
246
257
|
key: "getUnavailableReason",
|
|
@@ -423,13 +434,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
423
434
|
_id: product._id,
|
|
424
435
|
parentId: product._id,
|
|
425
436
|
quantity: product.quantity,
|
|
426
|
-
num: product.num
|
|
427
|
-
booking_id: product.booking_id
|
|
437
|
+
num: product.num
|
|
428
438
|
});
|
|
429
439
|
|
|
430
440
|
// 2. 展开 bundle 子商品
|
|
431
441
|
if (product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0) {
|
|
432
442
|
product.bundle.forEach(function (bundleItem, bundleIndex) {
|
|
443
|
+
var _ref3, _bundleItem$bundle_pr;
|
|
433
444
|
flattened.push({
|
|
434
445
|
type: 'bundle',
|
|
435
446
|
originProduct: originProduct,
|
|
@@ -438,8 +449,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
438
449
|
bundleIndex: bundleIndex,
|
|
439
450
|
// 虚拟商品属性
|
|
440
451
|
price: Number(bundleItem.price || 0),
|
|
441
|
-
id: bundleItem._bundle_product_id,
|
|
442
|
-
// 🔥 使用 _bundle_product_id
|
|
452
|
+
id: (_ref3 = (_bundleItem$bundle_pr = bundleItem.bundle_product_id) !== null && _bundleItem$bundle_pr !== void 0 ? _bundleItem$bundle_pr : bundleItem._bundle_product_id) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_id,
|
|
443
453
|
_id: "".concat(product._id, "_bundle_").concat(bundleIndex),
|
|
444
454
|
parentId: product._id,
|
|
445
455
|
num: bundleItem.num || 1,
|
|
@@ -448,7 +458,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
448
458
|
origin_total: new Decimal(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
|
|
449
459
|
original_price: bundleItem.original_price,
|
|
450
460
|
// 继承主商品属性
|
|
451
|
-
booking_id:
|
|
461
|
+
booking_id: product.booking_id,
|
|
452
462
|
discount_list: bundleItem.discount_list || []
|
|
453
463
|
});
|
|
454
464
|
});
|
|
@@ -588,10 +598,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
588
598
|
|
|
589
599
|
// 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
|
|
590
600
|
var sortedFlattenedList = flattenedList.sort(function (a, b) {
|
|
591
|
-
var
|
|
601
|
+
var _ref4, _a$original_price, _ref5, _b$original_price;
|
|
592
602
|
// 子商品优先使用 original_price,主商品使用 price
|
|
593
|
-
var priceA = new Decimal(a.type === 'bundle' ? (
|
|
594
|
-
var priceB = new Decimal(b.type === 'bundle' ? (
|
|
603
|
+
var priceA = new Decimal(a.type === 'bundle' ? (_ref4 = (_a$original_price = a.original_price) !== null && _a$original_price !== void 0 ? _a$original_price : a.price) !== null && _ref4 !== void 0 ? _ref4 : '0' : a.price || '0');
|
|
604
|
+
var priceB = new Decimal(b.type === 'bundle' ? (_ref5 = (_b$original_price = b.original_price) !== null && _b$original_price !== void 0 ? _b$original_price : b.price) !== null && _ref5 !== void 0 ? _ref5 : '0' : b.price || '0');
|
|
595
605
|
if (priceA.equals(priceB)) {
|
|
596
606
|
// 价格相同时,主商品优先
|
|
597
607
|
if (a.type !== b.type) {
|
|
@@ -730,6 +740,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
730
740
|
startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
|
|
731
741
|
};
|
|
732
742
|
}
|
|
743
|
+
if (_this3.isItemRewardProductDiscount(product)) {
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
733
746
|
|
|
734
747
|
// 编辑的商品使用了优惠券不可用
|
|
735
748
|
var isAvailableProduct = flatItem.type === 'main' ? !((_product2 = product) !== null && _product2 !== void 0 && _product2.booking_id && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.length && (_product4 = product) !== null && _product4 !== void 0 && (_product4 = _product4.discount_list) !== null && _product4 !== void 0 && _product4.every(function (d) {
|
|
@@ -833,7 +846,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
833
846
|
// 收集该折扣卡适用的商品(排除被其他专属折扣卡占用的商品)
|
|
834
847
|
var applicableProducts = [];
|
|
835
848
|
sortedFlattenedList.forEach(function (flatItem) {
|
|
836
|
-
var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price,
|
|
849
|
+
var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price, _ref6, _flatItem$original_pr;
|
|
837
850
|
// 🔥 检查该商品是否被其他专属折扣卡占用
|
|
838
851
|
var occupyingDiscountId = occupiedItems.get(flatItem._id);
|
|
839
852
|
if (occupyingDiscountId !== undefined && occupyingDiscountId !== discount.id) {
|
|
@@ -861,7 +874,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
861
874
|
|
|
862
875
|
// 对于主商品:使用 price
|
|
863
876
|
// 对于子商品:优先使用 flatItem.original_price,否则使用 flatItem.price
|
|
864
|
-
var originalAmount = flatItem.type === 'main' ? Number((_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : 0) : Number((
|
|
877
|
+
var originalAmount = flatItem.type === 'main' ? Number((_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : 0) : Number((_ref6 = (_flatItem$original_pr = flatItem.original_price) !== null && _flatItem$original_pr !== void 0 ? _flatItem$original_pr : flatItem.price) !== null && _ref6 !== void 0 ? _ref6 : 0);
|
|
865
878
|
|
|
866
879
|
// 传递 parentQuantity 用于差值处理时判断是否是真正的"数量为1"
|
|
867
880
|
var productData = {
|
|
@@ -916,6 +929,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
916
929
|
};
|
|
917
930
|
originProduct = flatItem.originProduct;
|
|
918
931
|
}
|
|
932
|
+
var isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
|
|
919
933
|
addModeDiscount.forEach(function (discount) {
|
|
920
934
|
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
|
|
921
935
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
@@ -941,7 +955,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
941
955
|
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
942
956
|
|
|
943
957
|
// 判断优惠券是否适用于该商品
|
|
944
|
-
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
958
|
+
if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
945
959
|
var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
|
|
946
960
|
// 记录此优惠券适用的商品
|
|
947
961
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -969,8 +983,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
969
983
|
discount_product_id: discount.product_id
|
|
970
984
|
},
|
|
971
985
|
metadata: {
|
|
972
|
-
num: num
|
|
973
|
-
discount_rule_uncheck_flag: discount === null || discount === void 0 ? void 0 : discount.discount_rule_uncheck_flag
|
|
986
|
+
num: num
|
|
974
987
|
}
|
|
975
988
|
};
|
|
976
989
|
applicableProducts.push(productData);
|
|
@@ -990,13 +1003,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
990
1003
|
};
|
|
991
1004
|
var optionDiscountAmount = 0;
|
|
992
1005
|
var discountedOptions = options.map(function (option) {
|
|
993
|
-
var
|
|
1006
|
+
var _ref7, _ref8, _option$_original_pri, _ref9, _option$num, _rest$price, _option$_original_pri2;
|
|
994
1007
|
// 折前单价:优先 price,缺失再 add_price;已写回折后价时用 _original_price(或旧字段 _original_add_price)
|
|
995
|
-
var rawUnit = (
|
|
1008
|
+
var rawUnit = (_ref7 = (_ref8 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref8 !== void 0 ? _ref8 : option.price) !== null && _ref7 !== void 0 ? _ref7 : option.add_price;
|
|
996
1009
|
var baseUnitNum = Number(rawUnit !== null && rawUnit !== void 0 ? rawUnit : 0);
|
|
997
1010
|
if (baseUnitNum <= 0) return option;
|
|
998
1011
|
var discountedPrice = getDiscountAmount(discount, baseUnitNum, baseUnitNum);
|
|
999
|
-
var optQty = Number((
|
|
1012
|
+
var optQty = Number((_ref9 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref9 !== void 0 ? _ref9 : 1);
|
|
1000
1013
|
optionDiscountAmount = new Decimal(optionDiscountAmount).plus(new Decimal(baseUnitNum).minus(discountedPrice).mul(optQty)).toNumber();
|
|
1001
1014
|
var _original_add_price = option._original_add_price,
|
|
1002
1015
|
rest = _objectWithoutProperties(option, _excluded);
|
|
@@ -1030,9 +1043,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1030
1043
|
var getOptionTotal = function getOptionTotal(options) {
|
|
1031
1044
|
if (!(options !== null && options !== void 0 && options.length)) return 0;
|
|
1032
1045
|
return options.reduce(function (sum, opt) {
|
|
1033
|
-
var
|
|
1034
|
-
var unit = Number((
|
|
1035
|
-
var n = Number((
|
|
1046
|
+
var _ref10, _opt$price, _ref11, _opt$num;
|
|
1047
|
+
var unit = Number((_ref10 = (_opt$price = opt.price) !== null && _opt$price !== void 0 ? _opt$price : opt.add_price) !== null && _ref10 !== void 0 ? _ref10 : 0);
|
|
1048
|
+
var n = Number((_ref11 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref11 !== void 0 ? _ref11 : 1);
|
|
1036
1049
|
return new Decimal(sum).plus(new Decimal(unit).mul(n)).toNumber();
|
|
1037
1050
|
}, 0);
|
|
1038
1051
|
};
|
|
@@ -1087,6 +1100,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1087
1100
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1088
1101
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1089
1102
|
var _product$discount_lis3, _product$discount_lis4;
|
|
1103
|
+
if (_this3.isItemRewardProductDiscount(product)) return false;
|
|
1090
1104
|
// 🔥 检查策略可用性(针对 good_pass 和折扣卡)
|
|
1091
1105
|
var discountType = discount.tag || discount.type;
|
|
1092
1106
|
var currentOriginUid = getOriginProductUid(originProduct);
|
|
@@ -1164,28 +1178,36 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1164
1178
|
return false;
|
|
1165
1179
|
});
|
|
1166
1180
|
|
|
1167
|
-
//
|
|
1168
|
-
//
|
|
1169
|
-
|
|
1170
|
-
|
|
1181
|
+
// 用户显式点击某张折扣卡时,本次选择优先于自动排序和扫码默认选择。
|
|
1182
|
+
// 目标仍必须在当前商品的 applicableDiscounts 中,因此不会绕过 Holder、时间或商品范围校验。
|
|
1183
|
+
var explicitlySelectedDiscountCard = (options === null || options === void 0 ? void 0 : options.isSelected) === true && options.discountId !== undefined ? applicableDiscounts.find(function (discount) {
|
|
1184
|
+
var discountType = discount.tag || discount.type;
|
|
1185
|
+
return String(discount.id) === String(options.discountId) && ['discount_card', 'product_discount_card'].includes(discountType);
|
|
1186
|
+
}) : undefined;
|
|
1187
|
+
|
|
1188
|
+
// 没有显式选择时保持现有行为:扫码且已选中的折扣卡优先,否则使用自动排序第一项。
|
|
1189
|
+
var scannedSelectedDiscountCard = applicableDiscounts.find(function (n) {
|
|
1171
1190
|
return n.isScan && n.isSelected && (n.tag || n.type) !== 'good_pass';
|
|
1172
1191
|
});
|
|
1192
|
+
var selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
|
|
1173
1193
|
var selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
1174
1194
|
|
|
1175
1195
|
// 如果是手动折扣,则不适用优惠券
|
|
1176
1196
|
var isManualDiscount = false;
|
|
1197
|
+
var isItemRewardProductDiscount = false;
|
|
1177
1198
|
if (flatItem.type === 'main') {
|
|
1178
1199
|
var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
|
|
1179
1200
|
// 主商品:判断自身是否手动折扣
|
|
1180
1201
|
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) {
|
|
1181
1202
|
return item.type === 'product';
|
|
1182
1203
|
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1183
|
-
var
|
|
1184
|
-
return !((
|
|
1204
|
+
var _ref12;
|
|
1205
|
+
return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
|
|
1185
1206
|
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
|
|
1186
1207
|
return item.type === 'product';
|
|
1187
1208
|
})));
|
|
1188
|
-
|
|
1209
|
+
isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
|
|
1210
|
+
if (product.inPromotion && !isItemRewardProductDiscount) {
|
|
1189
1211
|
isManualDiscount = false;
|
|
1190
1212
|
}
|
|
1191
1213
|
} else {
|
|
@@ -1196,8 +1218,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1196
1218
|
isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : ((_parentProduct$discou = parentProduct.discount_list) === null || _parentProduct$discou === void 0 ? void 0 : _parentProduct$discou.some(function (item) {
|
|
1197
1219
|
return item.type === 'product';
|
|
1198
1220
|
})) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
|
|
1199
|
-
var
|
|
1200
|
-
return !((
|
|
1221
|
+
var _ref13;
|
|
1222
|
+
return !((_ref13 = item.discount_list || []) !== null && _ref13 !== void 0 && _ref13.length);
|
|
1201
1223
|
}) && (!((_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) {
|
|
1202
1224
|
return item.type === 'product';
|
|
1203
1225
|
})));
|
|
@@ -1290,19 +1312,22 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1290
1312
|
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1291
1313
|
}))]);
|
|
1292
1314
|
} else {
|
|
1293
|
-
var
|
|
1294
|
-
var total = product.inPromotion ? (
|
|
1315
|
+
var _ref14, _product$_promotion$f, _product13, _product$origin_total;
|
|
1316
|
+
var total = product.inPromotion ? (_ref14 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref14 !== void 0 ? _ref14 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1295
1317
|
var main_product_selling_price = product.price;
|
|
1296
1318
|
if ((product.discount_list || []).some(function (item) {
|
|
1297
1319
|
return item.type === 'promotion';
|
|
1298
|
-
}) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1320
|
+
}) || isItemRewardProductDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1299
1321
|
var _product$total, _product$main_product;
|
|
1300
1322
|
total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
|
|
1301
1323
|
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;
|
|
1302
1324
|
}
|
|
1303
|
-
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
1304
|
-
price: product.price
|
|
1305
|
-
|
|
1325
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? _objectSpread({
|
|
1326
|
+
price: product.price,
|
|
1327
|
+
main_product_selling_price: isItemRewardProductDiscount ? main_product_selling_price : product.price
|
|
1328
|
+
}, isItemRewardProductDiscount ? {
|
|
1329
|
+
total: total
|
|
1330
|
+
} : {}) : {
|
|
1306
1331
|
_id: product._id.split('___')[0] + '___' + index,
|
|
1307
1332
|
total: total,
|
|
1308
1333
|
price: product.price,
|
|
@@ -1454,8 +1479,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1454
1479
|
_num: isGoodPass ? 1 : product.num,
|
|
1455
1480
|
config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
|
|
1456
1481
|
metadata: _objectSpread(_objectSpread({
|
|
1457
|
-
num: 1
|
|
1458
|
-
discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
|
|
1482
|
+
num: 1
|
|
1459
1483
|
}, productDiscountDifference !== undefined && {
|
|
1460
1484
|
product_discount_difference: productDiscountDifference
|
|
1461
1485
|
}), {}, {
|
|
@@ -1542,7 +1566,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1542
1566
|
metadata: {
|
|
1543
1567
|
// 🔥 使用拆分后的唯一 _id
|
|
1544
1568
|
custom_product_bundle_map_id: uniqueId,
|
|
1545
|
-
discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
|
|
1546
1569
|
num: 1
|
|
1547
1570
|
},
|
|
1548
1571
|
_num: 1,
|
|
@@ -1574,7 +1597,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1574
1597
|
_id: "".concat(flatItem._id, "_split_rest"),
|
|
1575
1598
|
num: normalNum,
|
|
1576
1599
|
quantity: normalNum,
|
|
1577
|
-
discount_list:
|
|
1600
|
+
discount_list: [],
|
|
1578
1601
|
processed: true
|
|
1579
1602
|
}));
|
|
1580
1603
|
}
|
|
@@ -1628,7 +1651,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1628
1651
|
metadata: _objectSpread({
|
|
1629
1652
|
// 🔥 使用唯一的 _id
|
|
1630
1653
|
custom_product_bundle_map_id: _uniqueId,
|
|
1631
|
-
discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
|
|
1632
1654
|
num: product.num || 1
|
|
1633
1655
|
}, _productDiscountDifference !== undefined && {
|
|
1634
1656
|
product_discount_difference: _productDiscountDifference
|
|
@@ -1644,7 +1666,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1644
1666
|
processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1645
1667
|
total: targetProductTotal,
|
|
1646
1668
|
price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
|
|
1647
|
-
discount_list:
|
|
1669
|
+
discount_list: [_discountDetail2],
|
|
1648
1670
|
processed: true
|
|
1649
1671
|
}));
|
|
1650
1672
|
}
|
|
@@ -1754,11 +1776,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1754
1776
|
processedItems.forEach(function (item) {
|
|
1755
1777
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1756
1778
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1757
|
-
var _item$
|
|
1779
|
+
var _item$metadata3;
|
|
1758
1780
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1759
1781
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1760
1782
|
num: item.num,
|
|
1761
|
-
custom_product_bundle_map_id: (_item$
|
|
1783
|
+
custom_product_bundle_map_id: (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.custom_product_bundle_map_id
|
|
1762
1784
|
})
|
|
1763
1785
|
// num: item.num, // 使用拆分后的 num
|
|
1764
1786
|
});
|
|
@@ -1777,11 +1799,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1777
1799
|
if (item.processed) {
|
|
1778
1800
|
// 🔥 同样需要更新 discount_list 中的 num
|
|
1779
1801
|
var _updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1780
|
-
var _item$
|
|
1802
|
+
var _item$metadata4;
|
|
1781
1803
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1782
1804
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1783
1805
|
num: item.num,
|
|
1784
|
-
custom_product_bundle_map_id: (_item$
|
|
1806
|
+
custom_product_bundle_map_id: (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.custom_product_bundle_map_id
|
|
1785
1807
|
})
|
|
1786
1808
|
// num: item.num, // 使用当前的 num
|
|
1787
1809
|
});
|
|
@@ -1822,8 +1844,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1822
1844
|
|
|
1823
1845
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1824
1846
|
var mainDiscountList = updatedMainDiscountList.filter(function (item) {
|
|
1825
|
-
var _item$
|
|
1826
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1847
|
+
var _item$metadata5;
|
|
1848
|
+
return !(item !== null && item !== void 0 && (_item$metadata5 = item.metadata) !== null && _item$metadata5 !== void 0 && _item$metadata5.custom_product_bundle_map_id);
|
|
1827
1849
|
});
|
|
1828
1850
|
if (mainDiscountList && mainDiscountList.length > 0) {
|
|
1829
1851
|
var _Decimal$minus$toNumb, _mainProductData$orig;
|
|
@@ -1896,8 +1918,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1896
1918
|
|
|
1897
1919
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1898
1920
|
var mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(function (item) {
|
|
1899
|
-
var _item$
|
|
1900
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1921
|
+
var _item$metadata6;
|
|
1922
|
+
return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
|
|
1901
1923
|
});
|
|
1902
1924
|
if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
|
|
1903
1925
|
var _Decimal$minus$toNumb2, _mainProductData$orig2;
|
|
@@ -1938,7 +1960,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1938
1960
|
} else {
|
|
1939
1961
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
1940
1962
|
mainProductArr.forEach(function (mainProduct) {
|
|
1941
|
-
var
|
|
1963
|
+
var _ref16, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
1942
1964
|
var mainProductData = _this3.hooks.getProduct(mainProduct);
|
|
1943
1965
|
|
|
1944
1966
|
// 重组bundle
|
|
@@ -1953,9 +1975,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1953
1975
|
} else {
|
|
1954
1976
|
// 🔥 关键:拆分后的bundle item
|
|
1955
1977
|
processedBundleItems.forEach(function (item) {
|
|
1956
|
-
var _item$price,
|
|
1978
|
+
var _item$price, _ref15, _item$bundle_selling_;
|
|
1957
1979
|
var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
|
|
1958
|
-
var nextBundleSellingPrice = (
|
|
1980
|
+
var nextBundleSellingPrice = (_ref15 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref15 !== void 0 ? _ref15 : bundleItem.bundle_selling_price;
|
|
1959
1981
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1960
1982
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1961
1983
|
var _discount$metadata10;
|
|
@@ -1982,7 +2004,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1982
2004
|
|
|
1983
2005
|
// 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
|
|
1984
2006
|
// 避免把主商品 discount_list 再扣一次。
|
|
1985
|
-
var mainSellingPrice = (
|
|
2007
|
+
var mainSellingPrice = (_ref16 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref16 !== void 0 ? _ref16 : 0;
|
|
1986
2008
|
var newTotal = Number(mainSellingPrice || 0);
|
|
1987
2009
|
var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
1988
2010
|
|
|
@@ -2119,7 +2141,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2119
2141
|
}, {
|
|
2120
2142
|
key: "checkPackageSubItemUsageRules",
|
|
2121
2143
|
value: function checkPackageSubItemUsageRules(discount, flatItem) {
|
|
2122
|
-
var _flatItem$product;
|
|
2123
2144
|
var limitedData = discount.limited_relation_product_data;
|
|
2124
2145
|
var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
|
|
2125
2146
|
var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
|
|
@@ -2131,17 +2152,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2131
2152
|
var ruleType = usageRules.type;
|
|
2132
2153
|
// 套餐适用范围配置
|
|
2133
2154
|
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
2134
|
-
var
|
|
2135
|
-
scopeType =
|
|
2136
|
-
|
|
2137
|
-
exclude_bundle_product_ids =
|
|
2138
|
-
|
|
2139
|
-
include_bundle_product_ids =
|
|
2140
|
-
|
|
2141
|
-
filter =
|
|
2155
|
+
var _ref17 = packageScope || {},
|
|
2156
|
+
scopeType = _ref17.type,
|
|
2157
|
+
_ref17$exclude_bundle = _ref17.exclude_bundle_product_ids,
|
|
2158
|
+
exclude_bundle_product_ids = _ref17$exclude_bundle === void 0 ? [] : _ref17$exclude_bundle,
|
|
2159
|
+
_ref17$include_bundle = _ref17.include_bundle_product_ids,
|
|
2160
|
+
include_bundle_product_ids = _ref17$include_bundle === void 0 ? [] : _ref17$include_bundle,
|
|
2161
|
+
_ref17$filter = _ref17.filter,
|
|
2162
|
+
filter = _ref17$filter === void 0 ? 0 : _ref17$filter;
|
|
2142
2163
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2143
2164
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2144
|
-
var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
|
|
2145
2165
|
|
|
2146
2166
|
// 主商品直接可用
|
|
2147
2167
|
if (isMainProduct) {
|
|
@@ -2184,13 +2204,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2184
2204
|
if (!filter) {
|
|
2185
2205
|
isScopeValid = true;
|
|
2186
2206
|
} else {
|
|
2187
|
-
isScopeValid = !exclude_bundle_product_ids.includes(Number(
|
|
2207
|
+
isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
|
|
2188
2208
|
}
|
|
2189
2209
|
}
|
|
2190
2210
|
|
|
2191
2211
|
// 包含套餐判断, products值兼容旧数据
|
|
2192
2212
|
if (scopeType === 'specific_packages' || scopeType === 'products') {
|
|
2193
|
-
isScopeValid = include_bundle_product_ids.includes(Number(
|
|
2213
|
+
isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
|
|
2194
2214
|
}
|
|
2195
2215
|
|
|
2196
2216
|
// 价格和套餐适用范围都符合,则可用
|
|
@@ -2240,42 +2260,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2240
2260
|
|
|
2241
2261
|
// 检查 rules
|
|
2242
2262
|
if (rules.length > 0) {
|
|
2243
|
-
|
|
2244
|
-
|
|
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
|
-
}
|
|
2258
|
-
}
|
|
2259
|
-
|
|
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) {
|
|
2263
|
+
// 检查原价
|
|
2264
|
+
if (_isOriginalPrice2 && rules.includes('original_price')) {
|
|
2267
2265
|
return true;
|
|
2268
2266
|
}
|
|
2269
2267
|
|
|
2270
|
-
// 检查原价
|
|
2271
|
-
// if (isOriginalPrice && rules.includes('original_price')) {
|
|
2272
|
-
// return true;
|
|
2273
|
-
// }
|
|
2274
|
-
|
|
2275
2268
|
// 检查加价
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2269
|
+
if (_isMarkupPrice2 && rules.includes('markup_price')) {
|
|
2270
|
+
return true;
|
|
2271
|
+
}
|
|
2279
2272
|
|
|
2280
2273
|
// 如果都不匹配,则不可用
|
|
2281
2274
|
return false;
|