@pisell/pisellos 2.0.50 → 2.0.52
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/modules/Cart/utils/cartProduct.js +33 -9
- package/dist/modules/Rules/index.js +1 -1
- package/dist/solution/BookingByStep/index.js +2 -2
- package/lib/modules/Cart/utils/cartProduct.js +29 -9
- package/lib/modules/Rules/index.js +1 -1
- package/lib/solution/BookingByStep/index.js +1 -1
- package/package.json +1 -1
|
@@ -22,8 +22,9 @@ import { isNormalProduct } from "../../Product/utils";
|
|
|
22
22
|
export var handleVariantProduct = function handleVariantProduct(product) {
|
|
23
23
|
// 判断组合商品,然后直接修改 product 里的价格和 is_charge_tax
|
|
24
24
|
if (product !== null && product !== void 0 && product.product_variant_id) {
|
|
25
|
+
var _product$variant;
|
|
25
26
|
// 还需要判断 能从 variant 里找到对应的组合规格信息,才可以替换
|
|
26
|
-
var targetVariant = product.variant.find(function (n) {
|
|
27
|
+
var targetVariant = product === null || product === void 0 || (_product$variant = product.variant) === null || _product$variant === void 0 ? void 0 : _product$variant.find(function (n) {
|
|
27
28
|
return n.id === product.product_variant_id;
|
|
28
29
|
});
|
|
29
30
|
if (targetVariant) {
|
|
@@ -45,6 +46,7 @@ export var handleVariantProduct = function handleVariantProduct(product) {
|
|
|
45
46
|
*/
|
|
46
47
|
export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
47
48
|
var _product$custom_depos;
|
|
49
|
+
console.log('formatProductToCartItem>>>>>>', params);
|
|
48
50
|
var cartItem = params.cartItem,
|
|
49
51
|
product = params.product,
|
|
50
52
|
bundle = params.bundle,
|
|
@@ -88,17 +90,17 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
88
90
|
}
|
|
89
91
|
// 拼装出 product_option_string
|
|
90
92
|
if (product_variant_id) {
|
|
91
|
-
var _product$
|
|
92
|
-
var sku_key = (_product$
|
|
93
|
+
var _product$variant2;
|
|
94
|
+
var sku_key = product === null || product === void 0 || (_product$variant2 = product.variant) === null || _product$variant2 === void 0 || (_product$variant2 = _product$variant2.find(function (n) {
|
|
93
95
|
return n.id === product_variant_id;
|
|
94
|
-
})) === null || _product$
|
|
96
|
+
})) === null || _product$variant2 === void 0 ? void 0 : _product$variant2.sku_key;
|
|
95
97
|
if (sku_key) {
|
|
96
98
|
var sku_key_arr = sku_key.split('_');
|
|
97
99
|
var product_option_string = [];
|
|
98
100
|
sku_key_arr.forEach(function (item) {
|
|
99
|
-
var _targetVariantGroup$v;
|
|
101
|
+
var _product$variant_grou, _targetVariantGroup$v;
|
|
100
102
|
var keyMap = item.split(':');
|
|
101
|
-
var targetVariantGroup = product.variant_group.find(function (n) {
|
|
103
|
+
var targetVariantGroup = product === null || product === void 0 || (_product$variant_grou = product.variant_group) === null || _product$variant_grou === void 0 ? void 0 : _product$variant_grou.find(function (n) {
|
|
102
104
|
return String(n.position_id) === keyMap[0];
|
|
103
105
|
});
|
|
104
106
|
var targetVariantItem = targetVariantGroup === null || targetVariantGroup === void 0 || (_targetVariantGroup$v = targetVariantGroup.variant_item) === null || _targetVariantGroup$v === void 0 ? void 0 : _targetVariantGroup$v.find(function (n) {
|
|
@@ -344,16 +346,38 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
344
346
|
productHasDeposit = true;
|
|
345
347
|
}
|
|
346
348
|
} else {
|
|
349
|
+
// 组合规格商品
|
|
350
|
+
if (product !== null && product !== void 0 && product.product_variant_id) {
|
|
351
|
+
var _product$variant3;
|
|
352
|
+
var variantProduct = product === null || product === void 0 || (_product$variant3 = product.variant) === null || _product$variant3 === void 0 ? void 0 : _product$variant3.find(function (item) {
|
|
353
|
+
return (item === null || item === void 0 ? void 0 : item.id) === (product === null || product === void 0 ? void 0 : product.product_variant_id);
|
|
354
|
+
});
|
|
355
|
+
if (variantProduct) {
|
|
356
|
+
var depositData = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.custom_deposit_data;
|
|
357
|
+
var _handleProductDeposit2 = handleProductDeposit({
|
|
358
|
+
depositData: depositData,
|
|
359
|
+
total: (cartItem === null || cartItem === void 0 ? void 0 : cartItem.total) || 0,
|
|
360
|
+
num: num
|
|
361
|
+
}),
|
|
362
|
+
_depositTotal = _handleProductDeposit2.depositTotal,
|
|
363
|
+
_result = _handleProductDeposit2.result;
|
|
364
|
+
if (_result) {
|
|
365
|
+
total = _depositTotal;
|
|
366
|
+
protocolIds.push.apply(protocolIds, _toConsumableArray((depositData === null || depositData === void 0 ? void 0 : depositData.self_deposit_policy_ids) || []));
|
|
367
|
+
productHasDeposit = true;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
347
371
|
if (bundle !== null && bundle !== void 0 && bundle.length) {
|
|
348
372
|
total = bundle.reduce(function (accumulator, currBundleProduct) {
|
|
349
373
|
var depositData = currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.custom_deposit_data;
|
|
350
|
-
var
|
|
374
|
+
var _handleProductDeposit3 = handleProductDeposit({
|
|
351
375
|
depositData: depositData,
|
|
352
376
|
total: currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.price,
|
|
353
377
|
num: (currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.num) || 1
|
|
354
378
|
}),
|
|
355
|
-
depositTotal =
|
|
356
|
-
result =
|
|
379
|
+
depositTotal = _handleProductDeposit3.depositTotal,
|
|
380
|
+
result = _handleProductDeposit3.result;
|
|
357
381
|
if (result) {
|
|
358
382
|
protocolIds.push.apply(protocolIds, _toConsumableArray((depositData === null || depositData === void 0 ? void 0 : depositData.self_deposit_policy_ids) || []));
|
|
359
383
|
productHasDeposit = true;
|
|
@@ -441,7 +441,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
441
441
|
productOriginTotal = product.total;
|
|
442
442
|
}
|
|
443
443
|
// 如果当前 product 有 discount_list,则必须从 origin_total 拿
|
|
444
|
-
if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.length) {
|
|
444
|
+
if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.length && product.origin_total) {
|
|
445
445
|
productOriginTotal = product.origin_total;
|
|
446
446
|
}
|
|
447
447
|
|
|
@@ -2182,12 +2182,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2182
2182
|
value: 10
|
|
2183
2183
|
};
|
|
2184
2184
|
resource.startTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
2185
|
-
// 找到resource.times
|
|
2185
|
+
// 找到resource.times里最晚的end_at
|
|
2186
2186
|
var targetResourceTimes = allResources === null || allResources === void 0 || (_allResources$find = allResources.find(function (n) {
|
|
2187
2187
|
return n.id === resource.id;
|
|
2188
2188
|
})) === null || _allResources$find === void 0 ? void 0 : _allResources$find.times;
|
|
2189
2189
|
var resourcesEndTime = targetResourceTimes.reduce(function (acc, curr) {
|
|
2190
|
-
return dayjs(curr.end_at).
|
|
2190
|
+
return dayjs(curr.end_at).isAfter(dayjs(acc.end_at)) ? curr : acc;
|
|
2191
2191
|
}, targetResourceTimes[0]);
|
|
2192
2192
|
|
|
2193
2193
|
// 将 operating_day_boundary 转换为与 resourcesEndTime.end_at 相同日期的完整日期时间
|
|
@@ -45,8 +45,9 @@ module.exports = __toCommonJS(cartProduct_exports);
|
|
|
45
45
|
var import_decimal = __toESM(require("decimal.js"));
|
|
46
46
|
var import_utils = require("../../Product/utils");
|
|
47
47
|
var handleVariantProduct = (product) => {
|
|
48
|
+
var _a;
|
|
48
49
|
if (product == null ? void 0 : product.product_variant_id) {
|
|
49
|
-
const targetVariant = product.variant.find(
|
|
50
|
+
const targetVariant = (_a = product == null ? void 0 : product.variant) == null ? void 0 : _a.find(
|
|
50
51
|
(n) => n.id === product.product_variant_id
|
|
51
52
|
);
|
|
52
53
|
if (targetVariant) {
|
|
@@ -60,7 +61,8 @@ var handleVariantProduct = (product) => {
|
|
|
60
61
|
return product;
|
|
61
62
|
};
|
|
62
63
|
var formatProductToCartItem = (params) => {
|
|
63
|
-
var _a, _b;
|
|
64
|
+
var _a, _b, _c;
|
|
65
|
+
console.log("formatProductToCartItem>>>>>>", params);
|
|
64
66
|
const {
|
|
65
67
|
cartItem,
|
|
66
68
|
product,
|
|
@@ -98,19 +100,19 @@ var formatProductToCartItem = (params) => {
|
|
|
98
100
|
cartItem.options = formatOptions(options);
|
|
99
101
|
}
|
|
100
102
|
if (product_variant_id) {
|
|
101
|
-
const sku_key = (_a = product.variant.find(
|
|
103
|
+
const sku_key = (_b = (_a = product == null ? void 0 : product.variant) == null ? void 0 : _a.find(
|
|
102
104
|
(n) => n.id === product_variant_id
|
|
103
|
-
)) == null ? void 0 :
|
|
105
|
+
)) == null ? void 0 : _b.sku_key;
|
|
104
106
|
if (sku_key) {
|
|
105
107
|
const sku_key_arr = sku_key.split("_");
|
|
106
108
|
const product_option_string = [];
|
|
107
109
|
sku_key_arr.forEach((item) => {
|
|
108
|
-
var _a2;
|
|
110
|
+
var _a2, _b2;
|
|
109
111
|
const keyMap = item.split(":");
|
|
110
|
-
const targetVariantGroup = product.variant_group.find(
|
|
112
|
+
const targetVariantGroup = (_a2 = product == null ? void 0 : product.variant_group) == null ? void 0 : _a2.find(
|
|
111
113
|
(n) => String(n.position_id) === keyMap[0]
|
|
112
114
|
);
|
|
113
|
-
const targetVariantItem = (
|
|
115
|
+
const targetVariantItem = (_b2 = targetVariantGroup == null ? void 0 : targetVariantGroup.variant_item) == null ? void 0 : _b2.find(
|
|
114
116
|
(n) => String(n.position_id) === keyMap[1]
|
|
115
117
|
);
|
|
116
118
|
if (targetVariantGroup && targetVariantItem) {
|
|
@@ -122,7 +124,7 @@ var formatProductToCartItem = (params) => {
|
|
|
122
124
|
cartItem.product_option_string = product_option_string.join(", ");
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
|
-
if (((
|
|
127
|
+
if (((_c = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _c.has_deposit) == 1) {
|
|
126
128
|
cartItem.deposit = getProductDeposit({
|
|
127
129
|
cartItem,
|
|
128
130
|
product,
|
|
@@ -268,7 +270,7 @@ var formatBundleToOrigin = (bundle) => {
|
|
|
268
270
|
});
|
|
269
271
|
};
|
|
270
272
|
var getProductDeposit = (params) => {
|
|
271
|
-
var _a;
|
|
273
|
+
var _a, _b;
|
|
272
274
|
const { cartItem, product, bundle, options } = params;
|
|
273
275
|
const num = (params == null ? void 0 : params.num) || 1;
|
|
274
276
|
if (((_a = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _a.has_deposit) == 1) {
|
|
@@ -294,6 +296,24 @@ var getProductDeposit = (params) => {
|
|
|
294
296
|
productHasDeposit = true;
|
|
295
297
|
}
|
|
296
298
|
} else {
|
|
299
|
+
if (product == null ? void 0 : product.product_variant_id) {
|
|
300
|
+
const variantProduct = (_b = product == null ? void 0 : product.variant) == null ? void 0 : _b.find(
|
|
301
|
+
(item) => (item == null ? void 0 : item.id) === (product == null ? void 0 : product.product_variant_id)
|
|
302
|
+
);
|
|
303
|
+
if (variantProduct) {
|
|
304
|
+
const depositData = variantProduct == null ? void 0 : variantProduct.custom_deposit_data;
|
|
305
|
+
const { depositTotal, result } = handleProductDeposit({
|
|
306
|
+
depositData,
|
|
307
|
+
total: (cartItem == null ? void 0 : cartItem.total) || 0,
|
|
308
|
+
num
|
|
309
|
+
});
|
|
310
|
+
if (result) {
|
|
311
|
+
total = depositTotal;
|
|
312
|
+
protocolIds.push(...(depositData == null ? void 0 : depositData.self_deposit_policy_ids) || []);
|
|
313
|
+
productHasDeposit = true;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
297
317
|
if (bundle == null ? void 0 : bundle.length) {
|
|
298
318
|
total = bundle.reduce((accumulator, currBundleProduct) => {
|
|
299
319
|
const depositData = currBundleProduct == null ? void 0 : currBundleProduct.custom_deposit_data;
|
|
@@ -301,7 +301,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
301
301
|
if (Number(((_g = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _g.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
|
|
302
302
|
productOriginTotal = product.total;
|
|
303
303
|
}
|
|
304
|
-
if ((_h = product.discount_list) == null ? void 0 : _h.length) {
|
|
304
|
+
if (((_h = product.discount_list) == null ? void 0 : _h.length) && product.origin_total) {
|
|
305
305
|
productOriginTotal = product.origin_total;
|
|
306
306
|
}
|
|
307
307
|
const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(productOriginTotal).minus(new import_decimal.default(product.price || 0)).toNumber() : new import_decimal.default(100).minus(selectedDiscount2.par_value || 0).div(100).mul(new import_decimal.default(productOriginTotal)).toNumber();
|
|
@@ -1510,7 +1510,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1510
1510
|
)) == null ? void 0 : _c.times;
|
|
1511
1511
|
const resourcesEndTime = targetResourceTimes.reduce(
|
|
1512
1512
|
(acc, curr) => {
|
|
1513
|
-
return (0, import_dayjs.default)(curr.end_at).
|
|
1513
|
+
return (0, import_dayjs.default)(curr.end_at).isAfter((0, import_dayjs.default)(acc.end_at)) ? curr : acc;
|
|
1514
1514
|
},
|
|
1515
1515
|
targetResourceTimes[0]
|
|
1516
1516
|
);
|