@pisell/pisellos 3.0.42 → 3.0.44
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.js +17 -12
- package/dist/modules/Cart/index.d.ts +14 -0
- package/dist/modules/Cart/index.js +38 -1
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +28 -8
- package/dist/modules/Date/index.js +70 -6
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +13 -6
- package/dist/modules/Discount/types.d.ts +10 -0
- package/dist/modules/ProductList/index.d.ts +7 -0
- package/dist/modules/ProductList/index.js +102 -39
- package/dist/modules/Rules/index.js +218 -80
- package/dist/modules/Rules/types.d.ts +7 -1
- package/dist/modules/Schedule/index.d.ts +9 -1
- package/dist/modules/Schedule/index.js +122 -2
- package/dist/modules/Schedule/types.d.ts +13 -0
- package/dist/solution/BookingByStep/index.d.ts +120 -30
- package/dist/solution/BookingByStep/index.js +755 -1078
- package/dist/solution/BookingByStep/utils/capacity.d.ts +47 -0
- package/dist/solution/BookingByStep/utils/capacity.js +132 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +21 -29
- package/dist/solution/BookingByStep/utils/resources.js +39 -95
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +11 -0
- package/dist/solution/BookingByStep/utils/timeslots.js +15 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +119 -44
- package/lib/modules/AccountList/index.js +4 -0
- package/lib/modules/Cart/index.d.ts +14 -0
- package/lib/modules/Cart/index.js +34 -1
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -0
- package/lib/modules/Cart/utils/cartProduct.js +20 -8
- package/lib/modules/Date/index.js +59 -2
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +17 -6
- package/lib/modules/Discount/types.d.ts +10 -0
- package/lib/modules/ProductList/index.d.ts +7 -0
- package/lib/modules/ProductList/index.js +45 -0
- package/lib/modules/Rules/index.js +154 -63
- package/lib/modules/Rules/types.d.ts +7 -1
- package/lib/modules/Schedule/index.d.ts +9 -1
- package/lib/modules/Schedule/index.js +79 -1
- package/lib/modules/Schedule/types.d.ts +13 -0
- package/lib/solution/BookingByStep/index.d.ts +120 -30
- package/lib/solution/BookingByStep/index.js +391 -589
- package/lib/solution/BookingByStep/utils/capacity.d.ts +47 -0
- package/lib/solution/BookingByStep/utils/capacity.js +106 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +21 -29
- package/lib/solution/BookingByStep/utils/resources.js +21 -58
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +11 -0
- package/lib/solution/BookingByStep/utils/timeslots.js +7 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +91 -19
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/modules/Schedule/index.ts
|
|
@@ -24,6 +34,12 @@ __export(Schedule_exports, {
|
|
|
24
34
|
module.exports = __toCommonJS(Schedule_exports);
|
|
25
35
|
var import_lodash_es = require("lodash-es");
|
|
26
36
|
var import_BaseModule = require("../BaseModule");
|
|
37
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
38
|
+
var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
|
|
39
|
+
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
40
|
+
var import_utils = require("../Date/utils");
|
|
41
|
+
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
42
|
+
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
27
43
|
var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
28
44
|
constructor(name, version) {
|
|
29
45
|
super(name, version);
|
|
@@ -35,6 +51,10 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
35
51
|
async initialize(core, options) {
|
|
36
52
|
var _a, _b;
|
|
37
53
|
this.core = core;
|
|
54
|
+
this.request = core.getPlugin("request");
|
|
55
|
+
if (!this.request) {
|
|
56
|
+
throw new Error("ScheduleModule 需要 request 插件支持");
|
|
57
|
+
}
|
|
38
58
|
this.store = options == null ? void 0 : options.store;
|
|
39
59
|
if (options.initialState) {
|
|
40
60
|
this.store.scheduleList = options.initialState.scheduleList;
|
|
@@ -51,9 +71,67 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
51
71
|
this.fatherModule = options.otherParams.fatherModule;
|
|
52
72
|
}
|
|
53
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* 加载当前店铺下所有 schedule
|
|
76
|
+
*
|
|
77
|
+
* @memberof ScheduleModule
|
|
78
|
+
*/
|
|
79
|
+
async loadAllSchedule() {
|
|
80
|
+
var _a;
|
|
81
|
+
const scheduleList = await this.request.get(
|
|
82
|
+
`/schedule`,
|
|
83
|
+
{ num: 999 },
|
|
84
|
+
{ useCache: true }
|
|
85
|
+
);
|
|
86
|
+
this.setScheduleList(((_a = scheduleList.data) == null ? void 0 : _a.list) || []);
|
|
87
|
+
}
|
|
54
88
|
setScheduleList(list) {
|
|
55
89
|
this.store.scheduleList = list;
|
|
56
90
|
}
|
|
91
|
+
async loadScheduleAvailableDate({
|
|
92
|
+
startDate,
|
|
93
|
+
endDate,
|
|
94
|
+
custom_page_id,
|
|
95
|
+
channel
|
|
96
|
+
}) {
|
|
97
|
+
var _a, _b, _c;
|
|
98
|
+
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
99
|
+
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
100
|
+
}
|
|
101
|
+
let dates = (0, import_utils.generateMonthDates)(startDate, endDate);
|
|
102
|
+
dates = (0, import_utils.disableAllDates)(dates);
|
|
103
|
+
if ((0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
104
|
+
return dates;
|
|
105
|
+
}
|
|
106
|
+
const res = await this.request.get(
|
|
107
|
+
`/schedule/product/availability/v2`,
|
|
108
|
+
{
|
|
109
|
+
start_date: startDate,
|
|
110
|
+
end_date: endDate,
|
|
111
|
+
custom_page_id,
|
|
112
|
+
channel
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
this.setAvailabilityScheduleDateList(res.data.date_list);
|
|
116
|
+
this.setOtherProductsIds(res.data.other_product_ids || []);
|
|
117
|
+
if (!((_a = res.data.date_list) == null ? void 0 : _a.length) && !((_b = res.data.other_product_ids) == null ? void 0 : _b.length) || (0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
118
|
+
return dates;
|
|
119
|
+
}
|
|
120
|
+
if ((_c = res.data.other_product_ids) == null ? void 0 : _c.length) {
|
|
121
|
+
dates.forEach((n) => {
|
|
122
|
+
n.status = "available";
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
res.data.date_list.forEach((n) => {
|
|
126
|
+
const index = dates.findIndex((m) => m.date === n.date);
|
|
127
|
+
if (index !== -1) {
|
|
128
|
+
dates[index].status = "available";
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
dates = (0, import_utils.disableDatesBeforeOneDay)(dates);
|
|
133
|
+
return dates;
|
|
134
|
+
}
|
|
57
135
|
getScheduleListByIds(ids) {
|
|
58
136
|
return this.store.scheduleList.filter((n) => ids.includes(n.id));
|
|
59
137
|
}
|
|
@@ -76,7 +154,7 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
76
154
|
cacheId: this.cacheId,
|
|
77
155
|
fatherModule: this.fatherModule,
|
|
78
156
|
store,
|
|
79
|
-
cacheKey: ["scheduleList", "availabilityDateList"]
|
|
157
|
+
cacheKey: ["scheduleList", "availabilityDateList", "otherProductsIds"]
|
|
80
158
|
});
|
|
81
159
|
}
|
|
82
160
|
}
|
|
@@ -9,6 +9,19 @@ export type ScheduleAvailabilityDateItem = {
|
|
|
9
9
|
schedule_id: number[];
|
|
10
10
|
product_ids: number[];
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* 加载日程可用日期参数接口
|
|
14
|
+
*/
|
|
15
|
+
export interface LoadScheduleAvailableDateParams {
|
|
16
|
+
/** 开始日期 */
|
|
17
|
+
startDate: string;
|
|
18
|
+
/** 结束日期 */
|
|
19
|
+
endDate: string;
|
|
20
|
+
/** 自定义页面ID */
|
|
21
|
+
custom_page_id?: number;
|
|
22
|
+
/** 渠道 */
|
|
23
|
+
channel?: string;
|
|
24
|
+
}
|
|
12
25
|
export interface ScheduleModuleAPI {
|
|
13
26
|
}
|
|
14
27
|
export type ScheduleItem = {
|
|
@@ -8,6 +8,7 @@ import { IStep } from '../../modules/Step/tyeps';
|
|
|
8
8
|
import { TimeSliceItem, ResourceItem } from './utils/resources';
|
|
9
9
|
import { ITime } from '../../modules/Date/types';
|
|
10
10
|
import dayjs from 'dayjs';
|
|
11
|
+
import { LoadScheduleAvailableDateParams } from '../../modules/Schedule/types';
|
|
11
12
|
import { IHolder, IFetchHolderAccountsParams } from '../../modules/AccountList/types';
|
|
12
13
|
export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
13
14
|
protected defaultName: string;
|
|
@@ -42,26 +43,70 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
42
43
|
* 更新step
|
|
43
44
|
*/
|
|
44
45
|
updateStep(key: string, step: IStep): void;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* 加载商品,然后导到商品列表里去
|
|
49
|
+
* @param {({
|
|
50
|
+
* category_ids?: number[];
|
|
51
|
+
* product_ids?: number[];
|
|
52
|
+
* collection?: number | string[];
|
|
53
|
+
* schedule_date?: string;
|
|
54
|
+
* })} {
|
|
55
|
+
* category_ids = [],
|
|
56
|
+
* product_ids = [],
|
|
57
|
+
* collection = [],
|
|
58
|
+
* schedule_date,
|
|
59
|
+
* }
|
|
60
|
+
* @return {*}
|
|
61
|
+
* @memberof BookingByStepImpl
|
|
62
|
+
*/
|
|
45
63
|
loadProducts({ category_ids, product_ids, collection, schedule_date, }: {
|
|
46
64
|
category_ids?: number[];
|
|
47
65
|
product_ids?: number[];
|
|
48
66
|
collection?: number | string[];
|
|
49
67
|
schedule_date?: string;
|
|
50
68
|
}): Promise<any>;
|
|
69
|
+
/**
|
|
70
|
+
* 通过 schedule 来读取商品,适用于 session 类商品
|
|
71
|
+
*
|
|
72
|
+
* @param {{
|
|
73
|
+
* date: string;
|
|
74
|
+
* product_ids?: number[];
|
|
75
|
+
* category_ids?: number[];
|
|
76
|
+
* }} {
|
|
77
|
+
* date,
|
|
78
|
+
* product_ids = [],
|
|
79
|
+
* category_ids = [],
|
|
80
|
+
* }
|
|
81
|
+
* @return {*}
|
|
82
|
+
* @memberof BookingByStepImpl
|
|
83
|
+
*/
|
|
51
84
|
loadProductByScheduleDate({ date, product_ids, category_ids, }: {
|
|
52
85
|
date: string;
|
|
53
86
|
product_ids?: number[];
|
|
54
87
|
category_ids?: number[];
|
|
55
88
|
}): Promise<any>;
|
|
89
|
+
/**
|
|
90
|
+
* 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
91
|
+
*
|
|
92
|
+
* @param {string} date
|
|
93
|
+
* @memberof BookingByStepImpl
|
|
94
|
+
*/
|
|
56
95
|
updateQuotationPriceAndCart(date: string): Promise<void>;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
96
|
+
/**
|
|
97
|
+
* ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
98
|
+
* 适用于先选日期的流程,确定日期是否可用
|
|
99
|
+
* 已知问题:如果挂接的商品的资源不可用,后端是不会计算的
|
|
100
|
+
*
|
|
101
|
+
* @param {LoadScheduleAvailableDateParams} {
|
|
102
|
+
* startDate,
|
|
103
|
+
* endDate,
|
|
104
|
+
* custom_page_id,
|
|
105
|
+
* channel,
|
|
106
|
+
* }
|
|
107
|
+
* @memberof BookingByStepImpl
|
|
108
|
+
*/
|
|
109
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, }: LoadScheduleAvailableDateParams): Promise<ITime[]>;
|
|
65
110
|
addAccount(account: Account | IHolder, extra?: {
|
|
66
111
|
type: 'account' | 'holder';
|
|
67
112
|
customerId: number;
|
|
@@ -73,7 +118,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
73
118
|
getAccounts(): Promise<(Account | null)[]>;
|
|
74
119
|
checkHasLoginAccount(): boolean;
|
|
75
120
|
setActiveAccount(id: string): void;
|
|
76
|
-
getActiveAccount(): Account |
|
|
121
|
+
getActiveAccount(): Account | undefined;
|
|
77
122
|
removeAccount(id: string): void;
|
|
78
123
|
/**
|
|
79
124
|
* 获取holder类型账户列表
|
|
@@ -127,7 +172,60 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
127
172
|
cover?: boolean;
|
|
128
173
|
}): Promise<void>;
|
|
129
174
|
getOtherParams(): Promise<Record<string, any>>;
|
|
175
|
+
/**
|
|
176
|
+
* 往购物车加商品数据(duration 类、普通商品)
|
|
177
|
+
* 老接口,先不删,怕 UI 有问题,直接桥接到新接口addProductToCart上
|
|
178
|
+
*
|
|
179
|
+
* @param {ProductData} productData
|
|
180
|
+
* @memberof BookingByStepImpl
|
|
181
|
+
*/
|
|
182
|
+
storeProduct(productData: ProductData): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* 往购物车加商品数据
|
|
185
|
+
*
|
|
186
|
+
* @param {({
|
|
187
|
+
* product: ProductData;
|
|
188
|
+
* date?: { startTime: string; endTime: string } | null;
|
|
189
|
+
* account?: Account | null;
|
|
190
|
+
* })} {
|
|
191
|
+
* product,
|
|
192
|
+
* date,
|
|
193
|
+
* account,
|
|
194
|
+
* }
|
|
195
|
+
* @return {*}
|
|
196
|
+
* @memberof BookingByStepImpl
|
|
197
|
+
*/
|
|
198
|
+
addProductToCart({ product, date, account, }: {
|
|
199
|
+
product: ProductData;
|
|
200
|
+
date?: {
|
|
201
|
+
startTime: string;
|
|
202
|
+
endTime: string;
|
|
203
|
+
} | null;
|
|
204
|
+
account?: Account | null;
|
|
205
|
+
}): void;
|
|
206
|
+
/**
|
|
207
|
+
* 添加完购物车以后做的一些检测,比如日期是否在同一天
|
|
208
|
+
*
|
|
209
|
+
* @param {({ date?: { startTime: string; endTime: string } | null })} { date }
|
|
210
|
+
* @memberof BookingByStepImpl
|
|
211
|
+
*/
|
|
212
|
+
addProductCheck({ date, }: {
|
|
213
|
+
date?: {
|
|
214
|
+
startTime: string;
|
|
215
|
+
endTime: string;
|
|
216
|
+
} | null;
|
|
217
|
+
}): void;
|
|
218
|
+
beforeUpdateCart(params: IUpdateItemParams, targetCartItem: CartItem): void;
|
|
130
219
|
updateCart(params: IUpdateItemParams): void;
|
|
220
|
+
/**
|
|
221
|
+
* 更新购物车以后的一些操作,比如检测资源是否重复,检测资源容量是否足够
|
|
222
|
+
*
|
|
223
|
+
* @param {IUpdateItemParams} params
|
|
224
|
+
* @param {CartItem} targetCartItem
|
|
225
|
+
* @return {*}
|
|
226
|
+
* @memberof BookingByStepImpl
|
|
227
|
+
*/
|
|
228
|
+
updateCartCheck(params: IUpdateItemParams, targetCartItem: CartItem): void;
|
|
131
229
|
deleteCart(cartItemId: string): void;
|
|
132
230
|
clearCart(): void;
|
|
133
231
|
clearCartByAccount(account_id: string): void;
|
|
@@ -148,7 +246,20 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
148
246
|
checkCartItems(type: ECartItemCheckType): string[];
|
|
149
247
|
destroy(): void;
|
|
150
248
|
getResourcesList(): any[];
|
|
249
|
+
/**
|
|
250
|
+
* 在日期那边点击下一步的时候,检查这一天购物车里的商品是不是都有资源可以用
|
|
251
|
+
*
|
|
252
|
+
* @return {*}
|
|
253
|
+
* @memberof BookingByStepImpl
|
|
254
|
+
*/
|
|
151
255
|
checkResourceListForDate(): boolean;
|
|
256
|
+
/**
|
|
257
|
+
* 给单个购物车里的商品获取资源列表,给 UI 用的
|
|
258
|
+
*
|
|
259
|
+
* @param {(string | number)} id
|
|
260
|
+
* @return {*}
|
|
261
|
+
* @memberof BookingByStepImpl
|
|
262
|
+
*/
|
|
152
263
|
getResourcesListByCartItem(id: string | number): {
|
|
153
264
|
id: number | undefined;
|
|
154
265
|
_id: string;
|
|
@@ -157,11 +268,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
157
268
|
holder_id: string | number | undefined;
|
|
158
269
|
holder_name: string | undefined;
|
|
159
270
|
} | undefined;
|
|
160
|
-
getResourceTimeSlot({ product, resources, currentResourceId, }: {
|
|
161
|
-
product: ProductData;
|
|
162
|
-
resources: any[];
|
|
163
|
-
currentResourceId: number;
|
|
164
|
-
}): TimeSliceItem[];
|
|
165
271
|
autoSelectAccountResources({ cartItem, holder_id, resources_code, timeSlots, countMap, capacity, }: {
|
|
166
272
|
cartItem: CartItem;
|
|
167
273
|
holder_id: string;
|
|
@@ -205,14 +311,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
205
311
|
count: number;
|
|
206
312
|
left: number;
|
|
207
313
|
}[];
|
|
208
|
-
addProductToCart({ product, date, account, }: {
|
|
209
|
-
product: ProductData;
|
|
210
|
-
date: {
|
|
211
|
-
startTime: string;
|
|
212
|
-
endTime: string;
|
|
213
|
-
};
|
|
214
|
-
account: Account;
|
|
215
|
-
}): void;
|
|
216
314
|
setOtherData(key: string, value: any): void;
|
|
217
315
|
getOtherData(key: string): any;
|
|
218
316
|
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
@@ -236,14 +334,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
236
334
|
scheduleIds?: number[];
|
|
237
335
|
resources?: ProductResourceItem[];
|
|
238
336
|
}): Promise<Record<string, TimeSliceItem[]>>;
|
|
239
|
-
getAvailableDateForSession(params?: {
|
|
240
|
-
startDate?: string;
|
|
241
|
-
endDate?: string;
|
|
242
|
-
type?: 'month';
|
|
243
|
-
}): Promise<{
|
|
244
|
-
dateList: ITime[];
|
|
245
|
-
firstAvailableDate: ITime | undefined;
|
|
246
|
-
}>;
|
|
247
337
|
getAvailableDateForSessionOptimize(params?: {
|
|
248
338
|
startDate?: string;
|
|
249
339
|
endDate?: string;
|