@pisell/pisellos 3.0.25 → 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 +392 -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 +77 -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,12 +161,22 @@ 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) {
|
|
167
168
|
schedule_ids = schedule_ids_data;
|
|
169
|
+
} else if (schedule_date) {
|
|
170
|
+
schedule_ids = [0];
|
|
168
171
|
}
|
|
169
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
|
+
}
|
|
170
180
|
const productsData = await this.request.post(
|
|
171
181
|
`/product/query`,
|
|
172
182
|
{
|
|
@@ -182,6 +192,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
182
192
|
status: "published",
|
|
183
193
|
num: 500,
|
|
184
194
|
skip: 1,
|
|
195
|
+
customer_id,
|
|
185
196
|
category_ids,
|
|
186
197
|
ids: product_ids,
|
|
187
198
|
collection,
|
|
@@ -212,6 +223,51 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
212
223
|
schedule_date: date
|
|
213
224
|
});
|
|
214
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
|
+
}
|
|
215
271
|
// 加载当前店铺下所有 schedule
|
|
216
272
|
async loadAllSchedule() {
|
|
217
273
|
var _a;
|
|
@@ -332,11 +388,23 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
332
388
|
* @param params
|
|
333
389
|
*/
|
|
334
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
|
+
}
|
|
335
400
|
return this.store.accountList.fetchHolderAccounts(params);
|
|
336
401
|
}
|
|
337
402
|
// 设置日期范围,注入到日期模块中
|
|
338
403
|
async setDateRange(dateRange) {
|
|
339
404
|
this.store.date.setDateRange(dateRange);
|
|
405
|
+
if (dateRange.length && this.store.cart.getItems().length) {
|
|
406
|
+
this.updateQuotationPriceAndCart(dateRange[0].date);
|
|
407
|
+
}
|
|
340
408
|
}
|
|
341
409
|
clearDateRange() {
|
|
342
410
|
this.store.date.clearDateRange();
|
|
@@ -412,9 +480,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
412
480
|
}
|
|
413
481
|
// 如果用户登录
|
|
414
482
|
async setLoginAccount(accountId, accountInfo) {
|
|
483
|
+
var _a, _b, _c;
|
|
415
484
|
const account = this.store.accountList.getAccount(accountId);
|
|
416
485
|
if (account) {
|
|
417
486
|
let stateAccountId = account.getId();
|
|
487
|
+
accountInfo.isLogin = true;
|
|
418
488
|
account.setAccountInfo(accountInfo);
|
|
419
489
|
const cartItems = this.store.cart.getItems();
|
|
420
490
|
cartItems.forEach((item) => {
|
|
@@ -426,6 +496,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
426
496
|
}
|
|
427
497
|
});
|
|
428
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
|
+
}
|
|
429
506
|
} else {
|
|
430
507
|
throw new Error(`没有找到${accountId}账户`);
|
|
431
508
|
}
|