@pisell/pisellos 0.0.486 → 0.0.488
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/Discount/types.d.ts +8 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +50 -11
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +50 -48
- package/lib/modules/Discount/types.d.ts +8 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +20 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +12 -13
- package/package.json +1 -1
|
@@ -18,6 +18,14 @@ interface Formattitle {
|
|
|
18
18
|
interface PackageSubItemUsageRules {
|
|
19
19
|
type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
|
|
20
20
|
rules: ("original_price" | "markup_price")[];
|
|
21
|
+
package_scope?: {
|
|
22
|
+
type: 'all_packages' | 'specific_packages';
|
|
23
|
+
exclude_bundle_product_ids: number[];
|
|
24
|
+
include_bundle_product_ids: number[];
|
|
25
|
+
filter: 0 | 1;
|
|
26
|
+
rule: any[];
|
|
27
|
+
rule_type: 'and' | 'or';
|
|
28
|
+
};
|
|
21
29
|
}
|
|
22
30
|
interface Limitedrelationproductdata {
|
|
23
31
|
id: number;
|
|
@@ -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(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -2344,6 +2344,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2344
2344
|
return true;
|
|
2345
2345
|
}
|
|
2346
2346
|
var ruleType = usageRules.type;
|
|
2347
|
+
// 套餐适用范围配置
|
|
2348
|
+
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
2349
|
+
var _ref14 = packageScope || {},
|
|
2350
|
+
scopeType = _ref14.type,
|
|
2351
|
+
_ref14$exclude_bundle = _ref14.exclude_bundle_product_ids,
|
|
2352
|
+
exclude_bundle_product_ids = _ref14$exclude_bundle === void 0 ? [] : _ref14$exclude_bundle,
|
|
2353
|
+
_ref14$include_bundle = _ref14.include_bundle_product_ids,
|
|
2354
|
+
include_bundle_product_ids = _ref14$include_bundle === void 0 ? [] : _ref14$include_bundle,
|
|
2355
|
+
_ref14$filter = _ref14.filter,
|
|
2356
|
+
filter = _ref14$filter === void 0 ? 0 : _ref14$filter;
|
|
2347
2357
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2348
2358
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2349
2359
|
|
|
@@ -2358,10 +2368,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2358
2368
|
return true; // 单独购买时可用
|
|
2359
2369
|
}
|
|
2360
2370
|
if (isBundleItem) {
|
|
2361
|
-
var _flatItem$bundleItem9, _flatItem$bundleItem10;
|
|
2371
|
+
var _flatItem$bundleItem9, _flatItem$bundleItem10, _flatItem$originProdu, _flatItem$originProdu2;
|
|
2362
2372
|
// 套餐中购买时,判断是否为原价
|
|
2363
2373
|
var priceType = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type;
|
|
2364
2374
|
var priceTypeExt = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type_ext;
|
|
2375
|
+
// 主商品id
|
|
2376
|
+
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.product_id) || (flatItem === null || flatItem === void 0 || (_flatItem$originProdu2 = flatItem.originProduct) === null || _flatItem$originProdu2 === void 0 ? void 0 : _flatItem$originProdu2.id);
|
|
2365
2377
|
// original_price 对应:
|
|
2366
2378
|
// 1. price_type: "markup" && price_type_ext: "product_price"
|
|
2367
2379
|
// markup_price 对应:
|
|
@@ -2373,16 +2385,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2373
2385
|
|
|
2374
2386
|
// 检查 rules
|
|
2375
2387
|
if (rules.length > 0) {
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2388
|
+
var _isOriginalPrice = isOriginalPrice && rules.includes('original_price');
|
|
2389
|
+
var _isMarkupPrice = isMarkupPrice && rules.includes('markup_price');
|
|
2390
|
+
// 价格是否符合规则:原价或加价
|
|
2391
|
+
var isPriceValid = _isOriginalPrice || _isMarkupPrice;
|
|
2392
|
+
// 套餐适用范围校验
|
|
2393
|
+
var isScopeValid = false;
|
|
2394
|
+
|
|
2395
|
+
// 排除套餐判断
|
|
2396
|
+
if (scopeType === 'all_packages') {
|
|
2397
|
+
// 所有套餐可用
|
|
2398
|
+
if (!filter) {
|
|
2399
|
+
isScopeValid = true;
|
|
2400
|
+
} else {
|
|
2401
|
+
isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
|
|
2402
|
+
}
|
|
2379
2403
|
}
|
|
2380
2404
|
|
|
2381
|
-
//
|
|
2382
|
-
if (
|
|
2405
|
+
// 包含套餐判断
|
|
2406
|
+
if (scopeType === 'specific_packages') {
|
|
2407
|
+
isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
// 价格和套餐适用范围都符合,则可用
|
|
2411
|
+
if (isPriceValid && isScopeValid) {
|
|
2383
2412
|
return true;
|
|
2384
2413
|
}
|
|
2385
2414
|
|
|
2415
|
+
// 检查原价
|
|
2416
|
+
// if (isOriginalPrice && rules.includes('original_price')) {
|
|
2417
|
+
// return true;
|
|
2418
|
+
// }
|
|
2419
|
+
|
|
2420
|
+
// 检查加价
|
|
2421
|
+
// if (isMarkupPrice && rules.includes('markup_price')) {
|
|
2422
|
+
// return true;
|
|
2423
|
+
// }
|
|
2424
|
+
|
|
2386
2425
|
// 如果都不匹配,则不可用
|
|
2387
2426
|
return false;
|
|
2388
2427
|
}
|
|
@@ -2409,19 +2448,19 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2409
2448
|
// markup_price 对应:
|
|
2410
2449
|
// price_type: "markup" && price_type_ext: ""
|
|
2411
2450
|
/** 原价 */
|
|
2412
|
-
var
|
|
2451
|
+
var _isOriginalPrice2 = _priceType === 'markup' && _priceTypeExt === 'product_price';
|
|
2413
2452
|
/** 加价 */
|
|
2414
|
-
var
|
|
2453
|
+
var _isMarkupPrice2 = _priceType === 'markup' && (_priceTypeExt === '' || !_priceTypeExt);
|
|
2415
2454
|
|
|
2416
2455
|
// 检查 rules
|
|
2417
2456
|
if (rules.length > 0) {
|
|
2418
2457
|
// 检查原价
|
|
2419
|
-
if (
|
|
2458
|
+
if (_isOriginalPrice2 && rules.includes('original_price')) {
|
|
2420
2459
|
return true;
|
|
2421
2460
|
}
|
|
2422
2461
|
|
|
2423
2462
|
// 检查加价
|
|
2424
|
-
if (
|
|
2463
|
+
if (_isMarkupPrice2 && rules.includes('markup_price')) {
|
|
2425
2464
|
return true;
|
|
2426
2465
|
}
|
|
2427
2466
|
|
|
@@ -2430,7 +2469,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2430
2469
|
}
|
|
2431
2470
|
|
|
2432
2471
|
// 原价包括:price_type: "markup" && price_type_ext: "product_price"
|
|
2433
|
-
return
|
|
2472
|
+
return _isOriginalPrice2;
|
|
2434
2473
|
}
|
|
2435
2474
|
return false;
|
|
2436
2475
|
}
|
|
@@ -358,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
358
358
|
};
|
|
359
359
|
setOtherData(key: string, value: any): void;
|
|
360
360
|
getOtherData(key: string): any;
|
|
361
|
-
getProductTypeById(id: number): Promise<"
|
|
361
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
362
362
|
/**
|
|
363
363
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
364
364
|
*
|
|
@@ -1791,7 +1791,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1791
1791
|
}
|
|
1792
1792
|
// 计算在时间片内有交集的预约容量总和
|
|
1793
1793
|
var totalCapacity = (countMap[n.id] || []).reduce(function (sum, item) {
|
|
1794
|
-
var hasOverlap =
|
|
1794
|
+
var hasOverlap = dayjs(item.time.start_at).isBefore(dayjs(timeSlots.end_at)) && dayjs(item.time.end_at).isAfter(dayjs(timeSlots.start_at));
|
|
1795
1795
|
return hasOverlap ? sum + item.pax : sum;
|
|
1796
1796
|
}, 0);
|
|
1797
1797
|
|
|
@@ -1898,8 +1898,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1898
1898
|
cartItems.forEach(function (item, index) {
|
|
1899
1899
|
var _getCapacityInfoByCar6 = getCapacityInfoByCartItem(item),
|
|
1900
1900
|
currentCapacity = _getCapacityInfoByCar6.currentCapacity;
|
|
1901
|
+
var hasOriginTimeSlot = Boolean(item._origin.start_time) && Boolean(item._origin.end_time) && !(timeSlots !== null && timeSlots !== void 0 && timeSlots.start_time);
|
|
1901
1902
|
// 如果商品已经有时间数据了,意味着是通过先选日期再选商品流程进来的,相当于时间切片已经选中了
|
|
1902
|
-
if (
|
|
1903
|
+
if (hasOriginTimeSlot) {
|
|
1903
1904
|
recordTimeSlots = {
|
|
1904
1905
|
start_time: item._origin.start_time,
|
|
1905
1906
|
end_time: item._origin.end_time,
|
|
@@ -1915,10 +1916,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1915
1916
|
return n.code === resources_code;
|
|
1916
1917
|
});
|
|
1917
1918
|
// 只有 duration 类商品且不含有灵活时间的商品需要这个操作
|
|
1918
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin3 = item._productOrigin) !== null && _item$_productOrigin3 !== void 0 && _item$_productOrigin3.duration && !hasFlexibleProduct) {
|
|
1919
|
-
var _item$_productOrigin4
|
|
1920
|
-
var
|
|
1921
|
-
var
|
|
1919
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin3 = item._productOrigin) !== null && _item$_productOrigin3 !== void 0 && _item$_productOrigin3.duration && !hasFlexibleProduct && !hasOriginTimeSlot) {
|
|
1920
|
+
var _item$_productOrigin4;
|
|
1921
|
+
var recordEndAt = recordTimeSlots.end_at ? dayjs(recordTimeSlots.end_at) : dayjs("".concat(item.start_date, " ").concat(recordTimeSlots.end_time));
|
|
1922
|
+
var start_at = recordEndAt;
|
|
1923
|
+
var end_at = start_at.add(((_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) || 10, 'minutes');
|
|
1922
1924
|
recordTimeSlots = {
|
|
1923
1925
|
start_time: start_at.format('HH:mm'),
|
|
1924
1926
|
end_time: end_at.format('HH:mm'),
|
|
@@ -1962,13 +1964,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1962
1964
|
errorList.push(item._id);
|
|
1963
1965
|
}
|
|
1964
1966
|
} else {
|
|
1965
|
-
var _item$
|
|
1967
|
+
var _item$_productOrigin5, _productResources$fin;
|
|
1966
1968
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1967
1969
|
// 能进到这种逻辑,说明是 duration 类商品或者灵活时长商品,且是第一种资源,还没有确定时间
|
|
1968
1970
|
var allCartItems = cloneDeep(_this11.store.cart.getItems());
|
|
1969
1971
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1970
1972
|
var selectedResources = [];
|
|
1971
|
-
var _resources = cloneDeep(((_item$
|
|
1973
|
+
var _resources = cloneDeep(((_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.product_resource) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.resources) || []);
|
|
1972
1974
|
var currentResourcesRenderList = [];
|
|
1973
1975
|
_resources.forEach(function (n) {
|
|
1974
1976
|
var _n$renderList;
|
|
@@ -2084,8 +2086,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2084
2086
|
var maxCutOffTime = undefined;
|
|
2085
2087
|
var maxCutOffTimeValue = dayjs();
|
|
2086
2088
|
cartItems.forEach(function (item) {
|
|
2087
|
-
var _item$
|
|
2088
|
-
(_item$
|
|
2089
|
+
var _item$_productOrigin6, _item$_productOrigin7, _item$_productOrigin8, _item$_productOrigin9;
|
|
2090
|
+
(_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.product_resource) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.resources) === null || _item$_productOrigin6 === void 0 || _item$_productOrigin6.forEach(function (n) {
|
|
2089
2091
|
// TODO: 少了个 status 的判断
|
|
2090
2092
|
if (n.code === resources_code) {
|
|
2091
2093
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2098,10 +2100,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2098
2100
|
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2099
2101
|
resourceIds.push(item.resource_id);
|
|
2100
2102
|
}
|
|
2101
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2103
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.product_resource) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.resources) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.find(function (n) {
|
|
2102
2104
|
return n.code === resources_code;
|
|
2103
|
-
})) === null || _item$
|
|
2104
|
-
if ((_item$
|
|
2105
|
+
})) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.id;
|
|
2106
|
+
if ((_item$_productOrigin8 = item._productOrigin) !== null && _item$_productOrigin8 !== void 0 && _item$_productOrigin8.cut_off_time && ((_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.cut_off_time.type) === 'advance') {
|
|
2105
2107
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2106
2108
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2107
2109
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2151,13 +2153,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2151
2153
|
cartItems.forEach(function (item) {
|
|
2152
2154
|
// 单个预约累加账号 多个预约取最大值
|
|
2153
2155
|
if (isSingleResource) {
|
|
2154
|
-
var _item$
|
|
2155
|
-
accountDuration += ((_item$
|
|
2156
|
+
var _item$_productOrigin10;
|
|
2157
|
+
accountDuration += ((_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) || 10;
|
|
2156
2158
|
} else {
|
|
2157
|
-
var _item$
|
|
2158
|
-
if (accountDuration < (((_item$
|
|
2159
|
-
var _item$
|
|
2160
|
-
accountDuration = ((_item$
|
|
2159
|
+
var _item$_productOrigin11;
|
|
2160
|
+
if (accountDuration < (((_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) || 10)) {
|
|
2161
|
+
var _item$_productOrigin12;
|
|
2162
|
+
accountDuration = ((_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.value) || 10;
|
|
2161
2163
|
}
|
|
2162
2164
|
}
|
|
2163
2165
|
});
|
|
@@ -2194,8 +2196,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2194
2196
|
}
|
|
2195
2197
|
var resourcesUseableMap = {};
|
|
2196
2198
|
var hasFlexibleDuration = cartItems.some(function (item) {
|
|
2197
|
-
var _item$
|
|
2198
|
-
return ((_item$
|
|
2199
|
+
var _item$_productOrigin13;
|
|
2200
|
+
return ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.type) === 'flexible';
|
|
2199
2201
|
});
|
|
2200
2202
|
var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.operating_day_boundary;
|
|
2201
2203
|
|
|
@@ -2203,11 +2205,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2203
2205
|
var maxBlockThreshold = 0;
|
|
2204
2206
|
if (hasFlexibleDuration) {
|
|
2205
2207
|
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2206
|
-
var _item$
|
|
2208
|
+
var _item$_productOrigin14;
|
|
2207
2209
|
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2208
|
-
if ((_item$
|
|
2209
|
-
var _item$
|
|
2210
|
-
return Math.max(max, ((_item$
|
|
2210
|
+
if ((_item$_productOrigin14 = item._productOrigin) !== null && _item$_productOrigin14 !== void 0 && (_item$_productOrigin14 = _item$_productOrigin14.duration) !== null && _item$_productOrigin14 !== void 0 && (_item$_productOrigin14 = _item$_productOrigin14.flexible_config) !== null && _item$_productOrigin14 !== void 0 && _item$_productOrigin14.is_enable_minimum_duration) {
|
|
2211
|
+
var _item$_productOrigin15;
|
|
2212
|
+
return Math.max(max, ((_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.flexible_config) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.block_threshold) || 0);
|
|
2211
2213
|
}
|
|
2212
2214
|
return 0;
|
|
2213
2215
|
}, 0);
|
|
@@ -2299,8 +2301,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2299
2301
|
maxCutOffTime = undefined;
|
|
2300
2302
|
maxCutOffTimeValue = dayjs();
|
|
2301
2303
|
cartItems.forEach(function (item) {
|
|
2302
|
-
var _item$
|
|
2303
|
-
(_item$
|
|
2304
|
+
var _item$_productOrigin16, _item$_productOrigin17, _item$_productOrigin18, _item$_productOrigin19;
|
|
2305
|
+
(_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.product_resource) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.resources) === null || _item$_productOrigin16 === void 0 || _item$_productOrigin16.forEach(function (n) {
|
|
2304
2306
|
// TODO: 少了个 status 的判断
|
|
2305
2307
|
if (n.code === resources_code) {
|
|
2306
2308
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2313,10 +2315,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2313
2315
|
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2314
2316
|
resourceIds.push(item.resource_id);
|
|
2315
2317
|
}
|
|
2316
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2318
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.product_resource) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.resources) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.find(function (n) {
|
|
2317
2319
|
return n.code === resources_code;
|
|
2318
|
-
})) === null || _item$
|
|
2319
|
-
if ((_item$
|
|
2320
|
+
})) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.id;
|
|
2321
|
+
if ((_item$_productOrigin18 = item._productOrigin) !== null && _item$_productOrigin18 !== void 0 && _item$_productOrigin18.cut_off_time && ((_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.cut_off_time.type) === 'advance') {
|
|
2320
2322
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2321
2323
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2322
2324
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2339,13 +2341,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2339
2341
|
cartItems.forEach(function (item) {
|
|
2340
2342
|
// 单个预约累加账号 多个预约取最大值
|
|
2341
2343
|
if (isSingleResource) {
|
|
2342
|
-
var _item$
|
|
2343
|
-
accountDuration += ((_item$
|
|
2344
|
+
var _item$_productOrigin20;
|
|
2345
|
+
accountDuration += ((_item$_productOrigin20 = item._productOrigin) === null || _item$_productOrigin20 === void 0 || (_item$_productOrigin20 = _item$_productOrigin20.duration) === null || _item$_productOrigin20 === void 0 ? void 0 : _item$_productOrigin20.value) || 10;
|
|
2344
2346
|
} else {
|
|
2345
|
-
var _item$
|
|
2346
|
-
if (accountDuration < (((_item$
|
|
2347
|
-
var _item$
|
|
2348
|
-
accountDuration = ((_item$
|
|
2347
|
+
var _item$_productOrigin21;
|
|
2348
|
+
if (accountDuration < (((_item$_productOrigin21 = item._productOrigin) === null || _item$_productOrigin21 === void 0 || (_item$_productOrigin21 = _item$_productOrigin21.duration) === null || _item$_productOrigin21 === void 0 ? void 0 : _item$_productOrigin21.value) || 10)) {
|
|
2349
|
+
var _item$_productOrigin22;
|
|
2350
|
+
accountDuration = ((_item$_productOrigin22 = item._productOrigin) === null || _item$_productOrigin22 === void 0 || (_item$_productOrigin22 = _item$_productOrigin22.duration) === null || _item$_productOrigin22 === void 0 ? void 0 : _item$_productOrigin22.value) || 10;
|
|
2349
2351
|
}
|
|
2350
2352
|
}
|
|
2351
2353
|
});
|
|
@@ -2371,18 +2373,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2371
2373
|
case 20:
|
|
2372
2374
|
resourcesUseableMap = {};
|
|
2373
2375
|
hasFlexibleDuration = cartItems.some(function (item) {
|
|
2374
|
-
var _item$
|
|
2375
|
-
return ((_item$
|
|
2376
|
+
var _item$_productOrigin23;
|
|
2377
|
+
return ((_item$_productOrigin23 = item._productOrigin) === null || _item$_productOrigin23 === void 0 || (_item$_productOrigin23 = _item$_productOrigin23.duration) === null || _item$_productOrigin23 === void 0 ? void 0 : _item$_productOrigin23.type) === 'flexible';
|
|
2376
2378
|
});
|
|
2377
2379
|
operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.operating_day_boundary; // 如果有 hasFlexibleDuration,需要把动态时长商品(可能是多个,取最长的那个最低禁止购买时长)的最低禁止购买时长作为 split 的值
|
|
2378
2380
|
maxBlockThreshold = 0;
|
|
2379
2381
|
if (hasFlexibleDuration) {
|
|
2380
2382
|
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2381
|
-
var _item$
|
|
2383
|
+
var _item$_productOrigin24;
|
|
2382
2384
|
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2383
|
-
if ((_item$
|
|
2384
|
-
var _item$
|
|
2385
|
-
return Math.max(max, ((_item$
|
|
2385
|
+
if ((_item$_productOrigin24 = item._productOrigin) !== null && _item$_productOrigin24 !== void 0 && (_item$_productOrigin24 = _item$_productOrigin24.duration) !== null && _item$_productOrigin24 !== void 0 && (_item$_productOrigin24 = _item$_productOrigin24.flexible_config) !== null && _item$_productOrigin24 !== void 0 && _item$_productOrigin24.is_enable_minimum_duration) {
|
|
2386
|
+
var _item$_productOrigin25;
|
|
2387
|
+
return Math.max(max, ((_item$_productOrigin25 = item._productOrigin) === null || _item$_productOrigin25 === void 0 || (_item$_productOrigin25 = _item$_productOrigin25.duration) === null || _item$_productOrigin25 === void 0 || (_item$_productOrigin25 = _item$_productOrigin25.flexible_config) === null || _item$_productOrigin25 === void 0 ? void 0 : _item$_productOrigin25.block_threshold) || 0);
|
|
2386
2388
|
}
|
|
2387
2389
|
return 0;
|
|
2388
2390
|
}, 0);
|
|
@@ -2543,10 +2545,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2543
2545
|
var osWarnTips = [];
|
|
2544
2546
|
var newResources = cloneDeep(item._origin.resources);
|
|
2545
2547
|
newResources.forEach(function (resource) {
|
|
2546
|
-
var _item$
|
|
2548
|
+
var _item$_productOrigin26;
|
|
2547
2549
|
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2548
|
-
if (((_item$
|
|
2549
|
-
var _allResources$find, _item$
|
|
2550
|
+
if (((_item$_productOrigin26 = item._productOrigin) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.duration) === null || _item$_productOrigin26 === void 0 ? void 0 : _item$_productOrigin26.type) === 'flexible') {
|
|
2551
|
+
var _allResources$find, _item$_productOrigin27, _item$_productOrigin28;
|
|
2550
2552
|
item.duration = {
|
|
2551
2553
|
type: 'minutes',
|
|
2552
2554
|
value: 10
|
|
@@ -2629,15 +2631,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2629
2631
|
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2630
2632
|
// 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
|
|
2631
2633
|
// 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
|
|
2632
|
-
if ((_item$
|
|
2634
|
+
if ((_item$_productOrigin27 = item._productOrigin) !== null && _item$_productOrigin27 !== void 0 && (_item$_productOrigin27 = _item$_productOrigin27.duration) !== null && _item$_productOrigin27 !== void 0 && (_item$_productOrigin27 = _item$_productOrigin27.flexible_config) !== null && _item$_productOrigin27 !== void 0 && _item$_productOrigin27.is_enable_minimum_duration && dayjs(currentStartTime).add(((_item$_productOrigin28 = item._productOrigin) === null || _item$_productOrigin28 === void 0 || (_item$_productOrigin28 = _item$_productOrigin28.duration) === null || _item$_productOrigin28 === void 0 || (_item$_productOrigin28 = _item$_productOrigin28.flexible_config) === null || _item$_productOrigin28 === void 0 ? void 0 : _item$_productOrigin28.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
|
|
2633
2635
|
if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
|
|
2634
2636
|
osWarnTips.push('pisell2.product.card.closing-soon.warning');
|
|
2635
2637
|
}
|
|
2636
2638
|
}
|
|
2637
2639
|
} else {
|
|
2638
|
-
var _item$
|
|
2640
|
+
var _item$_productOrigin29;
|
|
2639
2641
|
resource.startTime = currentStartTime;
|
|
2640
|
-
resource.endTime = dayjs(currentStartTime).add(((_item$
|
|
2642
|
+
resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin29 = item._productOrigin) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.duration) === null || _item$_productOrigin29 === void 0 ? void 0 : _item$_productOrigin29.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2641
2643
|
}
|
|
2642
2644
|
// delete resource.times;
|
|
2643
2645
|
});
|
|
@@ -18,6 +18,14 @@ interface Formattitle {
|
|
|
18
18
|
interface PackageSubItemUsageRules {
|
|
19
19
|
type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
|
|
20
20
|
rules: ("original_price" | "markup_price")[];
|
|
21
|
+
package_scope?: {
|
|
22
|
+
type: 'all_packages' | 'specific_packages';
|
|
23
|
+
exclude_bundle_product_ids: number[];
|
|
24
|
+
include_bundle_product_ids: number[];
|
|
25
|
+
filter: 0 | 1;
|
|
26
|
+
rule: any[];
|
|
27
|
+
rule_type: 'and' | 'or';
|
|
28
|
+
};
|
|
21
29
|
}
|
|
22
30
|
interface Limitedrelationproductdata {
|
|
23
31
|
id: number;
|
|
@@ -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(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -1892,7 +1892,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1892
1892
|
* @returns 是否可用
|
|
1893
1893
|
*/
|
|
1894
1894
|
checkPackageSubItemUsageRules(discount, flatItem) {
|
|
1895
|
-
var _a, _b, _c, _d;
|
|
1895
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1896
1896
|
const limitedData = discount.limited_relation_product_data;
|
|
1897
1897
|
const usageRules = limitedData == null ? void 0 : limitedData.package_sub_item_usage_rules;
|
|
1898
1898
|
const rules = ["original_price", ...(usageRules == null ? void 0 : usageRules.rules) || []];
|
|
@@ -1900,6 +1900,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1900
1900
|
return true;
|
|
1901
1901
|
}
|
|
1902
1902
|
const ruleType = usageRules.type;
|
|
1903
|
+
const packageScope = usageRules == null ? void 0 : usageRules.package_scope;
|
|
1904
|
+
const { type: scopeType, exclude_bundle_product_ids = [], include_bundle_product_ids = [], filter = 0 } = packageScope || {};
|
|
1903
1905
|
const isMainProduct = flatItem.type === "main";
|
|
1904
1906
|
const isBundleItem = flatItem.type === "bundle";
|
|
1905
1907
|
if (isMainProduct) {
|
|
@@ -1912,13 +1914,25 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1912
1914
|
if (isBundleItem) {
|
|
1913
1915
|
const priceType = (_a = flatItem.bundleItem) == null ? void 0 : _a.price_type;
|
|
1914
1916
|
const priceTypeExt = (_b = flatItem.bundleItem) == null ? void 0 : _b.price_type_ext;
|
|
1917
|
+
const mainProductId = ((_c = flatItem == null ? void 0 : flatItem.originProduct) == null ? void 0 : _c.product_id) || ((_d = flatItem == null ? void 0 : flatItem.originProduct) == null ? void 0 : _d.id);
|
|
1915
1918
|
const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
|
|
1916
1919
|
const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
|
|
1917
1920
|
if (rules.length > 0) {
|
|
1918
|
-
|
|
1919
|
-
|
|
1921
|
+
const _isOriginalPrice = isOriginalPrice && rules.includes("original_price");
|
|
1922
|
+
const _isMarkupPrice = isMarkupPrice && rules.includes("markup_price");
|
|
1923
|
+
const isPriceValid = _isOriginalPrice || _isMarkupPrice;
|
|
1924
|
+
let isScopeValid = false;
|
|
1925
|
+
if (scopeType === "all_packages") {
|
|
1926
|
+
if (!filter) {
|
|
1927
|
+
isScopeValid = true;
|
|
1928
|
+
} else {
|
|
1929
|
+
isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
|
|
1930
|
+
}
|
|
1920
1931
|
}
|
|
1921
|
-
if (
|
|
1932
|
+
if (scopeType === "specific_packages") {
|
|
1933
|
+
isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
|
|
1934
|
+
}
|
|
1935
|
+
if (isPriceValid && isScopeValid) {
|
|
1922
1936
|
return true;
|
|
1923
1937
|
}
|
|
1924
1938
|
return false;
|
|
@@ -1932,8 +1946,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1932
1946
|
return false;
|
|
1933
1947
|
}
|
|
1934
1948
|
if (isBundleItem) {
|
|
1935
|
-
const priceType = (
|
|
1936
|
-
const priceTypeExt = (
|
|
1949
|
+
const priceType = (_e = flatItem.bundleItem) == null ? void 0 : _e.price_type;
|
|
1950
|
+
const priceTypeExt = (_f = flatItem.bundleItem) == null ? void 0 : _f.price_type_ext;
|
|
1937
1951
|
const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
|
|
1938
1952
|
const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
|
|
1939
1953
|
if (rules.length > 0) {
|
|
@@ -358,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
358
358
|
};
|
|
359
359
|
setOtherData(key: string, value: any): void;
|
|
360
360
|
getOtherData(key: string): any;
|
|
361
|
-
getProductTypeById(id: number): Promise<"
|
|
361
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
362
362
|
/**
|
|
363
363
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
364
364
|
*
|
|
@@ -1155,7 +1155,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1155
1155
|
}
|
|
1156
1156
|
const totalCapacity = (countMap[n.id] || []).reduce(
|
|
1157
1157
|
(sum, item) => {
|
|
1158
|
-
const hasOverlap =
|
|
1158
|
+
const hasOverlap = (0, import_dayjs.default)(item.time.start_at).isBefore((0, import_dayjs.default)(timeSlots.end_at)) && (0, import_dayjs.default)(item.time.end_at).isAfter((0, import_dayjs.default)(timeSlots.start_at));
|
|
1159
1159
|
return hasOverlap ? sum + item.pax : sum;
|
|
1160
1160
|
},
|
|
1161
1161
|
0
|
|
@@ -1237,9 +1237,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1237
1237
|
}
|
|
1238
1238
|
);
|
|
1239
1239
|
cartItems2.forEach((item, index) => {
|
|
1240
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j
|
|
1240
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1241
1241
|
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
1242
|
-
|
|
1242
|
+
const hasOriginTimeSlot = Boolean(item._origin.start_time) && Boolean(item._origin.end_time) && !(timeSlots == null ? void 0 : timeSlots.start_time);
|
|
1243
|
+
if (hasOriginTimeSlot) {
|
|
1243
1244
|
recordTimeSlots = {
|
|
1244
1245
|
start_time: item._origin.start_time,
|
|
1245
1246
|
end_time: item._origin.end_time,
|
|
@@ -1251,13 +1252,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1251
1252
|
const currentResourceConfig = (_c = (_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b.resources) == null ? void 0 : _c.find(
|
|
1252
1253
|
(n) => n.code === resources_code
|
|
1253
1254
|
);
|
|
1254
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_d = item._productOrigin) == null ? void 0 : _d.duration) && !hasFlexibleProduct) {
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
"minutes"
|
|
1258
|
-
);
|
|
1255
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_d = item._productOrigin) == null ? void 0 : _d.duration) && !hasFlexibleProduct && !hasOriginTimeSlot) {
|
|
1256
|
+
const recordEndAt = recordTimeSlots.end_at ? (0, import_dayjs.default)(recordTimeSlots.end_at) : (0, import_dayjs.default)(`${item.start_date} ${recordTimeSlots.end_time}`);
|
|
1257
|
+
let start_at = recordEndAt;
|
|
1259
1258
|
let end_at = start_at.add(
|
|
1260
|
-
((
|
|
1259
|
+
((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) || 10,
|
|
1261
1260
|
"minutes"
|
|
1262
1261
|
);
|
|
1263
1262
|
recordTimeSlots = {
|
|
@@ -1311,7 +1310,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1311
1310
|
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1312
1311
|
let selectedResources = [];
|
|
1313
1312
|
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
1314
|
-
((
|
|
1313
|
+
((_h = (_g = item._productOrigin) == null ? void 0 : _g.product_resource) == null ? void 0 : _h.resources) || []
|
|
1315
1314
|
);
|
|
1316
1315
|
const currentResourcesRenderList = [];
|
|
1317
1316
|
resources2.forEach((n) => {
|
|
@@ -1359,11 +1358,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1359
1358
|
return recordCount >= currentCapacity;
|
|
1360
1359
|
});
|
|
1361
1360
|
});
|
|
1362
|
-
const targetRenderList = (
|
|
1361
|
+
const targetRenderList = (_i = productResources.find(
|
|
1363
1362
|
(n) => n.code === resources_code
|
|
1364
|
-
)) == null ? void 0 :
|
|
1363
|
+
)) == null ? void 0 : _i.renderList;
|
|
1365
1364
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
1366
|
-
if ((
|
|
1365
|
+
if ((_j = item._origin.resources) == null ? void 0 : _j.some(
|
|
1367
1366
|
(n) => n.form_id === targetRenderList[0].form_id
|
|
1368
1367
|
)) {
|
|
1369
1368
|
return;
|