@pisell/private-materials 3.3.68 → 3.3.69
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +3 -3
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +5 -5
- package/es/components/appointmentBooking/components/Cart/Item/index.js +4 -2
- package/es/components/appointmentBooking/components/Services/index.js +25 -32
- package/es/components/appointmentBooking/components/Voucher/index.js +13 -0
- package/es/components/appointmentBooking/deposit/components/PolicyModal/index.js +6 -7
- package/es/components/appointmentBooking/locales.js +3 -3
- package/es/components/booking/addons/index.js +9 -2
- package/es/components/booking/addons/model.js +5 -0
- package/es/components/booking/components/TabProduct/selectProductItem/index.js +3 -1
- package/es/components/booking/components/TabProduct/selectProductItem/index.less +6 -0
- package/es/components/booking/components/footer/index.js +9 -3
- package/es/components/booking/components/footer/utils.js +73 -35
- package/es/components/booking/components/voucher/index.js +110 -66
- package/es/components/booking/components/voucher/utils.d.ts +4 -0
- package/es/components/booking/components/voucher/utils.js +15 -0
- package/es/components/booking/hooks/useQuotation.d.ts +1 -0
- package/es/components/booking/hooks/useQuotation.js +16 -1
- package/es/components/booking/info/service2/utils.d.ts +1 -1
- package/es/components/booking/info/service2/utils.js +6 -2
- package/es/components/booking/info2/index.js +9 -4
- package/es/components/booking/info2/serve.d.ts +1 -1
- package/es/components/booking/info2/serve.js +12 -8
- package/es/components/booking/info2/service/addService/index.js +2 -2
- package/es/components/booking/info2/service/editService/index.js +5 -2
- package/es/components/booking/info2/utils.d.ts +1 -1
- package/es/components/booking/info2/utils.js +3 -2
- package/es/components/booking/info2/utilsByBooking.d.ts +1 -1
- package/es/components/booking/info2/utilsByBooking.js +5 -3
- package/es/components/booking/locales.d.ts +3 -0
- package/es/components/booking/locales.js +6 -3
- package/es/components/booking/utils.d.ts +2 -2
- package/es/components/eftposPay/amount.d.ts +1 -1
- package/es/components/eftposPay/device.d.ts +1 -1
- package/es/components/eftposPay/hooks.d.ts +2 -2
- package/es/components/eftposPay/store/index.d.ts +5 -5
- package/es/components/ticketBooking/components/addServiceVariant/addService.js +5 -4
- package/es/components/ticketBooking/components/ticketBooking/index.js +4 -2
- package/es/components/ticketBooking/utils/index.d.ts +5 -1
- package/es/components/ticketBooking/utils/index.js +50 -5
- package/lib/components/appointmentBooking/components/Cart/Item/index.js +5 -4
- package/lib/components/appointmentBooking/components/Services/index.js +6 -14
- package/lib/components/appointmentBooking/components/Voucher/index.js +9 -0
- package/lib/components/appointmentBooking/deposit/components/PolicyModal/index.js +0 -1
- package/lib/components/appointmentBooking/locales.js +3 -3
- package/lib/components/booking/addons/index.js +10 -2
- package/lib/components/booking/addons/model.js +3 -0
- package/lib/components/booking/components/TabProduct/selectProductItem/index.js +5 -1
- package/lib/components/booking/components/TabProduct/selectProductItem/index.less +6 -0
- package/lib/components/booking/components/footer/index.js +10 -5
- package/lib/components/booking/components/footer/utils.js +47 -11
- package/lib/components/booking/components/voucher/index.js +111 -67
- package/lib/components/booking/components/voucher/utils.d.ts +4 -0
- package/lib/components/booking/components/voucher/utils.js +43 -0
- package/lib/components/booking/hooks/useQuotation.d.ts +1 -0
- package/lib/components/booking/hooks/useQuotation.js +19 -1
- package/lib/components/booking/info/service2/utils.d.ts +1 -1
- package/lib/components/booking/info/service2/utils.js +3 -1
- package/lib/components/booking/info2/index.js +9 -9
- package/lib/components/booking/info2/serve.d.ts +1 -1
- package/lib/components/booking/info2/serve.js +1 -1
- package/lib/components/booking/info2/service/addService/index.js +2 -2
- package/lib/components/booking/info2/service/editService/index.js +5 -2
- package/lib/components/booking/info2/utils.d.ts +1 -1
- package/lib/components/booking/info2/utils.js +2 -2
- package/lib/components/booking/info2/utilsByBooking.d.ts +1 -1
- package/lib/components/booking/info2/utilsByBooking.js +3 -2
- package/lib/components/booking/locales.d.ts +3 -0
- package/lib/components/booking/locales.js +6 -3
- package/lib/components/booking/utils.d.ts +2 -2
- package/lib/components/eftposPay/amount.d.ts +1 -1
- package/lib/components/eftposPay/device.d.ts +1 -1
- package/lib/components/eftposPay/hooks.d.ts +2 -2
- package/lib/components/eftposPay/store/index.d.ts +5 -5
- package/lib/components/ticketBooking/components/addServiceVariant/addService.js +5 -3
- package/lib/components/ticketBooking/components/ticketBooking/index.js +4 -2
- package/lib/components/ticketBooking/utils/index.d.ts +5 -1
- package/lib/components/ticketBooking/utils/index.js +44 -4
- package/package.json +2 -2
|
@@ -11,7 +11,7 @@ import { getSumCapacity } from "../../info2/utilsByBooking";
|
|
|
11
11
|
import { getDays } from "../../utils";
|
|
12
12
|
import { appointmentTypes } from "../../info/service2/status";
|
|
13
13
|
import { isDaysBooking, formatDayTime, isEventBooking, isNormalProductByDurationSchedule } from "../../info/service2/utils";
|
|
14
|
-
import { locales, sendWarningLog } from '@pisell/utils';
|
|
14
|
+
import { isArr, locales, sendWarningLog } from '@pisell/utils';
|
|
15
15
|
import { PisellToast } from "@pisell/materials";
|
|
16
16
|
var formatNote = function formatNote(data) {
|
|
17
17
|
var _data$notes;
|
|
@@ -198,12 +198,17 @@ var formatResource = function formatResource(service) {
|
|
|
198
198
|
* @Date: 2024-12-07 14:52
|
|
199
199
|
*/
|
|
200
200
|
var formatHolders = function formatHolders(state, item, values) {
|
|
201
|
-
var _state$bookingConfig, _item$_extend, _item$_extend2;
|
|
201
|
+
var _state$bookingConfig, _item$_extend, _item$_extend2, _item$_extend3, _item$_extend4;
|
|
202
202
|
var form_id = (state === null || state === void 0 || (_state$bookingConfig = state.bookingConfig) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.config) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.basic) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.appointment_subject) === null || _state$bookingConfig === void 0 ? void 0 : _state$bookingConfig.form_id) || 0;
|
|
203
|
+
var form_record = (_item$_extend = item._extend) !== null && _item$_extend !== void 0 && _item$_extend.holder_id ? [(_item$_extend2 = item._extend) === null || _item$_extend2 === void 0 ? void 0 : _item$_extend2.holder_id] : [];
|
|
204
|
+
if ((_item$_extend3 = item._extend) !== null && _item$_extend3 !== void 0 && _item$_extend3.holder_id && isArr((_item$_extend4 = item._extend) === null || _item$_extend4 === void 0 ? void 0 : _item$_extend4.holder_id)) {
|
|
205
|
+
var _item$_extend5;
|
|
206
|
+
form_record = (_item$_extend5 = item._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.holder_id;
|
|
207
|
+
}
|
|
203
208
|
var obj = {
|
|
204
209
|
customer_id: values.customer_id,
|
|
205
210
|
form_id: form_id,
|
|
206
|
-
form_record:
|
|
211
|
+
form_record: form_record
|
|
207
212
|
};
|
|
208
213
|
|
|
209
214
|
// 连锁加盟子店铺 增加参数
|
|
@@ -222,9 +227,9 @@ var formatHolders = function formatHolders(state, item, values) {
|
|
|
222
227
|
* @Date: 2024-12-23 12:05
|
|
223
228
|
*/
|
|
224
229
|
export var formatProductPrice = function formatProductPrice(item) {
|
|
225
|
-
var _item$
|
|
226
|
-
var other = (_item$
|
|
227
|
-
var price = Number((_item$
|
|
230
|
+
var _item$_extend6, _item$_extend7;
|
|
231
|
+
var other = (_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.other;
|
|
232
|
+
var price = Number((_item$_extend7 = item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.price);
|
|
228
233
|
// 单规格, 单价 + 单规格价格
|
|
229
234
|
if (other !== null && other !== void 0 && other.option) {
|
|
230
235
|
var _other$option;
|
|
@@ -235,21 +240,21 @@ export var formatProductPrice = function formatProductPrice(item) {
|
|
|
235
240
|
return price;
|
|
236
241
|
};
|
|
237
242
|
var formatMetaData = function formatMetaData(item) {
|
|
238
|
-
var _item$
|
|
243
|
+
var _item$_extend8, _item$_extend9, _item$_extend11;
|
|
239
244
|
var metadata = {};
|
|
240
|
-
if ((_item$
|
|
245
|
+
if ((_item$_extend8 = item._extend) !== null && _item$_extend8 !== void 0 && _item$_extend8.capacity) {
|
|
241
246
|
metadata.capacity = item._extend.capacity;
|
|
242
247
|
}
|
|
243
248
|
if (item._extend.groupId) {
|
|
244
249
|
metadata.groupId = item._extend.groupId;
|
|
245
250
|
}
|
|
246
|
-
if ((_item$
|
|
247
|
-
var _item$
|
|
248
|
-
metadata.holder_id = (_item$
|
|
251
|
+
if ((_item$_extend9 = item._extend) !== null && _item$_extend9 !== void 0 && _item$_extend9.holder_id) {
|
|
252
|
+
var _item$_extend10;
|
|
253
|
+
metadata.holder_id = (_item$_extend10 = item._extend) === null || _item$_extend10 === void 0 ? void 0 : _item$_extend10.holder_id;
|
|
249
254
|
}
|
|
250
|
-
if ((_item$
|
|
251
|
-
var _item$
|
|
252
|
-
metadata.multiDayPrices = (_item$
|
|
255
|
+
if ((_item$_extend11 = item._extend) !== null && _item$_extend11 !== void 0 && _item$_extend11.multiDayPrices) {
|
|
256
|
+
var _item$_extend12;
|
|
257
|
+
metadata.multiDayPrices = (_item$_extend12 = item._extend) === null || _item$_extend12 === void 0 ? void 0 : _item$_extend12.multiDayPrices;
|
|
253
258
|
}
|
|
254
259
|
return metadata;
|
|
255
260
|
};
|
|
@@ -276,8 +281,8 @@ var formatMetaData = function formatMetaData(item) {
|
|
|
276
281
|
* @Author: WangHan
|
|
277
282
|
* @Date: 2024-12-07 14:21
|
|
278
283
|
*/
|
|
279
|
-
var formatProducts = function formatProducts(item) {
|
|
280
|
-
var _item$
|
|
284
|
+
var formatProducts = function formatProducts(item, quantity) {
|
|
285
|
+
var _item$_extend13, _item$_extend14, _item$_extend15, _item$_extend16;
|
|
281
286
|
var total = Number(item._extend.total);
|
|
282
287
|
var origin_total = Number(item._extend.origin_total);
|
|
283
288
|
var discount_amount = origin_total - total;
|
|
@@ -291,9 +296,9 @@ var formatProducts = function formatProducts(item) {
|
|
|
291
296
|
return item.type !== 'product';
|
|
292
297
|
});
|
|
293
298
|
return {
|
|
294
|
-
"num": item._extend.quantity,
|
|
299
|
+
"num": quantity || item._extend.quantity,
|
|
295
300
|
"price": formatProductPrice(item),
|
|
296
|
-
"source_product_price": (_item$
|
|
301
|
+
"source_product_price": (_item$_extend13 = item._extend) === null || _item$_extend13 === void 0 ? void 0 : _item$_extend13.price,
|
|
297
302
|
"product_id": (item === null || item === void 0 ? void 0 : item.product_id) || item.id,
|
|
298
303
|
"discount_amount": notManualDiscount.length > 0 ? 0 : discount_amount,
|
|
299
304
|
"product_discount_reason": item._extend.discount_reason || '',
|
|
@@ -303,10 +308,10 @@ var formatProducts = function formatProducts(item) {
|
|
|
303
308
|
"discount_per": item._extend.discount_per,
|
|
304
309
|
"discount_type": item._extend.discount_type || discount_type,
|
|
305
310
|
"order_detail_id": item._extend.order_detail_id || 0,
|
|
306
|
-
"product_bundle": formatProductBundle((_item$
|
|
311
|
+
"product_bundle": formatProductBundle((_item$_extend14 = item._extend) === null || _item$_extend14 === void 0 || (_item$_extend14 = _item$_extend14.other) === null || _item$_extend14 === void 0 ? void 0 : _item$_extend14.bundle),
|
|
307
312
|
"bundle_edit": item._extend.bundle_edit,
|
|
308
|
-
"product_option_item": formatProductOption((_item$
|
|
309
|
-
"product_variant_id": ((_item$
|
|
313
|
+
"product_option_item": formatProductOption((_item$_extend15 = item._extend) === null || _item$_extend15 === void 0 || (_item$_extend15 = _item$_extend15.other) === null || _item$_extend15 === void 0 ? void 0 : _item$_extend15.option),
|
|
314
|
+
"product_variant_id": ((_item$_extend16 = item._extend) === null || _item$_extend16 === void 0 || (_item$_extend16 = _item$_extend16.other) === null || _item$_extend16 === void 0 ? void 0 : _item$_extend16.product_variant_id) || 0,
|
|
310
315
|
"discount_list": notManualDiscount,
|
|
311
316
|
metadata: formatMetaData(item)
|
|
312
317
|
};
|
|
@@ -326,8 +331,8 @@ var formatDayRelationProducts = function formatDayRelationProducts(data, booking
|
|
|
326
331
|
|
|
327
332
|
// 过滤出卡片中的普通商品
|
|
328
333
|
var relation_products = list === null || list === void 0 ? void 0 : list.filter(function (item) {
|
|
329
|
-
var _item$
|
|
330
|
-
var holderId = (_item$
|
|
334
|
+
var _item$_extend17;
|
|
335
|
+
var holderId = (_item$_extend17 = item._extend) === null || _item$_extend17 === void 0 ? void 0 : _item$_extend17.holder_id;
|
|
331
336
|
var bookingHolderId = booking_item._extend.holder_id;
|
|
332
337
|
var isDayBookingProduct = appointmentTypes.includes(item.extension_type);
|
|
333
338
|
return holderId && holderId === bookingHolderId && !isDayBookingProduct;
|
|
@@ -353,15 +358,15 @@ var formatAppointmentProductLists = function formatAppointmentProductLists(data)
|
|
|
353
358
|
|
|
354
359
|
// 找出预约商品
|
|
355
360
|
list = list.filter(function (item) {
|
|
356
|
-
var _item$
|
|
357
|
-
return ((_item$
|
|
361
|
+
var _item$_extend18;
|
|
362
|
+
return ((_item$_extend18 = item._extend) === null || _item$_extend18 === void 0 ? void 0 : _item$_extend18.holder_id) && appointmentTypes.includes(item.extension_type);
|
|
358
363
|
});
|
|
359
364
|
|
|
360
365
|
// 对预约商品列表根据holder_id进行分组
|
|
361
366
|
var groupMap = new Map();
|
|
362
367
|
list.forEach(function (item) {
|
|
363
|
-
var _item$
|
|
364
|
-
var key = (_item$
|
|
368
|
+
var _item$_extend19;
|
|
369
|
+
var key = (_item$_extend19 = item._extend) === null || _item$_extend19 === void 0 ? void 0 : _item$_extend19.holder_id; // 分组键
|
|
365
370
|
if (!groupMap.has(key)) {
|
|
366
371
|
groupMap.set(key, []);
|
|
367
372
|
}
|
|
@@ -381,6 +386,12 @@ var formatAppointmentProductLists = function formatAppointmentProductLists(data)
|
|
|
381
386
|
return list || [];
|
|
382
387
|
} catch (error) {}
|
|
383
388
|
};
|
|
389
|
+
var getHolderByIndex = function getHolderByIndex(holder, index) {
|
|
390
|
+
var _holder$form_record;
|
|
391
|
+
return _objectSpread(_objectSpread({}, holder), {}, {
|
|
392
|
+
form_record: [holder === null || holder === void 0 || (_holder$form_record = holder.form_record) === null || _holder$form_record === void 0 ? void 0 : _holder$form_record[index]].filter(Boolean)
|
|
393
|
+
});
|
|
394
|
+
};
|
|
384
395
|
|
|
385
396
|
/**
|
|
386
397
|
* @title: 预约商品信息
|
|
@@ -414,7 +425,7 @@ var formatBookings = function formatBookings(data, values) {
|
|
|
414
425
|
var dayParams = {};
|
|
415
426
|
var eventOtherParams = data.eventOtherParams;
|
|
416
427
|
var bookings = [];
|
|
417
|
-
|
|
428
|
+
list.forEach(function (item) {
|
|
418
429
|
var start_date = item._extend.startDate.format('YYYY-MM-DD');
|
|
419
430
|
var end_date = item._extend.endDate.format('YYYY-MM-DD');
|
|
420
431
|
var end_time = item._extend.endDate.format("HH:mm");
|
|
@@ -428,9 +439,9 @@ var formatBookings = function formatBookings(data, values) {
|
|
|
428
439
|
|
|
429
440
|
// 跨日预约下的普通商品
|
|
430
441
|
if (isDay) {
|
|
431
|
-
var _item$
|
|
432
|
-
var startDate = ((_item$
|
|
433
|
-
var endDate = ((_item$
|
|
442
|
+
var _item$_extend20, _item$_extend21, _item$_extend22, _item$_extend23;
|
|
443
|
+
var startDate = ((_item$_extend20 = item._extend) === null || _item$_extend20 === void 0 ? void 0 : _item$_extend20.startDate) || ((_item$_extend21 = item._extend) === null || _item$_extend21 === void 0 ? void 0 : _item$_extend21.start_date);
|
|
444
|
+
var endDate = ((_item$_extend22 = item._extend) === null || _item$_extend22 === void 0 ? void 0 : _item$_extend22.endDate) || ((_item$_extend23 = item._extend) === null || _item$_extend23 === void 0 ? void 0 : _item$_extend23.end_date);
|
|
434
445
|
var _formatDayTime = formatDayTime({
|
|
435
446
|
startDate: startDate,
|
|
436
447
|
endDate: endDate
|
|
@@ -452,7 +463,7 @@ var formatBookings = function formatBookings(data, values) {
|
|
|
452
463
|
}
|
|
453
464
|
}, 'minutes');
|
|
454
465
|
}
|
|
455
|
-
|
|
466
|
+
var booking = _objectSpread(_objectSpread({
|
|
456
467
|
"product": formatProducts(item),
|
|
457
468
|
"relation_products": formatRelationDetails(item._extend.relation_details),
|
|
458
469
|
'id': item.booking_id || 0,
|
|
@@ -474,6 +485,19 @@ var formatBookings = function formatBookings(data, values) {
|
|
|
474
485
|
"resources": formatResource(item),
|
|
475
486
|
"metadata": formatMetaData(item)
|
|
476
487
|
}, eventOtherParams || {}), dayParams);
|
|
488
|
+
if (isDay) {
|
|
489
|
+
bookings.push(booking);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
for (var i = 0; i < (item._extend.quantity || 1); i++) {
|
|
493
|
+
bookings.push(_objectSpread(_objectSpread({}, booking), {}, {
|
|
494
|
+
"product": formatProducts(item, 1),
|
|
495
|
+
"number": item._extend.capacity ? getSumCapacity({
|
|
496
|
+
cacheItem: item
|
|
497
|
+
}, false) : item._extend.number || 1,
|
|
498
|
+
"holder": getHolderByIndex(booking.holder, i)
|
|
499
|
+
}));
|
|
500
|
+
}
|
|
477
501
|
});
|
|
478
502
|
return bookings;
|
|
479
503
|
};
|
|
@@ -491,8 +515,8 @@ var formatRelationProducts = function formatRelationProducts(data) {
|
|
|
491
515
|
var list = ((_data$service = data.service) === null || _data$service === void 0 ? void 0 : _data$service.value) || [];
|
|
492
516
|
// open items 下的商品
|
|
493
517
|
list = list.filter(function (item) {
|
|
494
|
-
var _item$
|
|
495
|
-
return !((_item$
|
|
518
|
+
var _item$_extend24;
|
|
519
|
+
return !((_item$_extend24 = item._extend) !== null && _item$_extend24 !== void 0 && _item$_extend24.holder_id);
|
|
496
520
|
});
|
|
497
521
|
var relationProducts = [];
|
|
498
522
|
relationProducts = list.map(function (item) {
|
|
@@ -587,7 +611,11 @@ export var formatValues = function formatValues(state) {
|
|
|
587
611
|
if (isDay || isEvent) {
|
|
588
612
|
values.relation_products = formatRelationProducts(state);
|
|
589
613
|
} else {
|
|
614
|
+
var _values$relation_prod;
|
|
590
615
|
values.relation_products = formatNormalProducts(state);
|
|
616
|
+
if (!((_values$relation_prod = values.relation_products) !== null && _values$relation_prod !== void 0 && _values$relation_prod.length)) {
|
|
617
|
+
values.relation_products = undefined;
|
|
618
|
+
}
|
|
591
619
|
}
|
|
592
620
|
// 服务
|
|
593
621
|
values.bookings = formatBookings(state, values);
|
|
@@ -617,8 +645,18 @@ export var formatValues = function formatValues(state) {
|
|
|
617
645
|
export var checkHolderIsError = function checkHolderIsError(state) {
|
|
618
646
|
var _state$client;
|
|
619
647
|
var holderError = state.service.value.some(function (item) {
|
|
648
|
+
var _item$_extend25;
|
|
620
649
|
// 普通商品不需要检测holder
|
|
621
|
-
|
|
650
|
+
if (isNormalProductByDurationSchedule(item)) {
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
if (item._extend.quantity === 1 && !item._extend.holder_id) {
|
|
654
|
+
return true;
|
|
655
|
+
}
|
|
656
|
+
if (item._extend.quantity > 1 && ((_item$_extend25 = item._extend) === null || _item$_extend25 === void 0 || (_item$_extend25 = _item$_extend25.holder_id) === null || _item$_extend25 === void 0 ? void 0 : _item$_extend25.length) !== item._extend.quantity) {
|
|
657
|
+
return true;
|
|
658
|
+
}
|
|
659
|
+
return false;
|
|
622
660
|
});
|
|
623
661
|
var clientId = (_state$client = state.client) === null || _state$client === void 0 || (_state$client = _state$client.value) === null || _state$client === void 0 ? void 0 : _state$client.id;
|
|
624
662
|
if (holderError && (!clientId || clientId === 0 || clientId === 1)) {
|
|
@@ -7,6 +7,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
9
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
11
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
13
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
14
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
15
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
16
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -22,7 +26,8 @@ import useEngineContext from "../../../../hooks/useEngineContext";
|
|
|
22
26
|
import { PisellInput, PisellGoodPassCard, PisellToast } from '@pisell/materials';
|
|
23
27
|
import { useIsBooking4Shop } from "../../hooks/useIsBooking4Shop";
|
|
24
28
|
import "./index.less";
|
|
25
|
-
import { useMemoizedFn, useDebounceFn } from 'ahooks';
|
|
29
|
+
import { useMemoizedFn, useDebounceFn, useDebounceEffect } from 'ahooks';
|
|
30
|
+
import { getServiceAddons } from "./utils";
|
|
26
31
|
var ShopDiscountHooks = {
|
|
27
32
|
onInited: 'shopDiscount:onInited',
|
|
28
33
|
onDestroy: 'shopDiscount:onDestroy',
|
|
@@ -35,10 +40,11 @@ var ShopDiscountHooks = {
|
|
|
35
40
|
};
|
|
36
41
|
var services = {};
|
|
37
42
|
var VoucherCard = function VoucherCard(props) {
|
|
38
|
-
var _context$appHelper, _state$client$value;
|
|
43
|
+
var _context$appHelper, _state$client$value, _state$service2;
|
|
39
44
|
var context = useEngineContext();
|
|
40
45
|
var state = props.state,
|
|
41
|
-
dispatch = props.dispatch
|
|
46
|
+
dispatch = props.dispatch,
|
|
47
|
+
source = props.source;
|
|
42
48
|
var _useState = useState(false),
|
|
43
49
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
50
|
showDetail = _useState2[0],
|
|
@@ -53,35 +59,27 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
53
59
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
54
60
|
discountList = _useState6[0],
|
|
55
61
|
setDisCountList = _useState6[1];
|
|
56
|
-
var
|
|
62
|
+
var serviceValueRef = useRef(state.service.value);
|
|
63
|
+
var addonsValueRef = useRef(state.addons.value);
|
|
57
64
|
var isBooking4Shop = useIsBooking4Shop(state);
|
|
58
65
|
var shopDiscount = pisellos.getModule('shopDiscount');
|
|
59
66
|
services = state.service;
|
|
60
|
-
var availableData = useMemo(function () {
|
|
61
|
-
if (!isBooking4Shop) return [];
|
|
62
|
-
var shopDiscount = pisellos.getModule('shopDiscount');
|
|
63
|
-
return discountList.filter(function (item) {
|
|
64
|
-
return !!item.isAvailable;
|
|
65
|
-
}).map(function (discount) {
|
|
66
|
-
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
67
|
-
savedAmount: shopDiscount.calcDiscountApplicableProductTotalPrice(discount)
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}, [discountList, isBooking4Shop]);
|
|
71
67
|
|
|
72
68
|
// 设置client
|
|
73
|
-
|
|
69
|
+
useDebounceEffect(function () {
|
|
74
70
|
if (isBooking4Shop) {
|
|
75
71
|
shopDiscount.setCustomer(state.client.value);
|
|
76
72
|
}
|
|
77
|
-
}, [(_state$client$value = state.client.value) === null || _state$client$value === void 0 ? void 0 : _state$client$value.id, isBooking4Shop]
|
|
73
|
+
}, [(_state$client$value = state.client.value) === null || _state$client$value === void 0 ? void 0 : _state$client$value.id, isBooking4Shop], {
|
|
74
|
+
wait: 200
|
|
75
|
+
});
|
|
78
76
|
|
|
79
77
|
// 设置productList
|
|
80
78
|
useEffect(function () {
|
|
81
79
|
if (isBooking4Shop) {
|
|
82
|
-
shopDiscount.setProductList(state.service.value);
|
|
80
|
+
shopDiscount.setProductList([].concat(_toConsumableArray(state.service.value), _toConsumableArray(state.addons.value)));
|
|
83
81
|
}
|
|
84
|
-
}, [state.service.value, isBooking4Shop]);
|
|
82
|
+
}, [state.service.value, state.addons.value, isBooking4Shop]);
|
|
85
83
|
var serviceMemo = useMemo(function () {
|
|
86
84
|
var _ref;
|
|
87
85
|
var val = (_ref = state.service.value || []) === null || _ref === void 0 ? void 0 : _ref.map(function (value) {
|
|
@@ -89,7 +87,6 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
89
87
|
return {
|
|
90
88
|
booking_id: value.booking_id,
|
|
91
89
|
id: value.id,
|
|
92
|
-
_id: value._id,
|
|
93
90
|
price: value.price,
|
|
94
91
|
total: value === null || value === void 0 || (_value$_extend = value._extend) === null || _value$_extend === void 0 ? void 0 : _value$_extend.total,
|
|
95
92
|
discount_list: value.discount_list,
|
|
@@ -98,24 +95,43 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
98
95
|
});
|
|
99
96
|
return val;
|
|
100
97
|
}, [state.service.value]);
|
|
98
|
+
var addonsMemo = useMemo(function () {
|
|
99
|
+
var _ref2;
|
|
100
|
+
var val = (_ref2 = state.addons.value || []) === null || _ref2 === void 0 ? void 0 : _ref2.map(function (value) {
|
|
101
|
+
var _value$_extend3, _value$_extend4;
|
|
102
|
+
return {
|
|
103
|
+
booking_id: value.booking_id,
|
|
104
|
+
id: value.id,
|
|
105
|
+
_id: value._id,
|
|
106
|
+
price: value.price,
|
|
107
|
+
total: value === null || value === void 0 || (_value$_extend3 = value._extend) === null || _value$_extend3 === void 0 ? void 0 : _value$_extend3.total,
|
|
108
|
+
discount_list: value.discount_list,
|
|
109
|
+
_key: value._key,
|
|
110
|
+
num: value === null || value === void 0 || (_value$_extend4 = value._extend) === null || _value$_extend4 === void 0 ? void 0 : _value$_extend4.quantity
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
return val;
|
|
114
|
+
}, [state.addons.value]);
|
|
115
|
+
var disabled = useMemo(function () {
|
|
116
|
+
var _state$bookingDetail;
|
|
117
|
+
if (['paid', 'partially_paid'].includes((_state$bookingDetail = state.bookingDetail) === null || _state$bookingDetail === void 0 ? void 0 : _state$bookingDetail.payment_status) && [].concat(_toConsumableArray(addonsMemo), _toConsumableArray(serviceMemo)).every(function (item) {
|
|
118
|
+
return item.booking_id;
|
|
119
|
+
})) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}, [state, addonsMemo, serviceMemo]);
|
|
101
124
|
var _useDebounceFn = useDebounceFn(function () {
|
|
102
125
|
var _state$service;
|
|
103
126
|
// console.log('state.service.value1', state.service.value);
|
|
104
|
-
if (
|
|
127
|
+
if (serviceValueRef.current === state.service.value && addonsValueRef.current === state.addons.value || !((_state$service = state.service) !== null && _state$service !== void 0 && (_state$service = _state$service.value) !== null && _state$service !== void 0 && _state$service.length)) {
|
|
105
128
|
return;
|
|
106
129
|
}
|
|
107
130
|
if (isBooking4Shop) {
|
|
108
|
-
var val = shopDiscount.calcDiscount(state.service.value);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// console.log('val.productList', val.productList);
|
|
113
|
-
dispatch({
|
|
114
|
-
type: 'setService',
|
|
115
|
-
payload: _objectSpread(_objectSpread({}, services), {}, {
|
|
116
|
-
value: ((val === null || val === void 0 ? void 0 : val.productList) || []).filter(Boolean)
|
|
117
|
-
})
|
|
118
|
-
});
|
|
131
|
+
var val = shopDiscount.calcDiscount([].concat(_toConsumableArray(state.service.value), _toConsumableArray(state.addons.value)));
|
|
132
|
+
console.log('input: ', state.service.value);
|
|
133
|
+
console.log('output: ', val);
|
|
134
|
+
productListToValue(val.productList);
|
|
119
135
|
}
|
|
120
136
|
}, {
|
|
121
137
|
wait: 500
|
|
@@ -125,7 +141,7 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
125
141
|
// 更新productList
|
|
126
142
|
useEffect(function () {
|
|
127
143
|
run();
|
|
128
|
-
}, [JSON.stringify(serviceMemo), isBooking4Shop]);
|
|
144
|
+
}, [JSON.stringify(serviceMemo), JSON.stringify(addonsMemo), isBooking4Shop]);
|
|
129
145
|
var fn = useMemoizedFn(function (result) {
|
|
130
146
|
var _result$productList;
|
|
131
147
|
if (!(result !== null && result !== void 0 && result.productList) || result !== null && result !== void 0 && (_result$productList = result.productList) !== null && _result$productList !== void 0 && _result$productList.some(function (item) {
|
|
@@ -133,18 +149,13 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
133
149
|
})) {
|
|
134
150
|
return;
|
|
135
151
|
}
|
|
136
|
-
|
|
137
|
-
type: 'setService',
|
|
138
|
-
payload: _objectSpread(_objectSpread({}, services), {}, {
|
|
139
|
-
value: result.productList
|
|
140
|
-
})
|
|
141
|
-
});
|
|
152
|
+
productListToValue(result.productList);
|
|
142
153
|
});
|
|
143
154
|
|
|
144
155
|
// 监听customer变化
|
|
145
156
|
useEffect(function () {
|
|
146
157
|
if (!isBooking4Shop) return;
|
|
147
|
-
|
|
158
|
+
var onScanCustomerChange = function onScanCustomerChange(customer) {
|
|
148
159
|
// 更新客户
|
|
149
160
|
dispatch({
|
|
150
161
|
type: 'setClient',
|
|
@@ -152,22 +163,49 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
152
163
|
value: customer
|
|
153
164
|
}
|
|
154
165
|
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
pisellos.effects.on(ShopDiscountHooks.onDiscountListChange, function (discount) {
|
|
166
|
+
};
|
|
167
|
+
var onDiscountListChange = function onDiscountListChange(discount) {
|
|
158
168
|
setDisCountList(discount);
|
|
159
|
-
}
|
|
169
|
+
};
|
|
170
|
+
pisellos.effects.on(ShopDiscountHooks.onScanCustomerChange, onScanCustomerChange);
|
|
171
|
+
pisellos.effects.on(ShopDiscountHooks.onLoadPrepareCalcResult, fn);
|
|
172
|
+
pisellos.effects.on(ShopDiscountHooks.onDiscountListChange, onDiscountListChange);
|
|
160
173
|
return function () {
|
|
161
174
|
shopDiscount.clear();
|
|
162
|
-
pisellos.effects.off(ShopDiscountHooks.onCustomerChange);
|
|
163
|
-
pisellos.effects.off(ShopDiscountHooks.onLoadPrepareCalcResult);
|
|
164
|
-
pisellos.effects.off(ShopDiscountHooks.onDiscountListChange);
|
|
175
|
+
pisellos.effects.off(ShopDiscountHooks.onCustomerChange, onScanCustomerChange);
|
|
176
|
+
pisellos.effects.off(ShopDiscountHooks.onLoadPrepareCalcResult, fn);
|
|
177
|
+
pisellos.effects.off(ShopDiscountHooks.onDiscountListChange, onDiscountListChange);
|
|
165
178
|
};
|
|
166
179
|
}, [state.bookingId, isBooking4Shop, fn]);
|
|
180
|
+
var productListToValue = useMemoizedFn(function (list, edit) {
|
|
181
|
+
var _getServiceAddons = getServiceAddons(list),
|
|
182
|
+
serviceList = _getServiceAddons.serviceList,
|
|
183
|
+
addonsList = _getServiceAddons.addonsList;
|
|
184
|
+
serviceValueRef.current = serviceList;
|
|
185
|
+
addonsValueRef.current = addonsList;
|
|
186
|
+
var other = {};
|
|
187
|
+
if (edit) {
|
|
188
|
+
other = {
|
|
189
|
+
edit: true
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
dispatch({
|
|
193
|
+
type: 'setService',
|
|
194
|
+
payload: _objectSpread({
|
|
195
|
+
value: serviceList
|
|
196
|
+
}, other)
|
|
197
|
+
});
|
|
198
|
+
dispatch({
|
|
199
|
+
type: 'setAddons',
|
|
200
|
+
payload: _objectSpread({
|
|
201
|
+
value: addonsList
|
|
202
|
+
}, other)
|
|
203
|
+
});
|
|
204
|
+
});
|
|
167
205
|
|
|
168
206
|
// apply code
|
|
169
207
|
var onScanCode = /*#__PURE__*/function () {
|
|
170
|
-
var
|
|
208
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
171
209
|
var val;
|
|
172
210
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
173
211
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -178,18 +216,11 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
178
216
|
val = _context.sent;
|
|
179
217
|
console.log(val);
|
|
180
218
|
if (val !== null && val !== void 0 && val.isAvailable) {
|
|
181
|
-
|
|
182
|
-
dispatch({
|
|
183
|
-
type: 'setService',
|
|
184
|
-
payload: {
|
|
185
|
-
value: val.productList,
|
|
186
|
-
edit: true
|
|
187
|
-
}
|
|
188
|
-
});
|
|
219
|
+
productListToValue(val.productList, true);
|
|
189
220
|
setCode('');
|
|
190
221
|
} else {
|
|
191
222
|
PisellToast({
|
|
192
|
-
content: locales.getText('pisell2.text.goodpass.code-invalid')
|
|
223
|
+
content: val.type === 'server' ? locales.getText('pisell2.text.goodpass.code-invalid') : locales.getText('pisell2.text.goodpass.code-invalid-cart')
|
|
193
224
|
});
|
|
194
225
|
}
|
|
195
226
|
case 5:
|
|
@@ -199,10 +230,27 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
199
230
|
}, _callee);
|
|
200
231
|
}));
|
|
201
232
|
return function onScanCode() {
|
|
202
|
-
return
|
|
233
|
+
return _ref3.apply(this, arguments);
|
|
203
234
|
};
|
|
204
235
|
}();
|
|
236
|
+
var availableData = useMemo(function () {
|
|
237
|
+
if (!isBooking4Shop) return [];
|
|
238
|
+
var shopDiscount = pisellos.getModule('shopDiscount');
|
|
239
|
+
return discountList.filter(function (item) {
|
|
240
|
+
return !!item.isAvailable;
|
|
241
|
+
}).map(function (discount) {
|
|
242
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
243
|
+
isDisabled: discount.isDisabled || discount.isDisabledForProductUsed || disabled,
|
|
244
|
+
savedAmount: shopDiscount.calcDiscountApplicableProductTotalPrice(discount)
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
}, [discountList, isBooking4Shop, disabled]);
|
|
205
248
|
if (!isBooking4Shop) return null;
|
|
249
|
+
var mixedSort = function mixedSort(val) {
|
|
250
|
+
return _toConsumableArray(val).sort(function (a, b) {
|
|
251
|
+
return Number(b === null || b === void 0 ? void 0 : b.isSelected) - Number(a === null || a === void 0 ? void 0 : a.isSelected);
|
|
252
|
+
});
|
|
253
|
+
};
|
|
206
254
|
return /*#__PURE__*/React.createElement("div", {
|
|
207
255
|
className: "pisell-lowcode__booking-footer-voucher-container"
|
|
208
256
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -227,7 +275,8 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
227
275
|
style: {
|
|
228
276
|
width: '100%'
|
|
229
277
|
},
|
|
230
|
-
dataSource: availableData,
|
|
278
|
+
dataSource: (_state$service2 = state.service) !== null && _state$service2 !== void 0 && (_state$service2 = _state$service2.value) !== null && _state$service2 !== void 0 && _state$service2.length ? availableData : [],
|
|
279
|
+
mixedSort: mixedSort,
|
|
231
280
|
onChange: function onChange(val) {
|
|
232
281
|
var shopDiscount = pisellos.getModule('shopDiscount');
|
|
233
282
|
var detail = shopDiscount.setDiscountSelected({
|
|
@@ -235,13 +284,7 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
235
284
|
isSelected: val.isSelected
|
|
236
285
|
});
|
|
237
286
|
console.log('setDiscountSelected:', detail);
|
|
238
|
-
|
|
239
|
-
type: 'setService',
|
|
240
|
-
payload: {
|
|
241
|
-
edit: true,
|
|
242
|
-
value: detail.productList
|
|
243
|
-
}
|
|
244
|
-
});
|
|
287
|
+
productListToValue(detail.productList, true);
|
|
245
288
|
}
|
|
246
289
|
}) : null, /*#__PURE__*/React.createElement("div", {
|
|
247
290
|
className: "voucher-code-input-wrapper"
|
|
@@ -258,6 +301,7 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
258
301
|
setCode((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
|
|
259
302
|
},
|
|
260
303
|
size: "small",
|
|
304
|
+
allowClear: true,
|
|
261
305
|
placeholder: locales.getText('pisell2.text.goodpass.enter-code')
|
|
262
306
|
// suffix={
|
|
263
307
|
// <PisellTooltip title="">
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export var getServiceAddons = function getServiceAddons(list) {
|
|
2
|
+
var serviceList = [];
|
|
3
|
+
var addonsList = [];
|
|
4
|
+
list.forEach(function (item) {
|
|
5
|
+
if (item.isAddons) {
|
|
6
|
+
addonsList.push(item);
|
|
7
|
+
} else {
|
|
8
|
+
serviceList.push(item);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
serviceList: serviceList,
|
|
13
|
+
addonsList: addonsList
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -19,6 +19,7 @@ import useEngineContext from "../../../../es/hooks/useEngineContext";
|
|
|
19
19
|
import { locales } from "@pisell/utils";
|
|
20
20
|
import { PisellModal } from "@pisell/materials";
|
|
21
21
|
import { getProductPrice } from "../info/service/serve";
|
|
22
|
+
import Decimal from 'decimal.js';
|
|
22
23
|
var formatBundleItemMap = function formatBundleItemMap(product) {
|
|
23
24
|
return product.bundle_group.reduce(function (pre, cur) {
|
|
24
25
|
var curObj = {};
|
|
@@ -28,6 +29,13 @@ var formatBundleItemMap = function formatBundleItemMap(product) {
|
|
|
28
29
|
return _objectSpread(_objectSpread({}, pre), curObj);
|
|
29
30
|
}, {});
|
|
30
31
|
};
|
|
32
|
+
export var calculateTotalPrice = function calculateTotalPrice(data) {
|
|
33
|
+
var _price = data.reduce(function (total, item) {
|
|
34
|
+
var _price = (item === null || item === void 0 ? void 0 : item.price) || (item === null || item === void 0 ? void 0 : item.add_price);
|
|
35
|
+
return total + _price * item.num;
|
|
36
|
+
}, 0);
|
|
37
|
+
return parseFloat(_price);
|
|
38
|
+
};
|
|
31
39
|
var setNewCartValue = function setNewCartValue(cartValue, newProducts) {
|
|
32
40
|
if (!newProducts.length) {
|
|
33
41
|
return {
|
|
@@ -70,9 +78,16 @@ var setNewCartValue = function setNewCartValue(cartValue, newProducts) {
|
|
|
70
78
|
isChangePrice = true;
|
|
71
79
|
isBundleChange = true;
|
|
72
80
|
}
|
|
81
|
+
if (bundleItemMap[bundle.id].price_type === 'markdown') {
|
|
82
|
+
bundleItemMap[bundle.id].price = new Decimal(bundleItemMap[bundle.id].price || 0).mul(-1).toNumber();
|
|
83
|
+
}
|
|
84
|
+
var selectBundleInfo = item._extend.other.bundle.find(function (item) {
|
|
85
|
+
return item.id === bundle.id;
|
|
86
|
+
});
|
|
87
|
+
var optionPrice = calculateTotalPrice((selectBundleInfo === null || selectBundleInfo === void 0 ? void 0 : selectBundleInfo.option) || []);
|
|
73
88
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
74
89
|
base_price: bundleItemMap[bundle.id].base_price,
|
|
75
|
-
price: bundleItemMap[bundle.id].price
|
|
90
|
+
price: new Decimal(bundleItemMap[bundle.id].price || 0).add(optionPrice).toNumber()
|
|
76
91
|
// product_price: bundleItemMap[item.id].product_price,
|
|
77
92
|
});
|
|
78
93
|
});
|
|
@@ -244,4 +244,4 @@ export declare const updateAppointmentServicePrice: (state: any, { start_date, e
|
|
|
244
244
|
* @Author: WangHan
|
|
245
245
|
* @Date: 2024-12-24 11:32
|
|
246
246
|
*/
|
|
247
|
-
export declare const updateServicePrice: (state: any) => never[]
|
|
247
|
+
export declare const updateServicePrice: (state: any) => Promise<any> | never[];
|