@pisell/pisellos 0.0.207 → 0.0.209
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/Cart/index.d.ts +1 -0
- package/dist/modules/Cart/index.js +42 -14
- package/dist/modules/Cart/utils/changePrice.d.ts +1 -1
- package/dist/modules/Cart/utils/changePrice.js +8 -3
- package/dist/modules/Order/index.js +2 -2
- package/dist/modules/Rules/index.js +5 -5
- 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 +10 -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.d.ts +1 -0
- package/lib/modules/Cart/index.js +19 -14
- package/lib/modules/Cart/utils/cartProduct.js +6 -3
- package/lib/modules/Cart/utils/changePrice.d.ts +1 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -1
- 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 +4 -6
- 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 +17 -14
- 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 +79 -53
- 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();
|
|
@@ -259,7 +258,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
259
258
|
cartItems,
|
|
260
259
|
res,
|
|
261
260
|
(id) => this.store.products.getProduct(id),
|
|
262
|
-
(params) => this.store.cart.updateItem(params)
|
|
261
|
+
(params) => this.store.cart.updateItem(params),
|
|
262
|
+
(params) => this.store.cart.updateItemInitInfo(params)
|
|
263
263
|
);
|
|
264
264
|
this.core.effects.emit(
|
|
265
265
|
`${this.store.cart.name}:onUpdateQuotationPrice`,
|
|
@@ -479,7 +479,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
479
479
|
this.updateQuotationPriceAndCart(date);
|
|
480
480
|
}
|
|
481
481
|
} else {
|
|
482
|
-
throw new Error(
|
|
482
|
+
throw new Error(`没有找到${accountId}账户`);
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
485
|
// 生成购物车的正规数据
|
|
@@ -503,11 +503,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
503
503
|
}
|
|
504
504
|
// 购物车提交订单
|
|
505
505
|
async submitOrder() {
|
|
506
|
-
var _a;
|
|
507
506
|
const cartItems = this.store.cart.getItems();
|
|
508
507
|
const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
|
|
509
508
|
newCartItems.forEach((item) => {
|
|
510
|
-
var
|
|
509
|
+
var _a;
|
|
511
510
|
if (item._origin.resources && item._origin.resources.length) {
|
|
512
511
|
item._origin.resources = item._origin.resources.map((n) => {
|
|
513
512
|
const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
|
|
@@ -517,7 +516,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
517
516
|
return { ...newResourcesItem };
|
|
518
517
|
});
|
|
519
518
|
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
520
|
-
if (!((
|
|
519
|
+
if (!((_a = item._origin) == null ? void 0 : _a.metadata)) {
|
|
521
520
|
item._origin.metadata = {};
|
|
522
521
|
}
|
|
523
522
|
item._origin.metadata.capacity = formatCapacity;
|
|
@@ -534,7 +533,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
534
533
|
query: {
|
|
535
534
|
cartItems: newCartItems,
|
|
536
535
|
type,
|
|
537
|
-
platform:
|
|
536
|
+
platform: this.platform
|
|
538
537
|
}
|
|
539
538
|
});
|
|
540
539
|
}
|
|
@@ -668,7 +667,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
668
667
|
updateCart(params) {
|
|
669
668
|
const targetCartItem = this.store.cart.getItem(params._id);
|
|
670
669
|
if (!targetCartItem) {
|
|
671
|
-
throw new Error(
|
|
670
|
+
throw new Error(`没有找到${params._id}购物车商品`);
|
|
672
671
|
}
|
|
673
672
|
this.beforeUpdateCart(params, targetCartItem);
|
|
674
673
|
this.store.cart.updateItem(params);
|
|
@@ -695,13 +694,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
695
694
|
const dateRange = this.store.date.getDateRange();
|
|
696
695
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
697
696
|
dateRange.forEach((n) => {
|
|
698
|
-
if (n.resource)
|
|
697
|
+
if (n.resource)
|
|
698
|
+
allOriginResources.push(...n.resource);
|
|
699
699
|
});
|
|
700
700
|
}
|
|
701
701
|
if (!allOriginResources.length) {
|
|
702
702
|
const dateList = this.store.date.getDateList();
|
|
703
703
|
dateList.forEach((n) => {
|
|
704
|
-
if (n.resource)
|
|
704
|
+
if (n.resource)
|
|
705
|
+
allOriginResources.push(...n.resource);
|
|
705
706
|
});
|
|
706
707
|
}
|
|
707
708
|
if (params.resources) {
|
|
@@ -830,7 +831,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
830
831
|
const resources = [];
|
|
831
832
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
832
833
|
dateRange.forEach((n) => {
|
|
833
|
-
if (n.resource)
|
|
834
|
+
if (n.resource)
|
|
835
|
+
resources.push(...n.resource);
|
|
834
836
|
});
|
|
835
837
|
}
|
|
836
838
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
@@ -844,7 +846,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
844
846
|
} else {
|
|
845
847
|
const dateList = this.store.date.getDateList();
|
|
846
848
|
dateList.forEach((n) => {
|
|
847
|
-
if (n.resource)
|
|
849
|
+
if (n.resource)
|
|
850
|
+
resources.push(...n.resource);
|
|
848
851
|
});
|
|
849
852
|
}
|
|
850
853
|
}
|
|
@@ -913,7 +916,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
913
916
|
}
|
|
914
917
|
return res.usable;
|
|
915
918
|
});
|
|
916
|
-
if (m.onlyComputed)
|
|
919
|
+
if (m.onlyComputed)
|
|
920
|
+
return false;
|
|
917
921
|
return !canUseArr.some((n2) => n2 === false);
|
|
918
922
|
});
|
|
919
923
|
});
|
|
@@ -924,7 +928,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
924
928
|
item.renderList = item.renderList.filter((n) => {
|
|
925
929
|
var _a2, _b2, _c2;
|
|
926
930
|
const recordCount = n.capacity || 0;
|
|
927
|
-
if (n.onlyComputed)
|
|
931
|
+
if (n.onlyComputed)
|
|
932
|
+
return false;
|
|
928
933
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
929
934
|
resource: n,
|
|
930
935
|
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
@@ -977,12 +982,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
977
982
|
const dateRange = this.store.date.getDateRange();
|
|
978
983
|
const resources = [];
|
|
979
984
|
dateRange.forEach((n) => {
|
|
980
|
-
if (n.resource)
|
|
985
|
+
if (n.resource)
|
|
986
|
+
resources.push(...n.resource);
|
|
981
987
|
});
|
|
982
988
|
const resourcesMap = (0, import_utils.getResourcesMap)(resources);
|
|
983
989
|
const targetCartItem = cartItems.find((n) => n._id === id);
|
|
984
990
|
if (!targetCartItem) {
|
|
985
|
-
throw new Error(
|
|
991
|
+
throw new Error(`没有找到${id}购物车商品`);
|
|
986
992
|
}
|
|
987
993
|
let selectedResources = [];
|
|
988
994
|
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(targetCartItem);
|
|
@@ -1008,7 +1014,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1008
1014
|
productResources.forEach((item) => {
|
|
1009
1015
|
item.renderList = item.renderList.filter((n) => {
|
|
1010
1016
|
const recordCount = n.capacity || 0;
|
|
1011
|
-
if (n.onlyComputed)
|
|
1017
|
+
if (n.onlyComputed)
|
|
1018
|
+
return false;
|
|
1012
1019
|
return recordCount >= currentCapacity;
|
|
1013
1020
|
});
|
|
1014
1021
|
});
|
|
@@ -1051,7 +1058,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1051
1058
|
let AllResources = [];
|
|
1052
1059
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
1053
1060
|
dateRange.forEach((n) => {
|
|
1054
|
-
if (n.resource)
|
|
1061
|
+
if (n.resource)
|
|
1062
|
+
AllResources.push(...n.resource);
|
|
1055
1063
|
});
|
|
1056
1064
|
}
|
|
1057
1065
|
if (!AllResources.length) {
|
|
@@ -1064,7 +1072,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1064
1072
|
} else {
|
|
1065
1073
|
const dateList = this.store.date.getDateList();
|
|
1066
1074
|
dateList.forEach((n) => {
|
|
1067
|
-
if (n.resource)
|
|
1075
|
+
if (n.resource)
|
|
1076
|
+
AllResources.push(...n.resource);
|
|
1068
1077
|
});
|
|
1069
1078
|
}
|
|
1070
1079
|
}
|
|
@@ -1086,8 +1095,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1086
1095
|
var _a2, _b2, _c2, _d;
|
|
1087
1096
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1088
1097
|
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
1089
|
-
if (aIsCombined && !bIsCombined)
|
|
1090
|
-
|
|
1098
|
+
if (aIsCombined && !bIsCombined)
|
|
1099
|
+
return 1;
|
|
1100
|
+
if (!aIsCombined && bIsCombined)
|
|
1101
|
+
return -1;
|
|
1091
1102
|
return 0;
|
|
1092
1103
|
});
|
|
1093
1104
|
const resourcesUseableMap = [
|
|
@@ -1174,7 +1185,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1174
1185
|
const resources = [];
|
|
1175
1186
|
if ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date) {
|
|
1176
1187
|
dateRange.forEach((n) => {
|
|
1177
|
-
if (n.resource)
|
|
1188
|
+
if (n.resource)
|
|
1189
|
+
resources.push(...n.resource);
|
|
1178
1190
|
});
|
|
1179
1191
|
}
|
|
1180
1192
|
const errorList = [];
|
|
@@ -1307,7 +1319,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1307
1319
|
productResources.forEach((item2) => {
|
|
1308
1320
|
item2.renderList = item2.renderList.filter((n) => {
|
|
1309
1321
|
const recordCount = (n.capacity || 0) - (selectResourcesMap[n.id] || 0);
|
|
1310
|
-
if (n.onlyComputed)
|
|
1322
|
+
if (n.onlyComputed)
|
|
1323
|
+
return false;
|
|
1311
1324
|
return recordCount >= currentCapacity;
|
|
1312
1325
|
});
|
|
1313
1326
|
});
|
|
@@ -1580,7 +1593,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1580
1593
|
targetProduct.setOtherParams("schedule", newScheduleArr);
|
|
1581
1594
|
} else if (targetProductData.duration) {
|
|
1582
1595
|
const dateRange = this.store.date.getDateRange();
|
|
1583
|
-
if (!(dateRange == null ? void 0 : dateRange.length))
|
|
1596
|
+
if (!(dateRange == null ? void 0 : dateRange.length))
|
|
1597
|
+
return;
|
|
1584
1598
|
this.getAvailableDate({
|
|
1585
1599
|
startDate: dateRange[0].date,
|
|
1586
1600
|
endDate: dateRange[dateRange.length - 1].date,
|
|
@@ -1637,8 +1651,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1637
1651
|
var _a2, _b2, _c2, _d2;
|
|
1638
1652
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1639
1653
|
const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
|
|
1640
|
-
if (aIsCombined && !bIsCombined)
|
|
1641
|
-
|
|
1654
|
+
if (aIsCombined && !bIsCombined)
|
|
1655
|
+
return 1;
|
|
1656
|
+
if (!aIsCombined && bIsCombined)
|
|
1657
|
+
return -1;
|
|
1642
1658
|
return 0;
|
|
1643
1659
|
});
|
|
1644
1660
|
const firstEnabledResourceId = (_f = (_e = (_d = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.find(
|
|
@@ -1737,19 +1753,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1737
1753
|
const resources = [];
|
|
1738
1754
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
1739
1755
|
dateRange.forEach((n) => {
|
|
1740
|
-
if (n.resource)
|
|
1756
|
+
if (n.resource)
|
|
1757
|
+
resources.push(...n.resource);
|
|
1741
1758
|
});
|
|
1742
1759
|
}
|
|
1743
1760
|
if (!resources.length) {
|
|
1744
1761
|
const dateList = this.store.date.getDateList();
|
|
1745
1762
|
dateList.forEach((n) => {
|
|
1746
|
-
if (n.resource)
|
|
1763
|
+
if (n.resource)
|
|
1764
|
+
resources.push(...n.resource);
|
|
1747
1765
|
});
|
|
1748
1766
|
}
|
|
1749
1767
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
1750
1768
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1751
1769
|
const cartItem = cartItems.find((item) => item._id === cartItemId);
|
|
1752
|
-
if (!cartItem)
|
|
1770
|
+
if (!cartItem)
|
|
1771
|
+
return [];
|
|
1753
1772
|
let selectedResources = [];
|
|
1754
1773
|
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
1755
1774
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -1775,7 +1794,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1775
1794
|
const targetResource = productResources.find(
|
|
1776
1795
|
(resource) => resource.code === resourceCode
|
|
1777
1796
|
);
|
|
1778
|
-
if (!targetResource)
|
|
1797
|
+
if (!targetResource)
|
|
1798
|
+
return [];
|
|
1779
1799
|
if (cartItem._origin.start_time) {
|
|
1780
1800
|
const startTime = (0, import_dayjs.default)(
|
|
1781
1801
|
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
@@ -1789,8 +1809,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1789
1809
|
var _a2, _b2, _c, _d;
|
|
1790
1810
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1791
1811
|
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
1792
|
-
if (aIsCombined && !bIsCombined)
|
|
1793
|
-
|
|
1812
|
+
if (aIsCombined && !bIsCombined)
|
|
1813
|
+
return 1;
|
|
1814
|
+
if (!aIsCombined && bIsCombined)
|
|
1815
|
+
return -1;
|
|
1794
1816
|
return 0;
|
|
1795
1817
|
}
|
|
1796
1818
|
);
|
|
@@ -1798,7 +1820,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1798
1820
|
const mTimes = m.times.filter((n) => {
|
|
1799
1821
|
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
1822
|
});
|
|
1801
|
-
if (mTimes.length === 0)
|
|
1823
|
+
if (mTimes.length === 0)
|
|
1824
|
+
return false;
|
|
1802
1825
|
const canUseArr = mTimes.map((item) => {
|
|
1803
1826
|
var _a2;
|
|
1804
1827
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
@@ -1819,14 +1842,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1819
1842
|
}
|
|
1820
1843
|
return res.usable;
|
|
1821
1844
|
});
|
|
1822
|
-
if (m.onlyComputed)
|
|
1845
|
+
if (m.onlyComputed)
|
|
1846
|
+
return false;
|
|
1823
1847
|
return !canUseArr.some((n) => n === false);
|
|
1824
1848
|
});
|
|
1825
1849
|
} else {
|
|
1826
1850
|
targetResource.renderList = targetResource.renderList.filter((n) => {
|
|
1827
1851
|
var _a2, _b2;
|
|
1828
1852
|
const recordCount = n.capacity || 0;
|
|
1829
|
-
if (n.onlyComputed)
|
|
1853
|
+
if (n.onlyComputed)
|
|
1854
|
+
return false;
|
|
1830
1855
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
1831
1856
|
resource: n,
|
|
1832
1857
|
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
@@ -2040,7 +2065,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2040
2065
|
});
|
|
2041
2066
|
}
|
|
2042
2067
|
isTargetNormalProduct(product) {
|
|
2043
|
-
if (!product)
|
|
2068
|
+
if (!product)
|
|
2069
|
+
return false;
|
|
2044
2070
|
return (0, import_utils4.isNormalProduct)(product);
|
|
2045
2071
|
}
|
|
2046
2072
|
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;
|