@pisell/pisellos 3.0.34 → 3.0.36
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/Cart/index.js +20 -34
- package/dist/modules/Cart/utils/cartAccount.d.ts +21 -0
- package/dist/modules/Cart/utils/cartAccount.js +52 -0
- package/dist/modules/Cart/utils/cartDate.d.ts +31 -0
- package/dist/modules/Cart/utils/cartDate.js +55 -0
- package/dist/modules/Cart/utils/cartDiscount.d.ts +19 -0
- package/dist/modules/Cart/utils/cartDiscount.js +35 -0
- package/dist/modules/Cart/utils/cartNote.d.ts +19 -0
- package/dist/modules/Cart/utils/cartNote.js +29 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +107 -0
- package/dist/modules/Cart/{utils.js → utils/cartProduct.js} +77 -416
- package/dist/modules/Cart/utils/cartRelationForms.d.ts +26 -0
- package/dist/modules/Cart/utils/cartRelationForms.js +29 -0
- package/dist/modules/Cart/utils/cartResource.d.ts +21 -0
- package/dist/modules/Cart/utils/cartResource.js +102 -0
- package/dist/modules/Cart/utils/index.d.ts +34 -0
- package/dist/modules/Cart/utils/index.js +63 -0
- package/dist/modules/Order/index.js +10 -4
- package/dist/modules/Product/types.d.ts +4 -0
- package/dist/modules/Product/utils.d.ts +17 -0
- package/dist/modules/Product/utils.js +41 -0
- package/dist/modules/Schedule/index.d.ts +2 -0
- package/dist/modules/Schedule/index.js +10 -0
- package/dist/modules/Schedule/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +10 -4
- package/dist/solution/BookingByStep/index.js +267 -122
- package/lib/modules/Cart/index.js +16 -24
- package/lib/modules/Cart/utils/cartAccount.d.ts +21 -0
- package/lib/modules/Cart/utils/cartAccount.js +65 -0
- package/lib/modules/Cart/utils/cartDate.d.ts +31 -0
- package/lib/modules/Cart/utils/cartDate.js +75 -0
- package/lib/modules/Cart/utils/cartDiscount.d.ts +19 -0
- package/lib/modules/Cart/utils/cartDiscount.js +52 -0
- package/lib/modules/Cart/utils/cartNote.d.ts +19 -0
- package/lib/modules/Cart/utils/cartNote.js +46 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +107 -0
- package/lib/modules/Cart/{utils.js → utils/cartProduct.js} +78 -328
- package/lib/modules/Cart/utils/cartRelationForms.d.ts +26 -0
- package/lib/modules/Cart/utils/cartRelationForms.js +48 -0
- package/lib/modules/Cart/utils/cartResource.d.ts +21 -0
- package/lib/modules/Cart/utils/cartResource.js +124 -0
- package/lib/modules/Cart/utils/index.d.ts +34 -0
- package/lib/modules/Cart/utils/index.js +91 -0
- package/lib/modules/Order/index.js +7 -3
- package/lib/modules/Product/types.d.ts +4 -0
- package/lib/modules/Product/utils.d.ts +17 -0
- package/lib/modules/Product/utils.js +46 -0
- package/lib/modules/Schedule/index.d.ts +2 -0
- package/lib/modules/Schedule/index.js +6 -0
- package/lib/modules/Schedule/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +10 -4
- package/lib/solution/BookingByStep/index.js +156 -75
- package/package.json +1 -1
- package/dist/modules/Cart/utils.d.ts +0 -257
- package/lib/modules/Cart/utils.d.ts +0 -257
|
@@ -26,92 +26,48 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
|
-
// src/modules/Cart/utils.ts
|
|
30
|
-
var
|
|
31
|
-
__export(
|
|
32
|
-
createCartItemOrigin: () => createCartItemOrigin,
|
|
33
|
-
deleteHolderFromCartItem: () => deleteHolderFromCartItem,
|
|
34
|
-
deleteRelationFormsFromCartItem: () => deleteRelationFormsFromCartItem,
|
|
35
|
-
deleteResourceFromCartItem: () => deleteResourceFromCartItem,
|
|
36
|
-
deleteTimeFromCartItem: () => deleteTimeFromCartItem,
|
|
37
|
-
formatAccountToCartItem: () => formatAccountToCartItem,
|
|
38
|
-
formatAccountToCartItemOrigin: () => formatAccountToCartItemOrigin,
|
|
29
|
+
// src/modules/Cart/utils/cartProduct.ts
|
|
30
|
+
var cartProduct_exports = {};
|
|
31
|
+
__export(cartProduct_exports, {
|
|
39
32
|
formatBundle: () => formatBundle,
|
|
40
33
|
formatBundleToOrigin: () => formatBundleToOrigin,
|
|
41
|
-
formatDateToCartItem: () => formatDateToCartItem,
|
|
42
|
-
formatDateToCartItemOrigin: () => formatDateToCartItemOrigin,
|
|
43
|
-
formatDiscountToCartItem: () => formatDiscountToCartItem,
|
|
44
|
-
formatDiscountToCartItemOrigin: () => formatDiscountToCartItemOrigin,
|
|
45
|
-
formatNoteToCartItem: () => formatNoteToCartItem,
|
|
46
|
-
formatNoteToCartItemOrigin: () => formatNoteToCartItemOrigin,
|
|
47
34
|
formatOptions: () => formatOptions,
|
|
48
35
|
formatOptionsToOrigin: () => formatOptionsToOrigin,
|
|
49
36
|
formatProductToCartItem: () => formatProductToCartItem,
|
|
50
37
|
formatProductToCartItemOrigin: () => formatProductToCartItemOrigin,
|
|
51
|
-
formatRelationFormsToCartItem: () => formatRelationFormsToCartItem,
|
|
52
|
-
formatRelationFormsToCartItemOrigin: () => formatRelationFormsToCartItemOrigin,
|
|
53
|
-
formatResourceToCartItem: () => formatResourceToCartItem,
|
|
54
|
-
formatResourceToCartItemOrigin: () => formatResourceToCartItemOrigin,
|
|
55
38
|
getProductDeposit: () => getProductDeposit,
|
|
56
39
|
getProductOriginTotalPrice: () => getProductOriginTotalPrice,
|
|
57
40
|
getProductTotalPrice: () => getProductTotalPrice,
|
|
58
|
-
getUniqueId: () => getUniqueId,
|
|
59
41
|
handleProductDeposit: () => handleProductDeposit,
|
|
60
|
-
|
|
42
|
+
handleVariantProduct: () => handleVariantProduct
|
|
61
43
|
});
|
|
62
|
-
module.exports = __toCommonJS(
|
|
63
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
44
|
+
module.exports = __toCommonJS(cartProduct_exports);
|
|
64
45
|
var import_decimal = __toESM(require("decimal.js"));
|
|
65
|
-
var
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// 固定
|
|
79
|
-
is_all: false,
|
|
80
|
-
// 商品相关
|
|
81
|
-
product: null,
|
|
82
|
-
// 时长类型
|
|
83
|
-
sub_type: null,
|
|
84
|
-
// 时长
|
|
85
|
-
duration: null,
|
|
86
|
-
// 资源相关
|
|
87
|
-
// 资源状态 -固定
|
|
88
|
-
like_status: "common",
|
|
89
|
-
// 资源类型 - 固定--谭景琳备注:马天宇说现在平行资源是不传这个的
|
|
90
|
-
// relation_type: "form",
|
|
91
|
-
// 所选资源
|
|
92
|
-
resources: null,
|
|
93
|
-
// 日程id - 固定
|
|
94
|
-
schedule_id: 0,
|
|
95
|
-
// 所选开始时间
|
|
96
|
-
start_date: null,
|
|
97
|
-
// 所选开始时间
|
|
98
|
-
start_time: null,
|
|
99
|
-
// 所选开始时间
|
|
100
|
-
select_date: null,
|
|
101
|
-
// 所选结束时间
|
|
102
|
-
end_time: null,
|
|
103
|
-
// 所选结束时间
|
|
104
|
-
end_date: null,
|
|
105
|
-
// 额外信息
|
|
106
|
-
metadata: {},
|
|
107
|
-
// holder相关
|
|
108
|
-
holder: null
|
|
109
|
-
};
|
|
46
|
+
var import_utils = require("../../Product/utils");
|
|
47
|
+
var handleVariantProduct = (product) => {
|
|
48
|
+
if (product == null ? void 0 : product.product_variant_id) {
|
|
49
|
+
const targetVariant = product.variant.find(
|
|
50
|
+
(n) => n.id === product.product_variant_id
|
|
51
|
+
);
|
|
52
|
+
if (targetVariant) {
|
|
53
|
+
product.price = targetVariant.price;
|
|
54
|
+
product.original_price = targetVariant.original_price;
|
|
55
|
+
product.is_charge_tax = targetVariant.is_charge_tax;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return product;
|
|
110
59
|
};
|
|
111
60
|
var formatProductToCartItem = (params) => {
|
|
112
61
|
var _a, _b;
|
|
113
|
-
const {
|
|
114
|
-
|
|
62
|
+
const {
|
|
63
|
+
cartItem,
|
|
64
|
+
product,
|
|
65
|
+
bundle,
|
|
66
|
+
options,
|
|
67
|
+
product_variant_id,
|
|
68
|
+
quantity = 1
|
|
69
|
+
} = params;
|
|
70
|
+
const num = quantity;
|
|
115
71
|
if (product) {
|
|
116
72
|
cartItem.id = product == null ? void 0 : product.id;
|
|
117
73
|
cartItem.name = product == null ? void 0 : product.title;
|
|
@@ -127,7 +83,7 @@ var formatProductToCartItem = (params) => {
|
|
|
127
83
|
cartItem.image = product == null ? void 0 : product.cover;
|
|
128
84
|
cartItem.like_status = "common";
|
|
129
85
|
cartItem.duration = product == null ? void 0 : product.duration;
|
|
130
|
-
cartItem.isNormalProduct = isNormalProduct(product);
|
|
86
|
+
cartItem.isNormalProduct = (0, import_utils.isNormalProduct)(product);
|
|
131
87
|
cartItem.is_charge_tax = product == null ? void 0 : product.is_charge_tax;
|
|
132
88
|
}
|
|
133
89
|
if (bundle == null ? void 0 : bundle.length) {
|
|
@@ -137,17 +93,25 @@ var formatProductToCartItem = (params) => {
|
|
|
137
93
|
cartItem.options = formatOptions(options);
|
|
138
94
|
}
|
|
139
95
|
if (product_variant_id) {
|
|
140
|
-
const sku_key = (_a = product.variant.find(
|
|
96
|
+
const sku_key = (_a = product.variant.find(
|
|
97
|
+
(n) => n.id === product_variant_id
|
|
98
|
+
)) == null ? void 0 : _a.sku_key;
|
|
141
99
|
if (sku_key) {
|
|
142
100
|
const sku_key_arr = sku_key.split("_");
|
|
143
101
|
const product_option_string = [];
|
|
144
102
|
sku_key_arr.forEach((item) => {
|
|
145
103
|
var _a2;
|
|
146
104
|
const keyMap = item.split(":");
|
|
147
|
-
const targetVariantGroup = product.variant_group.find(
|
|
148
|
-
|
|
105
|
+
const targetVariantGroup = product.variant_group.find(
|
|
106
|
+
(n) => String(n.position_id) === keyMap[0]
|
|
107
|
+
);
|
|
108
|
+
const targetVariantItem = (_a2 = targetVariantGroup == null ? void 0 : targetVariantGroup.variant_item) == null ? void 0 : _a2.find(
|
|
109
|
+
(n) => String(n.position_id) === keyMap[1]
|
|
110
|
+
);
|
|
149
111
|
if (targetVariantGroup && targetVariantItem) {
|
|
150
|
-
product_option_string.push(
|
|
112
|
+
product_option_string.push(
|
|
113
|
+
`${targetVariantGroup.name}:${targetVariantItem.name}`
|
|
114
|
+
);
|
|
151
115
|
}
|
|
152
116
|
});
|
|
153
117
|
cartItem.product_option_string = product_option_string.join(", ");
|
|
@@ -168,12 +132,19 @@ var formatProductToCartItem = (params) => {
|
|
|
168
132
|
};
|
|
169
133
|
var formatProductToCartItemOrigin = (params) => {
|
|
170
134
|
var _a, _b, _c, _d;
|
|
171
|
-
const {
|
|
135
|
+
const {
|
|
136
|
+
cartItem,
|
|
137
|
+
product,
|
|
138
|
+
bundle,
|
|
139
|
+
options,
|
|
140
|
+
product_variant_id,
|
|
141
|
+
quantity = 1
|
|
142
|
+
} = params;
|
|
172
143
|
let origin = cartItem._origin;
|
|
173
144
|
if (product) {
|
|
174
145
|
origin.product = {
|
|
175
146
|
...origin.product || {},
|
|
176
|
-
num:
|
|
147
|
+
num: quantity,
|
|
177
148
|
product_id: product.id,
|
|
178
149
|
product_variant_id: product_variant_id || 0,
|
|
179
150
|
product_bundle: ((_a = origin.product) == null ? void 0 : _a.product_bundle) || [],
|
|
@@ -190,176 +161,40 @@ var formatProductToCartItemOrigin = (params) => {
|
|
|
190
161
|
}
|
|
191
162
|
return origin;
|
|
192
163
|
};
|
|
193
|
-
var
|
|
194
|
-
const {
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const origin = cartItem._origin;
|
|
202
|
-
if (discounts && (discounts == null ? void 0 : discounts.length)) {
|
|
203
|
-
if (!origin.product) {
|
|
204
|
-
origin.product = {};
|
|
205
|
-
}
|
|
206
|
-
origin.product.discount_list = discounts;
|
|
207
|
-
} else {
|
|
208
|
-
if (!origin.product) {
|
|
209
|
-
origin.product = {};
|
|
210
|
-
}
|
|
211
|
-
origin.product.discount_list = [];
|
|
212
|
-
}
|
|
213
|
-
return origin;
|
|
214
|
-
};
|
|
215
|
-
var formatAccountToCartItem = (params) => {
|
|
216
|
-
const { cartItem, account } = params;
|
|
217
|
-
if (account) {
|
|
218
|
-
cartItem.holder_id = account.id;
|
|
219
|
-
cartItem.holder_title = account.username;
|
|
164
|
+
var getProductTotalPrice = (params) => {
|
|
165
|
+
const { product, bundle, options } = params;
|
|
166
|
+
const num = params.num || 1;
|
|
167
|
+
let price = Number(product.price);
|
|
168
|
+
if (bundle == null ? void 0 : bundle.length) {
|
|
169
|
+
price = bundle.reduce((accumulator, currentValue) => {
|
|
170
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
171
|
+
}, price);
|
|
220
172
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
};
|
|
225
|
-
var formatAccountToCartItemOrigin = (params) => {
|
|
226
|
-
const { cartItem, account } = params;
|
|
227
|
-
let origin = cartItem._origin;
|
|
228
|
-
if (account) {
|
|
229
|
-
if ((account == null ? void 0 : account.type) === "holder") {
|
|
230
|
-
const { customer_id, form_id, form_record_id } = (account == null ? void 0 : account._origin) || {};
|
|
231
|
-
origin.holder = {
|
|
232
|
-
customer_id,
|
|
233
|
-
form_id,
|
|
234
|
-
form_record: form_record_id ? [form_record_id] : null
|
|
235
|
-
};
|
|
236
|
-
} else {
|
|
237
|
-
origin.metadata.account = account;
|
|
238
|
-
}
|
|
173
|
+
if (options == null ? void 0 : options.length) {
|
|
174
|
+
price = options.reduce((accumulator, currentValue) => {
|
|
175
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
176
|
+
}, price);
|
|
239
177
|
}
|
|
240
|
-
return
|
|
178
|
+
return price * num;
|
|
241
179
|
};
|
|
242
|
-
var
|
|
243
|
-
const {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (firstResource.startTime && firstResource.endTime) {
|
|
249
|
-
cartItem.start_date = (0, import_dayjs.default)(firstResource.startTime).format("YYYY-MM-DD");
|
|
250
|
-
cartItem.start_time = (0, import_dayjs.default)(firstResource.startTime).format("HH:mm");
|
|
251
|
-
cartItem.end_date = (0, import_dayjs.default)(firstResource.endTime).format("YYYY-MM-DD");
|
|
252
|
-
cartItem.end_time = (0, import_dayjs.default)(firstResource.endTime).format("HH:mm");
|
|
253
|
-
}
|
|
254
|
-
} else {
|
|
255
|
-
cartItem.resource_id = void 0;
|
|
256
|
-
cartItem.relation_form_name = void 0;
|
|
257
|
-
cartItem.start_date = void 0;
|
|
258
|
-
cartItem.start_time = void 0;
|
|
259
|
-
cartItem.end_date = void 0;
|
|
260
|
-
cartItem.end_time = void 0;
|
|
180
|
+
var getProductOriginTotalPrice = (params) => {
|
|
181
|
+
const { product, bundle, options } = params;
|
|
182
|
+
const num = (params == null ? void 0 : params.num) || 1;
|
|
183
|
+
let price = Number(product.original_price);
|
|
184
|
+
if (isNaN(price) || price === 0) {
|
|
185
|
+
return void 0;
|
|
261
186
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
};
|
|
267
|
-
var formatResourceToCartItemOrigin = (params) => {
|
|
268
|
-
const { cartItem, resources } = params;
|
|
269
|
-
let origin = cartItem._origin;
|
|
270
|
-
if (resources && (resources == null ? void 0 : resources.length)) {
|
|
271
|
-
origin.resources = [];
|
|
272
|
-
const checkResourcesFormat = (resources2, arr) => {
|
|
273
|
-
resources2.forEach((resource) => {
|
|
274
|
-
var _a;
|
|
275
|
-
const childArr = [];
|
|
276
|
-
if ((_a = resource == null ? void 0 : resource.children) == null ? void 0 : _a.length) {
|
|
277
|
-
checkResourcesFormat(resource.children, childArr);
|
|
278
|
-
}
|
|
279
|
-
const obj = {
|
|
280
|
-
relation_type: "form",
|
|
281
|
-
like_status: "common",
|
|
282
|
-
id: resource.id,
|
|
283
|
-
main_field: resource.main_field,
|
|
284
|
-
resourceType: resource.resourceType,
|
|
285
|
-
form_id: resource.form_id,
|
|
286
|
-
relation_id: resource.id,
|
|
287
|
-
capacity: (resource == null ? void 0 : resource.capacity) || 0,
|
|
288
|
-
metadata: (resource == null ? void 0 : resource.metadata) || {}
|
|
289
|
-
// 后端可以在这里挂一个前端用于计算的数据
|
|
290
|
-
};
|
|
291
|
-
if (childArr.length) {
|
|
292
|
-
obj.children = childArr;
|
|
293
|
-
}
|
|
294
|
-
arr.push(obj);
|
|
295
|
-
});
|
|
296
|
-
};
|
|
297
|
-
checkResourcesFormat(resources, origin.resources);
|
|
298
|
-
const { startTime, endTime } = resources[0];
|
|
299
|
-
if (startTime && endTime) {
|
|
300
|
-
origin.select_date = (0, import_dayjs.default)(startTime).format("YYYY-MM-DD");
|
|
301
|
-
origin.start_date = (0, import_dayjs.default)(startTime).format("YYYY-MM-DD");
|
|
302
|
-
origin.start_time = (0, import_dayjs.default)(startTime).format("HH:mm");
|
|
303
|
-
origin.end_date = (0, import_dayjs.default)(endTime).format("YYYY-MM-DD");
|
|
304
|
-
origin.end_time = (0, import_dayjs.default)(endTime).format("HH:mm");
|
|
305
|
-
}
|
|
306
|
-
} else if ((resources == null ? void 0 : resources.length) === 0) {
|
|
307
|
-
origin.resources = [];
|
|
308
|
-
origin.select_date = null;
|
|
309
|
-
origin.start_date = null;
|
|
310
|
-
origin.start_time = null;
|
|
311
|
-
origin.end_date = null;
|
|
312
|
-
origin.end_time = null;
|
|
187
|
+
if (bundle == null ? void 0 : bundle.length) {
|
|
188
|
+
price = bundle.reduce((accumulator, currentValue) => {
|
|
189
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
190
|
+
}, price);
|
|
313
191
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
const oringin = formatRelationFormsToCartItemOrigin(params);
|
|
319
|
-
cartItem._origin = oringin;
|
|
320
|
-
return cartItem;
|
|
321
|
-
};
|
|
322
|
-
var formatRelationFormsToCartItemOrigin = (params) => {
|
|
323
|
-
const { cartItem, relationForms } = params;
|
|
324
|
-
const origin = cartItem._origin;
|
|
325
|
-
origin.relation_forms = relationForms;
|
|
326
|
-
return origin;
|
|
327
|
-
};
|
|
328
|
-
var formatDateToCartItem = (params) => {
|
|
329
|
-
const { cartItem, date } = params;
|
|
330
|
-
cartItem.start_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
|
|
331
|
-
cartItem.start_time = (0, import_dayjs.default)(date.startTime).format("HH:mm");
|
|
332
|
-
cartItem.end_date = (0, import_dayjs.default)(date.endTime).format("YYYY-MM-DD");
|
|
333
|
-
cartItem.end_time = (0, import_dayjs.default)(date.endTime).format("HH:mm");
|
|
334
|
-
const oringin = formatDateToCartItemOrigin(params);
|
|
335
|
-
cartItem._origin = oringin;
|
|
336
|
-
return cartItem;
|
|
337
|
-
};
|
|
338
|
-
var formatDateToCartItemOrigin = (params) => {
|
|
339
|
-
const { cartItem, date } = params;
|
|
340
|
-
const origin = cartItem._origin;
|
|
341
|
-
origin.select_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
|
|
342
|
-
origin.start_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
|
|
343
|
-
origin.start_time = (0, import_dayjs.default)(date.startTime).format("HH:mm");
|
|
344
|
-
origin.end_date = (0, import_dayjs.default)(date.endTime).format("YYYY-MM-DD");
|
|
345
|
-
origin.end_time = (0, import_dayjs.default)(date.endTime).format("HH:mm");
|
|
346
|
-
return origin;
|
|
347
|
-
};
|
|
348
|
-
var formatNoteToCartItem = (params) => {
|
|
349
|
-
const { cartItem, note } = params;
|
|
350
|
-
cartItem.note = note;
|
|
351
|
-
const oringin = formatNoteToCartItemOrigin(params);
|
|
352
|
-
cartItem._origin = oringin;
|
|
353
|
-
return cartItem;
|
|
354
|
-
};
|
|
355
|
-
var formatNoteToCartItemOrigin = (params) => {
|
|
356
|
-
const { cartItem, note } = params;
|
|
357
|
-
const origin = cartItem._origin;
|
|
358
|
-
if (!origin.product) {
|
|
359
|
-
origin.product = {};
|
|
192
|
+
if (options == null ? void 0 : options.length) {
|
|
193
|
+
price = options.reduce((accumulator, currentValue) => {
|
|
194
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
195
|
+
}, price);
|
|
360
196
|
}
|
|
361
|
-
|
|
362
|
-
return origin;
|
|
197
|
+
return price * num;
|
|
363
198
|
};
|
|
364
199
|
var formatOptions = (options) => {
|
|
365
200
|
if (!(options == null ? void 0 : options.length))
|
|
@@ -420,44 +255,6 @@ var formatBundleToOrigin = (bundle) => {
|
|
|
420
255
|
};
|
|
421
256
|
});
|
|
422
257
|
};
|
|
423
|
-
var isNormalProduct = (product) => {
|
|
424
|
-
return (product == null ? void 0 : product.extension_type) !== "product_appointment";
|
|
425
|
-
};
|
|
426
|
-
var getProductTotalPrice = (params) => {
|
|
427
|
-
const { product, bundle, options } = params;
|
|
428
|
-
const num = params.num || 1;
|
|
429
|
-
let price = Number(product.price);
|
|
430
|
-
if (bundle == null ? void 0 : bundle.length) {
|
|
431
|
-
price = bundle.reduce((accumulator, currentValue) => {
|
|
432
|
-
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
433
|
-
}, price);
|
|
434
|
-
}
|
|
435
|
-
if (options == null ? void 0 : options.length) {
|
|
436
|
-
price = options.reduce((accumulator, currentValue) => {
|
|
437
|
-
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
438
|
-
}, price);
|
|
439
|
-
}
|
|
440
|
-
return price * num;
|
|
441
|
-
};
|
|
442
|
-
var getProductOriginTotalPrice = (params) => {
|
|
443
|
-
const { product, bundle, options } = params;
|
|
444
|
-
const num = (params == null ? void 0 : params.num) || 1;
|
|
445
|
-
let price = Number(product.original_price);
|
|
446
|
-
if (isNaN(price) || price === 0) {
|
|
447
|
-
return void 0;
|
|
448
|
-
}
|
|
449
|
-
if (bundle == null ? void 0 : bundle.length) {
|
|
450
|
-
price = bundle.reduce((accumulator, currentValue) => {
|
|
451
|
-
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
452
|
-
}, price);
|
|
453
|
-
}
|
|
454
|
-
if (options == null ? void 0 : options.length) {
|
|
455
|
-
price = options.reduce((accumulator, currentValue) => {
|
|
456
|
-
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
457
|
-
}, price);
|
|
458
|
-
}
|
|
459
|
-
return price * num;
|
|
460
|
-
};
|
|
461
258
|
var getProductDeposit = (params) => {
|
|
462
259
|
var _a;
|
|
463
260
|
const { cartItem, product, bundle, options } = params;
|
|
@@ -526,64 +323,17 @@ var handleProductDeposit = (params) => {
|
|
|
526
323
|
}
|
|
527
324
|
return { result: false, depositTotal: new import_decimal.default(0) };
|
|
528
325
|
};
|
|
529
|
-
var deleteResourceFromCartItem = (cartItem) => {
|
|
530
|
-
cartItem.resource_id = void 0;
|
|
531
|
-
cartItem.relation_form_name = void 0;
|
|
532
|
-
delete cartItem._resourceOrigin;
|
|
533
|
-
cartItem._origin.resources = null;
|
|
534
|
-
return cartItem;
|
|
535
|
-
};
|
|
536
|
-
var deleteTimeFromCartItem = (cartItem) => {
|
|
537
|
-
cartItem.start_date = void 0;
|
|
538
|
-
cartItem.start_time = void 0;
|
|
539
|
-
cartItem.end_date = void 0;
|
|
540
|
-
cartItem.end_time = void 0;
|
|
541
|
-
cartItem._origin.select_date = null;
|
|
542
|
-
cartItem._origin.start_date = null;
|
|
543
|
-
cartItem._origin.start_time = null;
|
|
544
|
-
cartItem._origin.end_date = null;
|
|
545
|
-
cartItem._origin.end_time = null;
|
|
546
|
-
return cartItem;
|
|
547
|
-
};
|
|
548
|
-
var deleteRelationFormsFromCartItem = (cartItem) => {
|
|
549
|
-
cartItem._origin.relation_forms = null;
|
|
550
|
-
return cartItem;
|
|
551
|
-
};
|
|
552
|
-
var deleteHolderFromCartItem = (cartItem) => {
|
|
553
|
-
cartItem.holder_id = void 0;
|
|
554
|
-
cartItem.holder_title = void 0;
|
|
555
|
-
cartItem._origin.holder = null;
|
|
556
|
-
return cartItem;
|
|
557
|
-
};
|
|
558
326
|
// Annotate the CommonJS export names for ESM import in node:
|
|
559
327
|
0 && (module.exports = {
|
|
560
|
-
createCartItemOrigin,
|
|
561
|
-
deleteHolderFromCartItem,
|
|
562
|
-
deleteRelationFormsFromCartItem,
|
|
563
|
-
deleteResourceFromCartItem,
|
|
564
|
-
deleteTimeFromCartItem,
|
|
565
|
-
formatAccountToCartItem,
|
|
566
|
-
formatAccountToCartItemOrigin,
|
|
567
328
|
formatBundle,
|
|
568
329
|
formatBundleToOrigin,
|
|
569
|
-
formatDateToCartItem,
|
|
570
|
-
formatDateToCartItemOrigin,
|
|
571
|
-
formatDiscountToCartItem,
|
|
572
|
-
formatDiscountToCartItemOrigin,
|
|
573
|
-
formatNoteToCartItem,
|
|
574
|
-
formatNoteToCartItemOrigin,
|
|
575
330
|
formatOptions,
|
|
576
331
|
formatOptionsToOrigin,
|
|
577
332
|
formatProductToCartItem,
|
|
578
333
|
formatProductToCartItemOrigin,
|
|
579
|
-
formatRelationFormsToCartItem,
|
|
580
|
-
formatRelationFormsToCartItemOrigin,
|
|
581
|
-
formatResourceToCartItem,
|
|
582
|
-
formatResourceToCartItemOrigin,
|
|
583
334
|
getProductDeposit,
|
|
584
335
|
getProductOriginTotalPrice,
|
|
585
336
|
getProductTotalPrice,
|
|
586
|
-
getUniqueId,
|
|
587
337
|
handleProductDeposit,
|
|
588
|
-
|
|
338
|
+
handleVariantProduct
|
|
589
339
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CartItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 格式化关联表单到购物车
|
|
4
|
+
* @param params 参数
|
|
5
|
+
* @returns 格式化后的购物车
|
|
6
|
+
*/
|
|
7
|
+
export declare const formatRelationFormsToCartItem: (params: {
|
|
8
|
+
cartItem: CartItem;
|
|
9
|
+
relationForms: {
|
|
10
|
+
form_id: number;
|
|
11
|
+
form_record_ids: number[];
|
|
12
|
+
}[];
|
|
13
|
+
}) => CartItem;
|
|
14
|
+
export declare const formatRelationFormsToCartItemOrigin: (params: {
|
|
15
|
+
cartItem: CartItem;
|
|
16
|
+
relationForms: {
|
|
17
|
+
form_id: number;
|
|
18
|
+
form_record_ids: number[];
|
|
19
|
+
}[];
|
|
20
|
+
}) => any;
|
|
21
|
+
/**
|
|
22
|
+
* 从购物车中删除关联表单信息
|
|
23
|
+
* @param cartItem 购物车
|
|
24
|
+
* @returns 删除后的购物车
|
|
25
|
+
*/
|
|
26
|
+
export declare const deleteRelationFormsFromCartItem: (cartItem: CartItem) => CartItem;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/Cart/utils/cartRelationForms.ts
|
|
20
|
+
var cartRelationForms_exports = {};
|
|
21
|
+
__export(cartRelationForms_exports, {
|
|
22
|
+
deleteRelationFormsFromCartItem: () => deleteRelationFormsFromCartItem,
|
|
23
|
+
formatRelationFormsToCartItem: () => formatRelationFormsToCartItem,
|
|
24
|
+
formatRelationFormsToCartItemOrigin: () => formatRelationFormsToCartItemOrigin
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(cartRelationForms_exports);
|
|
27
|
+
var formatRelationFormsToCartItem = (params) => {
|
|
28
|
+
const { cartItem } = params;
|
|
29
|
+
const oringin = formatRelationFormsToCartItemOrigin(params);
|
|
30
|
+
cartItem._origin = oringin;
|
|
31
|
+
return cartItem;
|
|
32
|
+
};
|
|
33
|
+
var formatRelationFormsToCartItemOrigin = (params) => {
|
|
34
|
+
const { cartItem, relationForms } = params;
|
|
35
|
+
const origin = cartItem._origin;
|
|
36
|
+
origin.relation_forms = relationForms;
|
|
37
|
+
return origin;
|
|
38
|
+
};
|
|
39
|
+
var deleteRelationFormsFromCartItem = (cartItem) => {
|
|
40
|
+
cartItem._origin.relation_forms = null;
|
|
41
|
+
return cartItem;
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
deleteRelationFormsFromCartItem,
|
|
46
|
+
formatRelationFormsToCartItem,
|
|
47
|
+
formatRelationFormsToCartItemOrigin
|
|
48
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Resource } from '../../Resource/types';
|
|
2
|
+
import { CartItem } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* 格式化资源到购物车
|
|
5
|
+
* @param resource 资源
|
|
6
|
+
* @returns 格式化后的资源
|
|
7
|
+
*/
|
|
8
|
+
export declare const formatResourceToCartItem: (params: {
|
|
9
|
+
cartItem: CartItem;
|
|
10
|
+
resources: Resource[];
|
|
11
|
+
}) => CartItem;
|
|
12
|
+
export declare const formatResourceToCartItemOrigin: (params: {
|
|
13
|
+
cartItem: CartItem;
|
|
14
|
+
resources: Resource[];
|
|
15
|
+
}) => any;
|
|
16
|
+
/**
|
|
17
|
+
* 从购物车中删除资源相关信息
|
|
18
|
+
* @param cartItem 购物车
|
|
19
|
+
* @returns 删除后的购物车
|
|
20
|
+
*/
|
|
21
|
+
export declare const deleteResourceFromCartItem: (cartItem: CartItem) => CartItem;
|