@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,24 +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/dataVariant/evaluator.ts
|
|
20
|
+
var evaluator_exports = {};
|
|
21
|
+
__export(evaluator_exports, {
|
|
22
|
+
DataVariantEvaluator: () => DataVariantEvaluator,
|
|
23
|
+
default: () => evaluator_default
|
|
5
24
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
* Data Variant 评估器。
|
|
12
|
-
*
|
|
13
|
-
* 当前阶段只提供策略模型能力和示例验证,不接入 ProductList 业务链路。
|
|
14
|
-
*/
|
|
15
|
-
class DataVariantEvaluator {
|
|
16
|
-
adapter;
|
|
17
|
-
strategyConfigs = [];
|
|
25
|
+
module.exports = __toCommonJS(evaluator_exports);
|
|
26
|
+
var import_engine = require("../../engine");
|
|
27
|
+
var import_getDateIsInSchedule = require("../../../../modules/Schedule/getDateIsInSchedule");
|
|
28
|
+
var import_adapter = require("./adapter");
|
|
29
|
+
var DataVariantEvaluator = class {
|
|
18
30
|
constructor() {
|
|
19
|
-
this.
|
|
31
|
+
this.strategyConfigs = [];
|
|
32
|
+
this.adapter = new import_adapter.DataVariantAdapter();
|
|
20
33
|
}
|
|
21
|
-
|
|
22
34
|
/**
|
|
23
35
|
* 设置策略配置列表,仅保留 metadata.type === 'data_variant' 的策略。
|
|
24
36
|
*/
|
|
@@ -28,7 +40,6 @@ class DataVariantEvaluator {
|
|
|
28
40
|
getStrategyConfigs() {
|
|
29
41
|
return this.strategyConfigs;
|
|
30
42
|
}
|
|
31
|
-
|
|
32
43
|
/**
|
|
33
44
|
* 批量解析商品 Data Variant。
|
|
34
45
|
*
|
|
@@ -37,15 +48,28 @@ class DataVariantEvaluator {
|
|
|
37
48
|
resolveProducts(businessData) {
|
|
38
49
|
const strategyConfigs = businessData.strategyConfigs ? this.normalizeStrategyConfigs(businessData.strategyConfigs) : this.strategyConfigs;
|
|
39
50
|
const menuScopeMap = this.buildMenuScopeMap(businessData.menuList || []);
|
|
40
|
-
const scheduleTimePoints = this.buildScheduleTimePoints(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} = this.buildGlobalEffectiveRuleMap(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
const scheduleTimePoints = this.buildScheduleTimePoints(
|
|
52
|
+
strategyConfigs,
|
|
53
|
+
businessData.scheduleList || []
|
|
54
|
+
);
|
|
55
|
+
const { globalEffectiveRuleMap, rawResults } = this.buildGlobalEffectiveRuleMap(
|
|
56
|
+
strategyConfigs,
|
|
57
|
+
businessData,
|
|
58
|
+
menuScopeMap
|
|
59
|
+
);
|
|
60
|
+
const products = businessData.products.map((product) => {
|
|
61
|
+
const resolvedProduct = this.resolveProduct(
|
|
62
|
+
product,
|
|
63
|
+
businessData,
|
|
64
|
+
globalEffectiveRuleMap,
|
|
65
|
+
menuScopeMap
|
|
66
|
+
);
|
|
67
|
+
return this.resolveProductBundleItems(
|
|
68
|
+
resolvedProduct,
|
|
69
|
+
businessData,
|
|
70
|
+
globalEffectiveRuleMap,
|
|
71
|
+
menuScopeMap
|
|
72
|
+
);
|
|
49
73
|
});
|
|
50
74
|
return {
|
|
51
75
|
products,
|
|
@@ -55,51 +79,55 @@ class DataVariantEvaluator {
|
|
|
55
79
|
rawResults
|
|
56
80
|
};
|
|
57
81
|
}
|
|
58
|
-
|
|
59
82
|
/**
|
|
60
83
|
* 根据 operator/field 判断条件是否依赖当前商品。
|
|
61
84
|
*/
|
|
62
85
|
getConditionScope(rule) {
|
|
63
|
-
if (rule.operator ===
|
|
64
|
-
|
|
65
|
-
if (rule.operator ===
|
|
66
|
-
|
|
67
|
-
|
|
86
|
+
if (rule.operator === "schedule_match")
|
|
87
|
+
return "global";
|
|
88
|
+
if (rule.operator === "menu_match")
|
|
89
|
+
return "product";
|
|
90
|
+
if (rule.operator === "product_match")
|
|
91
|
+
return "product";
|
|
92
|
+
if (rule.field === "product" || rule.field === "productIdAndVariantId") {
|
|
93
|
+
return "product";
|
|
68
94
|
}
|
|
69
|
-
return
|
|
95
|
+
return "global";
|
|
70
96
|
}
|
|
71
|
-
|
|
72
97
|
/**
|
|
73
98
|
* 将餐牌 partyroom_package 预构建为 Map/Set 索引。
|
|
74
99
|
*/
|
|
75
100
|
buildMenuScopeMap(menuList) {
|
|
76
|
-
const map = new Map();
|
|
101
|
+
const map = /* @__PURE__ */ new Map();
|
|
77
102
|
for (const menu of menuList) {
|
|
78
|
-
if (menu
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
if ((menu == null ? void 0 : menu.status) && menu.status !== "valid")
|
|
104
|
+
continue;
|
|
105
|
+
const menuId = this.toNumber(menu == null ? void 0 : menu.form_record_id);
|
|
106
|
+
if (!menuId)
|
|
107
|
+
continue;
|
|
81
108
|
const scope = {
|
|
82
109
|
isAllProducts: false,
|
|
83
|
-
collectionIds: new Set(),
|
|
84
|
-
productKeys: new Set(),
|
|
85
|
-
productAllVariantIds: new Set()
|
|
110
|
+
collectionIds: /* @__PURE__ */ new Set(),
|
|
111
|
+
productKeys: /* @__PURE__ */ new Set(),
|
|
112
|
+
productAllVariantIds: /* @__PURE__ */ new Set()
|
|
86
113
|
};
|
|
87
114
|
const packageConfig = menu.partyroom_package;
|
|
88
|
-
const products = Array.isArray(packageConfig
|
|
89
|
-
if (packageConfig
|
|
115
|
+
const products = Array.isArray(packageConfig == null ? void 0 : packageConfig.products) ? packageConfig.products : [];
|
|
116
|
+
if ((packageConfig == null ? void 0 : packageConfig.type) === "product_all") {
|
|
90
117
|
scope.isAllProducts = true;
|
|
91
|
-
} else if (packageConfig
|
|
118
|
+
} else if ((packageConfig == null ? void 0 : packageConfig.type) === "product_collection") {
|
|
92
119
|
for (const item of products) {
|
|
93
120
|
const collectionId = this.toNumber(item.product_collection_id);
|
|
94
121
|
if (collectionId) {
|
|
95
122
|
scope.collectionIds.add(collectionId);
|
|
96
123
|
}
|
|
97
124
|
}
|
|
98
|
-
} else if (packageConfig
|
|
125
|
+
} else if ((packageConfig == null ? void 0 : packageConfig.type) === "products") {
|
|
99
126
|
for (const item of products) {
|
|
100
127
|
const productId = this.toNumber(item.product_id);
|
|
101
128
|
const variantId = this.toNumber(item.product_variant_id);
|
|
102
|
-
if (!productId)
|
|
129
|
+
if (!productId)
|
|
130
|
+
continue;
|
|
103
131
|
if (variantId === 0) {
|
|
104
132
|
scope.productAllVariantIds.add(productId);
|
|
105
133
|
} else {
|
|
@@ -111,7 +139,6 @@ class DataVariantEvaluator {
|
|
|
111
139
|
}
|
|
112
140
|
return map;
|
|
113
141
|
}
|
|
114
|
-
|
|
115
142
|
/**
|
|
116
143
|
* 从当前策略中所有 schedule_match.value 绑定的 schedule_id 提取时间点。
|
|
117
144
|
*
|
|
@@ -119,25 +146,27 @@ class DataVariantEvaluator {
|
|
|
119
146
|
*/
|
|
120
147
|
buildScheduleTimePoints(strategyConfigs, scheduleList) {
|
|
121
148
|
const scheduleIds = this.collectScheduleIdsFromStrategies(strategyConfigs);
|
|
122
|
-
if (!scheduleIds.length || !scheduleList.length)
|
|
149
|
+
if (!scheduleIds.length || !scheduleList.length)
|
|
150
|
+
return [];
|
|
123
151
|
const scheduleIdSet = new Set(scheduleIds);
|
|
124
|
-
const matchedSchedules = scheduleList.filter(
|
|
152
|
+
const matchedSchedules = scheduleList.filter(
|
|
153
|
+
(schedule) => scheduleIdSet.has(Number(schedule.id))
|
|
154
|
+
);
|
|
125
155
|
return this.extractTimePointsFromSchedules(matchedSchedules);
|
|
126
156
|
}
|
|
127
157
|
buildGlobalEffectiveRuleMap(strategyConfigs, businessData, menuScopeMap) {
|
|
128
|
-
const globalEffectiveRuleMap = new Map();
|
|
158
|
+
const globalEffectiveRuleMap = /* @__PURE__ */ new Map();
|
|
129
159
|
const rawResults = [];
|
|
130
160
|
const engine = this.createEngine(businessData, menuScopeMap);
|
|
131
161
|
const context = this.adapter.prepareGlobalContext(businessData);
|
|
132
162
|
for (const config of strategyConfigs) {
|
|
133
|
-
if (!this.isStrategyActive(config))
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
productRules
|
|
137
|
-
} = this.splitStrategyConfig(config);
|
|
163
|
+
if (!this.isStrategyActive(config))
|
|
164
|
+
continue;
|
|
165
|
+
const { globalConfig, productRules } = this.splitStrategyConfig(config);
|
|
138
166
|
const result = engine.evaluate(globalConfig, context);
|
|
139
167
|
rawResults.push(result);
|
|
140
|
-
if (!result.applicable)
|
|
168
|
+
if (!result.applicable)
|
|
169
|
+
continue;
|
|
141
170
|
globalEffectiveRuleMap.set(String(config.metadata.id), {
|
|
142
171
|
ruleId: String(config.metadata.id),
|
|
143
172
|
priority: this.getStrategyPriority(config),
|
|
@@ -146,18 +175,19 @@ class DataVariantEvaluator {
|
|
|
146
175
|
globalResult: result
|
|
147
176
|
});
|
|
148
177
|
}
|
|
149
|
-
return {
|
|
150
|
-
globalEffectiveRuleMap,
|
|
151
|
-
rawResults
|
|
152
|
-
};
|
|
178
|
+
return { globalEffectiveRuleMap, rawResults };
|
|
153
179
|
}
|
|
154
180
|
resolveProduct(product, businessData, globalEffectiveRuleMap, menuScopeMap) {
|
|
155
181
|
const dataVariants = this.getProductDataVariants(product);
|
|
156
|
-
if (!dataVariants.length)
|
|
182
|
+
if (!dataVariants.length)
|
|
183
|
+
return product;
|
|
157
184
|
const matchedVariants = [];
|
|
158
185
|
for (const variant of dataVariants) {
|
|
159
|
-
const rule = globalEffectiveRuleMap.get(
|
|
160
|
-
|
|
186
|
+
const rule = globalEffectiveRuleMap.get(
|
|
187
|
+
String(variant.data_variant_rule_id)
|
|
188
|
+
);
|
|
189
|
+
if (!rule)
|
|
190
|
+
continue;
|
|
161
191
|
if (!this.evaluateProductRules(rule, product, businessData, menuScopeMap)) {
|
|
162
192
|
continue;
|
|
163
193
|
}
|
|
@@ -168,10 +198,10 @@ class DataVariantEvaluator {
|
|
|
168
198
|
variant
|
|
169
199
|
});
|
|
170
200
|
}
|
|
171
|
-
if (!matchedVariants.length)
|
|
201
|
+
if (!matchedVariants.length)
|
|
202
|
+
return product;
|
|
172
203
|
return this.mergeMatchedVariants(product, matchedVariants);
|
|
173
204
|
}
|
|
174
|
-
|
|
175
205
|
/**
|
|
176
206
|
* 解析套餐子商品上的 Data Variant 覆盖。
|
|
177
207
|
*
|
|
@@ -182,14 +212,21 @@ class DataVariantEvaluator {
|
|
|
182
212
|
if (!Array.isArray(bundleGroups) || bundleGroups.length === 0) {
|
|
183
213
|
return product;
|
|
184
214
|
}
|
|
185
|
-
const resolvedGroups = bundleGroups.map(group => {
|
|
186
|
-
const bundleItems = group
|
|
215
|
+
const resolvedGroups = bundleGroups.map((group) => {
|
|
216
|
+
const bundleItems = group == null ? void 0 : group.bundle_item;
|
|
187
217
|
if (!Array.isArray(bundleItems) || bundleItems.length === 0) {
|
|
188
218
|
return group;
|
|
189
219
|
}
|
|
190
220
|
return {
|
|
191
221
|
...group,
|
|
192
|
-
bundle_item: bundleItems.map(
|
|
222
|
+
bundle_item: bundleItems.map(
|
|
223
|
+
(item) => this.resolveBundleItem(
|
|
224
|
+
item,
|
|
225
|
+
businessData,
|
|
226
|
+
globalEffectiveRuleMap,
|
|
227
|
+
menuScopeMap
|
|
228
|
+
)
|
|
229
|
+
)
|
|
193
230
|
};
|
|
194
231
|
});
|
|
195
232
|
return {
|
|
@@ -197,7 +234,6 @@ class DataVariantEvaluator {
|
|
|
197
234
|
bundle_group: resolvedGroups
|
|
198
235
|
};
|
|
199
236
|
}
|
|
200
|
-
|
|
201
237
|
/**
|
|
202
238
|
* 将 bundle_item 转为 DataVariantProduct 并评估 data_variants。
|
|
203
239
|
*/
|
|
@@ -206,10 +242,14 @@ class DataVariantEvaluator {
|
|
|
206
242
|
if (!this.getProductDataVariants(bundleProduct).length) {
|
|
207
243
|
return item;
|
|
208
244
|
}
|
|
209
|
-
const resolvedItem = this.resolveProduct(
|
|
245
|
+
const resolvedItem = this.resolveProduct(
|
|
246
|
+
bundleProduct,
|
|
247
|
+
businessData,
|
|
248
|
+
globalEffectiveRuleMap,
|
|
249
|
+
menuScopeMap
|
|
250
|
+
);
|
|
210
251
|
return this.mergeBundleItemResolvedData(item, resolvedItem);
|
|
211
252
|
}
|
|
212
|
-
|
|
213
253
|
/**
|
|
214
254
|
* bundle_item 的商品身份映射:bundle_product_id + bundle_variant_id。
|
|
215
255
|
*/
|
|
@@ -225,20 +265,18 @@ class DataVariantEvaluator {
|
|
|
225
265
|
data_variants: item.data_variants
|
|
226
266
|
};
|
|
227
267
|
}
|
|
228
|
-
|
|
229
268
|
/**
|
|
230
269
|
* 仅回写命中的字段,避免污染 bundle_item 的结构字段。
|
|
231
270
|
*/
|
|
232
271
|
mergeBundleItemResolvedData(originalItem, resolvedItem) {
|
|
272
|
+
var _a;
|
|
233
273
|
const appliedInfo = resolvedItem._dataVariant;
|
|
234
|
-
if (!appliedInfo
|
|
274
|
+
if (!((_a = appliedInfo == null ? void 0 : appliedInfo.appliedFields) == null ? void 0 : _a.length)) {
|
|
235
275
|
return originalItem;
|
|
236
276
|
}
|
|
237
|
-
const result = {
|
|
238
|
-
...originalItem
|
|
239
|
-
};
|
|
277
|
+
const result = { ...originalItem };
|
|
240
278
|
for (const field of appliedInfo.appliedFields) {
|
|
241
|
-
if (resolvedItem[field] !==
|
|
279
|
+
if (resolvedItem[field] !== void 0) {
|
|
242
280
|
result[field] = resolvedItem[field];
|
|
243
281
|
}
|
|
244
282
|
}
|
|
@@ -246,20 +284,20 @@ class DataVariantEvaluator {
|
|
|
246
284
|
return result;
|
|
247
285
|
}
|
|
248
286
|
evaluateProductRules(rule, product, businessData, menuScopeMap) {
|
|
249
|
-
if (!rule.productRules.length)
|
|
287
|
+
if (!rule.productRules.length)
|
|
288
|
+
return true;
|
|
250
289
|
const engine = this.createEngine(businessData, menuScopeMap);
|
|
251
290
|
const context = this.adapter.prepareProductContext(businessData, product);
|
|
252
291
|
const productOnlyConfig = {
|
|
253
292
|
...rule.strategyConfig,
|
|
254
293
|
conditions: {
|
|
255
|
-
operator:
|
|
294
|
+
operator: "and",
|
|
256
295
|
rules: rule.productRules,
|
|
257
296
|
actionIds: rule.strategyConfig.conditions.actionIds || []
|
|
258
297
|
}
|
|
259
298
|
};
|
|
260
299
|
return engine.evaluate(productOnlyConfig, context).applicable;
|
|
261
300
|
}
|
|
262
|
-
|
|
263
301
|
/**
|
|
264
302
|
* 拆分策略条件。
|
|
265
303
|
*
|
|
@@ -269,7 +307,7 @@ class DataVariantEvaluator {
|
|
|
269
307
|
const conditions = config.conditions;
|
|
270
308
|
const globalRules = [];
|
|
271
309
|
const productRules = [];
|
|
272
|
-
if (conditions.operator !==
|
|
310
|
+
if (conditions.operator !== "and") {
|
|
273
311
|
return {
|
|
274
312
|
globalConfig: {
|
|
275
313
|
...config,
|
|
@@ -283,7 +321,7 @@ class DataVariantEvaluator {
|
|
|
283
321
|
productRules.push(...this.flattenConditionRules(rule));
|
|
284
322
|
continue;
|
|
285
323
|
}
|
|
286
|
-
if (this.getConditionScope(rule) ===
|
|
324
|
+
if (this.getConditionScope(rule) === "product") {
|
|
287
325
|
productRules.push(rule);
|
|
288
326
|
} else {
|
|
289
327
|
globalRules.push(rule);
|
|
@@ -293,7 +331,7 @@ class DataVariantEvaluator {
|
|
|
293
331
|
globalConfig: {
|
|
294
332
|
...config,
|
|
295
333
|
conditions: {
|
|
296
|
-
operator:
|
|
334
|
+
operator: "and",
|
|
297
335
|
rules: globalRules,
|
|
298
336
|
actionIds: conditions.actionIds || []
|
|
299
337
|
}
|
|
@@ -303,48 +341,62 @@ class DataVariantEvaluator {
|
|
|
303
341
|
}
|
|
304
342
|
createEngine(businessData, menuScopeMap) {
|
|
305
343
|
const operatorHandlers = {
|
|
306
|
-
schedule_match: (fieldValue, compareValue) => this.evaluateScheduleMatch(
|
|
344
|
+
schedule_match: (fieldValue, compareValue) => this.evaluateScheduleMatch(
|
|
345
|
+
fieldValue,
|
|
346
|
+
compareValue,
|
|
347
|
+
businessData.scheduleList || []
|
|
348
|
+
),
|
|
307
349
|
menu_match: (fieldValue, compareValue) => this.evaluateMenuMatch(fieldValue, compareValue, menuScopeMap),
|
|
308
350
|
array_intersects: (fieldValue, compareValue) => this.evaluateArrayIntersects(fieldValue, compareValue)
|
|
309
351
|
};
|
|
310
|
-
return new
|
|
352
|
+
return new import_engine.StrategyEngine({
|
|
311
353
|
debug: false,
|
|
312
354
|
enableTrace: false,
|
|
313
355
|
operatorHandlers
|
|
314
356
|
});
|
|
315
357
|
}
|
|
316
358
|
evaluateScheduleMatch(fieldValue, compareValue, scheduleList) {
|
|
317
|
-
const scheduleDateTime = String(fieldValue ||
|
|
359
|
+
const scheduleDateTime = String(fieldValue || "");
|
|
318
360
|
const scheduleIds = this.normalizeNumberArray(compareValue);
|
|
319
|
-
if (!scheduleIds.length)
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
361
|
+
if (!scheduleIds.length)
|
|
362
|
+
return true;
|
|
363
|
+
if (!scheduleDateTime || !(scheduleList == null ? void 0 : scheduleList.length))
|
|
364
|
+
return false;
|
|
365
|
+
const matchedSchedules = scheduleList.filter(
|
|
366
|
+
(schedule) => scheduleIds.includes(Number(schedule.id))
|
|
367
|
+
);
|
|
368
|
+
return (0, import_getDateIsInSchedule.getDateIsInSchedule)(scheduleDateTime, matchedSchedules);
|
|
323
369
|
}
|
|
324
370
|
evaluateMenuMatch(fieldValue, compareValue, menuScopeMap) {
|
|
325
371
|
const menuIds = this.normalizeNumberArray(compareValue);
|
|
326
|
-
if (!menuIds.length)
|
|
372
|
+
if (!menuIds.length)
|
|
373
|
+
return true;
|
|
327
374
|
for (const menuId of menuIds) {
|
|
328
375
|
const scope = menuScopeMap.get(menuId);
|
|
329
|
-
if (!scope)
|
|
330
|
-
|
|
376
|
+
if (!scope)
|
|
377
|
+
continue;
|
|
378
|
+
if (this.isProductInMenuScope(fieldValue, scope))
|
|
379
|
+
return true;
|
|
331
380
|
}
|
|
332
381
|
return false;
|
|
333
382
|
}
|
|
334
383
|
evaluateArrayIntersects(fieldValue, compareValue) {
|
|
335
384
|
const fieldValues = this.normalizeComparableArray(fieldValue);
|
|
336
385
|
const compareValues = this.normalizeComparableArray(compareValue);
|
|
337
|
-
if (!fieldValues.length || !compareValues.length)
|
|
386
|
+
if (!fieldValues.length || !compareValues.length)
|
|
387
|
+
return false;
|
|
338
388
|
const compareSet = new Set(compareValues);
|
|
339
|
-
return fieldValues.some(item => compareSet.has(item));
|
|
389
|
+
return fieldValues.some((item) => compareSet.has(item));
|
|
340
390
|
}
|
|
341
391
|
collectScheduleIdsFromStrategies(strategyConfigs) {
|
|
342
|
-
const scheduleIds = new Set();
|
|
392
|
+
const scheduleIds = /* @__PURE__ */ new Set();
|
|
343
393
|
for (const config of strategyConfigs) {
|
|
344
|
-
if (!this.isStrategyActive(config))
|
|
394
|
+
if (!this.isStrategyActive(config))
|
|
395
|
+
continue;
|
|
345
396
|
const rules = this.flattenConditionRules(config.conditions);
|
|
346
397
|
for (const rule of rules) {
|
|
347
|
-
if (rule.operator !==
|
|
398
|
+
if (rule.operator !== "schedule_match")
|
|
399
|
+
continue;
|
|
348
400
|
for (const scheduleId of this.normalizeNumberArray(rule.value)) {
|
|
349
401
|
scheduleIds.add(scheduleId);
|
|
350
402
|
}
|
|
@@ -353,89 +405,95 @@ class DataVariantEvaluator {
|
|
|
353
405
|
return Array.from(scheduleIds);
|
|
354
406
|
}
|
|
355
407
|
extractTimePointsFromSchedules(schedules) {
|
|
356
|
-
const timePoints = new Set();
|
|
408
|
+
const timePoints = /* @__PURE__ */ new Set();
|
|
357
409
|
for (const schedule of schedules) {
|
|
358
410
|
switch (schedule.type) {
|
|
359
|
-
case
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
{
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
this.addRawTimePoint(timePoints, slot.start_time);
|
|
370
|
-
this.addRawTimePoint(timePoints, slot.end_time);
|
|
371
|
-
}
|
|
372
|
-
break;
|
|
411
|
+
case "standard": {
|
|
412
|
+
this.addDateTimePoint(timePoints, schedule.start_time);
|
|
413
|
+
this.addDateTimePoint(timePoints, schedule.end_time);
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
case "time-slots": {
|
|
417
|
+
const slots = Array.isArray(schedule.time_slot) ? schedule.time_slot : [];
|
|
418
|
+
for (const slot of slots) {
|
|
419
|
+
this.addRawTimePoint(timePoints, slot.start_time);
|
|
420
|
+
this.addRawTimePoint(timePoints, slot.end_time);
|
|
373
421
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
break;
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
case "designation": {
|
|
425
|
+
const designations = Array.isArray(schedule.designation) ? schedule.designation : schedule.designation ? [schedule.designation] : [];
|
|
426
|
+
for (const designation of designations) {
|
|
427
|
+
this.addRawTimePoint(timePoints, designation.start_time);
|
|
428
|
+
this.addRawTimePoint(timePoints, designation.end_time);
|
|
382
429
|
}
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
383
432
|
default:
|
|
384
433
|
break;
|
|
385
434
|
}
|
|
386
435
|
}
|
|
387
|
-
return Array.from(timePoints).sort(
|
|
436
|
+
return Array.from(timePoints).sort(
|
|
437
|
+
(a, b) => this.timeToMinutes(a) - this.timeToMinutes(b)
|
|
438
|
+
);
|
|
388
439
|
}
|
|
389
440
|
addDateTimePoint(points, value) {
|
|
390
441
|
const time = this.extractTimeFromDateTime(value);
|
|
391
|
-
if (time)
|
|
442
|
+
if (time)
|
|
443
|
+
points.add(time);
|
|
392
444
|
}
|
|
393
445
|
addRawTimePoint(points, value) {
|
|
394
446
|
const time = this.normalizeTime(value);
|
|
395
|
-
if (time)
|
|
447
|
+
if (time)
|
|
448
|
+
points.add(time);
|
|
396
449
|
}
|
|
397
450
|
extractTimeFromDateTime(value) {
|
|
398
|
-
if (!value)
|
|
451
|
+
if (!value)
|
|
452
|
+
return null;
|
|
399
453
|
const match = value.match(/(\d{1,2}):(\d{2})/);
|
|
400
|
-
if (!match)
|
|
401
|
-
|
|
454
|
+
if (!match)
|
|
455
|
+
return null;
|
|
456
|
+
return `${match[1].padStart(2, "0")}:${match[2]}`;
|
|
402
457
|
}
|
|
403
458
|
normalizeTime(value) {
|
|
404
|
-
if (!value)
|
|
459
|
+
if (!value)
|
|
460
|
+
return null;
|
|
405
461
|
const match = value.match(/^(\d{1,2}):(\d{2})/);
|
|
406
|
-
if (!match)
|
|
407
|
-
|
|
462
|
+
if (!match)
|
|
463
|
+
return null;
|
|
464
|
+
return `${match[1].padStart(2, "0")}:${match[2]}`;
|
|
408
465
|
}
|
|
409
466
|
timeToMinutes(value) {
|
|
410
|
-
const [hour, minute] = value.split(
|
|
411
|
-
if (!Number.isFinite(hour) || !Number.isFinite(minute))
|
|
467
|
+
const [hour, minute] = value.split(":").map((item) => Number(item));
|
|
468
|
+
if (!Number.isFinite(hour) || !Number.isFinite(minute))
|
|
469
|
+
return 0;
|
|
412
470
|
return hour * 60 + minute;
|
|
413
471
|
}
|
|
414
472
|
isProductInMenuScope(product, scope) {
|
|
415
|
-
if (scope.isAllProducts)
|
|
416
|
-
|
|
473
|
+
if (scope.isAllProducts)
|
|
474
|
+
return true;
|
|
475
|
+
if (!product || typeof product !== "object")
|
|
476
|
+
return false;
|
|
417
477
|
const productId = this.toNumber(product.id ?? product.product_id);
|
|
418
478
|
const variantId = this.toNumber(product.product_variant_id);
|
|
419
479
|
const productKey = this.buildProductKey(productId, variantId);
|
|
420
|
-
const collectionIds = Array.isArray(product.collection_ids) ? product.collection_ids.map(id => this.toNumber(id)) : [];
|
|
421
|
-
return collectionIds.some(id => scope.collectionIds.has(id)) || scope.productKeys.has(productKey) || scope.productAllVariantIds.has(productId);
|
|
480
|
+
const collectionIds = Array.isArray(product.collection_ids) ? product.collection_ids.map((id) => this.toNumber(id)) : [];
|
|
481
|
+
return collectionIds.some((id) => scope.collectionIds.has(id)) || scope.productKeys.has(productKey) || scope.productAllVariantIds.has(productId);
|
|
422
482
|
}
|
|
423
483
|
mergeMatchedVariants(product, matchedVariants) {
|
|
424
|
-
const original = {
|
|
425
|
-
...product
|
|
426
|
-
};
|
|
484
|
+
const original = { ...product };
|
|
427
485
|
const sortedVariants = [...matchedVariants].sort((a, b) => {
|
|
428
|
-
if (a.priority !== b.priority)
|
|
486
|
+
if (a.priority !== b.priority)
|
|
487
|
+
return a.priority - b.priority;
|
|
429
488
|
return Number(a.ruleId) - Number(b.ruleId);
|
|
430
489
|
});
|
|
431
|
-
const result = {
|
|
432
|
-
...product
|
|
433
|
-
};
|
|
490
|
+
const result = { ...product };
|
|
434
491
|
const appliedRuleIds = [];
|
|
435
|
-
const appliedFields = new Set();
|
|
492
|
+
const appliedFields = /* @__PURE__ */ new Set();
|
|
436
493
|
for (const matched of sortedVariants) {
|
|
437
494
|
for (const [key, value] of Object.entries(matched.data)) {
|
|
438
|
-
if (value ===
|
|
495
|
+
if (value === void 0)
|
|
496
|
+
continue;
|
|
439
497
|
result[key] = value;
|
|
440
498
|
appliedFields.add(key);
|
|
441
499
|
}
|
|
@@ -452,20 +510,31 @@ class DataVariantEvaluator {
|
|
|
452
510
|
return Array.isArray(product.data_variants) ? product.data_variants : [];
|
|
453
511
|
}
|
|
454
512
|
normalizeStrategyConfigs(configs) {
|
|
455
|
-
return configs.filter(
|
|
513
|
+
return configs.filter(
|
|
514
|
+
(config) => {
|
|
515
|
+
var _a;
|
|
516
|
+
return ((_a = config == null ? void 0 : config.metadata) == null ? void 0 : _a.type) === "data_variant";
|
|
517
|
+
}
|
|
518
|
+
);
|
|
456
519
|
}
|
|
457
520
|
isStrategyActive(config) {
|
|
458
|
-
|
|
459
|
-
|
|
521
|
+
var _a;
|
|
522
|
+
const status = (_a = config.metadata.custom) == null ? void 0 : _a.status;
|
|
523
|
+
return !status || status === "active";
|
|
460
524
|
}
|
|
461
525
|
getStrategyPriority(config) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
526
|
+
var _a;
|
|
527
|
+
const priority = Number((_a = config.metadata.custom) == null ? void 0 : _a.priority);
|
|
528
|
+
if (Number.isFinite(priority))
|
|
529
|
+
return priority;
|
|
530
|
+
return Math.max(
|
|
531
|
+
0,
|
|
532
|
+
...config.actions.map((action) => Number(action.priority || 0))
|
|
533
|
+
);
|
|
465
534
|
}
|
|
466
535
|
createAlwaysTrueConditions(actionIds) {
|
|
467
536
|
return {
|
|
468
|
-
operator:
|
|
537
|
+
operator: "and",
|
|
469
538
|
rules: [],
|
|
470
539
|
actionIds
|
|
471
540
|
};
|
|
@@ -482,16 +551,18 @@ class DataVariantEvaluator {
|
|
|
482
551
|
return rules;
|
|
483
552
|
}
|
|
484
553
|
isConditionGroup(rule) {
|
|
485
|
-
return
|
|
554
|
+
return "rules" in rule && Array.isArray(rule.rules);
|
|
486
555
|
}
|
|
487
556
|
normalizeNumberArray(value) {
|
|
488
|
-
if (!Array.isArray(value))
|
|
489
|
-
|
|
557
|
+
if (!Array.isArray(value))
|
|
558
|
+
return [];
|
|
559
|
+
return value.map((item) => this.toNumber(item)).filter((item) => item > 0);
|
|
490
560
|
}
|
|
491
561
|
normalizeComparableArray(value) {
|
|
492
|
-
const list = Array.isArray(value) ? value : value == null || value ===
|
|
493
|
-
const normalized = list.map(item => {
|
|
494
|
-
if (item == null || item ===
|
|
562
|
+
const list = Array.isArray(value) ? value : value == null || value === "" ? [] : [value];
|
|
563
|
+
const normalized = list.map((item) => {
|
|
564
|
+
if (item == null || item === "")
|
|
565
|
+
return "";
|
|
495
566
|
const parsed = Number(item);
|
|
496
567
|
return Number.isFinite(parsed) ? String(parsed) : String(item).trim();
|
|
497
568
|
}).filter(Boolean);
|
|
@@ -504,6 +575,9 @@ class DataVariantEvaluator {
|
|
|
504
575
|
const parsed = Number(value);
|
|
505
576
|
return Number.isFinite(parsed) ? parsed : 0;
|
|
506
577
|
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
|
|
578
|
+
};
|
|
579
|
+
var evaluator_default = DataVariantEvaluator;
|
|
580
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
581
|
+
0 && (module.exports = {
|
|
582
|
+
DataVariantEvaluator
|
|
583
|
+
});
|