@pisell/pisellos 2.2.178 → 2.2.180
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/Customer/index.d.ts +0 -6
- package/dist/modules/Customer/index.js +83 -129
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +93 -8
- package/dist/modules/Discount/types.d.ts +7 -1
- package/dist/modules/Order/index.d.ts +17 -87
- package/dist/modules/Order/index.js +501 -1357
- package/dist/modules/Order/types.d.ts +19 -198
- package/dist/modules/Order/types.js +0 -31
- package/dist/modules/Order/utils.d.ts +1 -50
- package/dist/modules/Order/utils.js +32 -261
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +21 -23
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +10 -26
- package/dist/modules/SalesSummary/index.js +2 -4
- package/dist/modules/SalesSummary/utils.js +7 -21
- package/dist/modules/Schedule/index.js +2 -6
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +1 -2
- package/dist/server/index.js +29 -87
- package/dist/server/modules/order/index.d.ts +0 -23
- package/dist/server/modules/order/index.js +46 -123
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/modules/order/utils/filterOrders.js +6 -20
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +113 -130
- package/dist/server/modules/schedule/index.js +6 -13
- package/dist/solution/BaseSales/index.d.ts +7 -89
- package/dist/solution/BaseSales/index.js +375 -1494
- package/dist/solution/BaseSales/types.d.ts +1 -67
- package/dist/solution/BaseSales/types.js +1 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
- package/dist/solution/BaseSales/utils.js +8 -46
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -133
- package/dist/solution/BookingTicket/index.js +175 -780
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/BookingTicket/types.js +0 -3
- package/dist/solution/BookingTicket/utils/cartView.js +2 -4
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +128 -231
- package/dist/solution/ScanOrder/utils.js +8 -46
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +9 -5
- package/dist/solution/VenueBooking/index.js +55 -103
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Customer/index.d.ts +0 -6
- package/lib/modules/Customer/index.js +11 -26
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +63 -8
- package/lib/modules/Discount/types.d.ts +7 -1
- package/lib/modules/Order/index.d.ts +17 -87
- package/lib/modules/Order/index.js +150 -677
- package/lib/modules/Order/types.d.ts +19 -198
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +1 -50
- package/lib/modules/Order/utils.js +22 -229
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +15 -18
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +14 -22
- package/lib/modules/SalesSummary/index.js +2 -4
- package/lib/modules/SalesSummary/utils.js +7 -21
- package/lib/modules/Schedule/index.js +1 -3
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +1 -3
- package/lib/server/index.js +4 -41
- package/lib/server/modules/order/index.d.ts +0 -23
- package/lib/server/modules/order/index.js +14 -46
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +4 -12
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +20 -30
- package/lib/server/modules/schedule/index.js +1 -2
- package/lib/solution/BaseSales/index.d.ts +7 -89
- package/lib/solution/BaseSales/index.js +22 -736
- package/lib/solution/BaseSales/types.d.ts +1 -67
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
- package/lib/solution/BaseSales/utils.js +6 -46
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -133
- package/lib/solution/BookingTicket/index.js +8 -352
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/BookingTicket/types.js +0 -6
- package/lib/solution/BookingTicket/utils/cartView.js +2 -4
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +66 -147
- package/lib/solution/ScanOrder/utils.js +6 -46
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +9 -5
- package/lib/solution/VenueBooking/index.js +14 -50
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/package.json +2 -2
- package/dist/modules/BookingContext/index.d.ts +0 -37
- package/dist/modules/BookingContext/index.js +0 -436
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/lib/modules/BookingContext/index.d.ts +0 -37
- package/lib/modules/BookingContext/index.js +0 -297
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
|
@@ -1,339 +0,0 @@
|
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
-
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."); }
|
|
13
|
-
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); }
|
|
14
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
|
-
import dayjs from 'dayjs';
|
|
18
|
-
import { formatResources, getResourceByIds, getSumCapacity, getUsableTime, setDefaultCapacitys, setDefaultResource } from "./resources";
|
|
19
|
-
import { hasActualResourceSelection, productNeedsResourceExtend } from "./resourceSelection";
|
|
20
|
-
import { isMultiDayProduct, isSessionProduct, getDays, getServiceTimes } from "./serviceTimes";
|
|
21
|
-
import { sliceDayIntoFiveMinutes, findNextDuration, getEndDate } from "./timeSlices";
|
|
22
|
-
import { flexibleObj, getDurationValue, isProductFlexibleDuration } from "./flexible";
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
|
|
26
|
-
*
|
|
27
|
-
* 设计原则:所有助手函数都通过 context 显式拿数据,**不读 mini-redux**,
|
|
28
|
-
* 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
|
|
32
|
-
export function derivePresetStartTimeFromDate(date) {
|
|
33
|
-
if (date == null) return undefined;
|
|
34
|
-
var d = dayjs(date);
|
|
35
|
-
if (!d.isValid()) return undefined;
|
|
36
|
-
var hhmm = d.format('HH:mm');
|
|
37
|
-
if (hhmm === '00:00') return undefined;
|
|
38
|
-
return hhmm;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 取预约时间偏好(sequential / parallel);默认 sequential。
|
|
43
|
-
*/
|
|
44
|
-
function getAppointmentTimingPreference(ctx) {
|
|
45
|
-
var _ctx$bookingConfig;
|
|
46
|
-
return (ctx === null || ctx === void 0 || (_ctx$bookingConfig = ctx.bookingConfig) === null || _ctx$bookingConfig === void 0 || (_ctx$bookingConfig = _ctx$bookingConfig.config) === null || _ctx$bookingConfig === void 0 || (_ctx$bookingConfig = _ctx$bookingConfig.information_tab) === null || _ctx$bookingConfig === void 0 ? void 0 : _ctx$bookingConfig.appointment_timing_preference) || 'sequential';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 灵活时长选项(cacheItem.duration.type === 'flexible' 时)。
|
|
51
|
-
*/
|
|
52
|
-
function getFlexibleOption(params) {
|
|
53
|
-
var _cacheItem$_extend, _cacheItem$_extend2, _usable$_extend, _params$ctx;
|
|
54
|
-
var cacheItem = params.cacheItem,
|
|
55
|
-
useStartTime = params.useStartTime;
|
|
56
|
-
var duration = getDurationValue(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.duration);
|
|
57
|
-
if (duration !== 'flexible') return null;
|
|
58
|
-
var startDate = dayjs("".concat(dayjs(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.start_date).format('YYYY-MM-DD'), " ").concat(useStartTime || (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.start_time) || '00:00'));
|
|
59
|
-
var usable = getUsableTime(cacheItem);
|
|
60
|
-
var usableEndAt = usable !== null && usable !== void 0 && (_usable$_extend = usable._extend) !== null && _usable$_extend !== void 0 && (_usable$_extend = _usable$_extend.usableTime) !== null && _usable$_extend !== void 0 && _usable$_extend.end_at ? dayjs(usable._extend.usableTime.end_at) : null;
|
|
61
|
-
var endDate = getEndDate(startDate, 'flexible', usableEndAt, (_params$ctx = params.ctx) === null || _params$ctx === void 0 ? void 0 : _params$ctx.shopOpeningHours);
|
|
62
|
-
var timeValue = endDate.diff(startDate, 'minute');
|
|
63
|
-
return {
|
|
64
|
-
label: String(timeValue),
|
|
65
|
-
value: flexibleObj.create(timeValue)
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* 时间切片对象(含灵活时长选项)。与 info2 `getTimeObj` 等价。
|
|
71
|
-
*/
|
|
72
|
-
export function getTimeObj(params) {
|
|
73
|
-
var _ctx$bookingConfig2;
|
|
74
|
-
var cacheItem = params.cacheItem,
|
|
75
|
-
useStartTime = params.useStartTime,
|
|
76
|
-
useDuration = params.useDuration,
|
|
77
|
-
ctx = params.ctx;
|
|
78
|
-
var isMultiDay = isMultiDayProduct(cacheItem);
|
|
79
|
-
var flexibleOption = getFlexibleOption({
|
|
80
|
-
cacheItem: cacheItem,
|
|
81
|
-
useStartTime: useStartTime,
|
|
82
|
-
ctx: ctx
|
|
83
|
-
});
|
|
84
|
-
var baseSlices = sliceDayIntoFiveMinutes(ctx === null || ctx === void 0 || (_ctx$bookingConfig2 = ctx.bookingConfig) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.config) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.basic) === null || _ctx$bookingConfig2 === void 0 ? void 0 : _ctx$bookingConfig2.service_time, isMultiDay);
|
|
85
|
-
var timeSlices = _toConsumableArray(baseSlices.timeSlices);
|
|
86
|
-
var durationSlicesBasedOnTime = _toConsumableArray(baseSlices.durationSlicesBasedOnTime);
|
|
87
|
-
if (flexibleOption) {
|
|
88
|
-
durationSlicesBasedOnTime.unshift(flexibleOption);
|
|
89
|
-
}
|
|
90
|
-
if (useDuration && !durationSlicesBasedOnTime.some(function (d) {
|
|
91
|
-
return d.value === useDuration;
|
|
92
|
-
})) {
|
|
93
|
-
durationSlicesBasedOnTime.unshift({
|
|
94
|
-
label: String(useDuration),
|
|
95
|
-
value: useDuration
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
timeSlices: timeSlices,
|
|
100
|
-
durationSlicesBasedOnTime: durationSlicesBasedOnTime
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
|
|
106
|
-
* 与 info2 `utilsByBooking.ts#getServiceStartTimeAndEndTime` 等价;显著差异:
|
|
107
|
-
* - 不读 `state.service.value` / `mini-redux`,由 ctx.previousService 显式注入。
|
|
108
|
-
* - 不读 `sessionStorage.serviceParams`,由 ctx.presetStartTime / ctx.resourceIdFromCalendar 注入。
|
|
109
|
-
* - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
|
|
110
|
-
*/
|
|
111
|
-
export function getServiceStartTimeAndEndTime(params) {
|
|
112
|
-
var _cacheItem$_extend3;
|
|
113
|
-
var cacheItem = params.cacheItem,
|
|
114
|
-
timeObj = params.timeObj,
|
|
115
|
-
ctx = params.ctx;
|
|
116
|
-
if (cacheItem !== null && cacheItem !== void 0 && cacheItem.isCustomItem) {
|
|
117
|
-
return {
|
|
118
|
-
duration: null
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
var appointmentTimingPreference = getAppointmentTimingPreference(ctx);
|
|
122
|
-
var lastServer = ctx.previousService || null;
|
|
123
|
-
var resolveDuration = function resolveDuration() {
|
|
124
|
-
var _cacheItem$duration;
|
|
125
|
-
if (isMultiDayProduct(cacheItem)) return getDays(cacheItem, 'days');
|
|
126
|
-
return findNextDuration(cacheItem.duration, timeObj.durationSlicesBasedOnTime, cacheItem === null || cacheItem === void 0 || (_cacheItem$duration = cacheItem.duration) === null || _cacheItem$duration === void 0 ? void 0 : _cacheItem$duration.value);
|
|
127
|
-
};
|
|
128
|
-
var _extend = {
|
|
129
|
-
duration: resolveDuration()
|
|
130
|
-
};
|
|
131
|
-
if (lastServer) {
|
|
132
|
-
var _lastServer$_extend, _lastServer$_extend2;
|
|
133
|
-
var lastStart = (_lastServer$_extend = lastServer._extend) === null || _lastServer$_extend === void 0 ? void 0 : _lastServer$_extend.startDate;
|
|
134
|
-
var lastEnd = (_lastServer$_extend2 = lastServer._extend) === null || _lastServer$_extend2 === void 0 ? void 0 : _lastServer$_extend2.endDate;
|
|
135
|
-
if (appointmentTimingPreference === 'parallel') {
|
|
136
|
-
_extend.start_time = dayjs(lastStart).format('HH:mm');
|
|
137
|
-
} else if (dayjs(lastEnd).isAfter(dayjs(lastStart), 'day')) {
|
|
138
|
-
var _timeObj$timeSlices;
|
|
139
|
-
_extend.start_time = (_timeObj$timeSlices = timeObj.timeSlices[timeObj.timeSlices.length - 1]) === null || _timeObj$timeSlices === void 0 ? void 0 : _timeObj$timeSlices.value;
|
|
140
|
-
} else {
|
|
141
|
-
_extend.start_time = lastEnd ? dayjs(lastEnd).format('HH:mm') : dayjs().format('HH:mm');
|
|
142
|
-
}
|
|
143
|
-
} else {
|
|
144
|
-
var presetStartTime = ctx.presetStartTime;
|
|
145
|
-
// 与 info2 getServiceStartTimeAndEndTime 一致:日历/顶部日期带 HH:mm 时原样使用,
|
|
146
|
-
// 不做 findNextSlice 栅格对齐(否则 01:47 会被抬到 01:50)。
|
|
147
|
-
if (presetStartTime && presetStartTime !== '00:00') {
|
|
148
|
-
_extend.start_time = presetStartTime;
|
|
149
|
-
} else if (cacheItem.currentDefaultTime) {
|
|
150
|
-
_extend.start_time = cacheItem.currentDefaultTime;
|
|
151
|
-
} else {
|
|
152
|
-
_extend.start_time = dayjs().format('HH:mm');
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
_extend = _objectSpread(_objectSpread({}, _extend), cacheItem._extend);
|
|
156
|
-
var _getServiceTimes = getServiceTimes(_objectSpread(_objectSpread({}, cacheItem), {}, {
|
|
157
|
-
_extend: _extend
|
|
158
|
-
})),
|
|
159
|
-
startDate = _getServiceTimes.startDate,
|
|
160
|
-
endDate = _getServiceTimes.endDate;
|
|
161
|
-
_extend.startDate = startDate;
|
|
162
|
-
_extend.endDate = endDate;
|
|
163
|
-
if (isMultiDayProduct(cacheItem)) {
|
|
164
|
-
var _extend$start_date, _extend$end_date;
|
|
165
|
-
_extend.start_time = _extend.start_time || startDate.format('HH:mm');
|
|
166
|
-
_extend.end_time = _extend.end_time || endDate.format('HH:mm');
|
|
167
|
-
_extend.start_date = (_extend$start_date = _extend.start_date) !== null && _extend$start_date !== void 0 ? _extend$start_date : startDate;
|
|
168
|
-
_extend.end_date = (_extend$end_date = _extend.end_date) !== null && _extend$end_date !== void 0 ? _extend$end_date : endDate;
|
|
169
|
-
}
|
|
170
|
-
var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 || (_cacheItem$_extend3 = _cacheItem$_extend3.other) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.session;
|
|
171
|
-
if (isSessionProduct(cacheItem) && session) {
|
|
172
|
-
var baseDate = ctx.date ? dayjs(ctx.date) : dayjs();
|
|
173
|
-
var startAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.start_at).format('HH:mm:ss')));
|
|
174
|
-
var endAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.end_at).format('HH:mm:ss')));
|
|
175
|
-
_extend.start_date = startAt;
|
|
176
|
-
_extend.startDate = startAt;
|
|
177
|
-
_extend.start_time = session.start_time;
|
|
178
|
-
_extend.end_date = endAt;
|
|
179
|
-
_extend.endDate = endAt;
|
|
180
|
-
_extend.end_time = session.end_time;
|
|
181
|
-
_extend.duration = getDays({
|
|
182
|
-
_extend: _extend
|
|
183
|
-
}, 'minutes');
|
|
184
|
-
}
|
|
185
|
-
return _extend;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
|
|
190
|
-
* 与 info2 `service/addService/utils.tsx#getProductExtend` 等价;剥 React `console.time` / JSX。
|
|
191
|
-
*
|
|
192
|
-
* 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
|
|
193
|
-
*/
|
|
194
|
-
export function getProductExtend(params) {
|
|
195
|
-
var _cacheItem$_extend4;
|
|
196
|
-
var cacheItem = params.cacheItem,
|
|
197
|
-
ctx = params.ctx,
|
|
198
|
-
isDisabledTime = params.isDisabledTime;
|
|
199
|
-
var isNew = cacheItem.new || !((_cacheItem$_extend4 = cacheItem._extend) !== null && _cacheItem$_extend4 !== void 0 && _cacheItem$_extend4.endDate);
|
|
200
|
-
var _cacheItem = _objectSpread({}, cacheItem);
|
|
201
|
-
var resourcesOriginMap = ctx.resourcesOriginMap || {};
|
|
202
|
-
_cacheItem._data = {};
|
|
203
|
-
if (isMultiDayProduct(cacheItem)) {
|
|
204
|
-
var _cacheItem$_extend5;
|
|
205
|
-
_cacheItem._extend = _cacheItem._extend || {};
|
|
206
|
-
_cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend5 = cacheItem._extend) === null || _cacheItem$_extend5 === void 0 ? void 0 : _cacheItem$_extend5.holder_id) || [];
|
|
207
|
-
_cacheItem._extend.sub_type = 'days';
|
|
208
|
-
}
|
|
209
|
-
if (isNew) {
|
|
210
|
-
var _ctx$bookingConfig3;
|
|
211
|
-
_cacheItem._data.timeObj = getTimeObj({
|
|
212
|
-
cacheItem: cacheItem,
|
|
213
|
-
ctx: ctx
|
|
214
|
-
});
|
|
215
|
-
_cacheItem._extend = getServiceStartTimeAndEndTime({
|
|
216
|
-
cacheItem: cacheItem,
|
|
217
|
-
timeObj: _cacheItem._data.timeObj,
|
|
218
|
-
ctx: ctx
|
|
219
|
-
});
|
|
220
|
-
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
221
|
-
_cacheItem._data.resourcesOrigin = getResourceByIds(resourcesOriginMap, cacheItem, {
|
|
222
|
-
resourceTab: ctx === null || ctx === void 0 || (_ctx$bookingConfig3 = ctx.bookingConfig) === null || _ctx$bookingConfig3 === void 0 || (_ctx$bookingConfig3 = _ctx$bookingConfig3.config) === null || _ctx$bookingConfig3 === void 0 ? void 0 : _ctx$bookingConfig3.resource_tab,
|
|
223
|
-
resourcesOrigin: ctx.resourcesOrigin || []
|
|
224
|
-
});
|
|
225
|
-
_cacheItem._extend.capacity = setDefaultCapacitys({
|
|
226
|
-
capacitys: _cacheItem._data.capacitys,
|
|
227
|
-
cacheItem: _cacheItem
|
|
228
|
-
});
|
|
229
|
-
var _formatResources = formatResources({
|
|
230
|
-
cacheItem: _cacheItem,
|
|
231
|
-
resourcesOrigin: _cacheItem._data.resourcesOrigin
|
|
232
|
-
}),
|
|
233
|
-
list = _formatResources.list,
|
|
234
|
-
maps = _formatResources.maps;
|
|
235
|
-
_cacheItem._data.resources = list;
|
|
236
|
-
_cacheItem._data.resourceMaps = maps;
|
|
237
|
-
_cacheItem._extend.resource = setDefaultResource({
|
|
238
|
-
cacheItem: _cacheItem,
|
|
239
|
-
resources: _cacheItem._data.resources,
|
|
240
|
-
resourceIdFromCalendar: ctx.resourceIdFromCalendar,
|
|
241
|
-
isAutoAllocationOn: ctx.isAutoAllocationOn
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// 灵活时长二次计算(资源默认选中后,按 usableTime 重算 flexible 分钟数)
|
|
245
|
-
if (isProductFlexibleDuration(_cacheItem === null || _cacheItem === void 0 ? void 0 : _cacheItem.duration)) {
|
|
246
|
-
var _cacheItem$_data$time;
|
|
247
|
-
_cacheItem._data.timeObj = getTimeObj({
|
|
248
|
-
cacheItem: _cacheItem,
|
|
249
|
-
useStartTime: _cacheItem._extend.start_time,
|
|
250
|
-
ctx: ctx
|
|
251
|
-
});
|
|
252
|
-
_cacheItem._extend.duration = (_cacheItem$_data$time = _cacheItem._data.timeObj) === null || _cacheItem$_data$time === void 0 || (_cacheItem$_data$time = _cacheItem$_data$time.durationSlicesBasedOnTime) === null || _cacheItem$_data$time === void 0 || (_cacheItem$_data$time = _cacheItem$_data$time[0]) === null || _cacheItem$_data$time === void 0 ? void 0 : _cacheItem$_data$time.value;
|
|
253
|
-
var _getServiceTimes2 = getServiceTimes(_cacheItem),
|
|
254
|
-
endDate = _getServiceTimes2.endDate;
|
|
255
|
-
_cacheItem._extend.endDate = endDate;
|
|
256
|
-
}
|
|
257
|
-
_cacheItem.autoClose = getIsAutoClose(_cacheItem, ctx.isAutoAllocationOn || function () {
|
|
258
|
-
return true;
|
|
259
|
-
});
|
|
260
|
-
if (_cacheItem._extend.bundle_edit !== undefined) {
|
|
261
|
-
_cacheItem._extend.bundle_edit = 1;
|
|
262
|
-
}
|
|
263
|
-
if (!isDisabledTime) {
|
|
264
|
-
_cacheItem._time = new Date().getTime();
|
|
265
|
-
}
|
|
266
|
-
} else {
|
|
267
|
-
var _cacheItem$_extend7;
|
|
268
|
-
if (!_cacheItem._data.capacitys) {
|
|
269
|
-
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
270
|
-
}
|
|
271
|
-
if (!_cacheItem._data.resourcesOrigin) {
|
|
272
|
-
var _cacheItem$_extend6, _ctx$bookingConfig4;
|
|
273
|
-
var extraResources = [];
|
|
274
|
-
if (Array.isArray((_cacheItem$_extend6 = _cacheItem._extend) === null || _cacheItem$_extend6 === void 0 ? void 0 : _cacheItem$_extend6.event_resources)) {
|
|
275
|
-
_cacheItem._extend.event_resources.forEach(function (er) {
|
|
276
|
-
extraResources.push({
|
|
277
|
-
form_id: er.form_id,
|
|
278
|
-
id: er.relation_id
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
_cacheItem._data.resourcesOrigin = getResourceByIds(resourcesOriginMap, cacheItem, {
|
|
283
|
-
extraResources: extraResources,
|
|
284
|
-
resourceTab: ctx === null || ctx === void 0 || (_ctx$bookingConfig4 = ctx.bookingConfig) === null || _ctx$bookingConfig4 === void 0 || (_ctx$bookingConfig4 = _ctx$bookingConfig4.config) === null || _ctx$bookingConfig4 === void 0 ? void 0 : _ctx$bookingConfig4.resource_tab,
|
|
285
|
-
resourcesOrigin: ctx.resourcesOrigin || []
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
if (!_cacheItem._data.resources) {
|
|
289
|
-
var _formatResources2 = formatResources({
|
|
290
|
-
cacheItem: _cacheItem,
|
|
291
|
-
resourcesOrigin: _cacheItem._data.resourcesOrigin
|
|
292
|
-
}),
|
|
293
|
-
_list = _formatResources2.list,
|
|
294
|
-
_maps = _formatResources2.maps;
|
|
295
|
-
_cacheItem._data.resources = _list;
|
|
296
|
-
_cacheItem._data.resourceMaps = _maps;
|
|
297
|
-
}
|
|
298
|
-
_cacheItem._data.timeObj = getTimeObj({
|
|
299
|
-
cacheItem: _cacheItem,
|
|
300
|
-
useStartTime: (_cacheItem$_extend7 = _cacheItem._extend) === null || _cacheItem$_extend7 === void 0 ? void 0 : _cacheItem$_extend7.start_time,
|
|
301
|
-
ctx: ctx
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
return _cacheItem;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* 是否可自动关闭弹窗(不需要用户进 EditService 抽屉)。
|
|
309
|
-
* 与 info2 `service/addService/utils.tsx#getIsAutoClose` 等价;
|
|
310
|
-
* `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
|
|
311
|
-
*/
|
|
312
|
-
export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
|
|
313
|
-
var _cacheItem$_data, _cacheItem$_extend8;
|
|
314
|
-
if (productNeedsResourceExtend(cacheItem) && !hasActualResourceSelection(cacheItem)) {
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
if (((_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 || (_cacheItem$_data = _cacheItem$_data.capacitys) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.type) !== 'custom') {
|
|
318
|
-
var _cacheItem$_data2;
|
|
319
|
-
var resources = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_data2 = cacheItem._data) === null || _cacheItem$_data2 === void 0 ? void 0 : _cacheItem$_data2.resources) || [];
|
|
320
|
-
if (resources.length === 1) {
|
|
321
|
-
var _first$select_type;
|
|
322
|
-
var first = resources[0];
|
|
323
|
-
if (((_first$select_type = first.select_type) === null || _first$select_type === void 0 ? void 0 : _first$select_type.type) === 'single' && (first.default_resource || []).length > 0) {
|
|
324
|
-
return true;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
var entries = Object.entries(((_cacheItem$_extend8 = cacheItem._extend) === null || _cacheItem$_extend8 === void 0 ? void 0 : _cacheItem$_extend8.resource) || {});
|
|
329
|
-
if (entries.length === 0) {
|
|
330
|
-
return !productNeedsResourceExtend(cacheItem);
|
|
331
|
-
}
|
|
332
|
-
return entries.every(function (_ref) {
|
|
333
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
334
|
-
key = _ref2[0],
|
|
335
|
-
value = _ref2[1];
|
|
336
|
-
return isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0;
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
export { getSumCapacity };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
|
|
3
|
-
*
|
|
4
|
-
* 与 info2 type 字段映射:
|
|
5
|
-
* - `no_product` ↔ type='products'
|
|
6
|
-
* - `time_out_of_range` ↔ type='time'
|
|
7
|
-
* - `count_out_of_range` ↔ type='limit'
|
|
8
|
-
* - `resource_unbound` ↔ type='unbound'
|
|
9
|
-
*
|
|
10
|
-
* OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
|
|
11
|
-
*/
|
|
12
|
-
export type ResourceUnavailableReason = 'no_product' | 'time_out_of_range' | 'count_out_of_range' | 'resource_unbound';
|
|
13
|
-
export interface ResourceError {
|
|
14
|
-
reason: ResourceUnavailableReason;
|
|
15
|
-
params: {
|
|
16
|
-
/** 资源名(time / limit 用)。 */
|
|
17
|
-
labelText?: string;
|
|
18
|
-
/** 起始时间(time / limit 用,格式 'hh:mm A')。 */
|
|
19
|
-
startText?: string;
|
|
20
|
-
/** 结束时间(time / limit 用,格式 'hh:mm A')。 */
|
|
21
|
-
endText?: string;
|
|
22
|
-
/**
|
|
23
|
-
* 结束时间是否跨到第二天。UI 收到 true 时可在 endText 前加 'tomorrow' / '明天' 前缀。
|
|
24
|
-
* 与 info2 旧实现「endText = locales.getText('pisell1.text.tomorrow') + endText」等价。
|
|
25
|
-
*/
|
|
26
|
-
isCrossDay?: boolean;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
|
|
31
|
-
*
|
|
32
|
-
* 行为对齐:
|
|
33
|
-
* 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
|
|
34
|
-
* 2. 资源 null / 无 _extend → 返回 []。
|
|
35
|
-
* 3. resource.usable=false 时:
|
|
36
|
-
* - 没有 _extend.usableTime → `time_out_of_range`
|
|
37
|
-
* - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
|
|
38
|
-
* 4. resource.unbound=true → 追加 `resource_unbound`。
|
|
39
|
-
* 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
|
|
40
|
-
*/
|
|
41
|
-
export declare function getResourceErrors(resource: any, cacheItem: any): ResourceError[];
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import { getServiceTimes } from "./serviceTimes";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
|
|
6
|
-
*
|
|
7
|
-
* 与 info2 type 字段映射:
|
|
8
|
-
* - `no_product` ↔ type='products'
|
|
9
|
-
* - `time_out_of_range` ↔ type='time'
|
|
10
|
-
* - `count_out_of_range` ↔ type='limit'
|
|
11
|
-
* - `resource_unbound` ↔ type='unbound'
|
|
12
|
-
*
|
|
13
|
-
* OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
|
|
18
|
-
*
|
|
19
|
-
* 行为对齐:
|
|
20
|
-
* 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
|
|
21
|
-
* 2. 资源 null / 无 _extend → 返回 []。
|
|
22
|
-
* 3. resource.usable=false 时:
|
|
23
|
-
* - 没有 _extend.usableTime → `time_out_of_range`
|
|
24
|
-
* - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
|
|
25
|
-
* 4. resource.unbound=true → 追加 `resource_unbound`。
|
|
26
|
-
* 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
|
|
27
|
-
*/
|
|
28
|
-
export function getResourceErrors(resource, cacheItem) {
|
|
29
|
-
if (!(cacheItem !== null && cacheItem !== void 0 && cacheItem.id)) {
|
|
30
|
-
return [{
|
|
31
|
-
reason: 'no_product',
|
|
32
|
-
params: {}
|
|
33
|
-
}];
|
|
34
|
-
}
|
|
35
|
-
if (!resource) return [];
|
|
36
|
-
var list = [];
|
|
37
|
-
if (!resource.usable) {
|
|
38
|
-
var _resource$_extend, _resource$_extend2;
|
|
39
|
-
var _getServiceTimes = getServiceTimes(cacheItem),
|
|
40
|
-
startDate = _getServiceTimes.startDate,
|
|
41
|
-
endDate = _getServiceTimes.endDate;
|
|
42
|
-
var startText = startDate.format('hh:mm A');
|
|
43
|
-
var endText = endDate.format('hh:mm A');
|
|
44
|
-
var isCrossDay = dayjs(endDate).isAfter(startDate, 'day');
|
|
45
|
-
if (!((_resource$_extend = resource._extend) !== null && _resource$_extend !== void 0 && _resource$_extend.usableTime)) {
|
|
46
|
-
list.push({
|
|
47
|
-
reason: 'time_out_of_range',
|
|
48
|
-
params: {
|
|
49
|
-
labelText: resource.labelText,
|
|
50
|
-
startText: startText,
|
|
51
|
-
endText: endText,
|
|
52
|
-
isCrossDay: isCrossDay
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
} else if (!((_resource$_extend2 = resource._extend) !== null && _resource$_extend2 !== void 0 && (_resource$_extend2 = _resource$_extend2.usableTime) !== null && _resource$_extend2 !== void 0 && (_resource$_extend2 = _resource$_extend2._extend) !== null && _resource$_extend2 !== void 0 && _resource$_extend2.isCountRange)) {
|
|
56
|
-
list.push({
|
|
57
|
-
reason: 'count_out_of_range',
|
|
58
|
-
params: {
|
|
59
|
-
labelText: resource.labelText,
|
|
60
|
-
startText: startText,
|
|
61
|
-
endText: endText,
|
|
62
|
-
isCrossDay: isCrossDay
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (resource.unbound) {
|
|
68
|
-
list.push({
|
|
69
|
-
reason: 'resource_unbound',
|
|
70
|
-
params: {}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return list;
|
|
74
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
|
|
3
|
-
*/
|
|
4
|
-
/** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
|
|
5
|
-
export declare function productNeedsResourceExtend(cacheItem: any): boolean;
|
|
6
|
-
/** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
|
|
7
|
-
export declare function hasActualResourceSelection(cacheItem: any): boolean;
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
/**
|
|
3
|
-
* 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
|
|
7
|
-
export function productNeedsResourceExtend(cacheItem) {
|
|
8
|
-
var _cacheItem$product_re;
|
|
9
|
-
var forms = cacheItem === null || cacheItem === void 0 || (_cacheItem$product_re = cacheItem.product_resource) === null || _cacheItem$product_re === void 0 ? void 0 : _cacheItem$product_re.resources;
|
|
10
|
-
if (!Array.isArray(forms)) return false;
|
|
11
|
-
return forms.some(function (d) {
|
|
12
|
-
return Number(d === null || d === void 0 ? void 0 : d.status) === 1;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
|
|
17
|
-
export function hasActualResourceSelection(cacheItem) {
|
|
18
|
-
var _cacheItem$_extend;
|
|
19
|
-
var resource = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.resource;
|
|
20
|
-
if (!resource || _typeof(resource) !== 'object') return false;
|
|
21
|
-
return Object.values(resource).some(function (rows) {
|
|
22
|
-
return Array.isArray(rows) && rows.length > 0;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 资源运行态计算 helper(搬自 info2 `utilsByBooking.ts` + `service/addService/utils.tsx`)。
|
|
3
|
-
*
|
|
4
|
-
* 本文件输入输出全部为 plain object,不依赖 React / locales / @pisell/icon / mini-redux。
|
|
5
|
-
* 调用方传入:resource origin map(`/form/schedule` 返回) / cacheItem(含 `_extend.duration / _extend.start_date / _extend.start_time` 等)。
|
|
6
|
-
*
|
|
7
|
-
* 三个 info2 独有特性保留:
|
|
8
|
-
* 1. `resource_display_scope='all'`:取全部资源
|
|
9
|
-
* 2. `extraResources`:拖入未绑定资源时兼容渲染
|
|
10
|
-
* 3. `getNoResource2()`:占位"无资源"行
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* 从已选资源中取「最早结束」的 usableTime,供灵活时长计算上限。
|
|
14
|
-
* 与 info2 `service/addService/utils.tsx#getUsableTime` 等价。
|
|
15
|
-
*/
|
|
16
|
-
export declare function getUsableTime(cacheItem: any): any | null;
|
|
17
|
-
/** Σ cacheItem._extend.capacity[].value × _extend.quantity。 */
|
|
18
|
-
export declare function getSumCapacity(cacheItem: any, isCalcQuantity?: boolean): number;
|
|
19
|
-
/**
|
|
20
|
-
* 判断单个 time 是否可用,写回 `_extend` 标记位(isDateRange / isCountRange / isUsable / isMaxLimitRange)。
|
|
21
|
-
* 与 info2 `utilsByBooking.ts#getResourceTimeIsUsable` 等价。
|
|
22
|
-
*/
|
|
23
|
-
export declare function getResourceTimeIsUsable(item: any, cacheItem: any, resourceItem: any): any;
|
|
24
|
-
/**
|
|
25
|
-
* 在 resource.times 中找到最佳可用 time,并写回 `_extend.usableTime`。
|
|
26
|
-
* 与 info2 `utilsByBooking.ts#formatTimes` 等价。
|
|
27
|
-
*/
|
|
28
|
-
export declare function formatTimes(resourceItem: any, cacheItem: any): any;
|
|
29
|
-
/**
|
|
30
|
-
* 单个 resource 的整体可用性 + labelText 填充。
|
|
31
|
-
* 与 info2 `utilsByBooking.ts#formatResource` 等价;不再接收 formatLabel 回调(OS 不渲染 JSX)。
|
|
32
|
-
*/
|
|
33
|
-
export declare function formatResource(resourceItem: any, cacheItem?: any): any;
|
|
34
|
-
/**
|
|
35
|
-
* 把单个 resource origin 类型(如「技师」)的 renderList 中每个资源跑一遍 formatResource,
|
|
36
|
-
* 并维护 unbound 标记(拖入未绑定资源时 UI 用)。
|
|
37
|
-
* 与 info2 `service/addService/utils.tsx#formatResources` 等价(剥 JSX)。
|
|
38
|
-
*/
|
|
39
|
-
export declare function formatResources(params: {
|
|
40
|
-
cacheItem: any;
|
|
41
|
-
resourcesOrigin: any[];
|
|
42
|
-
}): {
|
|
43
|
-
list: any[];
|
|
44
|
-
maps: Record<string, any>;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* 计算每类资源的默认值(写入 cacheItem._extend.resource)。
|
|
48
|
-
* 与 info2 `service/addService/utils.tsx#setDefaultResource` 等价;
|
|
49
|
-
* `resourceIdFromCalendar` 替代原版 sessionStorage `serviceParams.resource_id` 读取。
|
|
50
|
-
*/
|
|
51
|
-
export declare function setDefaultResource(params: {
|
|
52
|
-
cacheItem: any;
|
|
53
|
-
resources: any[];
|
|
54
|
-
resourceIdFromCalendar?: number;
|
|
55
|
-
isAutoAllocationOn?: (formId: any) => boolean;
|
|
56
|
-
}): Record<string, any[]>;
|
|
57
|
-
/**
|
|
58
|
-
* 计算默认容量(与 info2 `setDefaultCapacitys` 等价)。
|
|
59
|
-
* package:按 _extend.other.bundle 拆 quantity;custom:按 capacity.custom[].min;其他:[{id:0,value:1}]。
|
|
60
|
-
*/
|
|
61
|
-
export declare function setDefaultCapacitys(params: {
|
|
62
|
-
capacitys: any;
|
|
63
|
-
cacheItem: any;
|
|
64
|
-
}): Array<{
|
|
65
|
-
id: number | string;
|
|
66
|
-
value: number;
|
|
67
|
-
name?: string;
|
|
68
|
-
}>;
|
|
69
|
-
/**
|
|
70
|
-
* 通过商品 `product_resource.resources[]` 关联的 form/resource id,从 resourcesOriginMap 还原资源数据。
|
|
71
|
-
* 与 info2 `service/addService/utils.tsx#getResourceByIds` 等价(保留三特性)。
|
|
72
|
-
*/
|
|
73
|
-
export declare function getResourceByIds(resourcesOriginMap: Record<string, any>, cacheItem: any, extraParams?: {
|
|
74
|
-
extraResources?: Array<{
|
|
75
|
-
form_id: number | string;
|
|
76
|
-
id: number;
|
|
77
|
-
}>;
|
|
78
|
-
resourcesOrigin?: any[];
|
|
79
|
-
resourceTab?: Record<string, any>;
|
|
80
|
-
}): any[];
|