@pisell/pisellos 3.0.94 → 3.0.95
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/promotion/index.js +9 -0
- package/dist/modules/Cart/utils/changePrice.js +16 -9
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/modules/Cart/utils/changePrice.js +13 -9
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -23,8 +23,8 @@ function _updateAllCartItemPrice() {
|
|
|
23
23
|
_iterator = _createForOfIteratorHelper(cartItems);
|
|
24
24
|
_context2.prev = 1;
|
|
25
25
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
26
|
-
var _item$_productOrigin, _bundle;
|
|
27
|
-
var item, targetProduct, cartProduct, productInfo, bundle, _productInfo$variant;
|
|
26
|
+
var _item$_productOrigin$, _item$_productOrigin, _item$_origin, _targetProduct$varian, _ref, _targetVariant$price, _ref2, _targetVariant$base_p, _item$_productOrigin2, _bundle;
|
|
27
|
+
var item, targetProduct, cartProduct, productInfo, variantId, targetVariant, bundle, _productInfo$variant;
|
|
28
28
|
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
29
29
|
while (1) switch (_context.prev = _context.next) {
|
|
30
30
|
case 0:
|
|
@@ -40,10 +40,17 @@ function _updateAllCartItemPrice() {
|
|
|
40
40
|
if (!productInfo) {
|
|
41
41
|
productInfo = item._productOrigin;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
|
|
44
|
+
// 查找选择的规格id
|
|
45
|
+
variantId = (_item$_productOrigin$ = item === null || item === void 0 || (_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.product_variant_id) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : item === null || item === void 0 || (_item$_origin = item._origin) === null || _item$_origin === void 0 || (_item$_origin = _item$_origin.product) === null || _item$_origin === void 0 ? void 0 : _item$_origin.product_variant_id;
|
|
46
|
+
targetVariant = targetProduct === null || targetProduct === void 0 || (_targetProduct$varian = targetProduct.variant) === null || _targetProduct$varian === void 0 ? void 0 : _targetProduct$varian.find(function (variant) {
|
|
47
|
+
return Number(variant.id) === Number(variantId);
|
|
48
|
+
});
|
|
49
|
+
bundle = item._bundleOrigin; // productInfo.price = targetProduct?.price;
|
|
50
|
+
// productInfo.base_price = targetProduct?.base_price;
|
|
51
|
+
productInfo.price = (_ref = (_targetVariant$price = targetVariant === null || targetVariant === void 0 ? void 0 : targetVariant.price) !== null && _targetVariant$price !== void 0 ? _targetVariant$price : targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.price) !== null && _ref !== void 0 ? _ref : productInfo.price;
|
|
52
|
+
productInfo.base_price = (_ref2 = (_targetVariant$base_p = targetVariant === null || targetVariant === void 0 ? void 0 : targetVariant.base_price) !== null && _targetVariant$base_p !== void 0 ? _targetVariant$base_p : targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.base_price) !== null && _ref2 !== void 0 ? _ref2 : productInfo.base_price;
|
|
53
|
+
productInfo.product_variant_id = (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.product_variant_id;
|
|
47
54
|
bundle = (_bundle = bundle) === null || _bundle === void 0 ? void 0 : _bundle.map(function (n) {
|
|
48
55
|
var _targetProduct$bundle;
|
|
49
56
|
// 更新 bundle 的价格
|
|
@@ -75,8 +82,8 @@ function _updateAllCartItemPrice() {
|
|
|
75
82
|
// 如果有返回variant,则把对应variant的数据也补充进去
|
|
76
83
|
if (targetProduct !== null && targetProduct !== void 0 && targetProduct.variant) {
|
|
77
84
|
productInfo.variant = (_productInfo$variant = productInfo.variant) === null || _productInfo$variant === void 0 ? void 0 : _productInfo$variant.map(function (n) {
|
|
78
|
-
var _targetProduct$
|
|
79
|
-
var targetVariant = (_targetProduct$
|
|
85
|
+
var _targetProduct$varian2;
|
|
86
|
+
var targetVariant = (_targetProduct$varian2 = targetProduct.variant) === null || _targetProduct$varian2 === void 0 ? void 0 : _targetProduct$varian2.find(function (m) {
|
|
80
87
|
return m.id === n.id;
|
|
81
88
|
});
|
|
82
89
|
if (targetVariant) {
|
|
@@ -99,7 +106,7 @@ function _updateAllCartItemPrice() {
|
|
|
99
106
|
bundle: bundle,
|
|
100
107
|
options: item._optionsOrigin
|
|
101
108
|
});
|
|
102
|
-
case
|
|
109
|
+
case 17:
|
|
103
110
|
case "end":
|
|
104
111
|
return _context.stop();
|
|
105
112
|
}
|
|
@@ -71,7 +71,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
71
71
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
72
72
|
}): Promise<T>;
|
|
73
73
|
createOrder(params: CommitOrderParams['query']): {
|
|
74
|
-
type: "
|
|
74
|
+
type: "virtual" | "appointment_booking";
|
|
75
75
|
platform: string;
|
|
76
76
|
sales_channel: string;
|
|
77
77
|
order_sales_channel: string;
|
|
@@ -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
|
}
|
|
@@ -325,7 +325,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
325
325
|
date: string;
|
|
326
326
|
status: string;
|
|
327
327
|
week: string;
|
|
328
|
-
weekNum: 0 |
|
|
328
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
329
329
|
}[]>;
|
|
330
330
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
331
331
|
private getScheduleDataByIds;
|
|
@@ -34,7 +34,7 @@ __export(changePrice_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(changePrice_exports);
|
|
35
35
|
var import_decimal = __toESM(require("decimal.js"));
|
|
36
36
|
async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCart, updateItemInitInfo) {
|
|
37
|
-
var _a, _b;
|
|
37
|
+
var _a, _b, _c, _d, _e, _f;
|
|
38
38
|
for (const item of cartItems) {
|
|
39
39
|
const targetProduct = priceData.find((n) => n.id === item.id);
|
|
40
40
|
const cartProduct = await getProduct(
|
|
@@ -44,10 +44,14 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
|
|
|
44
44
|
if (!productInfo) {
|
|
45
45
|
productInfo = item._productOrigin;
|
|
46
46
|
}
|
|
47
|
+
const variantId = ((_a = item == null ? void 0 : item._productOrigin) == null ? void 0 : _a.product_variant_id) ?? ((_c = (_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.product_variant_id);
|
|
48
|
+
const targetVariant = (_d = targetProduct == null ? void 0 : targetProduct.variant) == null ? void 0 : _d.find(
|
|
49
|
+
(variant) => Number(variant.id) === Number(variantId)
|
|
50
|
+
);
|
|
47
51
|
let bundle = item._bundleOrigin;
|
|
48
|
-
productInfo.price = targetProduct == null ? void 0 : targetProduct.price;
|
|
49
|
-
productInfo.base_price = targetProduct == null ? void 0 : targetProduct.base_price;
|
|
50
|
-
productInfo.product_variant_id = (
|
|
52
|
+
productInfo.price = (targetVariant == null ? void 0 : targetVariant.price) ?? (targetProduct == null ? void 0 : targetProduct.price) ?? productInfo.price;
|
|
53
|
+
productInfo.base_price = (targetVariant == null ? void 0 : targetVariant.base_price) ?? (targetProduct == null ? void 0 : targetProduct.base_price) ?? productInfo.base_price;
|
|
54
|
+
productInfo.product_variant_id = (_e = item._productOrigin) == null ? void 0 : _e.product_variant_id;
|
|
51
55
|
bundle = bundle == null ? void 0 : bundle.map((n) => {
|
|
52
56
|
var _a2;
|
|
53
57
|
const targetBundle = (_a2 = targetProduct == null ? void 0 : targetProduct.bundle_group) == null ? void 0 : _a2.find(
|
|
@@ -76,14 +80,14 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
|
|
|
76
80
|
return n;
|
|
77
81
|
});
|
|
78
82
|
if (targetProduct == null ? void 0 : targetProduct.variant) {
|
|
79
|
-
productInfo.variant = (
|
|
83
|
+
productInfo.variant = (_f = productInfo.variant) == null ? void 0 : _f.map((n) => {
|
|
80
84
|
var _a2;
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
85
|
+
const targetVariant2 = (_a2 = targetProduct.variant) == null ? void 0 : _a2.find((m) => m.id === n.id);
|
|
86
|
+
if (targetVariant2) {
|
|
83
87
|
return {
|
|
84
88
|
...n,
|
|
85
|
-
price:
|
|
86
|
-
base_price:
|
|
89
|
+
price: targetVariant2.price,
|
|
90
|
+
base_price: targetVariant2.base_price
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
return n;
|
|
@@ -71,7 +71,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
71
71
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
72
72
|
}): Promise<T>;
|
|
73
73
|
createOrder(params: CommitOrderParams['query']): {
|
|
74
|
-
type: "
|
|
74
|
+
type: "virtual" | "appointment_booking";
|
|
75
75
|
platform: string;
|
|
76
76
|
sales_channel: string;
|
|
77
77
|
order_sales_channel: string;
|
|
@@ -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
|
}
|
|
@@ -325,7 +325,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
325
325
|
date: string;
|
|
326
326
|
status: string;
|
|
327
327
|
week: string;
|
|
328
|
-
weekNum: 0 |
|
|
328
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
329
329
|
}[]>;
|
|
330
330
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
331
331
|
private getScheduleDataByIds;
|