@pisell/pisellos 3.0.26 → 3.0.27
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/Account/index.d.ts +1 -0
- package/dist/modules/Account/index.js +6 -0
- package/dist/modules/Account/types.d.ts +2 -0
- package/dist/modules/AccountList/index.d.ts +1 -0
- package/dist/modules/AccountList/index.js +7 -0
- package/dist/modules/Product/index.d.ts +1 -0
- package/dist/modules/Product/index.js +6 -0
- package/dist/modules/ProductList/index.js +21 -9
- package/dist/plugins/user.d.ts +7 -0
- package/dist/plugins/user.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +389 -239
- package/lib/modules/Account/index.d.ts +1 -0
- package/lib/modules/Account/index.js +4 -0
- package/lib/modules/Account/types.d.ts +2 -0
- package/lib/modules/AccountList/index.d.ts +1 -0
- package/lib/modules/AccountList/index.js +3 -0
- package/lib/modules/Product/index.d.ts +1 -0
- package/lib/modules/Product/index.js +3 -0
- package/lib/modules/ProductList/index.js +16 -2
- package/lib/plugins/user.d.ts +7 -0
- package/lib/plugins/user.js +17 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +75 -0
- package/package.json +1 -1
|
@@ -97,6 +97,10 @@ var AccountModule = class extends import_BaseModule.BaseModule {
|
|
|
97
97
|
isActive() {
|
|
98
98
|
return this.store.active;
|
|
99
99
|
}
|
|
100
|
+
isLogin() {
|
|
101
|
+
var _a;
|
|
102
|
+
return ((_a = this.store.accountInfo) == null ? void 0 : _a.isLogin) || false;
|
|
103
|
+
}
|
|
100
104
|
};
|
|
101
105
|
// Annotate the CommonJS export names for ESM import in node:
|
|
102
106
|
0 && (module.exports = {
|
|
@@ -312,6 +312,9 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
312
312
|
console.error(error);
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
+
getLoginAccount() {
|
|
316
|
+
return this.store.accounts.find((n) => n.isLogin());
|
|
317
|
+
}
|
|
315
318
|
};
|
|
316
319
|
// Annotate the CommonJS export names for ESM import in node:
|
|
317
320
|
0 && (module.exports = {
|
|
@@ -18,6 +18,7 @@ export declare class Product extends BaseModule implements Module {
|
|
|
18
18
|
protected otherParams: any;
|
|
19
19
|
constructor(name?: string, version?: string);
|
|
20
20
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
21
|
+
updateData(data: ProductData): void;
|
|
21
22
|
/**
|
|
22
23
|
* 获取商品数据
|
|
23
24
|
*/
|
|
@@ -51,12 +51,15 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
51
51
|
async storeChange(path, value) {
|
|
52
52
|
var _a;
|
|
53
53
|
(_a = this.store.list) == null ? void 0 : _a.forEach((product) => {
|
|
54
|
-
|
|
54
|
+
const productModule = this.store.productMap.get(`product-${product.id}`);
|
|
55
|
+
if (!productModule) {
|
|
55
56
|
const newProductModule = new import_Product.Product(
|
|
56
57
|
`product_${product.id.toString()}`
|
|
57
58
|
);
|
|
58
59
|
this.core.registerModule(newProductModule, { initialState: product });
|
|
59
60
|
this.store.productMap.set(product.id.toString(), newProductModule);
|
|
61
|
+
} else {
|
|
62
|
+
productModule.updateData(product);
|
|
60
63
|
}
|
|
61
64
|
});
|
|
62
65
|
}
|
|
@@ -78,7 +81,18 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
78
81
|
return void 0;
|
|
79
82
|
}
|
|
80
83
|
async addProduct(products) {
|
|
81
|
-
|
|
84
|
+
if (!this.store.list) {
|
|
85
|
+
this.store.list = [];
|
|
86
|
+
}
|
|
87
|
+
products.forEach((n) => {
|
|
88
|
+
const index = this.store.list.findIndex((m) => m.id === n.id);
|
|
89
|
+
if (index === -1) {
|
|
90
|
+
this.store.list.push(n);
|
|
91
|
+
} else {
|
|
92
|
+
this.store.list[index] = n;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
this.storeChange();
|
|
82
96
|
}
|
|
83
97
|
async selectProducts(products) {
|
|
84
98
|
this.store.selectProducts = products;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/plugins/user.ts
|
|
16
|
+
var user_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(user_exports);
|
|
@@ -54,6 +54,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
54
54
|
product_ids?: number[];
|
|
55
55
|
category_ids?: number[];
|
|
56
56
|
}): Promise<any>;
|
|
57
|
+
updateQuotationPriceAndCart(date: string): Promise<void>;
|
|
57
58
|
loadAllSchedule(): Promise<void>;
|
|
58
59
|
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, }: {
|
|
59
60
|
startDate: string;
|
|
@@ -161,6 +161,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
161
161
|
schedule_ids = [],
|
|
162
162
|
schedule_date
|
|
163
163
|
}) {
|
|
164
|
+
var _a;
|
|
164
165
|
if (!(schedule_ids == null ? void 0 : schedule_ids.length)) {
|
|
165
166
|
const schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map((n) => n.id);
|
|
166
167
|
if (schedule_ids_data.length) {
|
|
@@ -169,6 +170,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
169
170
|
schedule_ids = [0];
|
|
170
171
|
}
|
|
171
172
|
}
|
|
173
|
+
let userPlugin = this.core.getPlugin("user");
|
|
174
|
+
let customer_id = void 0;
|
|
175
|
+
try {
|
|
176
|
+
customer_id = (_a = userPlugin == null ? void 0 : userPlugin.get()) == null ? void 0 : _a.id;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.error(error);
|
|
179
|
+
}
|
|
172
180
|
const productsData = await this.request.post(
|
|
173
181
|
`/product/query`,
|
|
174
182
|
{
|
|
@@ -184,6 +192,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
184
192
|
status: "published",
|
|
185
193
|
num: 500,
|
|
186
194
|
skip: 1,
|
|
195
|
+
customer_id,
|
|
187
196
|
category_ids,
|
|
188
197
|
ids: product_ids,
|
|
189
198
|
collection,
|
|
@@ -214,6 +223,51 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
214
223
|
schedule_date: date
|
|
215
224
|
});
|
|
216
225
|
}
|
|
226
|
+
async updateQuotationPriceAndCart(date) {
|
|
227
|
+
var _a;
|
|
228
|
+
const dateRange = this.store.date.getDateRange();
|
|
229
|
+
const scheduleList = this.store.schedule.getAvailabilityScheduleDateList() || [];
|
|
230
|
+
let scheduleIds = [];
|
|
231
|
+
if (dateRange && dateRange.length) {
|
|
232
|
+
scheduleIds = scheduleList.filter((n) => n.date === dateRange[0].date).flatMap((n) => n.schedule_id);
|
|
233
|
+
} else {
|
|
234
|
+
scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id);
|
|
235
|
+
}
|
|
236
|
+
await this.loadProducts({
|
|
237
|
+
...(_a = this.otherParams) == null ? void 0 : _a.productModuleParams,
|
|
238
|
+
scheduleIds,
|
|
239
|
+
schedule_date: date
|
|
240
|
+
});
|
|
241
|
+
const cartItems = this.store.cart.getItems();
|
|
242
|
+
if (cartItems.length) {
|
|
243
|
+
for (const item of cartItems) {
|
|
244
|
+
const targetProduct = await this.store.products.getProduct(item.id);
|
|
245
|
+
const productInfo = (0, import_lodash_es.cloneDeep)(targetProduct == null ? void 0 : targetProduct.getData());
|
|
246
|
+
let bundle = item._bundleOrigin;
|
|
247
|
+
bundle = bundle == null ? void 0 : bundle.map((n) => {
|
|
248
|
+
var _a2;
|
|
249
|
+
const targetBundle = (_a2 = productInfo == null ? void 0 : productInfo.bundle) == null ? void 0 : _a2.find((m) => m.group_id === n.id);
|
|
250
|
+
if (targetBundle) {
|
|
251
|
+
const targetBundleItem = targetBundle.items.find((m) => m.id === n.id);
|
|
252
|
+
if (targetBundleItem) {
|
|
253
|
+
return {
|
|
254
|
+
...n,
|
|
255
|
+
price: targetBundleItem.price,
|
|
256
|
+
base_price: targetBundleItem.base_price
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return n;
|
|
261
|
+
});
|
|
262
|
+
this.store.cart.updateItem({
|
|
263
|
+
_id: item._id,
|
|
264
|
+
product: productInfo,
|
|
265
|
+
bundle
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
217
271
|
// 加载当前店铺下所有 schedule
|
|
218
272
|
async loadAllSchedule() {
|
|
219
273
|
var _a;
|
|
@@ -334,11 +388,23 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
334
388
|
* @param params
|
|
335
389
|
*/
|
|
336
390
|
async fetchHolderAccountsAsync(params) {
|
|
391
|
+
var _a, _b, _c;
|
|
392
|
+
const cartItems = this.store.cart.getItems();
|
|
393
|
+
if (cartItems.length) {
|
|
394
|
+
let date = (_b = (_a = this.store.date.getDateRange()) == null ? void 0 : _a[0]) == null ? void 0 : _b.date;
|
|
395
|
+
if (!date) {
|
|
396
|
+
date = ((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.start_date) || "";
|
|
397
|
+
}
|
|
398
|
+
this.updateQuotationPriceAndCart(date);
|
|
399
|
+
}
|
|
337
400
|
return this.store.accountList.fetchHolderAccounts(params);
|
|
338
401
|
}
|
|
339
402
|
// 设置日期范围,注入到日期模块中
|
|
340
403
|
async setDateRange(dateRange) {
|
|
341
404
|
this.store.date.setDateRange(dateRange);
|
|
405
|
+
if (dateRange.length && this.store.cart.getItems().length) {
|
|
406
|
+
this.updateQuotationPriceAndCart(dateRange[0].date);
|
|
407
|
+
}
|
|
342
408
|
}
|
|
343
409
|
clearDateRange() {
|
|
344
410
|
this.store.date.clearDateRange();
|
|
@@ -414,9 +480,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
414
480
|
}
|
|
415
481
|
// 如果用户登录
|
|
416
482
|
async setLoginAccount(accountId, accountInfo) {
|
|
483
|
+
var _a, _b, _c;
|
|
417
484
|
const account = this.store.accountList.getAccount(accountId);
|
|
418
485
|
if (account) {
|
|
419
486
|
let stateAccountId = account.getId();
|
|
487
|
+
accountInfo.isLogin = true;
|
|
420
488
|
account.setAccountInfo(accountInfo);
|
|
421
489
|
const cartItems = this.store.cart.getItems();
|
|
422
490
|
cartItems.forEach((item) => {
|
|
@@ -428,6 +496,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
428
496
|
}
|
|
429
497
|
});
|
|
430
498
|
this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
|
|
499
|
+
if (cartItems.length) {
|
|
500
|
+
let date = (_b = (_a = this.store.date.getDateRange()) == null ? void 0 : _a[0]) == null ? void 0 : _b.date;
|
|
501
|
+
if (!date) {
|
|
502
|
+
date = ((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.start_date) || "";
|
|
503
|
+
}
|
|
504
|
+
this.updateQuotationPriceAndCart(date);
|
|
505
|
+
}
|
|
431
506
|
} else {
|
|
432
507
|
throw new Error(`没有找到${accountId}账户`);
|
|
433
508
|
}
|