@pisell/pisellos 0.0.15 → 0.0.17
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/AccountList/index.d.ts +5 -1
- package/dist/modules/AccountList/index.js +92 -39
- package/dist/modules/AccountList/types.d.ts +1 -0
- package/dist/modules/BaseModule.d.ts +6 -0
- package/dist/modules/BaseModule.js +41 -0
- package/dist/modules/Cart/index.d.ts +8 -0
- package/dist/modules/Cart/index.js +45 -6
- package/dist/modules/Cart/utils.js +14 -0
- package/dist/modules/Date/index.d.ts +5 -0
- package/dist/modules/Date/index.js +35 -2
- package/dist/modules/Discount/index.d.ts +4 -0
- package/dist/modules/Discount/index.js +32 -4
- package/dist/modules/Discount/types.d.ts +3 -0
- package/dist/modules/Rules/index.js +8 -5
- package/dist/modules/Step/index.d.ts +4 -0
- package/dist/modules/Step/index.js +29 -1
- package/dist/modules/Summary/index.d.ts +4 -0
- package/dist/modules/Summary/index.js +28 -2
- package/dist/solution/BookingByStep/index.d.ts +13 -2
- package/dist/solution/BookingByStep/index.js +194 -117
- package/dist/solution/BookingByStep/types.js +0 -3
- package/dist/solution/ShopDiscount/index.js +24 -3
- package/lib/modules/AccountList/index.d.ts +5 -1
- package/lib/modules/AccountList/index.js +34 -1
- package/lib/modules/AccountList/types.d.ts +1 -0
- package/lib/modules/BaseModule.d.ts +6 -0
- package/lib/modules/BaseModule.js +37 -0
- package/lib/modules/Cart/index.d.ts +8 -0
- package/lib/modules/Cart/index.js +26 -1
- package/lib/modules/Cart/utils.js +14 -0
- package/lib/modules/Date/index.d.ts +5 -0
- package/lib/modules/Date/index.js +21 -0
- package/lib/modules/Discount/index.d.ts +4 -0
- package/lib/modules/Discount/index.js +19 -0
- package/lib/modules/Discount/types.d.ts +3 -0
- package/lib/modules/Rules/index.js +10 -5
- package/lib/modules/Step/index.d.ts +4 -0
- package/lib/modules/Step/index.js +19 -0
- package/lib/modules/Summary/index.d.ts +4 -0
- package/lib/modules/Summary/index.js +17 -0
- package/lib/solution/BookingByStep/index.d.ts +13 -2
- package/lib/solution/BookingByStep/index.js +74 -7
- package/lib/solution/BookingByStep/types.js +0 -3
- package/lib/solution/ShopDiscount/index.js +21 -3
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ProductList, CartModule } from "../../modules";
|
|
2
2
|
import { AccountListModule } from "../../modules/AccountList";
|
|
3
3
|
import { DateModule } from "../../modules/Date";
|
|
4
|
-
import { GuestListModule } from "../../modules/Guests";
|
|
5
4
|
import { OrderModule } from "../../modules/Order";
|
|
6
5
|
import { PaymentModule } from "../../modules/Payment";
|
|
7
6
|
import { StepModule } from "../../modules/Step";
|
|
@@ -16,8 +15,6 @@ export function createModule(moduleName, solutionName, name, version) {
|
|
|
16
15
|
return new StepModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
17
16
|
case "products":
|
|
18
17
|
return new ProductList("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
19
|
-
case "guests":
|
|
20
|
-
return new GuestListModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
21
18
|
case "date":
|
|
22
19
|
return new DateModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
23
20
|
case "accountList":
|
|
@@ -154,18 +154,35 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
154
154
|
}, {
|
|
155
155
|
key: "registerDependentModules",
|
|
156
156
|
value: function registerDependentModules() {
|
|
157
|
-
var _this$options$otherPa, _this$options$otherPa2;
|
|
157
|
+
var _this$options$otherPa, _this$options$otherPa2, _this$options$otherPa3, _this$options$otherPa4, _this$options$otherPa5;
|
|
158
|
+
// 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
|
|
159
|
+
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
160
|
+
var targetCacheData = {};
|
|
161
|
+
if ((_this$options$otherPa = this.options.otherParams) !== null && _this$options$otherPa !== void 0 && _this$options$otherPa.cacheId) {
|
|
162
|
+
var sessionData = this.window.sessionStorage.getItem(this.name);
|
|
163
|
+
if (sessionData) {
|
|
164
|
+
var data = JSON.parse(sessionData);
|
|
165
|
+
targetCacheData = data[this.options.otherParams.cacheId];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
158
169
|
// 注册优惠模块
|
|
159
170
|
var discount = new DiscountModule("".concat(this.name, "_discount"));
|
|
160
171
|
this.core.registerModule(discount, {
|
|
161
|
-
|
|
172
|
+
initialState: targetCacheData[discount.name],
|
|
173
|
+
hooks: (_this$options$otherPa2 = this.options.otherParams) === null || _this$options$otherPa2 === void 0 || (_this$options$otherPa2 = _this$options$otherPa2.discount) === null || _this$options$otherPa2 === void 0 ? void 0 : _this$options$otherPa2.hooks,
|
|
174
|
+
otherParams: {
|
|
175
|
+
fatherModule: this.name,
|
|
176
|
+
openCache: (_this$options$otherPa3 = this.options.otherParams) !== null && _this$options$otherPa3 !== void 0 && _this$options$otherPa3.cacheId ? true : false,
|
|
177
|
+
cacheId: (_this$options$otherPa4 = this.options.otherParams) === null || _this$options$otherPa4 === void 0 ? void 0 : _this$options$otherPa4.cacheId
|
|
178
|
+
}
|
|
162
179
|
});
|
|
163
180
|
this.store.discount = discount;
|
|
164
181
|
|
|
165
182
|
// 注册规则模块
|
|
166
183
|
var rules = new RulesModule("".concat(this.name, "_rules"));
|
|
167
184
|
this.core.registerModule(rules, {
|
|
168
|
-
hooks: (_this$options$
|
|
185
|
+
hooks: (_this$options$otherPa5 = this.options.otherParams) === null || _this$options$otherPa5 === void 0 || (_this$options$otherPa5 = _this$options$otherPa5.rules) === null || _this$options$otherPa5 === void 0 ? void 0 : _this$options$otherPa5.hooks
|
|
169
186
|
});
|
|
170
187
|
this.store.rules = rules;
|
|
171
188
|
}
|
|
@@ -174,6 +191,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
174
191
|
value: function registerEventListeners() {
|
|
175
192
|
var _this2 = this;
|
|
176
193
|
this.core.effects.on(ShopDiscountHooks.onCustomerChange, function (customer) {
|
|
194
|
+
var _this2$options$otherP;
|
|
195
|
+
if ((_this2$options$otherP = _this2.options.otherParams) !== null && _this2$options$otherP !== void 0 && _this2$options$otherP.cacheId && _this2.getDiscountList().length) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
177
198
|
_this2.loadPrepareConfig({
|
|
178
199
|
customerId: customer.id,
|
|
179
200
|
action: "create",
|
|
@@ -6,10 +6,13 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private store;
|
|
9
|
+
private cacheId;
|
|
10
|
+
private openCache;
|
|
11
|
+
private fatherModule;
|
|
9
12
|
constructor(name?: string, version?: string);
|
|
10
13
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
11
14
|
addAccount(account: Account): Promise<void>;
|
|
12
|
-
updateAccount(id: string, updates:
|
|
15
|
+
updateAccount(id: string, updates: Account): Promise<void>;
|
|
13
16
|
removeAccount(id: string): Promise<void>;
|
|
14
17
|
getAccounts(): AccountModule[];
|
|
15
18
|
getAccount(id: string): AccountModule | null;
|
|
@@ -17,4 +20,5 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
17
20
|
getState(): AccountListState;
|
|
18
21
|
setActiveAccount(id: string | number): void;
|
|
19
22
|
getActiveAccount(): AccountModule | null;
|
|
23
|
+
storeChange(): void;
|
|
20
24
|
}
|
|
@@ -31,15 +31,36 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
31
31
|
this.defaultName = "accountList";
|
|
32
32
|
this.defaultVersion = "1.0.0";
|
|
33
33
|
this.store = {
|
|
34
|
+
accountList: [],
|
|
35
|
+
// 账号的纯数据列表
|
|
34
36
|
accounts: [],
|
|
37
|
+
// 账号的 module 列表
|
|
35
38
|
isLoading: false,
|
|
36
39
|
error: null
|
|
37
40
|
};
|
|
41
|
+
this.openCache = false;
|
|
38
42
|
}
|
|
39
43
|
async initialize(core, options) {
|
|
44
|
+
var _a, _b, _c;
|
|
40
45
|
this.core = core;
|
|
41
46
|
this.store = options == null ? void 0 : options.store;
|
|
42
47
|
this.store.accounts = [];
|
|
48
|
+
this.store.accountList = [];
|
|
49
|
+
if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.accountList)) {
|
|
50
|
+
const recordList = options.initialState.accountList || [];
|
|
51
|
+
recordList.forEach((account) => {
|
|
52
|
+
this.addAccount(account);
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
this.store.accountList = [];
|
|
56
|
+
}
|
|
57
|
+
if ((_b = options == null ? void 0 : options.otherParams) == null ? void 0 : _b.cacheId) {
|
|
58
|
+
this.openCache = options.otherParams.openCache;
|
|
59
|
+
this.cacheId = options.otherParams.cacheId;
|
|
60
|
+
}
|
|
61
|
+
if ((_c = options == null ? void 0 : options.otherParams) == null ? void 0 : _c.fatherModule) {
|
|
62
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
63
|
+
}
|
|
43
64
|
}
|
|
44
65
|
async addAccount(account) {
|
|
45
66
|
try {
|
|
@@ -47,7 +68,9 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
47
68
|
this.store.error = null;
|
|
48
69
|
if (this.store.accounts.some((a) => a.getId() === account.id)) {
|
|
49
70
|
throw new Error(`Account with id ${account.id} already exists`);
|
|
71
|
+
return;
|
|
50
72
|
}
|
|
73
|
+
this.store.accountList.push(account);
|
|
51
74
|
const accountModule = new import_Account.AccountModule(`account_${account.id}`);
|
|
52
75
|
this.core.registerModule(accountModule);
|
|
53
76
|
accountModule.setAccountInfo(account);
|
|
@@ -72,7 +95,11 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
72
95
|
if (!account) {
|
|
73
96
|
throw new Error(`Account with id ${id} not found`);
|
|
74
97
|
}
|
|
75
|
-
|
|
98
|
+
account.setAccountInfo(updates);
|
|
99
|
+
const index = this.store.accountList.findIndex((account2) => account2.id === id);
|
|
100
|
+
if (index !== -1) {
|
|
101
|
+
this.store.accountList[index] = updates;
|
|
102
|
+
}
|
|
76
103
|
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
|
|
77
104
|
} catch (error) {
|
|
78
105
|
this.store.error = error instanceof Error ? error.message : "Failed to update account";
|
|
@@ -94,6 +121,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
94
121
|
...this.store.accounts.slice(0, index),
|
|
95
122
|
...this.store.accounts.slice(index + 1)
|
|
96
123
|
];
|
|
124
|
+
this.store.accountList = this.store.accountList.filter((account) => account.id !== id);
|
|
97
125
|
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
|
|
98
126
|
} catch (error) {
|
|
99
127
|
this.store.error = error instanceof Error ? error.message : "Failed to remove account";
|
|
@@ -136,6 +164,11 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
136
164
|
getActiveAccount() {
|
|
137
165
|
return this.store.accounts.find((account) => account.isActive()) || null;
|
|
138
166
|
}
|
|
167
|
+
storeChange() {
|
|
168
|
+
if (this.openCache) {
|
|
169
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["accounts", "accountList"] });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
139
172
|
};
|
|
140
173
|
// Annotate the CommonJS export names for ESM import in node:
|
|
141
174
|
0 && (module.exports = {
|
|
@@ -8,4 +8,10 @@ export declare class BaseModule {
|
|
|
8
8
|
protected core: PisellCore;
|
|
9
9
|
constructor(name?: string, version?: string);
|
|
10
10
|
destory(): void;
|
|
11
|
+
checkSaveCache({ cacheId, fatherModule, store, cacheKey }: {
|
|
12
|
+
cacheId: string | undefined;
|
|
13
|
+
fatherModule: string | undefined;
|
|
14
|
+
store: any;
|
|
15
|
+
cacheKey: string[];
|
|
16
|
+
}): void;
|
|
11
17
|
}
|
|
@@ -34,6 +34,43 @@ var BaseModule = class {
|
|
|
34
34
|
this.core.effects.offByModuleDestroy(this.name);
|
|
35
35
|
this.core.unregisterModule(this);
|
|
36
36
|
}
|
|
37
|
+
// 提供统一的缓存 module 里的数据的方法
|
|
38
|
+
checkSaveCache({ cacheId, fatherModule, store, cacheKey }) {
|
|
39
|
+
const window = this.core.getPlugin("window");
|
|
40
|
+
if (cacheId) {
|
|
41
|
+
if (fatherModule) {
|
|
42
|
+
const currentCacheData = window.sessionStorage.getItem(fatherModule);
|
|
43
|
+
let currentCacheDataObj = JSON.parse(currentCacheData || "{}");
|
|
44
|
+
if (!currentCacheData || !currentCacheDataObj[cacheId]) {
|
|
45
|
+
currentCacheDataObj = {
|
|
46
|
+
[cacheId]: {
|
|
47
|
+
[this.name]: {}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (!currentCacheDataObj[cacheId][this.name]) {
|
|
52
|
+
currentCacheDataObj[cacheId][this.name] = {};
|
|
53
|
+
}
|
|
54
|
+
cacheKey.forEach((key) => {
|
|
55
|
+
currentCacheDataObj[cacheId][this.name][key] = store == null ? void 0 : store[key];
|
|
56
|
+
});
|
|
57
|
+
window.sessionStorage.setItem(fatherModule, JSON.stringify(currentCacheDataObj));
|
|
58
|
+
} else {
|
|
59
|
+
let currentCacheData = window.sessionStorage.getItem(cacheId);
|
|
60
|
+
let currentCacheDataObj = JSON.parse(currentCacheData || "{}");
|
|
61
|
+
if (!currentCacheDataObj) {
|
|
62
|
+
currentCacheDataObj = {};
|
|
63
|
+
}
|
|
64
|
+
if (!currentCacheDataObj[this.name]) {
|
|
65
|
+
currentCacheDataObj[this.name] = {};
|
|
66
|
+
}
|
|
67
|
+
cacheKey.forEach((key) => {
|
|
68
|
+
currentCacheDataObj[this.name][key] = store[key];
|
|
69
|
+
});
|
|
70
|
+
window.sessionStorage.setItem(cacheId, JSON.stringify(currentCacheDataObj));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
37
74
|
};
|
|
38
75
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
76
|
0 && (module.exports = {
|
|
@@ -11,6 +11,9 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
11
11
|
private request;
|
|
12
12
|
private window;
|
|
13
13
|
private store;
|
|
14
|
+
private cacheId;
|
|
15
|
+
private openCache;
|
|
16
|
+
private fatherModule;
|
|
14
17
|
constructor(name?: string, version?: string);
|
|
15
18
|
/**
|
|
16
19
|
* 初始化购物车模块
|
|
@@ -36,6 +39,10 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
36
39
|
* 获取购物车商品
|
|
37
40
|
*/
|
|
38
41
|
getItems(): CartItem[];
|
|
42
|
+
/**
|
|
43
|
+
* 获取购物车商品--通过购物车 id 获取单条
|
|
44
|
+
*/
|
|
45
|
+
getItem(id: string): CartItem | undefined;
|
|
39
46
|
/**
|
|
40
47
|
* 根据账户ID获取购物车
|
|
41
48
|
*/
|
|
@@ -56,4 +63,5 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
56
63
|
* 清除购物车
|
|
57
64
|
*/
|
|
58
65
|
clear(): void;
|
|
66
|
+
storeChange(): void;
|
|
59
67
|
}
|
|
@@ -33,14 +33,28 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
33
33
|
// 提供给 baseModule 用的默认名称 和 默认版本
|
|
34
34
|
this.defaultName = "cart";
|
|
35
35
|
this.defaultVersion = "1.0.0";
|
|
36
|
+
this.openCache = false;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* 初始化购物车模块
|
|
39
40
|
*/
|
|
40
41
|
async initialize(core, options) {
|
|
42
|
+
var _a, _b, _c;
|
|
41
43
|
this.core = core;
|
|
42
44
|
this.store = options.store;
|
|
43
|
-
|
|
45
|
+
if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
|
|
46
|
+
this.store.list = options.initialState.list;
|
|
47
|
+
this.core.effects.emit(`${this.name}:changed`, this.store.list);
|
|
48
|
+
} else {
|
|
49
|
+
this.store.list = [];
|
|
50
|
+
}
|
|
51
|
+
if ((_b = options.otherParams) == null ? void 0 : _b.cacheId) {
|
|
52
|
+
this.openCache = options.otherParams.openCache;
|
|
53
|
+
this.cacheId = options.otherParams.cacheId;
|
|
54
|
+
}
|
|
55
|
+
if ((_c = options.otherParams) == null ? void 0 : _c.fatherModule) {
|
|
56
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
57
|
+
}
|
|
44
58
|
this.request = core.getPlugin("request");
|
|
45
59
|
this.window = core.getPlugin("window");
|
|
46
60
|
if (!this.request) {
|
|
@@ -131,6 +145,12 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
131
145
|
getItems() {
|
|
132
146
|
return this.store.list;
|
|
133
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* 获取购物车商品--通过购物车 id 获取单条
|
|
150
|
+
*/
|
|
151
|
+
getItem(id) {
|
|
152
|
+
return this.store.list.find((item) => item._id === id);
|
|
153
|
+
}
|
|
134
154
|
/**
|
|
135
155
|
* 根据账户ID获取购物车
|
|
136
156
|
*/
|
|
@@ -172,6 +192,11 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
172
192
|
clear() {
|
|
173
193
|
this.store.list = [];
|
|
174
194
|
}
|
|
195
|
+
storeChange() {
|
|
196
|
+
if (this.openCache) {
|
|
197
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["list"] });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
175
200
|
};
|
|
176
201
|
// Annotate the CommonJS export names for ESM import in node:
|
|
177
202
|
0 && (module.exports = {
|
|
@@ -195,6 +195,13 @@ var formatResourceToCartItem = (params) => {
|
|
|
195
195
|
cartItem.end_date = (0, import_dayjs.default)(firstResource.endTime).format("YYYY-MM-DD");
|
|
196
196
|
cartItem.end_time = (0, import_dayjs.default)(firstResource.endTime).format("HH:mm");
|
|
197
197
|
}
|
|
198
|
+
} else {
|
|
199
|
+
cartItem.resource_id = void 0;
|
|
200
|
+
cartItem.relation_form_name = void 0;
|
|
201
|
+
cartItem.start_date = void 0;
|
|
202
|
+
cartItem.start_time = void 0;
|
|
203
|
+
cartItem.end_date = void 0;
|
|
204
|
+
cartItem.end_time = void 0;
|
|
198
205
|
}
|
|
199
206
|
const oringin = formatResourceToCartItemOrigin(params);
|
|
200
207
|
cartItem._origin = oringin;
|
|
@@ -226,6 +233,13 @@ var formatResourceToCartItemOrigin = (params) => {
|
|
|
226
233
|
origin.end_date = (0, import_dayjs.default)(endTime).format("YYYY-MM-DD");
|
|
227
234
|
origin.end_time = (0, import_dayjs.default)(endTime).format("HH:mm");
|
|
228
235
|
}
|
|
236
|
+
} else if ((resources == null ? void 0 : resources.length) === 0) {
|
|
237
|
+
origin.resources = [];
|
|
238
|
+
origin.select_date = null;
|
|
239
|
+
origin.start_date = null;
|
|
240
|
+
origin.start_time = null;
|
|
241
|
+
origin.end_date = null;
|
|
242
|
+
origin.end_time = null;
|
|
229
243
|
}
|
|
230
244
|
return origin;
|
|
231
245
|
};
|
|
@@ -6,6 +6,9 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
6
6
|
protected defaultVersion: string;
|
|
7
7
|
private store;
|
|
8
8
|
private request;
|
|
9
|
+
private cacheId;
|
|
10
|
+
private openCache;
|
|
11
|
+
private fatherModule;
|
|
9
12
|
constructor(name?: string, version?: string);
|
|
10
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
11
14
|
setDateRange(dateRange: ITime[]): void;
|
|
@@ -13,4 +16,6 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
13
16
|
getMonthDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
14
17
|
getDateList(): Promise<ITime[]>;
|
|
15
18
|
getAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
19
|
+
clearDateRange(): void;
|
|
20
|
+
storeChange(): void;
|
|
16
21
|
}
|
|
@@ -40,14 +40,27 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
40
40
|
super(name, version);
|
|
41
41
|
this.defaultName = "date";
|
|
42
42
|
this.defaultVersion = "1.0.0";
|
|
43
|
+
this.openCache = false;
|
|
43
44
|
}
|
|
44
45
|
async initialize(core, options) {
|
|
46
|
+
var _a, _b;
|
|
45
47
|
this.core = core;
|
|
46
48
|
this.store = options.store;
|
|
47
49
|
this.request = this.core.getPlugin("request");
|
|
50
|
+
if (options.initialState) {
|
|
51
|
+
this.store.dateRange = options.initialState.dateRange;
|
|
52
|
+
this.store.dateList = options.initialState.dateList;
|
|
53
|
+
}
|
|
48
54
|
if (!this.request) {
|
|
49
55
|
throw new Error("DateModule 需要 request 插件支持");
|
|
50
56
|
}
|
|
57
|
+
if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
58
|
+
this.openCache = options.otherParams.openCache;
|
|
59
|
+
this.cacheId = options.otherParams.cacheId;
|
|
60
|
+
}
|
|
61
|
+
if ((_b = options.otherParams) == null ? void 0 : _b.fatherModule) {
|
|
62
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
63
|
+
}
|
|
51
64
|
}
|
|
52
65
|
setDateRange(dateRange) {
|
|
53
66
|
this.store.dateRange = dateRange;
|
|
@@ -90,6 +103,14 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
90
103
|
return (0, import_utils.disableAllDates)(dates);
|
|
91
104
|
}
|
|
92
105
|
}
|
|
106
|
+
clearDateRange() {
|
|
107
|
+
this.store.dateRange = [];
|
|
108
|
+
}
|
|
109
|
+
storeChange() {
|
|
110
|
+
if (this.openCache) {
|
|
111
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["dateRange", "dateList"] });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
93
114
|
};
|
|
94
115
|
// Annotate the CommonJS export names for ESM import in node:
|
|
95
116
|
0 && (module.exports = {
|
|
@@ -7,6 +7,9 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
7
7
|
private request;
|
|
8
8
|
private window;
|
|
9
9
|
private store;
|
|
10
|
+
private cacheId;
|
|
11
|
+
private openCache;
|
|
12
|
+
private fatherModule;
|
|
10
13
|
constructor(name?: string, version?: string);
|
|
11
14
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
12
15
|
setDiscountList(discountList: Discount[]): Promise<void>;
|
|
@@ -23,4 +26,5 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
23
26
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number;
|
|
24
27
|
destroy(): Promise<void>;
|
|
25
28
|
clear(): Promise<void>;
|
|
29
|
+
storeChange(): void;
|
|
26
30
|
}
|
|
@@ -30,10 +30,24 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
30
30
|
super(name, version);
|
|
31
31
|
this.defaultName = "discount";
|
|
32
32
|
this.defaultVersion = "1.0.0";
|
|
33
|
+
this.openCache = false;
|
|
33
34
|
}
|
|
34
35
|
async initialize(core, options) {
|
|
36
|
+
var _a, _b, _c;
|
|
35
37
|
this.core = core;
|
|
36
38
|
this.store = options == null ? void 0 : options.store;
|
|
39
|
+
if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.discountList)) {
|
|
40
|
+
this.store.discountList = options == null ? void 0 : options.initialState.discountList;
|
|
41
|
+
} else {
|
|
42
|
+
this.store.discountList = [];
|
|
43
|
+
}
|
|
44
|
+
if ((_b = options == null ? void 0 : options.otherParams) == null ? void 0 : _b.cacheId) {
|
|
45
|
+
this.openCache = options.otherParams.openCache;
|
|
46
|
+
this.cacheId = options.otherParams.cacheId;
|
|
47
|
+
}
|
|
48
|
+
if ((_c = options == null ? void 0 : options.otherParams) == null ? void 0 : _c.fatherModule) {
|
|
49
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
50
|
+
}
|
|
37
51
|
this.request = core.getPlugin("request");
|
|
38
52
|
this.window = core.getPlugin("window");
|
|
39
53
|
if (!this.request) {
|
|
@@ -111,6 +125,11 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
111
125
|
this.store.discountList = [];
|
|
112
126
|
console.log("[Discount] clear");
|
|
113
127
|
}
|
|
128
|
+
storeChange() {
|
|
129
|
+
if (this.openCache) {
|
|
130
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["discountList"] });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
114
133
|
};
|
|
115
134
|
// Annotate the CommonJS export names for ESM import in node:
|
|
116
135
|
0 && (module.exports = {
|
|
@@ -71,7 +71,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
71
71
|
const { discount_list } = this.hooks.getProduct(product);
|
|
72
72
|
if (discount_list && discount_list.length > 0) {
|
|
73
73
|
const usedNewDiscount = discount_list.some(
|
|
74
|
-
(discount) =>
|
|
74
|
+
(discount) => {
|
|
75
|
+
var _a;
|
|
76
|
+
return newDiscountIds.includes((_a = discount == null ? void 0 : discount.discount) == null ? void 0 : _a.resource_id);
|
|
77
|
+
}
|
|
75
78
|
);
|
|
76
79
|
if (usedNewDiscount) {
|
|
77
80
|
hasApplicableDiscount = true;
|
|
@@ -129,15 +132,17 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
129
132
|
addModeDiscount.forEach((discount) => {
|
|
130
133
|
var _a;
|
|
131
134
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
132
|
-
if (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
|
|
135
|
+
if (!(product == null ? void 0 : product.booking_id) && (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id))) {
|
|
133
136
|
(_a = discountApplicability.get(discount.id)) == null ? void 0 : _a.push(product.id);
|
|
134
137
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
135
138
|
applicableProducts.push({
|
|
136
139
|
amount: product.price,
|
|
137
140
|
type: discount.tag,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
discount: {
|
|
142
|
+
resource_id: discount.id,
|
|
143
|
+
title: discount.format_title,
|
|
144
|
+
original_amount: product.origin_total
|
|
145
|
+
}
|
|
141
146
|
});
|
|
142
147
|
discountApplicableProducts.set(discount.id, applicableProducts);
|
|
143
148
|
}
|
|
@@ -5,6 +5,9 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
|
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
7
7
|
private store;
|
|
8
|
+
private cacheId;
|
|
9
|
+
private openCache;
|
|
10
|
+
private fatherModule;
|
|
8
11
|
constructor(name?: string, version?: string);
|
|
9
12
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
10
13
|
init(steps: IStep[]): void;
|
|
@@ -16,4 +19,5 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
|
|
|
16
19
|
prevStep(): void;
|
|
17
20
|
nextStep(): void;
|
|
18
21
|
gotoStep(stepIndex: number): void;
|
|
22
|
+
storeChange(): void;
|
|
19
23
|
}
|
|
@@ -28,10 +28,24 @@ var StepModule = class extends import_BaseModule.BaseModule {
|
|
|
28
28
|
super(name, version);
|
|
29
29
|
this.defaultName = "step";
|
|
30
30
|
this.defaultVersion = "1.0.0";
|
|
31
|
+
this.openCache = false;
|
|
31
32
|
}
|
|
32
33
|
async initialize(core, options) {
|
|
34
|
+
var _a, _b;
|
|
33
35
|
this.core = core;
|
|
34
36
|
this.store = options.store;
|
|
37
|
+
if (options.initialState) {
|
|
38
|
+
this.store.stepList = options.initialState.stepList;
|
|
39
|
+
this.store.currentStep = options.initialState.currentStep;
|
|
40
|
+
this.store.currentStepIndex = options.initialState.currentStepIndex;
|
|
41
|
+
}
|
|
42
|
+
if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
43
|
+
this.openCache = options.otherParams.openCache;
|
|
44
|
+
this.cacheId = options.otherParams.cacheId;
|
|
45
|
+
}
|
|
46
|
+
if ((_b = options.otherParams) == null ? void 0 : _b.fatherModule) {
|
|
47
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
48
|
+
}
|
|
35
49
|
}
|
|
36
50
|
init(steps) {
|
|
37
51
|
this.setSteps(steps);
|
|
@@ -69,6 +83,11 @@ var StepModule = class extends import_BaseModule.BaseModule {
|
|
|
69
83
|
gotoStep(stepIndex) {
|
|
70
84
|
this.setCurrentStep(stepIndex);
|
|
71
85
|
}
|
|
86
|
+
storeChange() {
|
|
87
|
+
if (this.openCache) {
|
|
88
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["currentStepIndex", "currentStep", "stepList"] });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
72
91
|
};
|
|
73
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74
93
|
0 && (module.exports = {
|
|
@@ -7,7 +7,11 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
|
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private shopStore;
|
|
9
9
|
private store;
|
|
10
|
+
private cacheId;
|
|
11
|
+
private openCache;
|
|
12
|
+
private fatherModule;
|
|
10
13
|
constructor(name?: string, version?: string);
|
|
11
14
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
12
15
|
getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
|
|
16
|
+
storeChange(): void;
|
|
13
17
|
}
|
|
@@ -29,11 +29,23 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
29
29
|
super(name, version);
|
|
30
30
|
this.defaultName = "summary";
|
|
31
31
|
this.defaultVersion = "1.0.0";
|
|
32
|
+
this.openCache = false;
|
|
32
33
|
}
|
|
33
34
|
async initialize(core, options) {
|
|
35
|
+
var _a, _b;
|
|
34
36
|
this.core = core;
|
|
35
37
|
this.store = options.store;
|
|
36
38
|
this.shopStore = this.core.getPlugin("shopStore");
|
|
39
|
+
if (options.initialState) {
|
|
40
|
+
this.store.summary = options.initialState.summary;
|
|
41
|
+
}
|
|
42
|
+
if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
43
|
+
this.openCache = options.otherParams.openCache;
|
|
44
|
+
this.cacheId = options.otherParams.cacheId;
|
|
45
|
+
}
|
|
46
|
+
if ((_b = options.otherParams) == null ? void 0 : _b.fatherModule) {
|
|
47
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
48
|
+
}
|
|
37
49
|
if (!this.shopStore) {
|
|
38
50
|
throw new Error("SummaryModule 需要 shopStore 插件支持");
|
|
39
51
|
}
|
|
@@ -45,6 +57,11 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
45
57
|
this.store.summary = summary;
|
|
46
58
|
return this.store.summary;
|
|
47
59
|
}
|
|
60
|
+
storeChange() {
|
|
61
|
+
if (this.openCache) {
|
|
62
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["summary"] });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
48
65
|
};
|
|
49
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
67
|
0 && (module.exports = {
|
|
@@ -38,8 +38,9 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
38
38
|
getActiveAccount(): Account | null;
|
|
39
39
|
removeAccount(id: string): void;
|
|
40
40
|
setDateRange(dateRange: ITime[]): Promise<void>;
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
clearDateRange(): void;
|
|
42
|
+
getDateRange(): Promise<ITime[]>;
|
|
43
|
+
getCart(): CartItem[];
|
|
43
44
|
getAvailableDate(params?: {
|
|
44
45
|
products?: ProductData[];
|
|
45
46
|
startDate?: string;
|
|
@@ -79,6 +80,14 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
79
80
|
deleteCartItemInfo(types: "resource" | "time"): void;
|
|
80
81
|
destory(): void;
|
|
81
82
|
getResourcesList(): any[];
|
|
83
|
+
getResourcesListByCartItem(id: string | number): {
|
|
84
|
+
id: number | undefined;
|
|
85
|
+
_id: string;
|
|
86
|
+
product: ProductData | undefined;
|
|
87
|
+
resources: import("./utils/resources").ResourceItem[];
|
|
88
|
+
holder_id: string | number | undefined;
|
|
89
|
+
holder_name: string | undefined;
|
|
90
|
+
} | undefined;
|
|
82
91
|
getResourceTimeSlot({ product, resources, currentResourceId, }: {
|
|
83
92
|
product: ProductData;
|
|
84
93
|
resources: any[];
|
|
@@ -111,4 +120,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
111
120
|
};
|
|
112
121
|
getTimeSlotByAllResources(resources_code: string): any[];
|
|
113
122
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
123
|
+
clearCache(): void;
|
|
124
|
+
clearCacheByModule(module: string): void;
|
|
114
125
|
}
|