@pisell/pisellos 0.0.569 → 0.10.2
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.js +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +1 -1
- package/dist/modules/BaseModule.js +8 -10
- package/dist/modules/Cart/index.js +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +9 -16
- package/dist/modules/Date/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +7 -22
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.js +2 -0
- package/dist/modules/Order/index.js +70 -40
- package/dist/modules/Payment/index.js +162 -97
- package/dist/modules/Payment/types.d.ts +4 -8
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +5 -4
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -12
- package/dist/modules/ProductList/types.d.ts +0 -1
- package/dist/modules/Rules/index.js +126 -427
- package/dist/modules/SalesSummary/utils.js +1 -2
- package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
- package/dist/modules/Schedule/index.js +1 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/utils.js +22 -43
- package/dist/plugins/request.js +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.js +129 -97
- package/dist/server/modules/menu/index.js +41 -32
- package/dist/server/modules/order/index.js +4 -2
- package/dist/server/modules/products/index.js +42 -24
- package/dist/server/modules/quotation/index.js +38 -29
- package/dist/server/modules/resource/index.js +4 -3
- package/dist/server/modules/schedule/index.js +35 -27
- package/dist/server/utils/product.js +1 -0
- package/dist/solution/BaseSales/index.js +41 -38
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
- package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
- package/dist/solution/BuyTickets/index.js +12 -9
- package/dist/solution/Checkout/index.js +252 -177
- package/dist/solution/Checkout/utils/index.js +16 -4
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- package/dist/solution/ScanOrder/index.js +60 -50
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/VenueBooking/index.d.ts +3 -31
- package/dist/solution/VenueBooking/index.js +496 -651
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +49 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +1 -1
- package/lib/modules/BaseModule.js +46 -25
- package/lib/modules/BookingContext/index.js +136 -158
- package/lib/modules/BookingContext/types.js +32 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
- package/lib/modules/BookingContext/utils/flexible.js +55 -38
- package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
- package/lib/modules/BookingContext/utils/index.js +41 -124
- package/lib/modules/BookingContext/utils/noResource.js +70 -58
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
- package/lib/modules/BookingContext/utils/productExtend.js +155 -202
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
- package/lib/modules/BookingContext/utils/resources.js +167 -209
- package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
- package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +251 -321
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +50 -28
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.js +169 -232
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +128 -130
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.js +76 -69
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.js +1909 -1572
- package/lib/modules/Order/types.js +35 -78
- package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
- package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
- package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
- package/lib/modules/Order/utils.js +634 -799
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.js +378 -518
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +4 -8
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.js +48 -51
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +211 -226
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +117 -117
- package/lib/modules/ProductList/types.d.ts +0 -1
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.js +100 -66
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.js +61 -60
- package/lib/modules/ResourcePlanner/planner.js +384 -346
- package/lib/modules/ResourcePlanner/types.js +16 -4
- package/lib/modules/Rules/index.js +903 -1475
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.js +90 -85
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.js +427 -351
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
- package/lib/modules/Schedule/index.js +114 -100
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.js +60 -46
- package/lib/modules/SurchargeList/types.js +16 -4
- package/lib/modules/index.js +63 -245
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.js +2337 -2675
- package/lib/server/modules/floor-plan/index.js +123 -102
- package/lib/server/modules/floor-plan/types.js +30 -15
- package/lib/server/modules/index.js +68 -106
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.js +642 -567
- package/lib/server/modules/order/types.js +32 -117
- package/lib/server/modules/order/utils/filterBookings.js +194 -219
- package/lib/server/modules/order/utils/filterOrders.js +92 -118
- package/lib/server/modules/payment/index.js +83 -59
- package/lib/server/modules/payment/types.js +16 -4
- package/lib/server/modules/products/index.js +459 -575
- package/lib/server/modules/products/types.js +34 -44
- package/lib/server/modules/quotation/index.js +172 -137
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.js +184 -213
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.js +123 -135
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +139 -196
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.js +456 -478
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.js +1016 -850
- package/lib/solution/BaseSales/types.js +37 -41
- package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
- package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
- package/lib/solution/BaseSales/utils.js +140 -155
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +459 -543
- package/lib/solution/BookingTicket/types.js +77 -99
- package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
- package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
- package/lib/solution/BookingTicket/utils/cartView.js +94 -110
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
- package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
- package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.js +1158 -1451
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +460 -493
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.js +320 -317
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.js +862 -831
- package/lib/solution/ScanOrder/types.js +34 -33
- package/lib/solution/ScanOrder/utils.js +371 -406
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.js +405 -379
- package/lib/solution/UnifiedBookingSales/types.js +31 -12
- package/lib/solution/VenueBooking/index.d.ts +3 -31
- package/lib/solution/VenueBooking/index.js +916 -967
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.js +41 -124
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,27 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
|
|
19
|
+
// src/model/strategy/adapter/itemRule/adapter.ts
|
|
20
|
+
var adapter_exports = {};
|
|
21
|
+
__export(adapter_exports, {
|
|
22
|
+
ItemRuleAdapter: () => ItemRuleAdapter,
|
|
23
|
+
default: () => adapter_default
|
|
5
24
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
class ItemRuleAdapter {
|
|
15
|
-
name = 'ItemRuleAdapter';
|
|
16
|
-
version = '1.0.0';
|
|
25
|
+
module.exports = __toCommonJS(adapter_exports);
|
|
26
|
+
var import_type = require("./type");
|
|
27
|
+
var ItemRuleAdapter = class {
|
|
28
|
+
constructor() {
|
|
29
|
+
this.name = "ItemRuleAdapter";
|
|
30
|
+
this.version = "1.0.0";
|
|
31
|
+
}
|
|
17
32
|
prepareContext(businessData) {
|
|
18
|
-
const {
|
|
19
|
-
pax,
|
|
20
|
-
cartItems,
|
|
21
|
-
serviceType,
|
|
22
|
-
submissionIndex,
|
|
23
|
-
custom
|
|
24
|
-
} = businessData;
|
|
33
|
+
const { pax, cartItems, serviceType, submissionIndex, custom } = businessData;
|
|
25
34
|
return {
|
|
26
35
|
entities: {
|
|
27
36
|
cartItems,
|
|
@@ -29,7 +38,7 @@ class ItemRuleAdapter {
|
|
|
29
38
|
pax
|
|
30
39
|
},
|
|
31
40
|
attributes: {
|
|
32
|
-
serviceType: serviceType ||
|
|
41
|
+
serviceType: serviceType || "",
|
|
33
42
|
totalPax: pax.total,
|
|
34
43
|
adultPax: pax.adult,
|
|
35
44
|
childPax: pax.child,
|
|
@@ -47,61 +56,47 @@ class ItemRuleAdapter {
|
|
|
47
56
|
const quantityChecks = [];
|
|
48
57
|
const prefillItems = [];
|
|
49
58
|
if (!result.applicable || !businessData) {
|
|
50
|
-
return {
|
|
51
|
-
quantityChecks,
|
|
52
|
-
prefillItems
|
|
53
|
-
};
|
|
59
|
+
return { quantityChecks, prefillItems };
|
|
54
60
|
}
|
|
55
61
|
for (const action of result.matchedActions) {
|
|
56
|
-
if (action.type ===
|
|
62
|
+
if (action.type === import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK) {
|
|
57
63
|
const checkResult = this.processQuantityCheck(action, businessData);
|
|
58
64
|
if (checkResult) {
|
|
59
65
|
quantityChecks.push(checkResult);
|
|
60
66
|
}
|
|
61
|
-
} else if (action.type ===
|
|
67
|
+
} else if (action.type === import_type.ITEM_RULE_ACTION_TYPES.PREFILL_CART) {
|
|
62
68
|
const items = this.processPrefillCart(action, businessData);
|
|
63
69
|
prefillItems.push(...items);
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
|
-
return {
|
|
67
|
-
quantityChecks,
|
|
68
|
-
prefillItems
|
|
69
|
-
};
|
|
72
|
+
return { quantityChecks, prefillItems };
|
|
70
73
|
}
|
|
71
74
|
formatConfig(result, businessData) {
|
|
72
|
-
return {
|
|
73
|
-
result,
|
|
74
|
-
businessData
|
|
75
|
-
};
|
|
75
|
+
return { result, businessData };
|
|
76
76
|
}
|
|
77
|
-
|
|
78
77
|
// ============================================
|
|
79
78
|
// Quantity Check 处理
|
|
80
79
|
// ============================================
|
|
81
|
-
|
|
82
80
|
processQuantityCheck(action, businessData) {
|
|
83
81
|
const config = action.config;
|
|
84
|
-
if (!config)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
quantityRules,
|
|
88
|
-
targetType,
|
|
89
|
-
targets,
|
|
90
|
-
validationMessage
|
|
91
|
-
} = config;
|
|
82
|
+
if (!config)
|
|
83
|
+
return null;
|
|
84
|
+
const { scope, quantityRules, targetType, targets, validationMessage } = config;
|
|
92
85
|
if (!this.shouldEvaluateForScope(scope, businessData.submissionIndex ?? 0)) {
|
|
93
86
|
return null;
|
|
94
87
|
}
|
|
95
|
-
const actualQuantity = this.calculateActualQuantity(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
const actualQuantity = this.calculateActualQuantity(
|
|
89
|
+
targets,
|
|
90
|
+
scope,
|
|
91
|
+
businessData
|
|
92
|
+
);
|
|
93
|
+
const { passed, failedRules, requiredMin, requiredMax, requiredExact, mustInclude } = this.evaluateQuantityRules(quantityRules, actualQuantity, businessData);
|
|
94
|
+
const message = this.formatValidationMessage(
|
|
95
|
+
validationMessage,
|
|
99
96
|
requiredMin,
|
|
100
97
|
requiredMax,
|
|
101
|
-
requiredExact
|
|
102
|
-
|
|
103
|
-
} = this.evaluateQuantityRules(quantityRules, actualQuantity, businessData);
|
|
104
|
-
const message = this.formatValidationMessage(validationMessage, requiredMin, requiredMax, requiredExact);
|
|
98
|
+
requiredExact
|
|
99
|
+
);
|
|
105
100
|
return {
|
|
106
101
|
ruleId: action.id,
|
|
107
102
|
passed,
|
|
@@ -114,44 +109,42 @@ class ItemRuleAdapter {
|
|
|
114
109
|
mustInclude,
|
|
115
110
|
validationMessage: message,
|
|
116
111
|
scope,
|
|
117
|
-
failedRules: passed ?
|
|
112
|
+
failedRules: passed ? void 0 : failedRules
|
|
118
113
|
};
|
|
119
114
|
}
|
|
120
|
-
|
|
121
115
|
/**
|
|
122
116
|
* 根据 scope 判断当前提交是否需要评估此规则
|
|
123
117
|
*/
|
|
124
118
|
shouldEvaluateForScope(scope, submissionIndex) {
|
|
125
119
|
switch (scope) {
|
|
126
|
-
case
|
|
120
|
+
case "each_submission":
|
|
127
121
|
return true;
|
|
128
|
-
case
|
|
122
|
+
case "first_submission_only":
|
|
129
123
|
return submissionIndex === 0;
|
|
130
|
-
case
|
|
124
|
+
case "subsequent_only":
|
|
131
125
|
return submissionIndex > 0;
|
|
132
|
-
case
|
|
126
|
+
case "cumulative":
|
|
133
127
|
return true;
|
|
134
128
|
default:
|
|
135
129
|
return true;
|
|
136
130
|
}
|
|
137
131
|
}
|
|
138
|
-
|
|
139
132
|
/**
|
|
140
133
|
* 计算目标商品在购物车中的实际数量
|
|
141
134
|
*
|
|
142
135
|
* cumulative scope 时还会加上历史订单数量。
|
|
143
136
|
*/
|
|
144
137
|
calculateActualQuantity(targets, scope, businessData) {
|
|
145
|
-
const targetIds = new Set(targets.map(t => t.product_id));
|
|
138
|
+
const targetIds = new Set(targets.map((t) => t.product_id));
|
|
146
139
|
let quantity = 0;
|
|
147
|
-
const countFromItems = items => {
|
|
140
|
+
const countFromItems = (items) => {
|
|
148
141
|
for (const item of items) {
|
|
149
142
|
if (targetIds.has(item.product_id)) {
|
|
150
143
|
quantity += item.quantity;
|
|
151
144
|
}
|
|
152
145
|
}
|
|
153
146
|
};
|
|
154
|
-
if (scope ===
|
|
147
|
+
if (scope === "cumulative") {
|
|
155
148
|
if (businessData.historicalItems) {
|
|
156
149
|
countFromItems(businessData.historicalItems);
|
|
157
150
|
}
|
|
@@ -173,42 +166,38 @@ class ItemRuleAdapter {
|
|
|
173
166
|
for (const rule of rules) {
|
|
174
167
|
const resolvedValue = this.resolveQuantityValue(rule, businessData);
|
|
175
168
|
switch (rule.comparison) {
|
|
176
|
-
case
|
|
177
|
-
{
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
169
|
+
case "minimum": {
|
|
170
|
+
if (requiredMin === void 0 || resolvedValue > requiredMin) {
|
|
171
|
+
requiredMin = resolvedValue;
|
|
172
|
+
}
|
|
173
|
+
if (actualQuantity < resolvedValue) {
|
|
174
|
+
failedRules.push(rule);
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
case "maximum": {
|
|
179
|
+
if (requiredMax === void 0 || resolvedValue < requiredMax) {
|
|
180
|
+
requiredMax = resolvedValue;
|
|
185
181
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (requiredMax === undefined || resolvedValue < requiredMax) {
|
|
189
|
-
requiredMax = resolvedValue;
|
|
190
|
-
}
|
|
191
|
-
if (actualQuantity > resolvedValue) {
|
|
192
|
-
failedRules.push(rule);
|
|
193
|
-
}
|
|
194
|
-
break;
|
|
182
|
+
if (actualQuantity > resolvedValue) {
|
|
183
|
+
failedRules.push(rule);
|
|
195
184
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
break;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case "exact": {
|
|
188
|
+
requiredExact = resolvedValue;
|
|
189
|
+
if (actualQuantity !== resolvedValue) {
|
|
190
|
+
failedRules.push(rule);
|
|
203
191
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
break;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case "must_include": {
|
|
195
|
+
mustInclude = true;
|
|
196
|
+
if (actualQuantity < 1) {
|
|
197
|
+
failedRules.push(rule);
|
|
211
198
|
}
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
212
201
|
}
|
|
213
202
|
}
|
|
214
203
|
return {
|
|
@@ -220,39 +209,36 @@ class ItemRuleAdapter {
|
|
|
220
209
|
mustInclude
|
|
221
210
|
};
|
|
222
211
|
}
|
|
223
|
-
|
|
224
212
|
/**
|
|
225
213
|
* 根据 source 解析出数量规则的实际数值
|
|
226
214
|
*/
|
|
227
215
|
resolveQuantityValue(rule, businessData) {
|
|
228
216
|
switch (rule.source) {
|
|
229
|
-
case
|
|
217
|
+
case "total_pax":
|
|
230
218
|
return businessData.pax.total;
|
|
231
|
-
case
|
|
219
|
+
case "adult_pax":
|
|
232
220
|
return businessData.pax.adult;
|
|
233
|
-
case
|
|
221
|
+
case "fixed":
|
|
234
222
|
return rule.value ?? 0;
|
|
235
223
|
default:
|
|
236
224
|
return rule.value ?? 0;
|
|
237
225
|
}
|
|
238
226
|
}
|
|
239
|
-
|
|
240
227
|
/**
|
|
241
228
|
* 格式化校验提示语,替换 {min} {max} 占位符
|
|
242
229
|
*/
|
|
243
230
|
formatValidationMessage(template, min, max, exact, locale) {
|
|
244
|
-
if (!template)
|
|
245
|
-
|
|
246
|
-
text =
|
|
247
|
-
text = text.replace(/\{
|
|
248
|
-
text = text.replace(/\{
|
|
231
|
+
if (!template)
|
|
232
|
+
return void 0;
|
|
233
|
+
let text = typeof template === "string" ? template : template[locale || "en"] || Object.values(template)[0] || "";
|
|
234
|
+
text = text.replace(/\{min\}/g, String(min ?? ""));
|
|
235
|
+
text = text.replace(/\{max\}/g, String(max ?? ""));
|
|
236
|
+
text = text.replace(/\{exact\}/g, String(exact ?? ""));
|
|
249
237
|
return text;
|
|
250
238
|
}
|
|
251
|
-
|
|
252
239
|
// ============================================
|
|
253
240
|
// Quantity Limit 提取(仅读取配置,不做校验)
|
|
254
241
|
// ============================================
|
|
255
|
-
|
|
256
242
|
/**
|
|
257
243
|
* 从单个 QUANTITY_CHECK action 中提取数量限制配置。
|
|
258
244
|
*
|
|
@@ -262,14 +248,9 @@ class ItemRuleAdapter {
|
|
|
262
248
|
*/
|
|
263
249
|
extractQuantityLimits(action, businessData) {
|
|
264
250
|
const config = action.config;
|
|
265
|
-
if (!config)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
quantityRules,
|
|
269
|
-
targetType,
|
|
270
|
-
targets,
|
|
271
|
-
validationMessage
|
|
272
|
-
} = config;
|
|
251
|
+
if (!config)
|
|
252
|
+
return null;
|
|
253
|
+
const { scope, quantityRules, targetType, targets, validationMessage } = config;
|
|
273
254
|
if (!this.shouldEvaluateForScope(scope, businessData.submissionIndex ?? 0)) {
|
|
274
255
|
return null;
|
|
275
256
|
}
|
|
@@ -280,34 +261,40 @@ class ItemRuleAdapter {
|
|
|
280
261
|
for (const rule of quantityRules) {
|
|
281
262
|
const resolvedValue = this.resolveQuantityValue(rule, businessData);
|
|
282
263
|
switch (rule.comparison) {
|
|
283
|
-
case
|
|
284
|
-
{
|
|
285
|
-
|
|
286
|
-
requiredMin = resolvedValue;
|
|
287
|
-
}
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
case 'maximum':
|
|
291
|
-
{
|
|
292
|
-
if (requiredMax === undefined || resolvedValue < requiredMax) {
|
|
293
|
-
requiredMax = resolvedValue;
|
|
294
|
-
}
|
|
295
|
-
break;
|
|
264
|
+
case "minimum": {
|
|
265
|
+
if (requiredMin === void 0 || resolvedValue > requiredMin) {
|
|
266
|
+
requiredMin = resolvedValue;
|
|
296
267
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
case 'must_include':
|
|
303
|
-
{
|
|
304
|
-
mustInclude = true;
|
|
305
|
-
break;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
case "maximum": {
|
|
271
|
+
if (requiredMax === void 0 || resolvedValue < requiredMax) {
|
|
272
|
+
requiredMax = resolvedValue;
|
|
306
273
|
}
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
case "exact": {
|
|
277
|
+
requiredExact = resolvedValue;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
case "must_include": {
|
|
281
|
+
mustInclude = true;
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
307
284
|
}
|
|
308
285
|
}
|
|
309
|
-
const remainingMax = this.calculateRemainingMax(
|
|
310
|
-
|
|
286
|
+
const remainingMax = this.calculateRemainingMax(
|
|
287
|
+
scope,
|
|
288
|
+
requiredMax,
|
|
289
|
+
targets,
|
|
290
|
+
businessData
|
|
291
|
+
);
|
|
292
|
+
const formattedValidationMessage = this.formatValidationMessage(
|
|
293
|
+
validationMessage,
|
|
294
|
+
requiredMin,
|
|
295
|
+
requiredMax,
|
|
296
|
+
requiredExact
|
|
297
|
+
);
|
|
311
298
|
return {
|
|
312
299
|
ruleId: action.id,
|
|
313
300
|
targetType,
|
|
@@ -322,7 +309,6 @@ class ItemRuleAdapter {
|
|
|
322
309
|
rawValidationMessage: validationMessage
|
|
323
310
|
};
|
|
324
311
|
}
|
|
325
|
-
|
|
326
312
|
/**
|
|
327
313
|
* 计算当前提交剩余可选的最大数量。
|
|
328
314
|
*
|
|
@@ -331,14 +317,14 @@ class ItemRuleAdapter {
|
|
|
331
317
|
* 其余场景返回 undefined,保持向后兼容。
|
|
332
318
|
*/
|
|
333
319
|
calculateRemainingMax(scope, requiredMax, targets, businessData) {
|
|
334
|
-
if (scope !==
|
|
335
|
-
return
|
|
320
|
+
if (scope !== "cumulative" || typeof requiredMax !== "number") {
|
|
321
|
+
return void 0;
|
|
336
322
|
}
|
|
337
323
|
const historicalItems = businessData.historicalItems;
|
|
338
|
-
if (!historicalItems
|
|
324
|
+
if (!(historicalItems == null ? void 0 : historicalItems.length)) {
|
|
339
325
|
return Math.max(0, requiredMax);
|
|
340
326
|
}
|
|
341
|
-
const targetIds = new Set(targets.map(t => t.product_id));
|
|
327
|
+
const targetIds = new Set(targets.map((t) => t.product_id));
|
|
342
328
|
let historicalQty = 0;
|
|
343
329
|
for (const item of historicalItems) {
|
|
344
330
|
if (targetIds.has(item.product_id)) {
|
|
@@ -347,18 +333,18 @@ class ItemRuleAdapter {
|
|
|
347
333
|
}
|
|
348
334
|
return Math.max(0, requiredMax - historicalQty);
|
|
349
335
|
}
|
|
350
|
-
|
|
351
336
|
// ============================================
|
|
352
337
|
// Prefill Cart 处理
|
|
353
338
|
// ============================================
|
|
354
|
-
|
|
355
339
|
processPrefillCart(action, businessData) {
|
|
356
340
|
const config = action.config;
|
|
357
|
-
if (!config
|
|
341
|
+
if (!(config == null ? void 0 : config.products))
|
|
342
|
+
return [];
|
|
358
343
|
const results = [];
|
|
359
344
|
for (const prefillProduct of config.products) {
|
|
360
345
|
const quantity = this.resolvePrefillQuantity(prefillProduct.quantityFrom, prefillProduct.quantity, businessData);
|
|
361
|
-
if (quantity <= 0)
|
|
346
|
+
if (quantity <= 0)
|
|
347
|
+
continue;
|
|
362
348
|
results.push({
|
|
363
349
|
ruleId: action.id,
|
|
364
350
|
product_id: prefillProduct.product_id,
|
|
@@ -368,22 +354,24 @@ class ItemRuleAdapter {
|
|
|
368
354
|
}
|
|
369
355
|
return results;
|
|
370
356
|
}
|
|
371
|
-
|
|
372
357
|
/**
|
|
373
358
|
* 根据 quantityFrom 计算预填数量
|
|
374
359
|
*/
|
|
375
360
|
resolvePrefillQuantity(quantityFrom, fixedValue, businessData) {
|
|
376
361
|
switch (quantityFrom) {
|
|
377
|
-
case
|
|
362
|
+
case "total_pax":
|
|
378
363
|
return businessData.pax.total;
|
|
379
|
-
case
|
|
364
|
+
case "adult_pax":
|
|
380
365
|
return businessData.pax.adult;
|
|
381
|
-
case
|
|
366
|
+
case "fixed":
|
|
382
367
|
return fixedValue ?? 0;
|
|
383
368
|
default:
|
|
384
369
|
return fixedValue ?? 0;
|
|
385
370
|
}
|
|
386
371
|
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
|
|
372
|
+
};
|
|
373
|
+
var adapter_default = ItemRuleAdapter;
|
|
374
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
375
|
+
0 && (module.exports = {
|
|
376
|
+
ItemRuleAdapter
|
|
377
|
+
});
|
|
@@ -1,46 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
|
|
19
|
+
// src/model/strategy/adapter/itemRule/evaluator.ts
|
|
20
|
+
var evaluator_exports = {};
|
|
21
|
+
__export(evaluator_exports, {
|
|
22
|
+
ItemRuleEvaluator: () => ItemRuleEvaluator
|
|
5
23
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
* ItemRule 评估器
|
|
12
|
-
*
|
|
13
|
-
* 组合 StrategyEngine + ItemRuleAdapter,提供面向业务的高层 API。
|
|
14
|
-
* 支持批量评估多条 item_rule 策略配置,聚合数量校验和预填购物车结果。
|
|
15
|
-
*/
|
|
16
|
-
class ItemRuleEvaluator {
|
|
17
|
-
engine;
|
|
18
|
-
adapter;
|
|
19
|
-
strategyConfigs = [];
|
|
24
|
+
module.exports = __toCommonJS(evaluator_exports);
|
|
25
|
+
var import_engine = require("../../engine");
|
|
26
|
+
var import_adapter = require("./adapter");
|
|
27
|
+
var import_type = require("./type");
|
|
28
|
+
var ItemRuleEvaluator = class {
|
|
20
29
|
constructor() {
|
|
21
|
-
this.
|
|
30
|
+
this.strategyConfigs = [];
|
|
31
|
+
this.engine = new import_engine.StrategyEngine({
|
|
22
32
|
debug: false,
|
|
23
33
|
enableTrace: false
|
|
24
34
|
});
|
|
25
|
-
this.adapter = new
|
|
35
|
+
this.adapter = new import_adapter.ItemRuleAdapter();
|
|
26
36
|
}
|
|
27
|
-
|
|
28
37
|
/**
|
|
29
38
|
* 设置策略配置列表
|
|
30
39
|
* 自动过滤 metadata.type === 'item_rule' 的配置
|
|
31
40
|
*/
|
|
32
41
|
setStrategyConfigs(configs) {
|
|
33
|
-
this.strategyConfigs = configs.filter(
|
|
42
|
+
this.strategyConfigs = configs.filter(
|
|
43
|
+
(c) => c.metadata.type === "item_rule"
|
|
44
|
+
);
|
|
34
45
|
}
|
|
35
46
|
getStrategyConfigs() {
|
|
36
47
|
return this.strategyConfigs;
|
|
37
48
|
}
|
|
38
|
-
|
|
39
49
|
/**
|
|
40
50
|
* 完整评估:数量校验 + 预填购物车
|
|
41
51
|
*/
|
|
42
52
|
evaluate(businessData) {
|
|
43
|
-
const configs = businessData.strategyConfigs ? businessData.strategyConfigs.filter(c => c.metadata.type ===
|
|
53
|
+
const configs = businessData.strategyConfigs ? businessData.strategyConfigs.filter((c) => c.metadata.type === "item_rule") : this.strategyConfigs;
|
|
44
54
|
const allQuantityChecks = [];
|
|
45
55
|
const allPrefillItems = [];
|
|
46
56
|
const rawResults = [];
|
|
@@ -48,14 +58,14 @@ class ItemRuleEvaluator {
|
|
|
48
58
|
for (const config of configs) {
|
|
49
59
|
const evalResult = this.engine.evaluate(config, context);
|
|
50
60
|
rawResults.push(evalResult);
|
|
51
|
-
const {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
const { quantityChecks, prefillItems } = this.adapter.transformResult(
|
|
62
|
+
evalResult,
|
|
63
|
+
businessData
|
|
64
|
+
);
|
|
55
65
|
allQuantityChecks.push(...quantityChecks);
|
|
56
66
|
allPrefillItems.push(...prefillItems);
|
|
57
67
|
}
|
|
58
|
-
const failedChecks = allQuantityChecks.filter(c => !c.passed);
|
|
68
|
+
const failedChecks = allQuantityChecks.filter((c) => !c.passed);
|
|
59
69
|
return {
|
|
60
70
|
quantityChecks: allQuantityChecks,
|
|
61
71
|
prefillItems: allPrefillItems,
|
|
@@ -64,7 +74,6 @@ class ItemRuleEvaluator {
|
|
|
64
74
|
rawResults
|
|
65
75
|
};
|
|
66
76
|
}
|
|
67
|
-
|
|
68
77
|
/**
|
|
69
78
|
* 获取当前配置中各商品的数量限制
|
|
70
79
|
*
|
|
@@ -73,14 +82,16 @@ class ItemRuleEvaluator {
|
|
|
73
82
|
* 会评估条件是否满足、根据 scope + submissionIndex 过滤。
|
|
74
83
|
*/
|
|
75
84
|
getQuantityLimits(businessData) {
|
|
76
|
-
const configs = businessData.strategyConfigs ? businessData.strategyConfigs.filter(c => c.metadata.type ===
|
|
85
|
+
const configs = businessData.strategyConfigs ? businessData.strategyConfigs.filter((c) => c.metadata.type === "item_rule") : this.strategyConfigs;
|
|
77
86
|
const results = [];
|
|
78
87
|
const context = this.adapter.prepareContext(businessData);
|
|
79
88
|
for (const config of configs) {
|
|
80
89
|
const evalResult = this.engine.evaluate(config, context);
|
|
81
|
-
if (!evalResult.applicable)
|
|
90
|
+
if (!evalResult.applicable)
|
|
91
|
+
continue;
|
|
82
92
|
for (const action of evalResult.matchedActions) {
|
|
83
|
-
if (action.type !==
|
|
93
|
+
if (action.type !== import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK)
|
|
94
|
+
continue;
|
|
84
95
|
const limit = this.adapter.extractQuantityLimits(action, businessData);
|
|
85
96
|
if (limit) {
|
|
86
97
|
results.push(limit);
|
|
@@ -89,7 +100,6 @@ class ItemRuleEvaluator {
|
|
|
89
100
|
}
|
|
90
101
|
return results;
|
|
91
102
|
}
|
|
92
|
-
|
|
93
103
|
/**
|
|
94
104
|
* 便捷方法:仅做数量校验,返回是否全部通过及失败详情
|
|
95
105
|
*/
|
|
@@ -100,7 +110,6 @@ class ItemRuleEvaluator {
|
|
|
100
110
|
failures: result.failedChecks
|
|
101
111
|
};
|
|
102
112
|
}
|
|
103
|
-
|
|
104
113
|
/**
|
|
105
114
|
* 便捷方法:仅获取需要预填到购物车的商品
|
|
106
115
|
*/
|
|
@@ -108,5 +117,8 @@ class ItemRuleEvaluator {
|
|
|
108
117
|
const result = this.evaluate(businessData);
|
|
109
118
|
return result.prefillItems;
|
|
110
119
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
120
|
+
};
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
ItemRuleEvaluator
|
|
124
|
+
});
|