@pisell/pisellos 0.0.492 → 0.0.494
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/cartProduct.js +1 -0
- package/dist/modules/Order/index.d.ts +5 -0
- package/dist/modules/Order/index.js +70 -5
- package/dist/modules/Order/utils.js +12 -2
- package/dist/modules/Quotation/index.d.ts +8 -0
- package/dist/modules/Quotation/index.js +46 -13
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/solution/BookingByStep/index.js +44 -42
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/ScanOrder/utils.js +22 -3
- package/dist/solution/VenueBooking/index.d.ts +8 -9
- package/dist/solution/VenueBooking/index.js +612 -565
- package/dist/solution/VenueBooking/types.d.ts +7 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +13 -2
- package/dist/solution/VenueBooking/utils/slotMerge.js +92 -15
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -0
- package/lib/modules/Order/index.d.ts +5 -0
- package/lib/modules/Order/index.js +37 -1
- package/lib/modules/Order/utils.js +13 -0
- package/lib/modules/Quotation/index.d.ts +8 -0
- package/lib/modules/Quotation/index.js +27 -6
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/solution/BookingByStep/index.js +4 -2
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/ScanOrder/utils.js +20 -3
- package/lib/solution/VenueBooking/index.d.ts +8 -9
- package/lib/solution/VenueBooking/index.js +79 -69
- package/lib/solution/VenueBooking/types.d.ts +7 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +13 -2
- package/lib/solution/VenueBooking/utils/slotMerge.js +67 -13
- 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";
|
|
@@ -382,6 +382,7 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
|
382
382
|
option: formatOptionsToOrigin(getBundleValueByKey('option')),
|
|
383
383
|
discount_list: d.discount_list,
|
|
384
384
|
"bundle_selling_price": d === null || d === void 0 ? void 0 : d.price,
|
|
385
|
+
"custom_price": d === null || d === void 0 ? void 0 : d.price,
|
|
385
386
|
metadata: {
|
|
386
387
|
custom_product_bundle_map_id: d._id,
|
|
387
388
|
product_discount_difference: product_discount_difference
|
|
@@ -15,6 +15,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
15
15
|
private cacheId;
|
|
16
16
|
private salesSummaryModuleName;
|
|
17
17
|
private rulesHooksOverride?;
|
|
18
|
+
/**
|
|
19
|
+
* Populate `savedAmount` on each discount based on product-level discount details.
|
|
20
|
+
* Only selected discounts get a non-zero value.
|
|
21
|
+
*/
|
|
22
|
+
static populateSavedAmounts(productList: Array<Record<string, any>>, discountList: Array<Record<string, any>>): void;
|
|
18
23
|
constructor(name?: string, version?: string);
|
|
19
24
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
20
25
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
5
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -185,7 +186,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
185
186
|
original_price: values.original_price !== undefined ? String(values.original_price) : product.original_price,
|
|
186
187
|
discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
|
|
187
188
|
num: (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num,
|
|
188
|
-
product_bundle: (_values$bundle = values.bundle) !== null && _values$bundle !== void 0 ? _values$bundle : product.product_bundle
|
|
189
|
+
product_bundle: (_values$bundle = values.bundle) !== null && _values$bundle !== void 0 ? _values$bundle : product.product_bundle,
|
|
190
|
+
metadata: _objectSpread(_objectSpread({}, product.metadata || {}), values.main_product_selling_price !== undefined ? {
|
|
191
|
+
main_product_selling_price: String(values.main_product_selling_price)
|
|
192
|
+
} : {})
|
|
189
193
|
});
|
|
190
194
|
}
|
|
191
195
|
};
|
|
@@ -361,6 +365,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
361
365
|
}
|
|
362
366
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
363
367
|
var _this$store$discount7;
|
|
368
|
+
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
364
369
|
(_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 || _this$store$discount7.setDiscountList(result.discountList);
|
|
365
370
|
tempOrder.discount_list = result.discountList.filter(function (d) {
|
|
366
371
|
return d.isSelected;
|
|
@@ -671,23 +676,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
671
676
|
key: "removeProductFromOrder",
|
|
672
677
|
value: function () {
|
|
673
678
|
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(identity) {
|
|
674
|
-
var tempOrder;
|
|
679
|
+
var tempOrder, beforeProducts, removedByStrictIdentity;
|
|
675
680
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
676
681
|
while (1) switch (_context9.prev = _context9.next) {
|
|
677
682
|
case 0:
|
|
678
683
|
tempOrder = this.ensureTempOrder();
|
|
684
|
+
beforeProducts = tempOrder.products;
|
|
679
685
|
tempOrder.products = tempOrder.products.filter(function (item) {
|
|
680
686
|
return !isIdentityMatch(item, identity);
|
|
681
687
|
});
|
|
688
|
+
removedByStrictIdentity = beforeProducts.length - tempOrder.products.length;
|
|
689
|
+
if (removedByStrictIdentity === 0 && identity.identity_key) {
|
|
690
|
+
tempOrder.products = tempOrder.products.filter(function (item) {
|
|
691
|
+
var isSameProduct = String(item.product_id) === String(identity.product_id) && String(item.product_variant_id) === String(identity.product_variant_id);
|
|
692
|
+
var hasNoIdentityKey = !item.identity_key;
|
|
693
|
+
return !(isSameProduct && hasNoIdentityKey);
|
|
694
|
+
});
|
|
695
|
+
}
|
|
682
696
|
this.applyDiscount();
|
|
683
|
-
_context9.next =
|
|
697
|
+
_context9.next = 8;
|
|
684
698
|
return this.recalculateSummary({
|
|
685
699
|
createIfMissing: true
|
|
686
700
|
});
|
|
687
|
-
case
|
|
701
|
+
case 8:
|
|
688
702
|
this.persistTempOrder();
|
|
689
703
|
return _context9.abrupt("return", tempOrder.products);
|
|
690
|
-
case
|
|
704
|
+
case 10:
|
|
691
705
|
case "end":
|
|
692
706
|
return _context9.stop();
|
|
693
707
|
}
|
|
@@ -1072,6 +1086,57 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1072
1086
|
}
|
|
1073
1087
|
return scanOrderMore;
|
|
1074
1088
|
}()
|
|
1089
|
+
}], [{
|
|
1090
|
+
key: "populateSavedAmounts",
|
|
1091
|
+
value:
|
|
1092
|
+
/**
|
|
1093
|
+
* Populate `savedAmount` on each discount based on product-level discount details.
|
|
1094
|
+
* Only selected discounts get a non-zero value.
|
|
1095
|
+
*/
|
|
1096
|
+
function populateSavedAmounts(productList, discountList) {
|
|
1097
|
+
var savedMap = new Map();
|
|
1098
|
+
var _iterator = _createForOfIteratorHelper(productList),
|
|
1099
|
+
_step;
|
|
1100
|
+
try {
|
|
1101
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1102
|
+
var product = _step.value;
|
|
1103
|
+
var qty = product.num || 1;
|
|
1104
|
+
var _iterator3 = _createForOfIteratorHelper(product.discount_list || []),
|
|
1105
|
+
_step3;
|
|
1106
|
+
try {
|
|
1107
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1108
|
+
var _pd$discount, _pd$metadata;
|
|
1109
|
+
var pd = _step3.value;
|
|
1110
|
+
var discountKey = ((_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) || pd.id;
|
|
1111
|
+
if (discountKey == null) continue;
|
|
1112
|
+
var amount = new Decimal(pd.amount || 0).times(qty).plus(((_pd$metadata = pd.metadata) === null || _pd$metadata === void 0 ? void 0 : _pd$metadata.product_discount_difference) || 0);
|
|
1113
|
+
savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
1114
|
+
}
|
|
1115
|
+
} catch (err) {
|
|
1116
|
+
_iterator3.e(err);
|
|
1117
|
+
} finally {
|
|
1118
|
+
_iterator3.f();
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
} catch (err) {
|
|
1122
|
+
_iterator.e(err);
|
|
1123
|
+
} finally {
|
|
1124
|
+
_iterator.f();
|
|
1125
|
+
}
|
|
1126
|
+
var _iterator2 = _createForOfIteratorHelper(discountList),
|
|
1127
|
+
_step2;
|
|
1128
|
+
try {
|
|
1129
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1130
|
+
var d = _step2.value;
|
|
1131
|
+
var key = d.id;
|
|
1132
|
+
d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
|
|
1133
|
+
}
|
|
1134
|
+
} catch (err) {
|
|
1135
|
+
_iterator2.e(err);
|
|
1136
|
+
} finally {
|
|
1137
|
+
_iterator2.f();
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1075
1140
|
}]);
|
|
1076
1141
|
return OrderModule;
|
|
1077
1142
|
}(BaseModule);
|
|
@@ -114,6 +114,16 @@ function normalizeSubmitProduct(product) {
|
|
|
114
114
|
if (rawMetadata.unique_identification_number) {
|
|
115
115
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
116
116
|
}
|
|
117
|
+
var priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'source_product_price'];
|
|
118
|
+
for (var _i = 0, _priceMetaKeys = priceMetaKeys; _i < _priceMetaKeys.length; _i++) {
|
|
119
|
+
var key = _priceMetaKeys[_i];
|
|
120
|
+
if (rawMetadata[key] !== undefined) {
|
|
121
|
+
cleanMetadata[key] = rawMetadata[key];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (rawMetadata.price_breakdown) {
|
|
125
|
+
cleanMetadata.price_breakdown = rawMetadata.price_breakdown;
|
|
126
|
+
}
|
|
117
127
|
return _objectSpread(_objectSpread(_objectSpread({}, submitProduct), bookingUid ? {
|
|
118
128
|
booking_uid: bookingUid
|
|
119
129
|
} : {}), {}, {
|
|
@@ -128,8 +138,8 @@ function resolveTableOccupancyDuration(tempOrder) {
|
|
|
128
138
|
var _metadata$table_confi, _metadata$tableConfig, _metadata$resource_co, _metadata$resourceCon;
|
|
129
139
|
var metadata = tempOrder.metadata || {};
|
|
130
140
|
var candidates = [metadata.table_occupancy_duration, metadata.booking_duration, metadata.table_duration, metadata.duration, (_metadata$table_confi = metadata.table_config) === null || _metadata$table_confi === void 0 ? void 0 : _metadata$table_confi.occupancy_duration, (_metadata$tableConfig = metadata.tableConfig) === null || _metadata$tableConfig === void 0 ? void 0 : _metadata$tableConfig.occupancy_duration, (_metadata$resource_co = metadata.resource_config) === null || _metadata$resource_co === void 0 ? void 0 : _metadata$resource_co.occupancy_duration, (_metadata$resourceCon = metadata.resourceConfig) === null || _metadata$resourceCon === void 0 ? void 0 : _metadata$resourceCon.occupancy_duration];
|
|
131
|
-
for (var
|
|
132
|
-
var value = _candidates[
|
|
141
|
+
for (var _i2 = 0, _candidates = candidates; _i2 < _candidates.length; _i2++) {
|
|
142
|
+
var value = _candidates[_i2];
|
|
133
143
|
var duration = Number(value);
|
|
134
144
|
if (Number.isFinite(duration) && duration > 0) {
|
|
135
145
|
return Math.floor(duration);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import type { ScheduleItem } from '../Schedule/types';
|
|
3
4
|
import type { QuotationItem } from './types';
|
|
4
5
|
export type { QuotationItem, QuotationProductData, QuotationSchedule, QuotationState } from './types';
|
|
5
6
|
export declare class QuotationModule extends BaseModule implements Module {
|
|
@@ -7,6 +8,7 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
7
8
|
protected defaultVersion: string;
|
|
8
9
|
private request;
|
|
9
10
|
private store;
|
|
11
|
+
private scheduleResolver?;
|
|
10
12
|
constructor(name?: string, version?: string);
|
|
11
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
12
14
|
loadQuotations(params?: {
|
|
@@ -26,6 +28,11 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
26
28
|
variantId?: number;
|
|
27
29
|
datetime: string;
|
|
28
30
|
}): string | null;
|
|
31
|
+
getQuotationShelfId(params: {
|
|
32
|
+
productId: number;
|
|
33
|
+
variantId?: number;
|
|
34
|
+
datetime: string;
|
|
35
|
+
}): number;
|
|
29
36
|
/**
|
|
30
37
|
* Batch pre-compute quotation prices for a set of products across multiple time points.
|
|
31
38
|
* Key format: `${productId}:${timePoint}`
|
|
@@ -35,6 +42,7 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
35
42
|
productIds: number[];
|
|
36
43
|
timePoints: string[];
|
|
37
44
|
}): Map<string, string | null>;
|
|
45
|
+
setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
|
|
38
46
|
private isQuotationActiveAt;
|
|
39
47
|
private findProductData;
|
|
40
48
|
}
|
|
@@ -35,6 +35,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
35
35
|
_defineProperty(_assertThisInitialized(_this), "store", {
|
|
36
36
|
list: []
|
|
37
37
|
});
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "scheduleResolver", void 0);
|
|
38
39
|
return _this;
|
|
39
40
|
}
|
|
40
41
|
_createClass(QuotationModule, [{
|
|
@@ -137,6 +138,29 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
137
138
|
}
|
|
138
139
|
return null;
|
|
139
140
|
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "getQuotationShelfId",
|
|
143
|
+
value: function getQuotationShelfId(params) {
|
|
144
|
+
var productId = params.productId,
|
|
145
|
+
variantId = params.variantId,
|
|
146
|
+
datetime = params.datetime;
|
|
147
|
+
var _iterator2 = _createForOfIteratorHelper(this.store.list),
|
|
148
|
+
_step2;
|
|
149
|
+
try {
|
|
150
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
151
|
+
var quotation = _step2.value;
|
|
152
|
+
if (!this.isQuotationActiveAt(quotation, datetime)) continue;
|
|
153
|
+
var match = this.findProductData(quotation.product_data, productId, variantId);
|
|
154
|
+
if (!match || match.value === 0) continue;
|
|
155
|
+
return quotation.id;
|
|
156
|
+
}
|
|
157
|
+
} catch (err) {
|
|
158
|
+
_iterator2.e(err);
|
|
159
|
+
} finally {
|
|
160
|
+
_iterator2.f();
|
|
161
|
+
}
|
|
162
|
+
return 0;
|
|
163
|
+
}
|
|
140
164
|
|
|
141
165
|
/**
|
|
142
166
|
* Batch pre-compute quotation prices for a set of products across multiple time points.
|
|
@@ -148,16 +172,16 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
148
172
|
value: function buildProductPriceMap(params) {
|
|
149
173
|
var map = new Map();
|
|
150
174
|
if (!this.store.list.length) return map;
|
|
151
|
-
var
|
|
152
|
-
|
|
175
|
+
var _iterator3 = _createForOfIteratorHelper(params.productIds),
|
|
176
|
+
_step3;
|
|
153
177
|
try {
|
|
154
|
-
for (
|
|
155
|
-
var productId =
|
|
156
|
-
var
|
|
157
|
-
|
|
178
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
179
|
+
var productId = _step3.value;
|
|
180
|
+
var _iterator4 = _createForOfIteratorHelper(params.timePoints),
|
|
181
|
+
_step4;
|
|
158
182
|
try {
|
|
159
|
-
for (
|
|
160
|
-
var timePoint =
|
|
183
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
184
|
+
var timePoint = _step4.value;
|
|
161
185
|
var key = "".concat(productId, ":").concat(timePoint);
|
|
162
186
|
var price = this.getPriceForProduct({
|
|
163
187
|
productId: productId,
|
|
@@ -168,24 +192,33 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
168
192
|
}
|
|
169
193
|
}
|
|
170
194
|
} catch (err) {
|
|
171
|
-
|
|
195
|
+
_iterator4.e(err);
|
|
172
196
|
} finally {
|
|
173
|
-
|
|
197
|
+
_iterator4.f();
|
|
174
198
|
}
|
|
175
199
|
}
|
|
176
200
|
} catch (err) {
|
|
177
|
-
|
|
201
|
+
_iterator3.e(err);
|
|
178
202
|
} finally {
|
|
179
|
-
|
|
203
|
+
_iterator3.f();
|
|
180
204
|
}
|
|
181
205
|
return map;
|
|
182
206
|
}
|
|
207
|
+
}, {
|
|
208
|
+
key: "setScheduleResolver",
|
|
209
|
+
value: function setScheduleResolver(resolver) {
|
|
210
|
+
this.scheduleResolver = resolver;
|
|
211
|
+
}
|
|
183
212
|
}, {
|
|
184
213
|
key: "isQuotationActiveAt",
|
|
185
214
|
value: function isQuotationActiveAt(quotation, datetime) {
|
|
186
|
-
var _quotation$schedule
|
|
215
|
+
var _quotation$schedule,
|
|
216
|
+
_this2 = this;
|
|
187
217
|
if (!((_quotation$schedule = quotation.schedule) !== null && _quotation$schedule !== void 0 && _quotation$schedule.length)) return false;
|
|
188
218
|
var scheduleItems = quotation.schedule.map(function (s) {
|
|
219
|
+
var _this2$scheduleResolv;
|
|
220
|
+
var full = (_this2$scheduleResolv = _this2.scheduleResolver) === null || _this2$scheduleResolv === void 0 ? void 0 : _this2$scheduleResolv.call(_this2, s.id);
|
|
221
|
+
if (full) return full;
|
|
189
222
|
return _objectSpread(_objectSpread({}, s), {}, {
|
|
190
223
|
repeat_type: s.repeat_type || 'none',
|
|
191
224
|
repeat_rule: s.repeat_rule || null,
|
|
@@ -60,8 +60,8 @@ var isInStandardSchedule = function isInStandardSchedule(targetDate, targetDateS
|
|
|
60
60
|
var startDate = dayjs(schedule.start_time);
|
|
61
61
|
var endDate = dayjs(schedule.end_time);
|
|
62
62
|
|
|
63
|
-
//
|
|
64
|
-
var isInBasicRange = targetDate.isSameOrAfter(startDate) && targetDate.
|
|
63
|
+
// 先检查是否在基础时间范围内(不考虑重复),end 为开区间
|
|
64
|
+
var isInBasicRange = targetDate.isSameOrAfter(startDate) && targetDate.isBefore(endDate);
|
|
65
65
|
if (schedule.repeat_type === 'none') {
|
|
66
66
|
return isInBasicRange;
|
|
67
67
|
}
|
|
@@ -75,24 +75,18 @@ var isInTimeSlotsSchedule = function isInTimeSlotsSchedule(targetDate, targetDat
|
|
|
75
75
|
if (!schedule.start_time) {
|
|
76
76
|
return false;
|
|
77
77
|
}
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
// 检查日期是否匹配
|
|
81
|
-
if (targetDateString !== scheduleDate) {
|
|
78
|
+
var scheduleStartDate = dayjs(schedule.start_time.split(' ')[0]);
|
|
79
|
+
if (!isDateInTimeSlotsSchedule(targetDate, schedule, scheduleStartDate)) {
|
|
82
80
|
return false;
|
|
83
81
|
}
|
|
84
|
-
|
|
85
|
-
// 检查是否在任一时间段内
|
|
86
82
|
var _iterator2 = _createForOfIteratorHelper(schedule.time_slot),
|
|
87
83
|
_step2;
|
|
88
84
|
try {
|
|
89
85
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
90
86
|
var timeSlot = _step2.value;
|
|
91
|
-
var slotStart = "".concat(
|
|
92
|
-
var slotEnd = "".concat(
|
|
93
|
-
|
|
94
|
-
var slotEndDate = dayjs(slotEnd);
|
|
95
|
-
if (targetDate.isSameOrAfter(slotStartDate) && targetDate.isSameOrBefore(slotEndDate)) {
|
|
87
|
+
var slotStart = dayjs("".concat(targetDateString, " ").concat(timeSlot.start_time, ":00"));
|
|
88
|
+
var slotEnd = dayjs("".concat(targetDateString, " ").concat(timeSlot.end_time, ":00"));
|
|
89
|
+
if (targetDate.isSameOrAfter(slotStart) && targetDate.isBefore(slotEnd)) {
|
|
96
90
|
return true;
|
|
97
91
|
}
|
|
98
92
|
}
|
|
@@ -120,7 +114,7 @@ var isInDesignationSchedule = function isInDesignationSchedule(targetDate, targe
|
|
|
120
114
|
var endDateTime = "".concat(designation.end_date, " ").concat(designation.end_time, ":00");
|
|
121
115
|
var startDate = dayjs(startDateTime);
|
|
122
116
|
var endDate = dayjs(endDateTime);
|
|
123
|
-
if (targetDate.isSameOrAfter(startDate) && targetDate.
|
|
117
|
+
if (targetDate.isSameOrAfter(startDate) && targetDate.isBefore(endDate)) {
|
|
124
118
|
return true;
|
|
125
119
|
}
|
|
126
120
|
}
|
|
@@ -218,9 +212,8 @@ var isInDailyRepeat = function isInDailyRepeat(targetDate, startDate, endDate, r
|
|
|
218
212
|
var startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
219
213
|
var endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
220
214
|
|
|
221
|
-
// 每日重复:每天都在相同的时间段内有效
|
|
222
|
-
|
|
223
|
-
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
215
|
+
// 每日重复:每天都在相同的时间段内有效 [start, end)
|
|
216
|
+
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay < endTimeOfDay;
|
|
224
217
|
};
|
|
225
218
|
|
|
226
219
|
// 每周重复逻辑
|
|
@@ -247,7 +240,7 @@ var isInWeeklyRepeat = function isInWeeklyRepeat(targetDate, startDate, endDate,
|
|
|
247
240
|
var targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
248
241
|
var startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
249
242
|
var endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
250
|
-
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay
|
|
243
|
+
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay < endTimeOfDay;
|
|
251
244
|
};
|
|
252
245
|
|
|
253
246
|
// 日程时间段类型
|
|
@@ -2010,7 +2010,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2010
2010
|
return n.code === resources_code;
|
|
2011
2011
|
})) === null || _productResources$fin === void 0 ? void 0 : _productResources$fin.renderList;
|
|
2012
2012
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
2013
|
-
var _item$_origin$resourc2;
|
|
2013
|
+
var _item$_origin$resourc2, _dateRange$5, _item$duration2, _item$_productOrigin6;
|
|
2014
2014
|
// 如果购物车里已经有同类型的 form_id 的资源了,则不处理
|
|
2015
2015
|
if ((_item$_origin$resourc2 = item._origin.resources) !== null && _item$_origin$resourc2 !== void 0 && _item$_origin$resourc2.some(function (n) {
|
|
2016
2016
|
return n.form_id === targetRenderList[0].form_id;
|
|
@@ -2020,7 +2020,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2020
2020
|
var fastestResource = findFastestAvailableResource({
|
|
2021
2021
|
resources: targetRenderList,
|
|
2022
2022
|
currentCapacity: currentCapacity,
|
|
2023
|
-
countMap: selectResourcesMap
|
|
2023
|
+
countMap: selectResourcesMap,
|
|
2024
|
+
targetDate: dateRange === null || dateRange === void 0 || (_dateRange$5 = dateRange[0]) === null || _dateRange$5 === void 0 ? void 0 : _dateRange$5.date,
|
|
2025
|
+
durationMinutes: (item === null || item === void 0 || (_item$duration2 = item.duration) === null || _item$duration2 === void 0 ? void 0 : _item$duration2.value) || (item === null || item === void 0 || (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.value) || 10
|
|
2024
2026
|
});
|
|
2025
2027
|
var targetResource = fastestResource || targetRenderList[0];
|
|
2026
2028
|
targetResource.capacity = currentCapacity;
|
|
@@ -2086,8 +2088,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2086
2088
|
var maxCutOffTime = undefined;
|
|
2087
2089
|
var maxCutOffTimeValue = dayjs();
|
|
2088
2090
|
cartItems.forEach(function (item) {
|
|
2089
|
-
var _item$
|
|
2090
|
-
(_item$
|
|
2091
|
+
var _item$_productOrigin7, _item$_productOrigin8, _item$_productOrigin9, _item$_productOrigin10;
|
|
2092
|
+
(_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.forEach(function (n) {
|
|
2091
2093
|
// TODO: 少了个 status 的判断
|
|
2092
2094
|
if (n.code === resources_code) {
|
|
2093
2095
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2100,10 +2102,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2100
2102
|
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2101
2103
|
resourceIds.push(item.resource_id);
|
|
2102
2104
|
}
|
|
2103
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2105
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.resources) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.find(function (n) {
|
|
2104
2106
|
return n.code === resources_code;
|
|
2105
|
-
})) === null || _item$
|
|
2106
|
-
if ((_item$
|
|
2107
|
+
})) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.id;
|
|
2108
|
+
if ((_item$_productOrigin9 = item._productOrigin) !== null && _item$_productOrigin9 !== void 0 && _item$_productOrigin9.cut_off_time && ((_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.cut_off_time.type) === 'advance') {
|
|
2107
2109
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2108
2110
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2109
2111
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2153,13 +2155,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2153
2155
|
cartItems.forEach(function (item) {
|
|
2154
2156
|
// 单个预约累加账号 多个预约取最大值
|
|
2155
2157
|
if (isSingleResource) {
|
|
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;
|
|
2158
|
-
} else {
|
|
2159
2158
|
var _item$_productOrigin11;
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2159
|
+
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;
|
|
2160
|
+
} else {
|
|
2161
|
+
var _item$_productOrigin12;
|
|
2162
|
+
if (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)) {
|
|
2163
|
+
var _item$_productOrigin13;
|
|
2164
|
+
accountDuration = ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) || 10;
|
|
2163
2165
|
}
|
|
2164
2166
|
}
|
|
2165
2167
|
});
|
|
@@ -2196,8 +2198,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2196
2198
|
}
|
|
2197
2199
|
var resourcesUseableMap = {};
|
|
2198
2200
|
var hasFlexibleDuration = cartItems.some(function (item) {
|
|
2199
|
-
var _item$
|
|
2200
|
-
return ((_item$
|
|
2201
|
+
var _item$_productOrigin14;
|
|
2202
|
+
return ((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.type) === 'flexible';
|
|
2201
2203
|
});
|
|
2202
2204
|
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;
|
|
2203
2205
|
|
|
@@ -2205,11 +2207,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2205
2207
|
var maxBlockThreshold = 0;
|
|
2206
2208
|
if (hasFlexibleDuration) {
|
|
2207
2209
|
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2208
|
-
var _item$
|
|
2210
|
+
var _item$_productOrigin15;
|
|
2209
2211
|
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2210
|
-
if ((_item$
|
|
2211
|
-
var _item$
|
|
2212
|
-
return Math.max(max, ((_item$
|
|
2212
|
+
if ((_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 && _item$_productOrigin15.is_enable_minimum_duration) {
|
|
2213
|
+
var _item$_productOrigin16;
|
|
2214
|
+
return Math.max(max, ((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.flexible_config) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.block_threshold) || 0);
|
|
2213
2215
|
}
|
|
2214
2216
|
return 0;
|
|
2215
2217
|
}, 0);
|
|
@@ -2301,8 +2303,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2301
2303
|
maxCutOffTime = undefined;
|
|
2302
2304
|
maxCutOffTimeValue = dayjs();
|
|
2303
2305
|
cartItems.forEach(function (item) {
|
|
2304
|
-
var _item$
|
|
2305
|
-
(_item$
|
|
2306
|
+
var _item$_productOrigin17, _item$_productOrigin18, _item$_productOrigin19, _item$_productOrigin20;
|
|
2307
|
+
(_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.forEach(function (n) {
|
|
2306
2308
|
// TODO: 少了个 status 的判断
|
|
2307
2309
|
if (n.code === resources_code) {
|
|
2308
2310
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2315,10 +2317,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2315
2317
|
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2316
2318
|
resourceIds.push(item.resource_id);
|
|
2317
2319
|
}
|
|
2318
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2320
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.product_resource) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.resources) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.find(function (n) {
|
|
2319
2321
|
return n.code === resources_code;
|
|
2320
|
-
})) === null || _item$
|
|
2321
|
-
if ((_item$
|
|
2322
|
+
})) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.id;
|
|
2323
|
+
if ((_item$_productOrigin19 = item._productOrigin) !== null && _item$_productOrigin19 !== void 0 && _item$_productOrigin19.cut_off_time && ((_item$_productOrigin20 = item._productOrigin) === null || _item$_productOrigin20 === void 0 ? void 0 : _item$_productOrigin20.cut_off_time.type) === 'advance') {
|
|
2322
2324
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2323
2325
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2324
2326
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2341,13 +2343,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2341
2343
|
cartItems.forEach(function (item) {
|
|
2342
2344
|
// 单个预约累加账号 多个预约取最大值
|
|
2343
2345
|
if (isSingleResource) {
|
|
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;
|
|
2346
|
-
} else {
|
|
2347
2346
|
var _item$_productOrigin21;
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2347
|
+
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;
|
|
2348
|
+
} else {
|
|
2349
|
+
var _item$_productOrigin22;
|
|
2350
|
+
if (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)) {
|
|
2351
|
+
var _item$_productOrigin23;
|
|
2352
|
+
accountDuration = ((_item$_productOrigin23 = item._productOrigin) === null || _item$_productOrigin23 === void 0 || (_item$_productOrigin23 = _item$_productOrigin23.duration) === null || _item$_productOrigin23 === void 0 ? void 0 : _item$_productOrigin23.value) || 10;
|
|
2351
2353
|
}
|
|
2352
2354
|
}
|
|
2353
2355
|
});
|
|
@@ -2373,18 +2375,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2373
2375
|
case 20:
|
|
2374
2376
|
resourcesUseableMap = {};
|
|
2375
2377
|
hasFlexibleDuration = cartItems.some(function (item) {
|
|
2376
|
-
var _item$
|
|
2377
|
-
return ((_item$
|
|
2378
|
+
var _item$_productOrigin24;
|
|
2379
|
+
return ((_item$_productOrigin24 = item._productOrigin) === null || _item$_productOrigin24 === void 0 || (_item$_productOrigin24 = _item$_productOrigin24.duration) === null || _item$_productOrigin24 === void 0 ? void 0 : _item$_productOrigin24.type) === 'flexible';
|
|
2378
2380
|
});
|
|
2379
2381
|
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 的值
|
|
2380
2382
|
maxBlockThreshold = 0;
|
|
2381
2383
|
if (hasFlexibleDuration) {
|
|
2382
2384
|
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2383
|
-
var _item$
|
|
2385
|
+
var _item$_productOrigin25;
|
|
2384
2386
|
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2385
|
-
if ((_item$
|
|
2386
|
-
var _item$
|
|
2387
|
-
return Math.max(max, ((_item$
|
|
2387
|
+
if ((_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 && _item$_productOrigin25.is_enable_minimum_duration) {
|
|
2388
|
+
var _item$_productOrigin26;
|
|
2389
|
+
return Math.max(max, ((_item$_productOrigin26 = item._productOrigin) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.duration) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.flexible_config) === null || _item$_productOrigin26 === void 0 ? void 0 : _item$_productOrigin26.block_threshold) || 0);
|
|
2388
2390
|
}
|
|
2389
2391
|
return 0;
|
|
2390
2392
|
}, 0);
|
|
@@ -2545,10 +2547,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2545
2547
|
var osWarnTips = [];
|
|
2546
2548
|
var newResources = cloneDeep(item._origin.resources);
|
|
2547
2549
|
newResources.forEach(function (resource) {
|
|
2548
|
-
var _item$
|
|
2550
|
+
var _item$_productOrigin27;
|
|
2549
2551
|
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2550
|
-
if (((_item$
|
|
2551
|
-
var _allResources$find, _item$
|
|
2552
|
+
if (((_item$_productOrigin27 = item._productOrigin) === null || _item$_productOrigin27 === void 0 || (_item$_productOrigin27 = _item$_productOrigin27.duration) === null || _item$_productOrigin27 === void 0 ? void 0 : _item$_productOrigin27.type) === 'flexible') {
|
|
2553
|
+
var _allResources$find, _item$_productOrigin28, _item$_productOrigin29;
|
|
2552
2554
|
item.duration = {
|
|
2553
2555
|
type: 'minutes',
|
|
2554
2556
|
value: 10
|
|
@@ -2631,15 +2633,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2631
2633
|
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2632
2634
|
// 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
|
|
2633
2635
|
// 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
|
|
2634
|
-
if ((_item$
|
|
2636
|
+
if ((_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 && _item$_productOrigin28.is_enable_minimum_duration && dayjs(currentStartTime).add(((_item$_productOrigin29 = item._productOrigin) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.duration) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.flexible_config) === null || _item$_productOrigin29 === void 0 ? void 0 : _item$_productOrigin29.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
|
|
2635
2637
|
if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
|
|
2636
2638
|
osWarnTips.push('pisell2.product.card.closing-soon.warning');
|
|
2637
2639
|
}
|
|
2638
2640
|
}
|
|
2639
2641
|
} else {
|
|
2640
|
-
var _item$
|
|
2642
|
+
var _item$_productOrigin30;
|
|
2641
2643
|
resource.startTime = currentStartTime;
|
|
2642
|
-
resource.endTime = dayjs(currentStartTime).add(((_item$
|
|
2644
|
+
resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin30 = item._productOrigin) === null || _item$_productOrigin30 === void 0 || (_item$_productOrigin30 = _item$_productOrigin30.duration) === null || _item$_productOrigin30 === void 0 ? void 0 : _item$_productOrigin30.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2643
2645
|
}
|
|
2644
2646
|
// delete resource.times;
|
|
2645
2647
|
});
|
|
@@ -19,10 +19,12 @@ export declare function calculateResourceAvailableTime({ resource, timeSlots, cu
|
|
|
19
19
|
* @param countMap 已预约数量映射
|
|
20
20
|
* @returns 最快可用的资源
|
|
21
21
|
*/
|
|
22
|
-
export declare function findFastestAvailableResource({ resources, currentCapacity, countMap, }: {
|
|
22
|
+
export declare function findFastestAvailableResource({ resources, currentCapacity, countMap, targetDate, durationMinutes, }: {
|
|
23
23
|
resources: ResourceItem[];
|
|
24
24
|
currentCapacity?: number;
|
|
25
25
|
countMap?: Record<number, number>;
|
|
26
|
+
targetDate?: string | Dayjs;
|
|
27
|
+
durationMinutes?: number;
|
|
26
28
|
}): ResourceItem | null;
|
|
27
29
|
/**
|
|
28
30
|
* 给定一个时间列表,通过开始和结束时间过滤出符合条件的时间段
|