@pisell/pisellos 0.0.10 → 0.0.13
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 +4 -2
- package/dist/modules/Account/index.js +23 -36
- package/dist/modules/Account/types.d.ts +1 -0
- package/dist/modules/AccountList/index.d.ts +2 -0
- package/dist/modules/AccountList/index.js +34 -11
- package/dist/modules/Cart/index.d.ts +17 -11
- package/dist/modules/Cart/index.js +179 -121
- package/dist/modules/Cart/types.d.ts +98 -9
- package/dist/modules/Cart/types.js +8 -0
- package/dist/modules/Cart/utils.d.ts +114 -0
- package/dist/modules/Cart/utils.js +345 -0
- package/dist/modules/Date/index.d.ts +11 -12
- package/dist/modules/Date/index.js +104 -60
- package/dist/modules/Date/types.d.ts +51 -20
- package/dist/modules/Date/types.js +2 -5
- package/dist/modules/Date/utils.d.ts +35 -0
- package/dist/modules/Date/utils.js +211 -0
- package/dist/modules/Discount/index.d.ts +26 -0
- package/dist/modules/Discount/index.js +234 -0
- package/dist/modules/Discount/types.d.ts +66 -0
- package/dist/modules/Discount/types.js +5 -0
- package/dist/modules/Order/index.d.ts +16 -12
- package/dist/modules/Order/index.js +38 -166
- package/dist/modules/Order/types.d.ts +18 -41
- package/dist/modules/Order/types.js +0 -14
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +45 -76
- package/dist/modules/Payment/types.d.ts +0 -2
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Product/types.d.ts +48 -1
- package/dist/modules/ProductList/index.d.ts +1 -0
- package/dist/modules/ProductList/index.js +21 -1
- package/dist/modules/ProductList/types.d.ts +1 -0
- package/dist/modules/Resource/types.d.ts +6 -2
- package/dist/modules/Rules/index.d.ts +32 -0
- package/dist/modules/Rules/index.js +423 -0
- package/dist/modules/Rules/types.d.ts +46 -0
- package/dist/modules/Rules/types.js +5 -0
- package/dist/modules/Summary/index.d.ts +13 -0
- package/dist/modules/Summary/index.js +80 -0
- package/dist/modules/Summary/types.d.ts +13 -0
- package/dist/modules/Summary/types.js +1 -0
- package/dist/modules/Summary/utils.d.ts +19 -0
- package/dist/modules/Summary/utils.js +56 -0
- package/dist/plugins/index.d.ts +3 -2
- package/dist/plugins/index.js +2 -1
- package/dist/plugins/request.d.ts +4 -3
- package/dist/plugins/request.js +30 -30
- package/dist/plugins/shopStore.d.ts +4 -0
- package/dist/plugins/shopStore.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +73 -12
- package/dist/solution/BookingByStep/index.js +635 -99
- package/dist/solution/BookingByStep/types.d.ts +2 -0
- package/dist/solution/BookingByStep/types.js +11 -8
- package/dist/solution/BookingByStep/utils/products.d.ts +11 -0
- package/dist/solution/BookingByStep/utils/products.js +47 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +59 -10
- package/dist/solution/BookingByStep/utils/resources.js +144 -79
- package/dist/solution/ShopDiscount/index.d.ts +50 -0
- package/dist/solution/ShopDiscount/index.js +546 -0
- package/dist/solution/ShopDiscount/types.d.ts +24 -0
- package/dist/solution/ShopDiscount/types.js +10 -0
- package/dist/solution/ShopDiscount/utils.d.ts +1 -0
- package/dist/solution/ShopDiscount/utils.js +7 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/modules/Account/index.d.ts +4 -2
- package/lib/modules/Account/index.js +14 -3
- package/lib/modules/Account/types.d.ts +1 -0
- package/lib/modules/AccountList/index.d.ts +2 -0
- package/lib/modules/AccountList/index.js +17 -0
- package/lib/modules/Cart/index.d.ts +17 -11
- package/lib/modules/Cart/index.js +72 -21
- package/lib/modules/Cart/types.d.ts +98 -9
- package/lib/modules/Cart/utils.d.ts +114 -0
- package/lib/modules/Cart/utils.js +320 -0
- package/lib/modules/Date/index.d.ts +11 -12
- package/lib/modules/Date/index.js +50 -31
- package/lib/modules/Date/types.d.ts +51 -20
- package/lib/modules/Date/types.js +0 -4
- package/lib/modules/Date/utils.d.ts +35 -0
- package/lib/modules/Date/utils.js +167 -0
- package/lib/modules/Discount/index.d.ts +26 -0
- package/lib/modules/Discount/index.js +118 -0
- package/lib/modules/Discount/types.d.ts +66 -0
- package/lib/modules/Discount/types.js +33 -0
- package/lib/modules/Order/index.d.ts +16 -12
- package/lib/modules/Order/index.js +23 -51
- package/lib/modules/Order/types.d.ts +18 -41
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +6 -17
- package/lib/modules/Payment/types.d.ts +0 -2
- package/lib/modules/Product/types.d.ts +48 -1
- package/lib/modules/ProductList/index.d.ts +1 -0
- package/lib/modules/ProductList/index.js +4 -0
- package/lib/modules/ProductList/types.d.ts +1 -0
- package/lib/modules/Resource/types.d.ts +6 -2
- package/lib/modules/Rules/index.d.ts +32 -0
- package/lib/modules/Rules/index.js +283 -0
- package/lib/modules/Rules/types.d.ts +46 -0
- package/lib/modules/Rules/types.js +33 -0
- package/lib/modules/Summary/index.d.ts +13 -0
- package/lib/modules/Summary/index.js +49 -0
- package/lib/modules/Summary/types.d.ts +13 -0
- package/lib/modules/Summary/types.js +17 -0
- package/lib/modules/Summary/utils.d.ts +19 -0
- package/lib/modules/Summary/utils.js +79 -0
- package/lib/plugins/index.d.ts +3 -2
- package/lib/plugins/index.js +3 -1
- package/lib/plugins/request.d.ts +4 -3
- package/lib/plugins/request.js +4 -20
- package/lib/plugins/shopStore.d.ts +4 -0
- package/lib/plugins/shopStore.js +17 -0
- package/lib/solution/BookingByStep/index.d.ts +73 -12
- package/lib/solution/BookingByStep/index.js +451 -24
- package/lib/solution/BookingByStep/types.d.ts +2 -0
- package/lib/solution/BookingByStep/types.js +3 -0
- package/lib/solution/BookingByStep/utils/products.d.ts +11 -0
- package/lib/solution/BookingByStep/utils/products.js +60 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +59 -10
- package/lib/solution/BookingByStep/utils/resources.js +106 -49
- package/lib/solution/ShopDiscount/index.d.ts +50 -0
- package/lib/solution/ShopDiscount/index.js +321 -0
- package/lib/solution/ShopDiscount/types.d.ts +24 -0
- package/lib/solution/ShopDiscount/types.js +38 -0
- package/lib/solution/ShopDiscount/utils.d.ts +1 -0
- package/lib/solution/ShopDiscount/utils.js +32 -0
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/package.json +4 -4
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
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
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/modules/Cart/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
createCartItemOrigin: () => createCartItemOrigin,
|
|
33
|
+
formatAccountToCartItem: () => formatAccountToCartItem,
|
|
34
|
+
formatAccountToCartItemOrigin: () => formatAccountToCartItemOrigin,
|
|
35
|
+
formatBundle: () => formatBundle,
|
|
36
|
+
formatBundleToOrigin: () => formatBundleToOrigin,
|
|
37
|
+
formatOptions: () => formatOptions,
|
|
38
|
+
formatOptionsToOrigin: () => formatOptionsToOrigin,
|
|
39
|
+
formatProductToCartItem: () => formatProductToCartItem,
|
|
40
|
+
formatProductToCartItemOrigin: () => formatProductToCartItemOrigin,
|
|
41
|
+
formatResourceToCartItem: () => formatResourceToCartItem,
|
|
42
|
+
formatResourceToCartItemOrigin: () => formatResourceToCartItemOrigin,
|
|
43
|
+
getProductOriginTotalPrice: () => getProductOriginTotalPrice,
|
|
44
|
+
getProductTotalPrice: () => getProductTotalPrice,
|
|
45
|
+
getUniqueId: () => getUniqueId,
|
|
46
|
+
isNormalProduct: () => isNormalProduct
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(utils_exports);
|
|
49
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
50
|
+
var getUniqueId = (prefix = "", maxLength = 11) => {
|
|
51
|
+
return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
|
|
52
|
+
};
|
|
53
|
+
var createCartItemOrigin = () => {
|
|
54
|
+
return {
|
|
55
|
+
// 新增为0
|
|
56
|
+
id: 0,
|
|
57
|
+
// 数量 固定为1
|
|
58
|
+
number: 1,
|
|
59
|
+
// 客户端报名所有活动;
|
|
60
|
+
registration_type: "all",
|
|
61
|
+
// 暂时不用
|
|
62
|
+
relation_products: [],
|
|
63
|
+
// 固定
|
|
64
|
+
is_all: false,
|
|
65
|
+
// 商品相关
|
|
66
|
+
product: null,
|
|
67
|
+
// 时长类型
|
|
68
|
+
sub_type: null,
|
|
69
|
+
// 时长
|
|
70
|
+
duration: null,
|
|
71
|
+
// 资源相关
|
|
72
|
+
// 资源状态 -固定
|
|
73
|
+
like_status: "common",
|
|
74
|
+
// 资源类型 - 固定
|
|
75
|
+
relation_type: "form",
|
|
76
|
+
// 所选资源
|
|
77
|
+
resources: null,
|
|
78
|
+
// 日程id - 固定
|
|
79
|
+
schedule_id: 0,
|
|
80
|
+
// 所选开始时间
|
|
81
|
+
start_date: null,
|
|
82
|
+
// 所选开始时间
|
|
83
|
+
start_time: null,
|
|
84
|
+
// 所选开始时间
|
|
85
|
+
select_date: null,
|
|
86
|
+
// 所选结束时间
|
|
87
|
+
end_time: null,
|
|
88
|
+
// 所选结束时间
|
|
89
|
+
end_date: null,
|
|
90
|
+
// 额外信息
|
|
91
|
+
metadata: {}
|
|
92
|
+
// holder相关
|
|
93
|
+
// holder: null,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
var formatProductToCartItem = (params) => {
|
|
97
|
+
const { cartItem, product, bundle, options } = params;
|
|
98
|
+
if (product) {
|
|
99
|
+
cartItem.id = product == null ? void 0 : product.id;
|
|
100
|
+
cartItem.name = product == null ? void 0 : product.title;
|
|
101
|
+
cartItem.price = product == null ? void 0 : product.price;
|
|
102
|
+
cartItem.total = getProductTotalPrice({ product, bundle, options });
|
|
103
|
+
cartItem.origin_total = getProductOriginTotalPrice({ product, bundle, options });
|
|
104
|
+
cartItem.num = 1;
|
|
105
|
+
cartItem.image = product == null ? void 0 : product.cover;
|
|
106
|
+
cartItem.like_status = "common";
|
|
107
|
+
cartItem.duration = product == null ? void 0 : product.duration;
|
|
108
|
+
cartItem.isNormalProduct = isNormalProduct(product);
|
|
109
|
+
cartItem.is_charge_tax = product == null ? void 0 : product.is_charge_tax;
|
|
110
|
+
}
|
|
111
|
+
if (bundle == null ? void 0 : bundle.length) {
|
|
112
|
+
cartItem.bundle = formatBundle(bundle);
|
|
113
|
+
}
|
|
114
|
+
if (options == null ? void 0 : options.length) {
|
|
115
|
+
cartItem.options = formatOptions(options);
|
|
116
|
+
}
|
|
117
|
+
const oringin = formatProductToCartItemOrigin(params);
|
|
118
|
+
cartItem._origin = oringin;
|
|
119
|
+
return cartItem;
|
|
120
|
+
};
|
|
121
|
+
var formatProductToCartItemOrigin = (params) => {
|
|
122
|
+
var _a, _b, _c, _d;
|
|
123
|
+
const { cartItem, product, bundle, options } = params;
|
|
124
|
+
let origin = cartItem._origin;
|
|
125
|
+
if (product) {
|
|
126
|
+
origin.product = {
|
|
127
|
+
...origin.product || {},
|
|
128
|
+
num: 1,
|
|
129
|
+
product_id: product.id,
|
|
130
|
+
product_variant_id: (product == null ? void 0 : product.product_variant_id) || 0,
|
|
131
|
+
product_bundle: ((_a = origin.product) == null ? void 0 : _a.product_bundle) || [],
|
|
132
|
+
product_option_item: ((_b = origin.product) == null ? void 0 : _b.product_option_item) || []
|
|
133
|
+
};
|
|
134
|
+
origin.sub_type = (_c = product == null ? void 0 : product.duration) == null ? void 0 : _c.type;
|
|
135
|
+
origin.duration = (_d = product == null ? void 0 : product.duration) == null ? void 0 : _d.value;
|
|
136
|
+
if (bundle == null ? void 0 : bundle.length) {
|
|
137
|
+
origin.product.product_bundle = formatBundleToOrigin(bundle);
|
|
138
|
+
}
|
|
139
|
+
if (options == null ? void 0 : options.length) {
|
|
140
|
+
origin.product.product_option_item = formatOptionsToOrigin(options);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return origin;
|
|
144
|
+
};
|
|
145
|
+
var formatAccountToCartItem = (params) => {
|
|
146
|
+
const { cartItem, account } = params;
|
|
147
|
+
if (account) {
|
|
148
|
+
cartItem.holder_id = account.id;
|
|
149
|
+
cartItem.holder_title = account.username;
|
|
150
|
+
}
|
|
151
|
+
const oringin = formatAccountToCartItemOrigin(params);
|
|
152
|
+
cartItem._origin = oringin;
|
|
153
|
+
return cartItem;
|
|
154
|
+
};
|
|
155
|
+
var formatAccountToCartItemOrigin = (params) => {
|
|
156
|
+
const { cartItem, account } = params;
|
|
157
|
+
let origin = cartItem._origin;
|
|
158
|
+
if (account) {
|
|
159
|
+
origin.metadata.account = account;
|
|
160
|
+
}
|
|
161
|
+
return origin;
|
|
162
|
+
};
|
|
163
|
+
var formatResourceToCartItem = (params) => {
|
|
164
|
+
const { cartItem, resources } = params;
|
|
165
|
+
if (resources && (resources == null ? void 0 : resources.length)) {
|
|
166
|
+
const firstResource = resources[0];
|
|
167
|
+
cartItem.resource_id = firstResource == null ? void 0 : firstResource.id;
|
|
168
|
+
cartItem.relation_form_name = firstResource == null ? void 0 : firstResource.main_field;
|
|
169
|
+
if (firstResource.startTime && firstResource.endTime) {
|
|
170
|
+
cartItem.start_date = (0, import_dayjs.default)(firstResource.startTime).format("YYYY-MM-DD");
|
|
171
|
+
cartItem.start_time = (0, import_dayjs.default)(firstResource.startTime).format("HH:mm");
|
|
172
|
+
cartItem.end_date = (0, import_dayjs.default)(firstResource.endTime).format("YYYY-MM-DD");
|
|
173
|
+
cartItem.end_time = (0, import_dayjs.default)(firstResource.endTime).format("HH:mm");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const oringin = formatResourceToCartItemOrigin(params);
|
|
177
|
+
cartItem._origin = oringin;
|
|
178
|
+
return cartItem;
|
|
179
|
+
};
|
|
180
|
+
var formatResourceToCartItemOrigin = (params) => {
|
|
181
|
+
const { cartItem, resources } = params;
|
|
182
|
+
let origin = cartItem._origin;
|
|
183
|
+
if (resources && (resources == null ? void 0 : resources.length)) {
|
|
184
|
+
origin.resources = [];
|
|
185
|
+
resources.forEach((resource) => {
|
|
186
|
+
origin.resources.push({
|
|
187
|
+
relation_type: "form",
|
|
188
|
+
like_status: "common",
|
|
189
|
+
id: resource.id,
|
|
190
|
+
main_field: resource.main_field,
|
|
191
|
+
resourceType: resource.resourceType,
|
|
192
|
+
form_id: resource.form_id,
|
|
193
|
+
relation_id: resource.id,
|
|
194
|
+
capacity: (resource == null ? void 0 : resource.capacity) || 0
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
const { startTime, endTime } = resources[0];
|
|
198
|
+
if (startTime && endTime) {
|
|
199
|
+
origin.select_date = (0, import_dayjs.default)(startTime).format("YYYY-MM-DD");
|
|
200
|
+
origin.start_date = (0, import_dayjs.default)(startTime).format("YYYY-MM-DD");
|
|
201
|
+
origin.start_time = (0, import_dayjs.default)(startTime).format("HH:mm");
|
|
202
|
+
origin.end_date = (0, import_dayjs.default)(endTime).format("YYYY-MM-DD");
|
|
203
|
+
origin.end_time = (0, import_dayjs.default)(endTime).format("HH:mm");
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return origin;
|
|
207
|
+
};
|
|
208
|
+
var formatOptions = (options) => {
|
|
209
|
+
if (!(options == null ? void 0 : options.length))
|
|
210
|
+
return [];
|
|
211
|
+
return options.map((item) => {
|
|
212
|
+
return {
|
|
213
|
+
id: item == null ? void 0 : item.id,
|
|
214
|
+
name: item == null ? void 0 : item.name,
|
|
215
|
+
num: item == null ? void 0 : item.num,
|
|
216
|
+
price: item == null ? void 0 : item.price,
|
|
217
|
+
total: item == null ? void 0 : item.price,
|
|
218
|
+
origin_total: item == null ? void 0 : item.original_price
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
var formatOptionsToOrigin = (options) => {
|
|
223
|
+
if (!(options == null ? void 0 : options.length)) {
|
|
224
|
+
return [];
|
|
225
|
+
}
|
|
226
|
+
return options.map((d) => {
|
|
227
|
+
return {
|
|
228
|
+
num: d.num,
|
|
229
|
+
option_group_item_id: d.product_option_item_id,
|
|
230
|
+
option_group_id: d.option_group_id
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
var formatBundle = (bundle) => {
|
|
235
|
+
if (!(bundle == null ? void 0 : bundle.length))
|
|
236
|
+
return [];
|
|
237
|
+
return bundle.map((item) => {
|
|
238
|
+
return {
|
|
239
|
+
id: item == null ? void 0 : item.id,
|
|
240
|
+
title: item == null ? void 0 : item.title,
|
|
241
|
+
num: item == null ? void 0 : item.num,
|
|
242
|
+
price: item == null ? void 0 : item.price,
|
|
243
|
+
total: item == null ? void 0 : item.price,
|
|
244
|
+
price_type: item == null ? void 0 : item.price_type,
|
|
245
|
+
bundle_sum_price: item == null ? void 0 : item.bundle_sum_price,
|
|
246
|
+
bundle_sum_type: item == null ? void 0 : item.bundle_sum_type,
|
|
247
|
+
options: formatOptions(item == null ? void 0 : item.option)
|
|
248
|
+
};
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
var formatBundleToOrigin = (bundle) => {
|
|
252
|
+
if (!(bundle == null ? void 0 : bundle.length))
|
|
253
|
+
return [];
|
|
254
|
+
return bundle.map((d) => {
|
|
255
|
+
return {
|
|
256
|
+
bundle_group_id: d.group_id,
|
|
257
|
+
bundle_id: d.id,
|
|
258
|
+
bundle_product_id: (d == null ? void 0 : d._bundle_product_id) || (d == null ? void 0 : d.product_id),
|
|
259
|
+
bundle_variant_id: d.bundle_variant_id,
|
|
260
|
+
num: d.num,
|
|
261
|
+
extension_id: d.extension_id,
|
|
262
|
+
extension_type: d.extension_type,
|
|
263
|
+
option: formatOptionsToOrigin(d.option)
|
|
264
|
+
};
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
var isNormalProduct = (product) => {
|
|
268
|
+
return (product == null ? void 0 : product.extension_type) !== "product_appointment";
|
|
269
|
+
};
|
|
270
|
+
var getProductTotalPrice = (params) => {
|
|
271
|
+
const { product, bundle, options } = params;
|
|
272
|
+
let price = Number(product.price);
|
|
273
|
+
if (bundle == null ? void 0 : bundle.length) {
|
|
274
|
+
price = bundle.reduce((accumulator, currentValue) => {
|
|
275
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
276
|
+
}, price);
|
|
277
|
+
}
|
|
278
|
+
if (options == null ? void 0 : options.length) {
|
|
279
|
+
price = options.reduce((accumulator, currentValue) => {
|
|
280
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
281
|
+
}, price);
|
|
282
|
+
}
|
|
283
|
+
return price;
|
|
284
|
+
};
|
|
285
|
+
var getProductOriginTotalPrice = (params) => {
|
|
286
|
+
const { product, bundle, options } = params;
|
|
287
|
+
let price = Number(product.original_price);
|
|
288
|
+
if (isNaN(price) || price === 0) {
|
|
289
|
+
return void 0;
|
|
290
|
+
}
|
|
291
|
+
if (bundle == null ? void 0 : bundle.length) {
|
|
292
|
+
price = bundle.reduce((accumulator, currentValue) => {
|
|
293
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
294
|
+
}, price);
|
|
295
|
+
}
|
|
296
|
+
if (options == null ? void 0 : options.length) {
|
|
297
|
+
price = options.reduce((accumulator, currentValue) => {
|
|
298
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
299
|
+
}, price);
|
|
300
|
+
}
|
|
301
|
+
return price;
|
|
302
|
+
};
|
|
303
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
304
|
+
0 && (module.exports = {
|
|
305
|
+
createCartItemOrigin,
|
|
306
|
+
formatAccountToCartItem,
|
|
307
|
+
formatAccountToCartItemOrigin,
|
|
308
|
+
formatBundle,
|
|
309
|
+
formatBundleToOrigin,
|
|
310
|
+
formatOptions,
|
|
311
|
+
formatOptionsToOrigin,
|
|
312
|
+
formatProductToCartItem,
|
|
313
|
+
formatProductToCartItemOrigin,
|
|
314
|
+
formatResourceToCartItem,
|
|
315
|
+
formatResourceToCartItemOrigin,
|
|
316
|
+
getProductOriginTotalPrice,
|
|
317
|
+
getProductTotalPrice,
|
|
318
|
+
getUniqueId,
|
|
319
|
+
isNormalProduct
|
|
320
|
+
});
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { Module, PisellCore, ModuleOptions } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import {
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from "../../types";
|
|
2
|
+
import { BaseModule } from "../BaseModule";
|
|
3
|
+
import { DateModuleAPI, IGetAvailableTimeListParams, ITime } from "./types";
|
|
4
4
|
export declare class DateModule extends BaseModule implements Module, DateModuleAPI {
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
7
|
-
private
|
|
7
|
+
private store;
|
|
8
|
+
private request;
|
|
8
9
|
constructor(name?: string, version?: string);
|
|
9
|
-
initialize(core: PisellCore, options
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
isDateAvailable(date: Date): boolean;
|
|
16
|
-
isTimeSlotAvailable(timeSlot: TimeSlot): boolean;
|
|
10
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
11
|
+
setDateRange(dateRange: ITime[]): void;
|
|
12
|
+
getDateRange(): ITime[];
|
|
13
|
+
getMonthDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
14
|
+
getDateList(): Promise<ITime[]>;
|
|
15
|
+
getAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
17
16
|
}
|
|
@@ -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/Date/index.ts
|
|
@@ -22,51 +32,60 @@ __export(Date_exports, {
|
|
|
22
32
|
DateModule: () => DateModule
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(Date_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
25
36
|
var import_BaseModule = require("../BaseModule");
|
|
26
|
-
var
|
|
37
|
+
var import_utils = require("./utils");
|
|
27
38
|
var DateModule = class extends import_BaseModule.BaseModule {
|
|
28
39
|
constructor(name, version) {
|
|
29
40
|
super(name, version);
|
|
30
41
|
this.defaultName = "date";
|
|
31
42
|
this.defaultVersion = "1.0.0";
|
|
32
|
-
this.state = {
|
|
33
|
-
selectedDate: null,
|
|
34
|
-
selectedTimeSlot: null,
|
|
35
|
-
availableTimeSlots: []
|
|
36
|
-
};
|
|
37
43
|
}
|
|
38
44
|
async initialize(core, options) {
|
|
39
45
|
this.core = core;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async setDate(date) {
|
|
45
|
-
this.state.selectedDate = date;
|
|
46
|
-
await this.core.effects.emit(import_types.DateHooks.OnDateChange, date);
|
|
47
|
-
}
|
|
48
|
-
async setTimeSlot(timeSlot) {
|
|
49
|
-
this.state.selectedTimeSlot = timeSlot;
|
|
50
|
-
await this.core.effects.emit(import_types.DateHooks.OnTimeSlotChange, timeSlot);
|
|
46
|
+
this.store = options.store;
|
|
47
|
+
this.request = this.core.getPlugin("request");
|
|
51
48
|
}
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
setDateRange(dateRange) {
|
|
50
|
+
this.store.dateRange = dateRange;
|
|
54
51
|
}
|
|
55
|
-
|
|
56
|
-
return this.
|
|
52
|
+
getDateRange() {
|
|
53
|
+
return this.store.dateRange;
|
|
57
54
|
}
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
async getMonthDates(params) {
|
|
56
|
+
const dates = await this.getAvailableTimeList(params);
|
|
57
|
+
this.store.dateList = dates;
|
|
58
|
+
return dates;
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
return this.
|
|
63
|
-
(slot) => slot.start.getDate() === date.getDate() && slot.start.getMonth() === date.getMonth() && slot.start.getFullYear() === date.getFullYear() && slot.isAvailable
|
|
64
|
-
);
|
|
60
|
+
async getDateList() {
|
|
61
|
+
return this.store.dateList;
|
|
65
62
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
async getAvailableTimeList(params) {
|
|
64
|
+
var _a;
|
|
65
|
+
const { url, query, rules } = params;
|
|
66
|
+
const fetchUrl = url || "/schedule/resource/list";
|
|
67
|
+
const { start_date, end_date, resource_ids } = query || {};
|
|
68
|
+
if (!start_date || !end_date) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
let dates = (0, import_utils.generateMonthDates)(start_date, end_date);
|
|
72
|
+
if (!(resource_ids == null ? void 0 : resource_ids.length) || (0, import_dayjs.default)(end_date).isBefore((0, import_dayjs.default)())) {
|
|
73
|
+
return (0, import_utils.disableAllDates)(dates);
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const res = await this.request.get(fetchUrl, { start_date, end_date, resource_ids }, { useCache: true });
|
|
77
|
+
if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.length)) {
|
|
78
|
+
return (0, import_utils.disableAllDates)(dates);
|
|
79
|
+
}
|
|
80
|
+
dates = (0, import_utils.handleAvailableDateByResource)(res.data, dates);
|
|
81
|
+
if (rules == null ? void 0 : rules.length) {
|
|
82
|
+
dates = (0, import_utils.handleAvailableDatesByRules)(dates, rules);
|
|
83
|
+
}
|
|
84
|
+
return dates;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.log("getAvailableTimeList_error", error);
|
|
87
|
+
return (0, import_utils.disableAllDates)(dates);
|
|
88
|
+
}
|
|
70
89
|
}
|
|
71
90
|
};
|
|
72
91
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,33 +1,64 @@
|
|
|
1
1
|
export declare enum DateHooks {
|
|
2
|
-
OnDateChange = "date:onDateChange",
|
|
3
|
-
OnTimeSlotChange = "date:onTimeSlotChange",
|
|
4
|
-
OnGetDateList = "date:onGetDateList"
|
|
5
2
|
}
|
|
6
3
|
/**
|
|
7
|
-
*
|
|
4
|
+
* 日期模块状态
|
|
8
5
|
*/
|
|
9
|
-
export interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
export interface DateState {
|
|
7
|
+
/**
|
|
8
|
+
* 可用时间列表
|
|
9
|
+
*/
|
|
10
|
+
dateList: ITime[];
|
|
11
|
+
/**
|
|
12
|
+
* 日期范围
|
|
13
|
+
*/
|
|
14
|
+
dateRange: ITime[];
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
17
|
+
* 时间
|
|
16
18
|
*/
|
|
17
|
-
export interface
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
export interface ITime {
|
|
20
|
+
date: string;
|
|
21
|
+
week: string;
|
|
22
|
+
weekNum: number;
|
|
23
|
+
status: "unavailable" | "available";
|
|
24
|
+
resource?: any[];
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
27
|
* 日期模块 API
|
|
24
28
|
*/
|
|
25
29
|
export interface DateModuleAPI {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
/**
|
|
31
|
+
* 获取可用时间列表
|
|
32
|
+
*/
|
|
33
|
+
getAvailableTimeList: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
|
|
34
|
+
/**
|
|
35
|
+
* 设置日期范围
|
|
36
|
+
*/
|
|
37
|
+
setDateRange: (range: ITime[]) => void;
|
|
38
|
+
/**
|
|
39
|
+
* 获取月份日期
|
|
40
|
+
*/
|
|
41
|
+
getMonthDates: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
|
|
42
|
+
}
|
|
43
|
+
export interface IGetAvailableTimeListParams {
|
|
44
|
+
url?: string;
|
|
45
|
+
query?: {
|
|
46
|
+
start_date: string;
|
|
47
|
+
end_date: string;
|
|
48
|
+
resource_ids?: Array<number | string>;
|
|
49
|
+
};
|
|
50
|
+
rules?: Array<{
|
|
51
|
+
/**
|
|
52
|
+
* 提前量
|
|
53
|
+
*/
|
|
54
|
+
cut_off_time?: {
|
|
55
|
+
future_day?: number;
|
|
56
|
+
unit?: number;
|
|
57
|
+
unit_type?: "minutes" | "hours" | "days";
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* 资源ID
|
|
61
|
+
*/
|
|
62
|
+
resourceFormIds?: number[];
|
|
63
|
+
}>;
|
|
33
64
|
}
|
|
@@ -23,10 +23,6 @@ __export(types_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(types_exports);
|
|
25
25
|
var DateHooks = /* @__PURE__ */ ((DateHooks2) => {
|
|
26
|
-
DateHooks2["OnDateChange"] = "date:onDateChange";
|
|
27
|
-
DateHooks2["OnTimeSlotChange"] = "date:onTimeSlotChange";
|
|
28
|
-
DateHooks2["OnGetDateList"] = "date:onGetDateList";
|
|
29
|
-
return DateHooks2;
|
|
30
26
|
})(DateHooks || {});
|
|
31
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
28
|
0 && (module.exports = {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IGetAvailableTimeListParams, ITime } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* 生成当前月份的所有日期
|
|
4
|
+
* @param startDate 开始日期
|
|
5
|
+
* @param endDate 结束日期
|
|
6
|
+
* @returns 日期列表
|
|
7
|
+
*/
|
|
8
|
+
export declare const generateMonthDates: (startDate: string, endDate: string) => ITime[];
|
|
9
|
+
/**
|
|
10
|
+
* 禁用所有日期
|
|
11
|
+
* @param dates 日期列表
|
|
12
|
+
* @returns 日期列表
|
|
13
|
+
*/
|
|
14
|
+
export declare const disableAllDates: (dates: ITime[]) => ITime[];
|
|
15
|
+
/**
|
|
16
|
+
* 禁用某一天之前的日期,如不传则默认今天
|
|
17
|
+
* @param dates 日期列表
|
|
18
|
+
* @param oneDay 日期
|
|
19
|
+
* @returns 日期列表
|
|
20
|
+
*/
|
|
21
|
+
export declare const disableDatesBeforeOneDay: (dates: ITime[], oneDay?: string) => ITime[];
|
|
22
|
+
/**
|
|
23
|
+
* 根据资源中的日期处理出每个日期下存在的可用资源,根据form_id进行分类
|
|
24
|
+
* @param resources 资源列表
|
|
25
|
+
* @param dates 日期列表
|
|
26
|
+
* @returns 日期列表
|
|
27
|
+
*/
|
|
28
|
+
export declare const handleAvailableDateByResource: (resources: any[], dates: ITime[]) => ITime[];
|
|
29
|
+
/**
|
|
30
|
+
* 根据规则判定哪些日期是可用的
|
|
31
|
+
* @param dates 日期列表
|
|
32
|
+
* @param rules 提前量规则
|
|
33
|
+
* @returns 日期列表
|
|
34
|
+
*/
|
|
35
|
+
export declare const handleAvailableDatesByRules: (dates: ITime[], rules: IGetAvailableTimeListParams["rules"]) => ITime[];
|