@pisell/pisellos 2.1.108 → 2.1.109
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/walletPass/evaluator.js +2 -1
- package/dist/model/strategy/adapter/walletPass/type.d.ts +11 -0
- package/dist/modules/Cart/utils/cartProduct.js +46 -25
- package/dist/modules/Discount/types.d.ts +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +171 -74
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -1
- package/lib/model/strategy/adapter/walletPass/type.d.ts +11 -0
- package/lib/modules/Cart/utils/cartProduct.js +31 -12
- package/lib/modules/Discount/types.d.ts +2 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +228 -141
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -46,6 +46,18 @@ var import_decimal = __toESM(require("decimal.js"));
|
|
|
46
46
|
var import_utils = require("../../Product/utils");
|
|
47
47
|
var import_utils2 = require("../../../solution/ShopDiscount/utils");
|
|
48
48
|
var import_utils3 = require("../../Summary/utils");
|
|
49
|
+
var toDiscountPayload = (discountItem) => {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
return {
|
|
52
|
+
amount: discountItem.amount,
|
|
53
|
+
tag: discountItem.type,
|
|
54
|
+
par_value: (_a = discountItem.discount) == null ? void 0 : _a.percent,
|
|
55
|
+
config: discountItem.config,
|
|
56
|
+
metadata: {
|
|
57
|
+
discount_card_type: (_b = discountItem == null ? void 0 : discountItem.discount) == null ? void 0 : _b.discount_card_type
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
49
61
|
var handleVariantProduct = (product) => {
|
|
50
62
|
var _a;
|
|
51
63
|
if (product == null ? void 0 : product.product_variant_id) {
|
|
@@ -192,18 +204,24 @@ var formatProductToCartItemOrigin = (params) => {
|
|
|
192
204
|
var getProductTotalPrice = (params) => {
|
|
193
205
|
const { product, bundle, options, discounts } = params;
|
|
194
206
|
let price = Number(product.price);
|
|
207
|
+
const optionRows = (options == null ? void 0 : options.map((currentValue) => ({
|
|
208
|
+
unit: Number(currentValue.price ?? currentValue.add_price ?? 0),
|
|
209
|
+
num: Number(currentValue.num ?? currentValue.quantity ?? 1)
|
|
210
|
+
}))) ?? [];
|
|
195
211
|
if (discounts == null ? void 0 : discounts.length) {
|
|
196
212
|
discounts.forEach((currentValue) => {
|
|
197
213
|
var _a;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
214
|
+
const payload = toDiscountPayload(currentValue);
|
|
215
|
+
price = (0, import_utils2.getDiscountAmount)(payload, price, price);
|
|
216
|
+
if (((_a = currentValue == null ? void 0 : currentValue.config) == null ? void 0 : _a.deductOptionPrice) && optionRows.length) {
|
|
217
|
+
for (let i = 0; i < optionRows.length; i++) {
|
|
218
|
+
const row = optionRows[i];
|
|
219
|
+
optionRows[i] = {
|
|
220
|
+
...row,
|
|
221
|
+
unit: (0, import_utils2.getDiscountAmount)(payload, row.unit, row.unit)
|
|
222
|
+
};
|
|
205
223
|
}
|
|
206
|
-
}
|
|
224
|
+
}
|
|
207
225
|
});
|
|
208
226
|
}
|
|
209
227
|
if (bundle == null ? void 0 : bundle.length) {
|
|
@@ -211,10 +229,11 @@ var getProductTotalPrice = (params) => {
|
|
|
211
229
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
212
230
|
}, price);
|
|
213
231
|
}
|
|
214
|
-
if (
|
|
215
|
-
price =
|
|
216
|
-
|
|
217
|
-
|
|
232
|
+
if (optionRows.length) {
|
|
233
|
+
price = optionRows.reduce(
|
|
234
|
+
(accumulator, row) => accumulator + row.unit * row.num,
|
|
235
|
+
price
|
|
236
|
+
);
|
|
218
237
|
}
|
|
219
238
|
return Math.max(0, price);
|
|
220
239
|
};
|
|
@@ -120,6 +120,8 @@ export interface Discount {
|
|
|
120
120
|
allowCrossProduct?: boolean;
|
|
121
121
|
/** 可用商品数量上限 */
|
|
122
122
|
applicableProductLimit?: number;
|
|
123
|
+
/** 是否抵扣单规格价格 (Option Price) */
|
|
124
|
+
deductOptionPrice?: boolean;
|
|
123
125
|
};
|
|
124
126
|
applicableProductIds?: number[];
|
|
125
127
|
applicableProductDetails: ApplicableProductDetails[];
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|