@pisell/pisellos 2.2.260 → 2.2.261
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/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- 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 +1 -1
- 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 +17 -13
- package/dist/modules/Order/index.d.ts +33 -2
- package/dist/modules/Order/index.js +615 -288
- package/dist/modules/Order/types.d.ts +20 -2
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +116 -29
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/modules/Rules/index.d.ts +4 -3
- package/dist/modules/Rules/index.js +42 -17
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/modules/SalesSummary/index.d.ts +7 -3
- package/dist/modules/SalesSummary/index.js +67 -39
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +2 -1
- package/dist/modules/SurchargeList/index.d.ts +6 -4
- package/dist/modules/SurchargeList/index.js +62 -39
- package/dist/modules/SurchargeList/types.d.ts +6 -2
- package/dist/server/index.d.ts +3 -50
- package/dist/server/index.js +1075 -1040
- package/dist/server/modules/order/index.d.ts +22 -3
- package/dist/server/modules/order/index.js +398 -316
- package/dist/server/modules/products/index.d.ts +7 -26
- package/dist/server/modules/products/index.js +76 -166
- package/dist/server/modules/products/types.d.ts +0 -14
- package/dist/solution/BaseSales/index.d.ts +22 -2
- package/dist/solution/BaseSales/index.js +995 -701
- package/dist/solution/BaseSales/types.d.ts +1 -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 +74 -29
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +9 -1
- package/dist/solution/BookingTicket/index.js +153 -6
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/VenueBooking/index.js +30 -19
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- 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 +11 -1
- package/lib/modules/Order/index.d.ts +33 -2
- package/lib/modules/Order/index.js +402 -64
- package/lib/modules/Order/types.d.ts +20 -2
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +90 -3
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/modules/Rules/index.d.ts +4 -3
- package/lib/modules/Rules/index.js +27 -7
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/modules/SalesSummary/index.d.ts +7 -3
- package/lib/modules/SalesSummary/index.js +28 -11
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +2 -0
- package/lib/modules/SurchargeList/index.d.ts +6 -4
- package/lib/modules/SurchargeList/index.js +41 -21
- package/lib/modules/SurchargeList/types.d.ts +6 -2
- package/lib/server/index.d.ts +3 -50
- package/lib/server/index.js +244 -215
- package/lib/server/modules/order/index.d.ts +22 -3
- package/lib/server/modules/order/index.js +103 -53
- package/lib/server/modules/products/index.d.ts +7 -26
- package/lib/server/modules/products/index.js +35 -113
- package/lib/server/modules/products/types.d.ts +0 -14
- package/lib/solution/BaseSales/index.d.ts +22 -2
- package/lib/solution/BaseSales/index.js +246 -60
- package/lib/solution/BaseSales/types.d.ts +1 -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 +59 -16
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +9 -1
- package/lib/solution/BookingTicket/index.js +101 -0
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -152
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -755
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -282
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -146
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -139
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -564
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -295
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -146
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
|
@@ -77,19 +77,34 @@ function getOrderProductOriginalPriceForPromotion(product) {
|
|
|
77
77
|
}
|
|
78
78
|
return getOrderProductBasePrice(product);
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
var X_ITEMS_FOR_Y_PRICE = "X_ITEMS_FOR_Y_PRICE";
|
|
81
|
+
var ITEM_REWARD = "ITEM_REWARD";
|
|
82
|
+
function isManagedPromotionDiscountItem(item) {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
if ((item == null ? void 0 : item.type) === "promotion")
|
|
85
|
+
return true;
|
|
86
|
+
return (item == null ? void 0 : item.type) === "product" && ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.actionType) === ITEM_REWARD;
|
|
87
|
+
}
|
|
88
|
+
function updatePromotionDiscountList(item, promotionDiscount, options) {
|
|
81
89
|
let discountList = Array.isArray(item.discount_list) ? [...item.discount_list] : [];
|
|
82
|
-
discountList = discountList.filter((d) => (d
|
|
90
|
+
discountList = discountList.filter((d) => !isManagedPromotionDiscountItem(d));
|
|
83
91
|
if (promotionDiscount) {
|
|
92
|
+
const discountType = (options == null ? void 0 : options.discountType) || "promotion";
|
|
84
93
|
discountList.push({
|
|
85
|
-
type:
|
|
94
|
+
type: discountType,
|
|
86
95
|
amount: promotionDiscount.amount,
|
|
87
96
|
discount: {
|
|
88
97
|
original_amount: promotionDiscount.original_amount,
|
|
89
98
|
fixed_amount: promotionDiscount.fixed_amount,
|
|
90
99
|
title: promotionDiscount.title,
|
|
91
100
|
resource_id: ""
|
|
92
|
-
}
|
|
101
|
+
},
|
|
102
|
+
...discountType === "product" ? {
|
|
103
|
+
metadata: {
|
|
104
|
+
source: "promotion",
|
|
105
|
+
actionType: (options == null ? void 0 : options.actionType) || ITEM_REWARD
|
|
106
|
+
}
|
|
107
|
+
} : {}
|
|
93
108
|
});
|
|
94
109
|
}
|
|
95
110
|
if (discountList.length > 0) {
|
|
@@ -98,7 +113,15 @@ function updatePromotionDiscountList(item, promotionDiscount) {
|
|
|
98
113
|
delete item.discount_list;
|
|
99
114
|
}
|
|
100
115
|
}
|
|
101
|
-
|
|
116
|
+
function evaluatorHasActionType(evaluator, actionType) {
|
|
117
|
+
var _a;
|
|
118
|
+
const configs = (_a = evaluator == null ? void 0 : evaluator.getStrategyConfigs) == null ? void 0 : _a.call(evaluator);
|
|
119
|
+
if (!Array.isArray(configs))
|
|
120
|
+
return false;
|
|
121
|
+
return configs.some(
|
|
122
|
+
(config) => ((config == null ? void 0 : config.actions) || []).some((action) => (action == null ? void 0 : action.type) === actionType)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
102
125
|
function applyPromoUnitPriceToLine(item, input) {
|
|
103
126
|
const metadata = item.metadata || (item.metadata = {});
|
|
104
127
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(item)).toNumber();
|
|
@@ -125,6 +148,9 @@ function applyPromoUnitPriceToLine(item, input) {
|
|
|
125
148
|
amount: discountAmount,
|
|
126
149
|
original_amount: catalogSource,
|
|
127
150
|
fixed_amount: discountAmount
|
|
151
|
+
}, {
|
|
152
|
+
actionType: input.actionType,
|
|
153
|
+
discountType: input.actionType === ITEM_REWARD ? "product" : "promotion"
|
|
128
154
|
});
|
|
129
155
|
} else {
|
|
130
156
|
updatePromotionDiscountList(item, null);
|
|
@@ -457,6 +483,9 @@ function splitXItemsPromoLinesByGroup(lines, strategyActionMap) {
|
|
|
457
483
|
function generateNumericId() {
|
|
458
484
|
return Math.floor(Math.random() * 1e9) + Date.now();
|
|
459
485
|
}
|
|
486
|
+
function isBookingEditProductLine(product) {
|
|
487
|
+
return (product == null ? void 0 : product.booking_id) !== void 0 && (product == null ? void 0 : product.booking_id) !== null && product.booking_id !== 0 && product.booking_id !== "0";
|
|
488
|
+
}
|
|
460
489
|
function convertToPromotionProduct(product, index) {
|
|
461
490
|
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
462
491
|
const numericId = generateNumericId();
|
|
@@ -469,6 +498,7 @@ function convertToPromotionProduct(product, index) {
|
|
|
469
498
|
price: getOrderProductOriginalPriceForPromotion(product),
|
|
470
499
|
quantity: Number((product == null ? void 0 : product.num) ?? 1) || 1,
|
|
471
500
|
bundle: getProductBundleForEvaluator(product),
|
|
501
|
+
_promotionOnlyForItemReward: isBookingEditProductLine(product),
|
|
472
502
|
_originalItem: originalItem,
|
|
473
503
|
_originalId: getOrderProductUid(product),
|
|
474
504
|
_originalIndex: index
|
|
@@ -570,6 +600,9 @@ function resolveStrategyRequiredQuantity(matched) {
|
|
|
570
600
|
if (matched.actionType === "BUY_X_GET_Y_FREE") {
|
|
571
601
|
return Number(detail.buyQuantity) || 1;
|
|
572
602
|
}
|
|
603
|
+
if (matched.actionType === "ITEM_REWARD") {
|
|
604
|
+
return Number(detail.triggerQuantity) || 1;
|
|
605
|
+
}
|
|
573
606
|
return 1;
|
|
574
607
|
}
|
|
575
608
|
function resolveStrategyEligibleProducts(matched) {
|
|
@@ -670,7 +703,7 @@ function appendPromotionTags(products, evaluator) {
|
|
|
670
703
|
});
|
|
671
704
|
}
|
|
672
705
|
function processCartPromotion(list, evaluator, options) {
|
|
673
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
706
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
674
707
|
const empty = {
|
|
675
708
|
products: Array.isArray(list) ? [...list] : [],
|
|
676
709
|
totalDiscount: 0,
|
|
@@ -680,6 +713,10 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
680
713
|
};
|
|
681
714
|
if (!list || list.length === 0 || !evaluator)
|
|
682
715
|
return empty;
|
|
716
|
+
const shouldIncludeEditProductsForItemReward = evaluatorHasActionType(
|
|
717
|
+
evaluator,
|
|
718
|
+
ITEM_REWARD
|
|
719
|
+
);
|
|
683
720
|
const mainProductsWithIndex = [];
|
|
684
721
|
const existingGiftsWithIndex = [];
|
|
685
722
|
const editProductsWithIndex = [];
|
|
@@ -690,8 +727,12 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
690
727
|
editProductsWithIndex.push({ item, originalListIndex: i });
|
|
691
728
|
} else if (giftInfo) {
|
|
692
729
|
existingGiftsWithIndex.push({ item, originalListIndex: i });
|
|
693
|
-
} else if ((item
|
|
694
|
-
|
|
730
|
+
} else if (isBookingEditProductLine(item)) {
|
|
731
|
+
if (shouldIncludeEditProductsForItemReward) {
|
|
732
|
+
mainProductsWithIndex.push({ item, originalListIndex: i });
|
|
733
|
+
} else {
|
|
734
|
+
editProductsWithIndex.push({ item, originalListIndex: i });
|
|
735
|
+
}
|
|
695
736
|
} else {
|
|
696
737
|
mainProductsWithIndex.push({ item, originalListIndex: i });
|
|
697
738
|
}
|
|
@@ -734,7 +775,8 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
734
775
|
name: ((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.product_name) || (item == null ? void 0 : item.title) || "",
|
|
735
776
|
price: getOrderProductBasePrice(item),
|
|
736
777
|
quantity: Number((item == null ? void 0 : item.num) ?? 1) || 1,
|
|
737
|
-
bundle: getProductBundleForEvaluator(item)
|
|
778
|
+
bundle: getProductBundleForEvaluator(item),
|
|
779
|
+
_promotionOnlyForItemReward: isBookingEditProductLine(item)
|
|
738
780
|
};
|
|
739
781
|
});
|
|
740
782
|
for (let i = 0; i < consolidatedMainProductsWithIndex.length; i++) {
|
|
@@ -820,7 +862,8 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
820
862
|
applyPromoUnitPriceToLine(newItem, {
|
|
821
863
|
promoUnitPrice,
|
|
822
864
|
originalBasePrice,
|
|
823
|
-
strategyTitle: (_b = priced.strategyMetadata) == null ? void 0 : _b.name
|
|
865
|
+
strategyTitle: (_b = priced.strategyMetadata) == null ? void 0 : _b.name,
|
|
866
|
+
actionType: priced.strategyId ? (_c = strategyActionMap.get(priced.strategyId)) == null ? void 0 : _c.actionType : void 0
|
|
824
867
|
});
|
|
825
868
|
} else {
|
|
826
869
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(newItem)).toNumber();
|
|
@@ -868,7 +911,7 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
868
911
|
giftOptions: gift.giftOptions
|
|
869
912
|
};
|
|
870
913
|
const bundleIdx = priced.matchedBundleIndex;
|
|
871
|
-
if (bundleIdx !== void 0 && Array.isArray(newItem.product_bundle) && ((
|
|
914
|
+
if (bundleIdx !== void 0 && Array.isArray(newItem.product_bundle) && ((_d = newItem.product_bundle[bundleIdx]) == null ? void 0 : _d._promotion)) {
|
|
872
915
|
newItem.product_bundle[bundleIdx]._promotion.giftInfo = giftInfoData;
|
|
873
916
|
} else if (metadata._promotion) {
|
|
874
917
|
metadata._promotion.giftInfo = giftInfoData;
|
|
@@ -888,14 +931,14 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
888
931
|
const next = item;
|
|
889
932
|
next._sortIndex = originalListIndex;
|
|
890
933
|
next._sortSubIndex = 0;
|
|
891
|
-
const strategyId = (
|
|
934
|
+
const strategyId = (_e = getGiftInfo(next)) == null ? void 0 : _e.strategyId;
|
|
892
935
|
if (strategyId) {
|
|
893
936
|
const latest = strategyGiftInfoMap.get(strategyId);
|
|
894
937
|
const owner = strategyGiftInfoOwner.get(strategyId);
|
|
895
|
-
if (latest && ((
|
|
938
|
+
if (latest && ((_f = next.metadata) == null ? void 0 : _f._giftInfo)) {
|
|
896
939
|
next.metadata._giftInfo.sourceProductIds = latest.sourceProductIds;
|
|
897
940
|
}
|
|
898
|
-
if (owner && ((
|
|
941
|
+
if (owner && ((_g = next.metadata) == null ? void 0 : _g._giftInfo)) {
|
|
899
942
|
next.metadata._giftInfo.sourceProductId = owner;
|
|
900
943
|
}
|
|
901
944
|
}
|
|
@@ -948,11 +991,11 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
948
991
|
}
|
|
949
992
|
const giftActions = calculateGiftActions(extendedGifts, existingGifts);
|
|
950
993
|
for (const gift of existingGifts) {
|
|
951
|
-
const strategyId = (
|
|
994
|
+
const strategyId = (_h = getGiftInfo(gift)) == null ? void 0 : _h.strategyId;
|
|
952
995
|
if (!strategyId)
|
|
953
996
|
continue;
|
|
954
997
|
const latest = strategyGiftInfoMap.get(strategyId);
|
|
955
|
-
if (latest && ((
|
|
998
|
+
if (latest && ((_i = gift.metadata) == null ? void 0 : _i._giftInfo)) {
|
|
956
999
|
gift.metadata._giftInfo.lastEvaluatedGiftCount = latest.giftCount;
|
|
957
1000
|
}
|
|
958
1001
|
}
|
|
@@ -88,7 +88,8 @@ function normalizeBundleItems(bundleItems, preferPriceField = false) {
|
|
|
88
88
|
price: bundleItem.price ?? unitStr,
|
|
89
89
|
bundle_selling_price: unitStr,
|
|
90
90
|
original_price: bundleItem.original_price ?? bundleItem.product_price ?? bundleItem.price ?? unitStr,
|
|
91
|
-
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option)
|
|
91
|
+
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option),
|
|
92
|
+
discount_list: preferPriceField ? [] : bundleItem.discount_list
|
|
92
93
|
};
|
|
93
94
|
normalizedItem.bundle_selling_price = (0, import_utils.getBundleSellingMagnitude)(magnitudeSource).toFixed(2);
|
|
94
95
|
if ((normalizedItem.price_type ?? normalizedItem.custom_price_type) === "markdown" && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
|
|
@@ -129,10 +130,9 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
129
130
|
payload.price ?? payload.selling_price ?? (matchedVariant == null ? void 0 : matchedVariant.price) ?? (matchedVariant == null ? void 0 : matchedVariant.base_price) ?? (origin == null ? void 0 : origin.price) ?? (origin == null ? void 0 : origin.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.selling_price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price),
|
|
130
131
|
"0.00"
|
|
131
132
|
);
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
);
|
|
133
|
+
const explicitLineTotal = payload.line_total ?? payload.total ?? ((_c = payload._extend) == null ? void 0 : _c.total);
|
|
134
|
+
const hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
135
|
+
const lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
136
136
|
const hasPriceOverride = payload.price_override !== void 0 && payload.price_override !== null && payload.price_override !== "";
|
|
137
137
|
const productOptionItem = (0, import_utils.normalizeProductSkuOptions)(
|
|
138
138
|
normalizeOptionItems(
|
|
@@ -180,7 +180,7 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
180
180
|
const optionSum = (0, import_utils.sumOptionUnitPrice)(productOptionItem).toNumber();
|
|
181
181
|
const mainProductOriginalPrice = toPriceString(Number(sourceProductPrice) + optionSum);
|
|
182
182
|
const bundleOnlyComposite = (0, import_utils.composeLinePrice)({ mainPrice: 0, bundle: productBundle });
|
|
183
|
-
const derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
|
|
183
|
+
const derivedMainSelling = hasExplicitLineTotal ? Number(lineCompositeTotal) - Number(bundleOnlyComposite) : Number(mainProductOriginalPrice);
|
|
184
184
|
const mainProductSellingPrice = toPriceString(
|
|
185
185
|
Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice)
|
|
186
186
|
);
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
322
322
|
* 获取当前的客户搜索条件
|
|
323
323
|
* @returns 当前搜索条件
|
|
324
324
|
*/
|
|
325
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
325
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
326
326
|
/**
|
|
327
327
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
328
328
|
* @returns 客户状态
|
|
@@ -551,6 +551,14 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
551
551
|
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
552
552
|
cover?: boolean;
|
|
553
553
|
}): Promise<void>;
|
|
554
|
+
private getDeviceTaskPlugin;
|
|
555
|
+
handlePrintWristband(params: {
|
|
556
|
+
voucher_ids: number[];
|
|
557
|
+
}): Promise<void>;
|
|
558
|
+
handleRedeem(params: {
|
|
559
|
+
voucher_ids: number[];
|
|
560
|
+
is_checkin: boolean;
|
|
561
|
+
}): Promise<any>;
|
|
554
562
|
/**
|
|
555
563
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
556
564
|
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
@@ -52,6 +52,7 @@ var import_buildNormalProductCacheItemFromOrderLine = require("../../modules/Boo
|
|
|
52
52
|
var import_orderLineDisplay = require("../../modules/BookingContext/utils/orderLineDisplay");
|
|
53
53
|
var import_bookingStatus = require("./utils/bookingStatus");
|
|
54
54
|
var import_resolveBestAddTimePlan = require("./utils/resolveBestAddTimePlan");
|
|
55
|
+
var import_utils = require("../../modules/Order/utils");
|
|
55
56
|
__reExport(BookingTicket_exports, require("./types"), module.exports);
|
|
56
57
|
var OPEN_DATA_SECTION_CODES = ["sale", "reservation", "fulfillment", "menu", "workflow"];
|
|
57
58
|
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
@@ -1505,6 +1506,106 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1505
1506
|
await this.configureIdGeneratorFromOpenData();
|
|
1506
1507
|
}
|
|
1507
1508
|
}
|
|
1509
|
+
getDeviceTaskPlugin() {
|
|
1510
|
+
var _a;
|
|
1511
|
+
const app = this.core.getPlugin("app");
|
|
1512
|
+
return ((_a = app == null ? void 0 : app.getApp()) == null ? void 0 : _a.getPlugin("deviceTask")) || null;
|
|
1513
|
+
}
|
|
1514
|
+
// 打印手环,单个或批量都可以
|
|
1515
|
+
async handlePrintWristband(params) {
|
|
1516
|
+
var _a;
|
|
1517
|
+
const deviceTask = this.getDeviceTaskPlugin();
|
|
1518
|
+
if (!(deviceTask == null ? void 0 : deviceTask.dispatch)) {
|
|
1519
|
+
this.logger.addLog({
|
|
1520
|
+
type: "info",
|
|
1521
|
+
title: "[BookingTicket] handlePrintWristband: deviceTask.dispatch 不可用",
|
|
1522
|
+
metadata: {
|
|
1523
|
+
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1524
|
+
}
|
|
1525
|
+
});
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
this.logger.addLog({
|
|
1529
|
+
type: "info",
|
|
1530
|
+
title: "[BookingTicket] handlePrintWristband",
|
|
1531
|
+
metadata: {
|
|
1532
|
+
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
const deviceId = await this.getShortNumberOrDeviceId();
|
|
1536
|
+
const idempotencyKey = (0, import_utils.createUuidV4)();
|
|
1537
|
+
deviceTask.dispatch({
|
|
1538
|
+
action: "print_all",
|
|
1539
|
+
device_id: deviceId,
|
|
1540
|
+
payload: {
|
|
1541
|
+
type: "WRISTBAND",
|
|
1542
|
+
data: {
|
|
1543
|
+
order_id: (_a = this.getOrderIdentity()) == null ? void 0 : _a.orderId,
|
|
1544
|
+
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1545
|
+
}
|
|
1546
|
+
},
|
|
1547
|
+
idempotency_key: idempotencyKey,
|
|
1548
|
+
name: "PRINT_WRISTBAND",
|
|
1549
|
+
source: "bookingTicket",
|
|
1550
|
+
source_type: "handlePrintWristband",
|
|
1551
|
+
source_id: idempotencyKey
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
// 触发核销
|
|
1555
|
+
async handleRedeem(params) {
|
|
1556
|
+
var _a, _b, _c;
|
|
1557
|
+
const voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
|
|
1558
|
+
const status = params.is_checkin ? "used" : "unused";
|
|
1559
|
+
this.logger.addLog({
|
|
1560
|
+
type: "info",
|
|
1561
|
+
title: "[BookingTicket] handleRedeem",
|
|
1562
|
+
metadata: {
|
|
1563
|
+
voucher_ids: voucherIds,
|
|
1564
|
+
status
|
|
1565
|
+
}
|
|
1566
|
+
});
|
|
1567
|
+
const voucherIdSet = new Set(voucherIds);
|
|
1568
|
+
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
1569
|
+
const vouchers = (tempOrder == null ? void 0 : tempOrder.vouchers) || ((_c = this.store.order) == null ? void 0 : _c.getVouchers()) || [];
|
|
1570
|
+
let hasUpdatedVoucher = false;
|
|
1571
|
+
const nextVouchers = vouchers.map((voucher) => {
|
|
1572
|
+
if (!voucherIdSet.has(voucher.voucher_id))
|
|
1573
|
+
return voucher;
|
|
1574
|
+
hasUpdatedVoucher = true;
|
|
1575
|
+
return {
|
|
1576
|
+
...voucher,
|
|
1577
|
+
status
|
|
1578
|
+
};
|
|
1579
|
+
});
|
|
1580
|
+
if (tempOrder && hasUpdatedVoucher) {
|
|
1581
|
+
await this.replaceTempOrder({
|
|
1582
|
+
...tempOrder,
|
|
1583
|
+
vouchers: nextVouchers
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
this.core.effects.emit(`${this.name}:onVouchersChange`, {});
|
|
1587
|
+
if (voucherIds.length === 0) {
|
|
1588
|
+
return {
|
|
1589
|
+
code: 200,
|
|
1590
|
+
status: true,
|
|
1591
|
+
message: "",
|
|
1592
|
+
data: []
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
const identity = this.getOrderIdentity();
|
|
1596
|
+
const externalSaleNumber = (tempOrder == null ? void 0 : tempOrder.external_sale_number) || (identity == null ? void 0 : identity.externalSaleNumber) || void 0;
|
|
1597
|
+
const orderId = (tempOrder == null ? void 0 : tempOrder.order_id) ?? (identity == null ? void 0 : identity.orderId) ?? void 0;
|
|
1598
|
+
const orderLookup = externalSaleNumber || orderId || (identity == null ? void 0 : identity.orderNumber) || (identity == null ? void 0 : identity.shopOrderNumber) || (identity == null ? void 0 : identity.shopFullOrderNumber) || void 0;
|
|
1599
|
+
return this.request.post("/machinecode/batch", {
|
|
1600
|
+
ids: voucherIds,
|
|
1601
|
+
status,
|
|
1602
|
+
order_lookup: orderLookup,
|
|
1603
|
+
order_id: orderId,
|
|
1604
|
+
external_sale_number: externalSaleNumber
|
|
1605
|
+
}, {
|
|
1606
|
+
osServer: true
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1508
1609
|
/**
|
|
1509
1610
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
1510
1611
|
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
@@ -48,6 +48,10 @@ var import_utils2 = require("../../modules/Order/utils");
|
|
|
48
48
|
var import_dayjs = __toESM(require("dayjs"));
|
|
49
49
|
var import_itemRule = require("../../model/strategy/adapter/itemRule");
|
|
50
50
|
__reExport(ScanOrder_exports, require("./types"), module.exports);
|
|
51
|
+
function isItemRewardProductDiscount(discount) {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
54
|
+
}
|
|
51
55
|
var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
52
56
|
constructor(name, version) {
|
|
53
57
|
super(name, version);
|
|
@@ -742,6 +746,10 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
742
746
|
for (const product of tempOrder.products) {
|
|
743
747
|
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
744
748
|
continue;
|
|
749
|
+
if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
750
|
+
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
745
753
|
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
746
754
|
var _a2;
|
|
747
755
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
@@ -65,6 +65,10 @@ var OPEN_DATA_SECTION_CODES = [
|
|
|
65
65
|
"workflow",
|
|
66
66
|
"checkout"
|
|
67
67
|
];
|
|
68
|
+
function isItemRewardProductDiscount(discount) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
71
|
+
}
|
|
68
72
|
function cloneCustomDepositData(customDepositData) {
|
|
69
73
|
if (!customDepositData || typeof customDepositData !== "object")
|
|
70
74
|
return void 0;
|
|
@@ -1339,6 +1343,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1339
1343
|
for (const product of tempOrder.products) {
|
|
1340
1344
|
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
1341
1345
|
continue;
|
|
1346
|
+
if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
1347
|
+
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1342
1350
|
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
1343
1351
|
var _a2;
|
|
1344
1352
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
package/package.json
CHANGED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { EvaluationResult, RuntimeContext } from '../../type';
|
|
2
|
-
import type { BusinessAdapter } from '../type';
|
|
3
|
-
import type { DataVariantBusinessData, DataVariantProduct } from './type';
|
|
4
|
-
/**
|
|
5
|
-
* Data Variant 适配器。
|
|
6
|
-
*
|
|
7
|
-
* 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
|
|
8
|
-
*/
|
|
9
|
-
export declare class DataVariantAdapter implements BusinessAdapter {
|
|
10
|
-
name: string;
|
|
11
|
-
version: string;
|
|
12
|
-
/**
|
|
13
|
-
* 准备批量全局上下文。
|
|
14
|
-
*
|
|
15
|
-
* 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
|
|
16
|
-
*/
|
|
17
|
-
prepareContext(businessData: DataVariantBusinessData): RuntimeContext;
|
|
18
|
-
/**
|
|
19
|
-
* 准备全局预计算上下文。
|
|
20
|
-
*/
|
|
21
|
-
prepareGlobalContext(businessData: DataVariantBusinessData): RuntimeContext;
|
|
22
|
-
/**
|
|
23
|
-
* 准备单商品上下文。
|
|
24
|
-
*
|
|
25
|
-
* 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
|
|
26
|
-
*/
|
|
27
|
-
prepareProductContext(businessData: DataVariantBusinessData, product: DataVariantProduct): RuntimeContext;
|
|
28
|
-
transformResult(result: EvaluationResult): EvaluationResult;
|
|
29
|
-
formatConfig(result: EvaluationResult, businessData?: DataVariantBusinessData): {
|
|
30
|
-
result: EvaluationResult;
|
|
31
|
-
businessData?: DataVariantBusinessData;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* 构建 menu_match 使用的轻量商品对象。
|
|
35
|
-
*
|
|
36
|
-
* collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
|
|
37
|
-
*/
|
|
38
|
-
buildProductValue(product: DataVariantProduct): {
|
|
39
|
-
id: number;
|
|
40
|
-
product_variant_id: number;
|
|
41
|
-
collection_ids: number[];
|
|
42
|
-
};
|
|
43
|
-
private toNumber;
|
|
44
|
-
/**
|
|
45
|
-
* 归一化客户 id:无效值返回 undefined,有效值统一为 number。
|
|
46
|
-
*/
|
|
47
|
-
private normalizeCustomerId;
|
|
48
|
-
}
|
|
49
|
-
export default DataVariantAdapter;
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
-
/**
|
|
11
|
-
* Data Variant 适配器。
|
|
12
|
-
*
|
|
13
|
-
* 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
|
|
14
|
-
*/
|
|
15
|
-
export var DataVariantAdapter = /*#__PURE__*/function () {
|
|
16
|
-
function DataVariantAdapter() {
|
|
17
|
-
_classCallCheck(this, DataVariantAdapter);
|
|
18
|
-
_defineProperty(this, "name", 'DataVariantAdapter');
|
|
19
|
-
_defineProperty(this, "version", '1.0.0');
|
|
20
|
-
}
|
|
21
|
-
_createClass(DataVariantAdapter, [{
|
|
22
|
-
key: "prepareContext",
|
|
23
|
-
value:
|
|
24
|
-
/**
|
|
25
|
-
* 准备批量全局上下文。
|
|
26
|
-
*
|
|
27
|
-
* 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
|
|
28
|
-
*/
|
|
29
|
-
function prepareContext(businessData) {
|
|
30
|
-
return this.prepareGlobalContext(businessData);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 准备全局预计算上下文。
|
|
35
|
-
*/
|
|
36
|
-
}, {
|
|
37
|
-
key: "prepareGlobalContext",
|
|
38
|
-
value: function prepareGlobalContext(businessData) {
|
|
39
|
-
var products = businessData.products,
|
|
40
|
-
scheduleDateTime = businessData.scheduleDateTime,
|
|
41
|
-
channel = businessData.channel,
|
|
42
|
-
orderType = businessData.orderType,
|
|
43
|
-
businessCode = businessData.businessCode,
|
|
44
|
-
customerId = businessData.customerId,
|
|
45
|
-
custom = businessData.custom;
|
|
46
|
-
|
|
47
|
-
// customer_id 统一归一化为 number,避免 in 运算符因 string/number 不一致而误判
|
|
48
|
-
var normalizedCustomerId = this.normalizeCustomerId(customerId);
|
|
49
|
-
var resolvedBusinessCode = businessCode || (custom === null || custom === void 0 ? void 0 : custom.business_code) || (custom === null || custom === void 0 ? void 0 : custom.businessCode) || '';
|
|
50
|
-
return {
|
|
51
|
-
entities: {
|
|
52
|
-
products: products
|
|
53
|
-
},
|
|
54
|
-
attributes: _objectSpread(_objectSpread({}, custom), {}, {
|
|
55
|
-
schedule: scheduleDateTime || '',
|
|
56
|
-
channel: channel || (custom === null || custom === void 0 ? void 0 : custom.channel) || '',
|
|
57
|
-
orderType: orderType || (custom === null || custom === void 0 ? void 0 : custom.orderType) || (custom === null || custom === void 0 ? void 0 : custom.order_type) || '',
|
|
58
|
-
// snake_case 与策略配置 field 对齐;customerId 保留兼容旧配置
|
|
59
|
-
customer_id: normalizedCustomerId,
|
|
60
|
-
customerId: normalizedCustomerId,
|
|
61
|
-
business_code: resolvedBusinessCode
|
|
62
|
-
}),
|
|
63
|
-
metadata: {
|
|
64
|
-
timestamp: Date.now()
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* 准备单商品上下文。
|
|
71
|
-
*
|
|
72
|
-
* 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
|
|
73
|
-
*/
|
|
74
|
-
}, {
|
|
75
|
-
key: "prepareProductContext",
|
|
76
|
-
value: function prepareProductContext(businessData, product) {
|
|
77
|
-
var base = this.prepareGlobalContext(businessData);
|
|
78
|
-
var productValue = this.buildProductValue(product);
|
|
79
|
-
return _objectSpread(_objectSpread({}, base), {}, {
|
|
80
|
-
entities: _objectSpread(_objectSpread({}, base.entities), {}, {
|
|
81
|
-
currentProduct: product
|
|
82
|
-
}),
|
|
83
|
-
attributes: _objectSpread(_objectSpread({}, base.attributes), {}, {
|
|
84
|
-
product: productValue,
|
|
85
|
-
productIdAndVariantId: {
|
|
86
|
-
product_id: productValue.id,
|
|
87
|
-
product_variant_id: productValue.product_variant_id
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "transformResult",
|
|
94
|
-
value: function transformResult(result) {
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "formatConfig",
|
|
99
|
-
value: function formatConfig(result, businessData) {
|
|
100
|
-
return {
|
|
101
|
-
result: result,
|
|
102
|
-
businessData: businessData
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 构建 menu_match 使用的轻量商品对象。
|
|
108
|
-
*
|
|
109
|
-
* collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
|
|
110
|
-
*/
|
|
111
|
-
}, {
|
|
112
|
-
key: "buildProductValue",
|
|
113
|
-
value: function buildProductValue(product) {
|
|
114
|
-
var _product$id,
|
|
115
|
-
_product$product_vari,
|
|
116
|
-
_this = this;
|
|
117
|
-
var productId = this.toNumber((_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id);
|
|
118
|
-
var variantId = this.toNumber((_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id);
|
|
119
|
-
var collectionIds = Array.isArray(product.collection) ? product.collection.map(function (item) {
|
|
120
|
-
return _this.toNumber(item === null || item === void 0 ? void 0 : item.id);
|
|
121
|
-
}).filter(function (id) {
|
|
122
|
-
return id > 0;
|
|
123
|
-
}) : [];
|
|
124
|
-
return {
|
|
125
|
-
id: productId,
|
|
126
|
-
product_variant_id: variantId,
|
|
127
|
-
collection_ids: collectionIds
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}, {
|
|
131
|
-
key: "toNumber",
|
|
132
|
-
value: function toNumber(value) {
|
|
133
|
-
var parsed = Number(value);
|
|
134
|
-
return Number.isFinite(parsed) ? parsed : 0;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 归一化客户 id:无效值返回 undefined,有效值统一为 number。
|
|
139
|
-
*/
|
|
140
|
-
}, {
|
|
141
|
-
key: "normalizeCustomerId",
|
|
142
|
-
value: function normalizeCustomerId(value) {
|
|
143
|
-
if (value === undefined || value === null || value === '') {
|
|
144
|
-
return undefined;
|
|
145
|
-
}
|
|
146
|
-
var parsed = Number(value);
|
|
147
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
148
|
-
}
|
|
149
|
-
}]);
|
|
150
|
-
return DataVariantAdapter;
|
|
151
|
-
}();
|
|
152
|
-
export default DataVariantAdapter;
|