@pisell/pisellos 2.1.172 → 2.1.174
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +26 -99
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +12 -63
- package/dist/model/strategy/adapter/walletPass/locales.js +3 -12
- package/dist/model/strategy/engine.d.ts +5 -18
- package/dist/model/strategy/engine.js +45 -145
- package/dist/model/strategy/type.d.ts +0 -17
- package/dist/model/strategy/type.js +0 -4
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +25 -56
- package/dist/modules/Cart/utils/changePrice.js +16 -9
- package/dist/modules/Discount/availability.d.ts +7 -0
- package/dist/modules/Discount/availability.js +52 -0
- package/dist/modules/Discount/entitlementPass.d.ts +34 -0
- package/dist/modules/Discount/entitlementPass.js +147 -0
- package/dist/modules/Discount/entitlementState.d.ts +8 -0
- package/dist/modules/Discount/entitlementState.js +205 -0
- package/dist/modules/Discount/index.d.ts +12 -3
- package/dist/modules/Discount/index.js +211 -17
- package/dist/modules/Discount/types.d.ts +42 -22
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +67 -1
- package/dist/modules/Order/index.js +923 -30
- package/dist/modules/Order/types.d.ts +176 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +128 -0
- package/dist/modules/Order/utils.js +621 -5
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Product/types.d.ts +7 -0
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -3
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +248 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/entitlementLines.d.ts +8 -0
- package/dist/modules/Rules/entitlementLines.js +157 -0
- package/dist/modules/Rules/index.d.ts +17 -11
- package/dist/modules/Rules/index.js +495 -726
- package/dist/modules/Rules/types.d.ts +2 -4
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +60 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +480 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
- package/dist/modules/ScanOrderLogger/index.js +174 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +3 -9
- package/dist/modules/Summary/utils.js +67 -57
- package/dist/modules/index.d.ts +5 -0
- package/dist/modules/index.js +6 -1
- package/dist/plugins/window.d.ts +3 -2
- package/dist/solution/BookingByStep/index.d.ts +17 -3
- package/dist/solution/BookingByStep/index.js +322 -247
- package/dist/solution/BookingByStep/types.d.ts +4 -1
- package/dist/solution/BookingByStep/types.js +7 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ScanOrder/index.d.ts +158 -0
- package/dist/solution/ScanOrder/index.js +3474 -0
- package/dist/solution/ScanOrder/types.d.ts +307 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +172 -0
- package/dist/solution/ScanOrder/utils.js +796 -0
- package/dist/solution/ShopDiscount/index.d.ts +6 -2
- package/dist/solution/ShopDiscount/index.js +194 -110
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +1 -2
- package/dist/solution/ShopDiscount/utils.d.ts +1 -0
- package/dist/solution/ShopDiscount/utils.js +52 -27
- package/dist/solution/VenueBooking/index.d.ts +225 -0
- package/dist/solution/VenueBooking/index.js +3749 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +156 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +131 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/model/strategy/adapter/promotion/evaluator.js +8 -57
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +7 -36
- package/lib/model/strategy/adapter/walletPass/locales.js +3 -12
- package/lib/model/strategy/engine.d.ts +5 -18
- package/lib/model/strategy/engine.js +21 -85
- package/lib/model/strategy/type.d.ts +0 -17
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +12 -39
- package/lib/modules/Cart/utils/changePrice.js +13 -9
- package/lib/modules/Discount/availability.d.ts +7 -0
- package/lib/modules/Discount/availability.js +91 -0
- package/lib/modules/Discount/entitlementPass.d.ts +34 -0
- package/lib/modules/Discount/entitlementPass.js +184 -0
- package/lib/modules/Discount/entitlementState.d.ts +8 -0
- package/lib/modules/Discount/entitlementState.js +206 -0
- package/lib/modules/Discount/index.d.ts +12 -3
- package/lib/modules/Discount/index.js +123 -12
- package/lib/modules/Discount/types.d.ts +42 -22
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +67 -1
- package/lib/modules/Order/index.js +529 -1
- package/lib/modules/Order/types.d.ts +176 -12
- package/lib/modules/Order/utils.d.ts +128 -0
- package/lib/modules/Order/utils.js +514 -2
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Product/types.d.ts +7 -0
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +5 -4
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +152 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/entitlementLines.d.ts +8 -0
- package/lib/modules/Rules/entitlementLines.js +158 -0
- package/lib/modules/Rules/index.d.ts +17 -11
- package/lib/modules/Rules/index.js +548 -798
- package/lib/modules/Rules/types.d.ts +2 -4
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +60 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +420 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
- package/lib/modules/ScanOrderLogger/index.js +147 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +3 -9
- package/lib/modules/Summary/utils.js +45 -34
- package/lib/modules/index.d.ts +5 -0
- package/lib/modules/index.js +11 -1
- package/lib/plugins/window.d.ts +3 -2
- package/lib/solution/BookingByStep/index.d.ts +17 -3
- package/lib/solution/BookingByStep/index.js +45 -4
- package/lib/solution/BookingByStep/types.d.ts +4 -1
- package/lib/solution/BookingByStep/types.js +15 -0
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ScanOrder/index.d.ts +158 -0
- package/lib/solution/ScanOrder/index.js +2135 -0
- package/lib/solution/ScanOrder/types.d.ts +307 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +172 -0
- package/lib/solution/ScanOrder/utils.js +658 -0
- package/lib/solution/ShopDiscount/index.d.ts +6 -2
- package/lib/solution/ShopDiscount/index.js +94 -50
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +1 -0
- package/lib/solution/ShopDiscount/utils.js +48 -11
- package/lib/solution/VenueBooking/index.d.ts +225 -0
- package/lib/solution/VenueBooking/index.js +2073 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +156 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +92 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/modules/Rules/entitlementLines.ts
|
|
30
|
+
var entitlementLines_exports = {};
|
|
31
|
+
__export(entitlementLines_exports, {
|
|
32
|
+
finalizeEntitlementLines: () => finalizeEntitlementLines,
|
|
33
|
+
isEntitlementRuntimeLine: () => isEntitlementRuntimeLine,
|
|
34
|
+
prepareEntitlementLines: () => prepareEntitlementLines,
|
|
35
|
+
rebuildEntitlementLine: () => rebuildEntitlementLine
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(entitlementLines_exports);
|
|
38
|
+
var import_lodash_es = require("lodash-es");
|
|
39
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
40
|
+
var import_entitlementPass = require("../Discount/entitlementPass");
|
|
41
|
+
var import_entitlementState = require("../Discount/entitlementState");
|
|
42
|
+
var SOURCE = "entitlement_source_identity";
|
|
43
|
+
function isManualDiscount(data) {
|
|
44
|
+
var _a;
|
|
45
|
+
return data.isManualDiscount ?? (data.total != data.origin_total && (data.bundle || []).every((item) => {
|
|
46
|
+
var _a2;
|
|
47
|
+
return !((_a2 = item.discount_list) == null ? void 0 : _a2.length);
|
|
48
|
+
}) && (!((_a = data.discount_list) == null ? void 0 : _a.length) || data.discount_list.every((item) => item.type === "product")));
|
|
49
|
+
}
|
|
50
|
+
function isEntitlementRuntimeLine(product, mappedProduct) {
|
|
51
|
+
var _a;
|
|
52
|
+
return ((_a = product.metadata) == null ? void 0 : _a[SOURCE]) != null && !(0, import_entitlementState.isPersistedEntitlementLine)(product, mappedProduct) && !isManualDiscount(mappedProduct ?? product);
|
|
53
|
+
}
|
|
54
|
+
function rebuildEntitlementLine(origin, bundle, hooks, count) {
|
|
55
|
+
const data = hooks.getProduct(origin);
|
|
56
|
+
const quantity = count ?? data.quantity ?? data.num ?? 1;
|
|
57
|
+
const discounts = (data.discount_list || []).map(
|
|
58
|
+
(item) => {
|
|
59
|
+
var _a;
|
|
60
|
+
return (0, import_entitlementPass.isEntitlementPass)(item) && !((_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id) ? { ...item, _num: quantity, metadata: { ...item.metadata, num: quantity } } : item;
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
const mainDiscount = discounts.filter((item) => {
|
|
64
|
+
var _a;
|
|
65
|
+
return !((_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id);
|
|
66
|
+
}).reduce((sum, item) => sum.plus(item.amount || 0), new import_decimal.default(0));
|
|
67
|
+
const originalPrice = new import_decimal.default(data.original_price ?? data.price ?? 0);
|
|
68
|
+
const sourceSellingPrice = originalPrice.minus(mainDiscount).toNumber();
|
|
69
|
+
const optionPrice = (data.options || []).reduce((sum, item) => sum.plus(new import_decimal.default(item.price || 0).times(item.num || 0)), new import_decimal.default(0));
|
|
70
|
+
const bundleTotal = bundle.reduce((sum, item) => sum.plus(new import_decimal.default(item.price || 0).times(item.num || 1)), new import_decimal.default(0));
|
|
71
|
+
const bundleOriginalTotal = bundle.reduce((sum, item) => sum.plus(new import_decimal.default(item.original_price ?? item.price ?? 0).times(item.num || 1)), new import_decimal.default(0));
|
|
72
|
+
return hooks.setProduct(origin, {
|
|
73
|
+
quantity,
|
|
74
|
+
discount_list: discounts,
|
|
75
|
+
bundle,
|
|
76
|
+
price: sourceSellingPrice,
|
|
77
|
+
main_product_selling_price: sourceSellingPrice,
|
|
78
|
+
total: new import_decimal.default(sourceSellingPrice).plus(optionPrice).plus(bundleTotal).toNumber(),
|
|
79
|
+
origin_total: originalPrice.plus(optionPrice).plus(bundleOriginalTotal).toNumber()
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function setLineIdentity(row, id) {
|
|
83
|
+
row._id = id;
|
|
84
|
+
row.metadata = { ...row.metadata, unique_identification_number: id };
|
|
85
|
+
if (row._extend)
|
|
86
|
+
row._extend.unique_identification_number = id;
|
|
87
|
+
return row;
|
|
88
|
+
}
|
|
89
|
+
function prepareEntitlementLines(products, hooks, canUseEntitlement) {
|
|
90
|
+
return products.flatMap((original) => {
|
|
91
|
+
var _a, _b, _c, _d;
|
|
92
|
+
const data = hooks.getProduct(original);
|
|
93
|
+
if ((0, import_entitlementState.isPersistedEntitlementLine)(original, data) || isManualDiscount(data))
|
|
94
|
+
return [original];
|
|
95
|
+
const applicable = canUseEntitlement(original);
|
|
96
|
+
if (!((_a = original.metadata) == null ? void 0 : _a[SOURCE]) && !(0, import_entitlementState.hasEntitlementDiscount)(data) && !applicable)
|
|
97
|
+
return [original];
|
|
98
|
+
const origin = (0, import_lodash_es.cloneDeep)(original);
|
|
99
|
+
origin.metadata = { ...origin.metadata, [SOURCE]: ((_b = origin.metadata) == null ? void 0 : _b[SOURCE]) ?? data._id };
|
|
100
|
+
const bundle = (data.bundle || []).map((item) => {
|
|
101
|
+
var _a2;
|
|
102
|
+
const entitlement = (item.discount_list || []).find(import_entitlementPass.isEntitlementPass);
|
|
103
|
+
if (!entitlement)
|
|
104
|
+
return item;
|
|
105
|
+
const discounts = (item.discount_list || []).filter((discount) => !(0, import_entitlementPass.isEntitlementPass)(discount));
|
|
106
|
+
const originalPrice = item.original_price ?? ((_a2 = entitlement.discount) == null ? void 0 : _a2.original_amount) ?? item.product_price ?? item.price ?? 0;
|
|
107
|
+
const amount = discounts.reduce((sum, discount) => sum.plus(discount.amount || 0), new import_decimal.default(0));
|
|
108
|
+
const price = new import_decimal.default(originalPrice).minus(amount.div(item.num || 1)).toNumber();
|
|
109
|
+
return { ...item, original_price: originalPrice, price, bundle_selling_price: price, discount_list: discounts };
|
|
110
|
+
});
|
|
111
|
+
const mainEntitlement = (_c = data.discount_list) == null ? void 0 : _c.find(import_entitlementPass.isEntitlementPass);
|
|
112
|
+
const restored = hooks.setProduct(origin, {
|
|
113
|
+
original_price: data.original_price ?? ((_d = mainEntitlement == null ? void 0 : mainEntitlement.discount) == null ? void 0 : _d.original_amount) ?? data.price,
|
|
114
|
+
discount_list: (data.discount_list || []).filter((item) => !(0, import_entitlementPass.isEntitlementPass)(item)),
|
|
115
|
+
bundle
|
|
116
|
+
});
|
|
117
|
+
const row = rebuildEntitlementLine(restored, bundle, hooks);
|
|
118
|
+
const count = Math.max(1, Math.floor(Number(data.quantity || data.num || 1)));
|
|
119
|
+
if (!applicable || count <= 1 || !bundle.length && !Array.isArray(data.holder_id))
|
|
120
|
+
return [row];
|
|
121
|
+
return Array.from({ length: count }, (_, index) => {
|
|
122
|
+
var _a2, _b2;
|
|
123
|
+
const unit = (0, import_lodash_es.cloneDeep)(row);
|
|
124
|
+
for (const source of [unit, unit._extend]) {
|
|
125
|
+
if (Array.isArray(source == null ? void 0 : source.holder_id))
|
|
126
|
+
source.holder_id = source.holder_id.slice(index, index + 1);
|
|
127
|
+
}
|
|
128
|
+
if (Array.isArray((_b2 = (_a2 = unit._origin) == null ? void 0 : _a2.holder) == null ? void 0 : _b2.form_record)) {
|
|
129
|
+
const records = unit._origin.holder.form_record;
|
|
130
|
+
if (records.length > 1)
|
|
131
|
+
unit._origin.holder.form_record = records.slice(index, index + 1);
|
|
132
|
+
}
|
|
133
|
+
return setLineIdentity(rebuildEntitlementLine(unit, hooks.getProduct(unit).bundle || [], hooks, 1), `${data._id}:entitlement-unit:${index}`);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function finalizeEntitlementLines(products, hooks) {
|
|
138
|
+
const runtime = (item) => isEntitlementRuntimeLine(item, hooks.getProduct(item));
|
|
139
|
+
const seen = new Set(products.filter((item) => !runtime(item)).map((item) => String(item._id)));
|
|
140
|
+
return products.map((origin, index) => {
|
|
141
|
+
if (!runtime(origin))
|
|
142
|
+
return origin;
|
|
143
|
+
const base = String(origin._id ?? hooks.getProduct(origin)._id);
|
|
144
|
+
let id = base;
|
|
145
|
+
let ordinal = index;
|
|
146
|
+
while (seen.has(id))
|
|
147
|
+
id = `${base}:entitlement-split:${ordinal++}`;
|
|
148
|
+
seen.add(id);
|
|
149
|
+
return id === String(origin._id) ? origin : setLineIdentity((0, import_lodash_es.cloneDeep)(origin), id);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
153
|
+
0 && (module.exports = {
|
|
154
|
+
finalizeEntitlementLines,
|
|
155
|
+
isEntitlementRuntimeLine,
|
|
156
|
+
prepareEntitlementLines,
|
|
157
|
+
rebuildEntitlementLine
|
|
158
|
+
});
|
|
@@ -1,49 +1,55 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
3
|
import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
|
|
4
|
-
import { Discount } from
|
|
5
|
-
import {
|
|
4
|
+
import { Discount } from "../Discount/types";
|
|
5
|
+
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
6
6
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
7
7
|
protected defaultName: string;
|
|
8
8
|
protected defaultVersion: string;
|
|
9
9
|
private store;
|
|
10
|
-
window: WindowPlugin;
|
|
11
10
|
private hooks;
|
|
11
|
+
private entitlementPassEnabled;
|
|
12
|
+
private defaultWalletPassEvaluator?;
|
|
13
|
+
setEntitlementPassEnabled(enabled: boolean): void;
|
|
14
|
+
private getWalletPassEvaluator;
|
|
12
15
|
constructor(name?: string, version?: string);
|
|
13
16
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
14
17
|
setRulesList(rulesList: Rules[]): Promise<void>;
|
|
15
18
|
getRulesList(): Rules[];
|
|
19
|
+
private normalizeHolderRecordIds;
|
|
20
|
+
/**
|
|
21
|
+
* 商品未开启 Holder 选择时跳过匹配;已开启时,特定 form Holder 卡
|
|
22
|
+
* 只适用于同一 Holder Record,是否必填不影响匹配规则。
|
|
23
|
+
*/
|
|
16
24
|
private checkHolderMatch;
|
|
17
|
-
|
|
18
|
-
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, orderTotalAmount, holders, isFormSubject, }: {
|
|
25
|
+
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, isFormSubject, }: {
|
|
19
26
|
oldDiscountList: Discount[];
|
|
20
27
|
newDiscountList: Discount[];
|
|
21
28
|
productList: any[];
|
|
22
29
|
holders: {
|
|
23
|
-
form_record_id: number;
|
|
30
|
+
form_record_id: number | string;
|
|
24
31
|
}[];
|
|
25
|
-
orderTotalAmount: number;
|
|
26
32
|
isFormSubject: boolean;
|
|
27
33
|
}): {
|
|
28
34
|
isAvailable: boolean;
|
|
29
35
|
discountList: Discount[];
|
|
30
36
|
productList: any[];
|
|
31
37
|
unavailableReason?: UnavailableReason;
|
|
38
|
+
evaluatedDiscountList?: Discount[];
|
|
32
39
|
};
|
|
33
40
|
filterDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
34
41
|
private getUnavailableReason;
|
|
35
|
-
calcDiscount({ discountList, productList, holders, isFormSubject,
|
|
42
|
+
calcDiscount({ discountList, productList, holders, isFormSubject, }: {
|
|
36
43
|
discountList: Discount[];
|
|
37
44
|
productList: any[];
|
|
38
45
|
holders: {
|
|
39
|
-
form_record_id: number;
|
|
46
|
+
form_record_id: number | string;
|
|
40
47
|
}[];
|
|
41
48
|
isFormSubject: boolean;
|
|
42
|
-
orderTotalAmount: number;
|
|
43
49
|
}, options?: {
|
|
44
50
|
isSelected?: boolean;
|
|
45
51
|
discountId?: number;
|
|
46
|
-
selectedList?:
|
|
52
|
+
selectedList?: SetDiscountSelectedParams[];
|
|
47
53
|
scan?: boolean;
|
|
48
54
|
}): DiscountResult;
|
|
49
55
|
/**
|