@pisell/pisellos 0.0.207 → 0.0.208
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/effects/index.d.ts +1 -1
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +9 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +8 -5
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/lib/core/index.js +28 -27
- package/lib/effects/index.d.ts +1 -1
- package/lib/effects/index.js +7 -3
- package/lib/modules/Account/index.js +10 -9
- package/lib/modules/AccountList/index.js +11 -14
- package/lib/modules/BaseModule.js +3 -6
- package/lib/modules/Cart/index.js +9 -14
- package/lib/modules/Cart/utils/cartProduct.js +6 -3
- package/lib/modules/Date/index.js +4 -8
- package/lib/modules/Date/types.js +0 -1
- package/lib/modules/Discount/index.js +6 -11
- package/lib/modules/Guests/index.js +15 -10
- package/lib/modules/Order/index.js +2 -4
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +86 -98
- package/lib/modules/Payment/wallet.js +1 -1
- package/lib/modules/Product/index.js +5 -6
- package/lib/modules/ProductList/index.js +4 -5
- package/lib/modules/Resource/index.js +12 -8
- package/lib/modules/Rules/index.js +13 -10
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.js +5 -8
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +4 -2
- package/lib/modules/Step/index.js +4 -7
- package/lib/modules/Summary/index.js +4 -9
- package/lib/plugins/request.js +33 -34
- package/lib/plugins/window.js +113 -101
- package/lib/solution/BookingByStep/index.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +77 -52
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- package/lib/solution/BookingByStep/utils/timeslots.js +12 -6
- package/lib/solution/BuyTickets/index.js +15 -15
- package/lib/solution/ShopDiscount/index.js +11 -15
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/package.json +1 -1
package/lib/plugins/window.js
CHANGED
|
@@ -23,7 +23,9 @@ __export(window_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(window_exports);
|
|
25
25
|
var SimpleStorage = class {
|
|
26
|
-
|
|
26
|
+
constructor() {
|
|
27
|
+
this.items = {};
|
|
28
|
+
}
|
|
27
29
|
get length() {
|
|
28
30
|
return Object.keys(this.items).length;
|
|
29
31
|
}
|
|
@@ -45,16 +47,18 @@ var SimpleStorage = class {
|
|
|
45
47
|
}
|
|
46
48
|
};
|
|
47
49
|
var SimpleLocation = class {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
constructor() {
|
|
51
|
+
this.hash = "";
|
|
52
|
+
this.host = "localhost";
|
|
53
|
+
this.hostname = "localhost";
|
|
54
|
+
this.href = "https://localhost";
|
|
55
|
+
this.origin = "https://localhost";
|
|
56
|
+
this.pathname = "/";
|
|
57
|
+
this.port = "";
|
|
58
|
+
this.protocol = "https:";
|
|
59
|
+
this.search = "";
|
|
60
|
+
this.ancestorOrigins = {};
|
|
61
|
+
}
|
|
58
62
|
assign(url) {
|
|
59
63
|
}
|
|
60
64
|
reload() {
|
|
@@ -66,25 +70,29 @@ var SimpleLocation = class {
|
|
|
66
70
|
}
|
|
67
71
|
};
|
|
68
72
|
var SimpleNavigator = class {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
constructor() {
|
|
74
|
+
this.userAgent = "PisellOS/1.0";
|
|
75
|
+
this.language = "zh-CN";
|
|
76
|
+
this.languages = ["zh-CN", "en-US"];
|
|
77
|
+
this.onLine = true;
|
|
78
|
+
this.cookieEnabled = true;
|
|
79
|
+
// 以下属性只提供必要实现
|
|
80
|
+
this.appCodeName = "PisellOS";
|
|
81
|
+
this.appName = "PisellOS";
|
|
82
|
+
this.appVersion = "1.0";
|
|
83
|
+
this.platform = "PisellOS";
|
|
84
|
+
this.product = "PisellOS";
|
|
85
|
+
}
|
|
80
86
|
javaEnabled() {
|
|
81
87
|
return false;
|
|
82
88
|
}
|
|
83
89
|
};
|
|
84
90
|
var SimpleHistory = class {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
constructor() {
|
|
92
|
+
this.length = 0;
|
|
93
|
+
this.scrollRestoration = "auto";
|
|
94
|
+
this.state = null;
|
|
95
|
+
}
|
|
88
96
|
back() {
|
|
89
97
|
}
|
|
90
98
|
forward() {
|
|
@@ -97,8 +105,17 @@ var SimpleHistory = class {
|
|
|
97
105
|
}
|
|
98
106
|
};
|
|
99
107
|
var SimpleDocument = class {
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
constructor() {
|
|
109
|
+
// 仅实现基本功能
|
|
110
|
+
this.elements = {};
|
|
111
|
+
// Document 接口的必要属性
|
|
112
|
+
this.URL = "https://localhost";
|
|
113
|
+
this.documentURI = "https://localhost";
|
|
114
|
+
this.origin = "https://localhost";
|
|
115
|
+
this.characterSet = "UTF-8";
|
|
116
|
+
this.contentType = "text/html";
|
|
117
|
+
this.compatMode = "CSS1Compat";
|
|
118
|
+
}
|
|
102
119
|
createElement(tagName) {
|
|
103
120
|
const element = {
|
|
104
121
|
tagName: tagName.toUpperCase(),
|
|
@@ -138,13 +155,6 @@ var SimpleDocument = class {
|
|
|
138
155
|
getElementById(id) {
|
|
139
156
|
return this.elements[id] || null;
|
|
140
157
|
}
|
|
141
|
-
// Document 接口的必要属性
|
|
142
|
-
URL = "https://localhost";
|
|
143
|
-
documentURI = "https://localhost";
|
|
144
|
-
origin = "https://localhost";
|
|
145
|
-
characterSet = "UTF-8";
|
|
146
|
-
contentType = "text/html";
|
|
147
|
-
compatMode = "CSS1Compat";
|
|
148
158
|
querySelector() {
|
|
149
159
|
return null;
|
|
150
160
|
}
|
|
@@ -159,82 +169,84 @@ var SimpleDocument = class {
|
|
|
159
169
|
}
|
|
160
170
|
};
|
|
161
171
|
var WindowPluginImpl = class {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
constructor() {
|
|
173
|
+
this.name = "window";
|
|
174
|
+
this.version = "1.0.0";
|
|
175
|
+
// 定时器相关
|
|
176
|
+
this.setTimeout = Object.assign(
|
|
177
|
+
function(handler, timeout, ...args) {
|
|
178
|
+
if (typeof globalThis !== "undefined" && globalThis.setTimeout) {
|
|
179
|
+
return globalThis.setTimeout(handler, timeout, ...args);
|
|
180
|
+
}
|
|
181
|
+
const timeoutId = Date.now();
|
|
182
|
+
Promise.resolve().then(() => {
|
|
183
|
+
setTimeout(() => {
|
|
184
|
+
if (typeof handler === "function") {
|
|
185
|
+
handler(...args);
|
|
186
|
+
} else {
|
|
187
|
+
eval(handler);
|
|
188
|
+
}
|
|
189
|
+
}, timeout || 0);
|
|
190
|
+
});
|
|
191
|
+
return timeoutId;
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
__promisify__: function(delay, value) {
|
|
195
|
+
return new Promise((resolve) => setTimeout(resolve, delay, value));
|
|
196
|
+
}
|
|
169
197
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
handler(...args);
|
|
175
|
-
} else {
|
|
176
|
-
eval(handler);
|
|
177
|
-
}
|
|
178
|
-
}, timeout || 0);
|
|
179
|
-
});
|
|
180
|
-
return timeoutId;
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
__promisify__: function(delay, value) {
|
|
184
|
-
return new Promise((resolve) => setTimeout(resolve, delay, value));
|
|
198
|
+
);
|
|
199
|
+
this.clearTimeout = function(timeout2) {
|
|
200
|
+
if (typeof globalThis !== "undefined" && globalThis.clearTimeout) {
|
|
201
|
+
globalThis.clearTimeout(timeout2);
|
|
185
202
|
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
203
|
+
};
|
|
204
|
+
this.setInterval = Object.assign(
|
|
205
|
+
function(handler, timeout, ...args) {
|
|
206
|
+
if (typeof globalThis !== "undefined" && globalThis.setInterval) {
|
|
207
|
+
return globalThis.setInterval(handler, timeout, ...args);
|
|
208
|
+
}
|
|
209
|
+
const intervalId = Date.now();
|
|
210
|
+
const recursiveTimeout = () => {
|
|
211
|
+
this.setTimeout(() => {
|
|
212
|
+
if (typeof handler === "function") {
|
|
213
|
+
handler(...args);
|
|
214
|
+
} else {
|
|
215
|
+
eval(handler);
|
|
216
|
+
}
|
|
217
|
+
recursiveTimeout();
|
|
218
|
+
}, timeout || 0);
|
|
219
|
+
};
|
|
220
|
+
recursiveTimeout();
|
|
221
|
+
return intervalId;
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
__promisify__: function(delay, value) {
|
|
225
|
+
return new Promise((resolve) => setInterval(resolve, delay, value));
|
|
226
|
+
}
|
|
197
227
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
handler(...args);
|
|
203
|
-
} else {
|
|
204
|
-
eval(handler);
|
|
205
|
-
}
|
|
206
|
-
recursiveTimeout();
|
|
207
|
-
}, timeout || 0);
|
|
208
|
-
};
|
|
209
|
-
recursiveTimeout();
|
|
210
|
-
return intervalId;
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
__promisify__: function(delay, value) {
|
|
214
|
-
return new Promise((resolve) => setInterval(resolve, delay, value));
|
|
228
|
+
);
|
|
229
|
+
this.clearInterval = function(timeout2) {
|
|
230
|
+
if (typeof globalThis !== "undefined" && globalThis.clearInterval) {
|
|
231
|
+
globalThis.clearInterval(timeout2);
|
|
215
232
|
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
// 浏览器环境对象
|
|
227
|
-
location = new SimpleLocation();
|
|
228
|
-
navigator = new SimpleNavigator();
|
|
229
|
-
document = new SimpleDocument();
|
|
230
|
-
history = new SimpleHistory();
|
|
233
|
+
};
|
|
234
|
+
// 存储相关
|
|
235
|
+
this.localStorage = new SimpleStorage();
|
|
236
|
+
this.sessionStorage = new SimpleStorage();
|
|
237
|
+
// 浏览器环境对象
|
|
238
|
+
this.location = new SimpleLocation();
|
|
239
|
+
this.navigator = new SimpleNavigator();
|
|
240
|
+
this.document = new SimpleDocument();
|
|
241
|
+
this.history = new SimpleHistory();
|
|
242
|
+
}
|
|
231
243
|
// 初始化方法
|
|
232
244
|
initialize() {
|
|
233
|
-
console.log("[WindowPlugin]
|
|
245
|
+
console.log("[WindowPlugin] 初始化完成");
|
|
234
246
|
}
|
|
235
247
|
// 销毁方法
|
|
236
248
|
destroy() {
|
|
237
|
-
console.log("[WindowPlugin]
|
|
249
|
+
console.log("[WindowPlugin] 已销毁");
|
|
238
250
|
}
|
|
239
251
|
};
|
|
240
252
|
var window_default = new WindowPluginImpl();
|
|
@@ -21,6 +21,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
21
21
|
private otherParams;
|
|
22
22
|
private cacheId;
|
|
23
23
|
private otherData;
|
|
24
|
+
private platform;
|
|
24
25
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
25
26
|
initStep(stepList: (keyof BookingByStepState)[]): void;
|
|
26
27
|
getCurrentStep(): {
|
|
@@ -50,40 +50,39 @@ var import_capacity = require("./utils/capacity");
|
|
|
50
50
|
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
51
51
|
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
52
52
|
var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
otherData = {};
|
|
63
|
-
// 提供给 UI 层的临时数据存储,会进缓存
|
|
53
|
+
constructor() {
|
|
54
|
+
super(...arguments);
|
|
55
|
+
this.defaultName = "bookingByStep";
|
|
56
|
+
this.defaultVersion = "1.0.0";
|
|
57
|
+
this.isSolution = true;
|
|
58
|
+
this.otherParams = {};
|
|
59
|
+
this.otherData = {};
|
|
60
|
+
}
|
|
61
|
+
// 平台类型,用于判断是 PC / H5
|
|
64
62
|
async initialize(core, options) {
|
|
65
|
-
var _a, _b, _c, _d;
|
|
63
|
+
var _a, _b, _c, _d, _e;
|
|
66
64
|
this.core = core;
|
|
67
65
|
this.store = options.store || {};
|
|
68
66
|
this.otherParams = options.otherParams || {};
|
|
69
|
-
console.log("[BookingByStep]
|
|
67
|
+
console.log("[BookingByStep] 初始化完成");
|
|
70
68
|
this.request = core.getPlugin("request");
|
|
71
69
|
this.window = core.getPlugin("window");
|
|
72
70
|
this.shopStore = core.getPlugin("shopStore");
|
|
73
71
|
if (!this.request) {
|
|
74
|
-
throw new Error("bookingByStep
|
|
72
|
+
throw new Error("bookingByStep解决方案需要 request 插件支持");
|
|
75
73
|
}
|
|
76
74
|
if (!this.shopStore) {
|
|
77
|
-
throw new Error("SummaryModule
|
|
75
|
+
throw new Error("SummaryModule 需要 shopStore 插件支持");
|
|
78
76
|
}
|
|
79
77
|
let targetCacheData = {};
|
|
80
78
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
81
|
-
|
|
79
|
+
this.platform = (_b = this.otherParams) == null ? void 0 : _b.platform;
|
|
80
|
+
if ((_c = this.otherParams) == null ? void 0 : _c.cacheId) {
|
|
82
81
|
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
83
82
|
if (sessionData) {
|
|
84
83
|
const data = JSON.parse(sessionData);
|
|
85
84
|
targetCacheData = data[this.otherParams.cacheId];
|
|
86
|
-
this.otherData = ((
|
|
85
|
+
this.otherData = ((_e = (_d = data[this.otherParams.cacheId]) == null ? void 0 : _d[this.name]) == null ? void 0 : _e["otherData"]) || {};
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
const moduleArr = [
|
|
@@ -111,7 +110,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
111
110
|
}
|
|
112
111
|
});
|
|
113
112
|
} else {
|
|
114
|
-
throw new Error(
|
|
113
|
+
throw new Error(`模块 ${step} 不存在`);
|
|
115
114
|
}
|
|
116
115
|
});
|
|
117
116
|
this.store.schedule.loadAllSchedule();
|
|
@@ -479,7 +478,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
479
478
|
this.updateQuotationPriceAndCart(date);
|
|
480
479
|
}
|
|
481
480
|
} else {
|
|
482
|
-
throw new Error(
|
|
481
|
+
throw new Error(`没有找到${accountId}账户`);
|
|
483
482
|
}
|
|
484
483
|
}
|
|
485
484
|
// 生成购物车的正规数据
|
|
@@ -503,11 +502,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
503
502
|
}
|
|
504
503
|
// 购物车提交订单
|
|
505
504
|
async submitOrder() {
|
|
506
|
-
var _a;
|
|
507
505
|
const cartItems = this.store.cart.getItems();
|
|
508
506
|
const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
|
|
509
507
|
newCartItems.forEach((item) => {
|
|
510
|
-
var
|
|
508
|
+
var _a;
|
|
511
509
|
if (item._origin.resources && item._origin.resources.length) {
|
|
512
510
|
item._origin.resources = item._origin.resources.map((n) => {
|
|
513
511
|
const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
|
|
@@ -517,7 +515,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
517
515
|
return { ...newResourcesItem };
|
|
518
516
|
});
|
|
519
517
|
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
520
|
-
if (!((
|
|
518
|
+
if (!((_a = item._origin) == null ? void 0 : _a.metadata)) {
|
|
521
519
|
item._origin.metadata = {};
|
|
522
520
|
}
|
|
523
521
|
item._origin.metadata.capacity = formatCapacity;
|
|
@@ -534,7 +532,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
534
532
|
query: {
|
|
535
533
|
cartItems: newCartItems,
|
|
536
534
|
type,
|
|
537
|
-
platform:
|
|
535
|
+
platform: this.platform
|
|
538
536
|
}
|
|
539
537
|
});
|
|
540
538
|
}
|
|
@@ -668,7 +666,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
668
666
|
updateCart(params) {
|
|
669
667
|
const targetCartItem = this.store.cart.getItem(params._id);
|
|
670
668
|
if (!targetCartItem) {
|
|
671
|
-
throw new Error(
|
|
669
|
+
throw new Error(`没有找到${params._id}购物车商品`);
|
|
672
670
|
}
|
|
673
671
|
this.beforeUpdateCart(params, targetCartItem);
|
|
674
672
|
this.store.cart.updateItem(params);
|
|
@@ -695,13 +693,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
695
693
|
const dateRange = this.store.date.getDateRange();
|
|
696
694
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
697
695
|
dateRange.forEach((n) => {
|
|
698
|
-
if (n.resource)
|
|
696
|
+
if (n.resource)
|
|
697
|
+
allOriginResources.push(...n.resource);
|
|
699
698
|
});
|
|
700
699
|
}
|
|
701
700
|
if (!allOriginResources.length) {
|
|
702
701
|
const dateList = this.store.date.getDateList();
|
|
703
702
|
dateList.forEach((n) => {
|
|
704
|
-
if (n.resource)
|
|
703
|
+
if (n.resource)
|
|
704
|
+
allOriginResources.push(...n.resource);
|
|
705
705
|
});
|
|
706
706
|
}
|
|
707
707
|
if (params.resources) {
|
|
@@ -830,7 +830,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
830
830
|
const resources = [];
|
|
831
831
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
832
832
|
dateRange.forEach((n) => {
|
|
833
|
-
if (n.resource)
|
|
833
|
+
if (n.resource)
|
|
834
|
+
resources.push(...n.resource);
|
|
834
835
|
});
|
|
835
836
|
}
|
|
836
837
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
@@ -844,7 +845,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
844
845
|
} else {
|
|
845
846
|
const dateList = this.store.date.getDateList();
|
|
846
847
|
dateList.forEach((n) => {
|
|
847
|
-
if (n.resource)
|
|
848
|
+
if (n.resource)
|
|
849
|
+
resources.push(...n.resource);
|
|
848
850
|
});
|
|
849
851
|
}
|
|
850
852
|
}
|
|
@@ -913,7 +915,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
913
915
|
}
|
|
914
916
|
return res.usable;
|
|
915
917
|
});
|
|
916
|
-
if (m.onlyComputed)
|
|
918
|
+
if (m.onlyComputed)
|
|
919
|
+
return false;
|
|
917
920
|
return !canUseArr.some((n2) => n2 === false);
|
|
918
921
|
});
|
|
919
922
|
});
|
|
@@ -924,7 +927,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
924
927
|
item.renderList = item.renderList.filter((n) => {
|
|
925
928
|
var _a2, _b2, _c2;
|
|
926
929
|
const recordCount = n.capacity || 0;
|
|
927
|
-
if (n.onlyComputed)
|
|
930
|
+
if (n.onlyComputed)
|
|
931
|
+
return false;
|
|
928
932
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
929
933
|
resource: n,
|
|
930
934
|
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
@@ -977,12 +981,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
977
981
|
const dateRange = this.store.date.getDateRange();
|
|
978
982
|
const resources = [];
|
|
979
983
|
dateRange.forEach((n) => {
|
|
980
|
-
if (n.resource)
|
|
984
|
+
if (n.resource)
|
|
985
|
+
resources.push(...n.resource);
|
|
981
986
|
});
|
|
982
987
|
const resourcesMap = (0, import_utils.getResourcesMap)(resources);
|
|
983
988
|
const targetCartItem = cartItems.find((n) => n._id === id);
|
|
984
989
|
if (!targetCartItem) {
|
|
985
|
-
throw new Error(
|
|
990
|
+
throw new Error(`没有找到${id}购物车商品`);
|
|
986
991
|
}
|
|
987
992
|
let selectedResources = [];
|
|
988
993
|
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(targetCartItem);
|
|
@@ -1008,7 +1013,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1008
1013
|
productResources.forEach((item) => {
|
|
1009
1014
|
item.renderList = item.renderList.filter((n) => {
|
|
1010
1015
|
const recordCount = n.capacity || 0;
|
|
1011
|
-
if (n.onlyComputed)
|
|
1016
|
+
if (n.onlyComputed)
|
|
1017
|
+
return false;
|
|
1012
1018
|
return recordCount >= currentCapacity;
|
|
1013
1019
|
});
|
|
1014
1020
|
});
|
|
@@ -1051,7 +1057,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1051
1057
|
let AllResources = [];
|
|
1052
1058
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
1053
1059
|
dateRange.forEach((n) => {
|
|
1054
|
-
if (n.resource)
|
|
1060
|
+
if (n.resource)
|
|
1061
|
+
AllResources.push(...n.resource);
|
|
1055
1062
|
});
|
|
1056
1063
|
}
|
|
1057
1064
|
if (!AllResources.length) {
|
|
@@ -1064,7 +1071,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1064
1071
|
} else {
|
|
1065
1072
|
const dateList = this.store.date.getDateList();
|
|
1066
1073
|
dateList.forEach((n) => {
|
|
1067
|
-
if (n.resource)
|
|
1074
|
+
if (n.resource)
|
|
1075
|
+
AllResources.push(...n.resource);
|
|
1068
1076
|
});
|
|
1069
1077
|
}
|
|
1070
1078
|
}
|
|
@@ -1086,8 +1094,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1086
1094
|
var _a2, _b2, _c2, _d;
|
|
1087
1095
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1088
1096
|
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
1089
|
-
if (aIsCombined && !bIsCombined)
|
|
1090
|
-
|
|
1097
|
+
if (aIsCombined && !bIsCombined)
|
|
1098
|
+
return 1;
|
|
1099
|
+
if (!aIsCombined && bIsCombined)
|
|
1100
|
+
return -1;
|
|
1091
1101
|
return 0;
|
|
1092
1102
|
});
|
|
1093
1103
|
const resourcesUseableMap = [
|
|
@@ -1174,7 +1184,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1174
1184
|
const resources = [];
|
|
1175
1185
|
if ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date) {
|
|
1176
1186
|
dateRange.forEach((n) => {
|
|
1177
|
-
if (n.resource)
|
|
1187
|
+
if (n.resource)
|
|
1188
|
+
resources.push(...n.resource);
|
|
1178
1189
|
});
|
|
1179
1190
|
}
|
|
1180
1191
|
const errorList = [];
|
|
@@ -1307,7 +1318,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1307
1318
|
productResources.forEach((item2) => {
|
|
1308
1319
|
item2.renderList = item2.renderList.filter((n) => {
|
|
1309
1320
|
const recordCount = (n.capacity || 0) - (selectResourcesMap[n.id] || 0);
|
|
1310
|
-
if (n.onlyComputed)
|
|
1321
|
+
if (n.onlyComputed)
|
|
1322
|
+
return false;
|
|
1311
1323
|
return recordCount >= currentCapacity;
|
|
1312
1324
|
});
|
|
1313
1325
|
});
|
|
@@ -1580,7 +1592,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1580
1592
|
targetProduct.setOtherParams("schedule", newScheduleArr);
|
|
1581
1593
|
} else if (targetProductData.duration) {
|
|
1582
1594
|
const dateRange = this.store.date.getDateRange();
|
|
1583
|
-
if (!(dateRange == null ? void 0 : dateRange.length))
|
|
1595
|
+
if (!(dateRange == null ? void 0 : dateRange.length))
|
|
1596
|
+
return;
|
|
1584
1597
|
this.getAvailableDate({
|
|
1585
1598
|
startDate: dateRange[0].date,
|
|
1586
1599
|
endDate: dateRange[dateRange.length - 1].date,
|
|
@@ -1637,8 +1650,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1637
1650
|
var _a2, _b2, _c2, _d2;
|
|
1638
1651
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1639
1652
|
const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
|
|
1640
|
-
if (aIsCombined && !bIsCombined)
|
|
1641
|
-
|
|
1653
|
+
if (aIsCombined && !bIsCombined)
|
|
1654
|
+
return 1;
|
|
1655
|
+
if (!aIsCombined && bIsCombined)
|
|
1656
|
+
return -1;
|
|
1642
1657
|
return 0;
|
|
1643
1658
|
});
|
|
1644
1659
|
const firstEnabledResourceId = (_f = (_e = (_d = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.find(
|
|
@@ -1737,19 +1752,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1737
1752
|
const resources = [];
|
|
1738
1753
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
1739
1754
|
dateRange.forEach((n) => {
|
|
1740
|
-
if (n.resource)
|
|
1755
|
+
if (n.resource)
|
|
1756
|
+
resources.push(...n.resource);
|
|
1741
1757
|
});
|
|
1742
1758
|
}
|
|
1743
1759
|
if (!resources.length) {
|
|
1744
1760
|
const dateList = this.store.date.getDateList();
|
|
1745
1761
|
dateList.forEach((n) => {
|
|
1746
|
-
if (n.resource)
|
|
1762
|
+
if (n.resource)
|
|
1763
|
+
resources.push(...n.resource);
|
|
1747
1764
|
});
|
|
1748
1765
|
}
|
|
1749
1766
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
1750
1767
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1751
1768
|
const cartItem = cartItems.find((item) => item._id === cartItemId);
|
|
1752
|
-
if (!cartItem)
|
|
1769
|
+
if (!cartItem)
|
|
1770
|
+
return [];
|
|
1753
1771
|
let selectedResources = [];
|
|
1754
1772
|
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
1755
1773
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -1775,7 +1793,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1775
1793
|
const targetResource = productResources.find(
|
|
1776
1794
|
(resource) => resource.code === resourceCode
|
|
1777
1795
|
);
|
|
1778
|
-
if (!targetResource)
|
|
1796
|
+
if (!targetResource)
|
|
1797
|
+
return [];
|
|
1779
1798
|
if (cartItem._origin.start_time) {
|
|
1780
1799
|
const startTime = (0, import_dayjs.default)(
|
|
1781
1800
|
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
@@ -1789,8 +1808,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1789
1808
|
var _a2, _b2, _c, _d;
|
|
1790
1809
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1791
1810
|
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
1792
|
-
if (aIsCombined && !bIsCombined)
|
|
1793
|
-
|
|
1811
|
+
if (aIsCombined && !bIsCombined)
|
|
1812
|
+
return 1;
|
|
1813
|
+
if (!aIsCombined && bIsCombined)
|
|
1814
|
+
return -1;
|
|
1794
1815
|
return 0;
|
|
1795
1816
|
}
|
|
1796
1817
|
);
|
|
@@ -1798,7 +1819,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1798
1819
|
const mTimes = m.times.filter((n) => {
|
|
1799
1820
|
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(startTime)) && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(endTime));
|
|
1800
1821
|
});
|
|
1801
|
-
if (mTimes.length === 0)
|
|
1822
|
+
if (mTimes.length === 0)
|
|
1823
|
+
return false;
|
|
1802
1824
|
const canUseArr = mTimes.map((item) => {
|
|
1803
1825
|
var _a2;
|
|
1804
1826
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
@@ -1819,14 +1841,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1819
1841
|
}
|
|
1820
1842
|
return res.usable;
|
|
1821
1843
|
});
|
|
1822
|
-
if (m.onlyComputed)
|
|
1844
|
+
if (m.onlyComputed)
|
|
1845
|
+
return false;
|
|
1823
1846
|
return !canUseArr.some((n) => n === false);
|
|
1824
1847
|
});
|
|
1825
1848
|
} else {
|
|
1826
1849
|
targetResource.renderList = targetResource.renderList.filter((n) => {
|
|
1827
1850
|
var _a2, _b2;
|
|
1828
1851
|
const recordCount = n.capacity || 0;
|
|
1829
|
-
if (n.onlyComputed)
|
|
1852
|
+
if (n.onlyComputed)
|
|
1853
|
+
return false;
|
|
1830
1854
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
1831
1855
|
resource: n,
|
|
1832
1856
|
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
@@ -2040,7 +2064,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2040
2064
|
});
|
|
2041
2065
|
}
|
|
2042
2066
|
isTargetNormalProduct(product) {
|
|
2043
|
-
if (!product)
|
|
2067
|
+
if (!product)
|
|
2068
|
+
return false;
|
|
2044
2069
|
return (0, import_utils4.isNormalProduct)(product);
|
|
2045
2070
|
}
|
|
2046
2071
|
isTargetCartIdNormalProduct(id) {
|
|
@@ -6,7 +6,7 @@ import { CartItem, ProductData } from '../../../modules';
|
|
|
6
6
|
* 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
type DateType = Dayjs;
|
|
10
10
|
export interface TimeSliceItem {
|
|
11
11
|
start_time: string;
|
|
12
12
|
end_time: string;
|
|
@@ -444,8 +444,10 @@ var getTimeSlicesByResources = ({
|
|
|
444
444
|
var _a, _b, _c, _d;
|
|
445
445
|
const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
|
|
446
446
|
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
447
|
-
if (aIsCombined && !bIsCombined)
|
|
448
|
-
|
|
447
|
+
if (aIsCombined && !bIsCombined)
|
|
448
|
+
return 1;
|
|
449
|
+
if (!aIsCombined && bIsCombined)
|
|
450
|
+
return -1;
|
|
449
451
|
return 0;
|
|
450
452
|
});
|
|
451
453
|
let timeSliceList = resources.reduce(
|
|
@@ -528,7 +530,8 @@ var getOthersCartSelectedResources = (cartItems, cartItemId, resourcesMap) => {
|
|
|
528
530
|
}, []);
|
|
529
531
|
};
|
|
530
532
|
function filterScheduleByDateRange(schedule, startDate, endDate) {
|
|
531
|
-
if (!(schedule == null ? void 0 : schedule.length))
|
|
533
|
+
if (!(schedule == null ? void 0 : schedule.length))
|
|
534
|
+
return [];
|
|
532
535
|
const start = new Date(startDate);
|
|
533
536
|
const end = new Date(endDate);
|
|
534
537
|
return schedule.filter((item) => {
|
|
@@ -594,7 +597,8 @@ function filterResourcesByFormItem(resources, form_id) {
|
|
|
594
597
|
}
|
|
595
598
|
function checkTwoResourcesIntersection(resource1, resource2) {
|
|
596
599
|
var _a, _b;
|
|
597
|
-
if (resource1.id === resource2.id)
|
|
600
|
+
if (resource1.id === resource2.id)
|
|
601
|
+
return true;
|
|
598
602
|
if (((_a = resource1.metadata.combined_resource) == null ? void 0 : _a.status) === 1 && // 如果现在选择的是组合资源,需要判断
|
|
599
603
|
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
600
604
|
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|