@pisell/private-materials 6.6.51 → 6.6.53
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.js +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/components/booking/components/footer/amount.d.ts +1 -0
- package/es/components/booking/components/footer/amount.js +9 -0
- package/es/components/booking/components/footer/utils.js +4 -0
- package/es/components/booking/info/service2/utils.js +46 -42
- package/es/components/ticketBooking/utils/index.js +3 -1
- package/lib/components/booking/components/footer/amount.d.ts +1 -0
- package/lib/components/booking/components/footer/amount.js +11 -0
- package/lib/components/booking/components/footer/utils.js +4 -0
- package/lib/components/booking/info/service2/utils.js +15 -13
- package/lib/components/ticketBooking/utils/index.js +3 -1
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const getRelationDetailsTotal: (relation_details: any) => number;
|
|
2
2
|
export declare const getProductDiscountProductDiscountDifference: (product: any) => any;
|
|
3
|
+
export declare const getOptionDiscountAmount: (discounts: any[]) => number;
|
|
3
4
|
export declare const getIsPriceIncludeTax: (state: any) => any;
|
|
4
5
|
/**
|
|
5
6
|
* 总金额
|
|
@@ -807,6 +807,12 @@ var getDiscountAmount = function getDiscountAmount(discounts) {
|
|
|
807
807
|
return total.add(new Decimal(discount.amount || 0));
|
|
808
808
|
}, new Decimal(0)).toNumber();
|
|
809
809
|
};
|
|
810
|
+
export var getOptionDiscountAmount = function getOptionDiscountAmount(discounts) {
|
|
811
|
+
return (discounts || []).reduce(function (total, discount) {
|
|
812
|
+
var _discount$metadata;
|
|
813
|
+
return total.add(new Decimal((discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.optionDiscountAmount) || 0));
|
|
814
|
+
}, new Decimal(0)).toNumber();
|
|
815
|
+
};
|
|
810
816
|
|
|
811
817
|
/**
|
|
812
818
|
* 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
|
|
@@ -821,6 +827,9 @@ var getMainProductTotal = function getMainProductTotal(item) {
|
|
|
821
827
|
total = total.add((_item$_extend$other5 = item._extend.other) === null || _item$_extend$other5 === void 0 ? void 0 : _item$_extend$other5.option.reduce(function (t, option) {
|
|
822
828
|
return t.add(new Decimal(option.price || 0).mul(option.num || 1));
|
|
823
829
|
}, new Decimal(0)));
|
|
830
|
+
if (item.booking_id) {
|
|
831
|
+
total = total.sub(getOptionDiscountAmount((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
832
|
+
}
|
|
824
833
|
}
|
|
825
834
|
var _iterator13 = _createForOfIteratorHelper(((_item$_extend$other6 = item._extend.other) === null || _item$_extend$other6 === void 0 ? void 0 : _item$_extend$other6.bundle) || []),
|
|
826
835
|
_step13;
|
|
@@ -22,6 +22,7 @@ import { PisellToast } from '@pisell/materials';
|
|
|
22
22
|
import { getClientName } from "../../../../plus/clientName/utils";
|
|
23
23
|
import { cloneDeep } from 'lodash';
|
|
24
24
|
import Decimal from 'decimal.js';
|
|
25
|
+
import { getOptionDiscountAmount } from "./amount";
|
|
25
26
|
var formatNote = function formatNote(data) {
|
|
26
27
|
var _data$notes;
|
|
27
28
|
return ((_data$notes = data.notes) === null || _data$notes === void 0 ? void 0 : _data$notes.orderNote) || '';
|
|
@@ -461,6 +462,9 @@ export var getMainProductSellingPrice = function getMainProductSellingPrice(item
|
|
|
461
462
|
var currentNum = new Decimal(currentValue.num || 0);
|
|
462
463
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
463
464
|
}, optionPrice);
|
|
465
|
+
if (item !== null && item !== void 0 && item.booking_id) {
|
|
466
|
+
optionPrice = optionPrice.sub(getOptionDiscountAmount((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
467
|
+
}
|
|
464
468
|
}
|
|
465
469
|
return new Decimal((_item$_extend35 = item._extend) === null || _item$_extend35 === void 0 ? void 0 : _item$_extend35.main_product_selling_price).add(optionPrice).toNumber();
|
|
466
470
|
};
|
|
@@ -215,12 +215,14 @@ export var handleChangeHolder = function handleChangeHolder(products, currentIte
|
|
|
215
215
|
var handleAddHolder = function handleAddHolder() {};
|
|
216
216
|
var handleLike = function handleLike(products, currentItem, other) {
|
|
217
217
|
return products.map(function (item) {
|
|
218
|
+
var _item$_extend3, _item$_extend4;
|
|
219
|
+
var isSameGroup = (item === null || item === void 0 || (_item$_extend3 = item._extend) === null || _item$_extend3 === void 0 ? void 0 : _item$_extend3.groupId) && ((_item$_extend4 = item._extend) === null || _item$_extend4 === void 0 ? void 0 : _item$_extend4.groupId) === (currentItem === null || currentItem === void 0 ? void 0 : currentItem.serviceId);
|
|
218
220
|
if (currentItem.isParallelResource) {
|
|
219
|
-
if (item._id === currentItem.serviceId) {
|
|
220
|
-
var _item$
|
|
221
|
+
if (item._id === currentItem.serviceId || isSameGroup) {
|
|
222
|
+
var _item$_extend5, _item$_extend6;
|
|
221
223
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
222
224
|
_extend: _objectSpread(_objectSpread({}, item._extend), {}, {
|
|
223
|
-
resource: _objectSpread(_objectSpread({}, (_item$
|
|
225
|
+
resource: _objectSpread(_objectSpread({}, (_item$_extend5 = item._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.resource), {}, _defineProperty({}, currentItem.resourceId, (_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.resource[currentItem.resourceId].map(function (item) {
|
|
224
226
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
225
227
|
like_status: other.like_status
|
|
226
228
|
});
|
|
@@ -230,7 +232,7 @@ var handleLike = function handleLike(products, currentItem, other) {
|
|
|
230
232
|
}
|
|
231
233
|
return item;
|
|
232
234
|
} else {
|
|
233
|
-
if (item._id === currentItem._id) {
|
|
235
|
+
if (item._id === currentItem._id || isSameGroup) {
|
|
234
236
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
235
237
|
_extend: _objectSpread(_objectSpread({}, item._extend), {}, {
|
|
236
238
|
like_status: other.like_status
|
|
@@ -245,14 +247,16 @@ var handleLike = function handleLike(products, currentItem, other) {
|
|
|
245
247
|
// 更新资源
|
|
246
248
|
var handleChangeResource = function handleChangeResource(products, currentItem, other, state) {
|
|
247
249
|
return products.map(function (item) {
|
|
250
|
+
var _item$_extend7, _item$_extend8, _currentItem$_origin2;
|
|
248
251
|
var _ref = other || {},
|
|
249
252
|
props = _ref.props,
|
|
250
253
|
value = _ref.value;
|
|
251
254
|
var _ref2 = props || {},
|
|
252
255
|
isParallelResource = _ref2.isParallelResource,
|
|
253
256
|
resourceId = _ref2.resourceId;
|
|
257
|
+
var isSameGroup = (item === null || item === void 0 || (_item$_extend7 = item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.groupId) && ((_item$_extend8 = item._extend) === null || _item$_extend8 === void 0 ? void 0 : _item$_extend8.groupId) === (currentItem === null || currentItem === void 0 || (_currentItem$_origin2 = currentItem._origin) === null || _currentItem$_origin2 === void 0 || (_currentItem$_origin2 = _currentItem$_origin2._extend) === null || _currentItem$_origin2 === void 0 ? void 0 : _currentItem$_origin2.groupId);
|
|
254
258
|
if (isParallelResource) {
|
|
255
|
-
if (item._id === currentItem._id) {
|
|
259
|
+
if (item._id === currentItem._id || isSameGroup) {
|
|
256
260
|
var hasDataItem = getProductExtend({
|
|
257
261
|
cacheItem: _objectSpread(_objectSpread({}, item), {}, {
|
|
258
262
|
new: 0
|
|
@@ -286,7 +290,7 @@ var handleChangeResource = function handleChangeResource(products, currentItem,
|
|
|
286
290
|
}
|
|
287
291
|
return item;
|
|
288
292
|
} else {
|
|
289
|
-
if (item._id === currentItem._id) {
|
|
293
|
+
if (item._id === currentItem._id || isSameGroup) {
|
|
290
294
|
var _resourceItem$_extend;
|
|
291
295
|
var resourceItem = currentResource(state, other.id, item);
|
|
292
296
|
var _ref3 = (resourceItem === null || resourceItem === void 0 || (_resourceItem$_extend = resourceItem._extend) === null || _resourceItem$_extend === void 0 ? void 0 : _resourceItem$_extend.usableTime) || {},
|
|
@@ -345,8 +349,8 @@ export var updateServices = function updateServices(state, currentItem, type, ot
|
|
|
345
349
|
if (type === 'delete_holders') {
|
|
346
350
|
var _products2;
|
|
347
351
|
products = (_products2 = products) === null || _products2 === void 0 ? void 0 : _products2.filter(function (item) {
|
|
348
|
-
var _item$
|
|
349
|
-
return (item === null || item === void 0 || (_item$
|
|
352
|
+
var _item$_extend9;
|
|
353
|
+
return (item === null || item === void 0 || (_item$_extend9 = item._extend) === null || _item$_extend9 === void 0 ? void 0 : _item$_extend9.holder_id) !== other;
|
|
350
354
|
});
|
|
351
355
|
}
|
|
352
356
|
|
|
@@ -560,7 +564,7 @@ export var genRowKey = function genRowKey(key) {
|
|
|
560
564
|
return "rowKey-".concat(key);
|
|
561
565
|
};
|
|
562
566
|
var getGeneralParams = function getGeneralParams(item, state, isParallelResource) {
|
|
563
|
-
var _state$bookingConfig4, _state$bookingConfig5, _formData$, _item$
|
|
567
|
+
var _state$bookingConfig4, _state$bookingConfig5, _formData$, _item$_extend11, _item$_extend12, _item$_extend13, _item$_extend14, _item$_extend15;
|
|
564
568
|
var pet = state.pet,
|
|
565
569
|
service = state.service;
|
|
566
570
|
var _ref8 = pet || {},
|
|
@@ -603,7 +607,7 @@ var getGeneralParams = function getGeneralParams(item, state, isParallelResource
|
|
|
603
607
|
};
|
|
604
608
|
});
|
|
605
609
|
} else {
|
|
606
|
-
var _item$
|
|
610
|
+
var _item$_extend10;
|
|
607
611
|
var _ref10 = service || {},
|
|
608
612
|
resourcesOrigin = _ref10.resourcesOrigin;
|
|
609
613
|
var resource = formatResources({
|
|
@@ -614,7 +618,7 @@ var getGeneralParams = function getGeneralParams(item, state, isParallelResource
|
|
|
614
618
|
multiResources = [{
|
|
615
619
|
_id: item._id,
|
|
616
620
|
id: item._extend.resource,
|
|
617
|
-
status: ((_item$
|
|
621
|
+
status: ((_item$_extend10 = item._extend) === null || _item$_extend10 === void 0 ? void 0 : _item$_extend10.like_status) || 'common',
|
|
618
622
|
lists: mapListItems(resource)
|
|
619
623
|
}];
|
|
620
624
|
}
|
|
@@ -639,10 +643,10 @@ var getGeneralParams = function getGeneralParams(item, state, isParallelResource
|
|
|
639
643
|
holderMode: (item === null || item === void 0 ? void 0 : item._extend.quantity) > 1 ? 'multiple' : undefined,
|
|
640
644
|
isErrorHolder: getIsSubjectRequire(state),
|
|
641
645
|
addHolderButtonText: (formData === null || formData === void 0 || (_formData$ = formData[0]) === null || _formData$ === void 0 || (_formData$ = _formData$.form) === null || _formData$ === void 0 ? void 0 : _formData$.title) || "",
|
|
642
|
-
holder_id: item === null || item === void 0 || (_item$
|
|
643
|
-
start_date: !isNormalProduct ? item === null || item === void 0 || (_item$
|
|
644
|
-
end_date: !isNormalProduct ? (item === null || item === void 0 || (_item$
|
|
645
|
-
rowKey: genRowKey(item === null || item === void 0 || (_item$
|
|
646
|
+
holder_id: item === null || item === void 0 || (_item$_extend11 = item._extend) === null || _item$_extend11 === void 0 ? void 0 : _item$_extend11.holder_id,
|
|
647
|
+
start_date: !isNormalProduct ? item === null || item === void 0 || (_item$_extend12 = item._extend) === null || _item$_extend12 === void 0 ? void 0 : _item$_extend12.startDate : "",
|
|
648
|
+
end_date: !isNormalProduct ? (item === null || item === void 0 || (_item$_extend13 = item._extend) === null || _item$_extend13 === void 0 ? void 0 : _item$_extend13.endDate) || (item === null || item === void 0 || (_item$_extend14 = item._extend) === null || _item$_extend14 === void 0 ? void 0 : _item$_extend14.end_date) : "",
|
|
649
|
+
rowKey: genRowKey(item === null || item === void 0 || (_item$_extend15 = item._extend) === null || _item$_extend15 === void 0 || (_item$_extend15 = _item$_extend15.other) === null || _item$_extend15 === void 0 ? void 0 : _item$_extend15.rowKey)
|
|
646
650
|
}, parallelResourceOtherParams);
|
|
647
651
|
};
|
|
648
652
|
var calcAddTimeTotalPrice = function calcAddTimeTotalPrice(total, addTimeProducts) {
|
|
@@ -663,18 +667,18 @@ export var formatProducts = function formatProducts(lists, state) {
|
|
|
663
667
|
var isParallelResource = arguments.length > 4 ? arguments[4] : undefined;
|
|
664
668
|
if (!(lists !== null && lists !== void 0 && lists.length)) return [];
|
|
665
669
|
var formItem = function formItem(item) {
|
|
666
|
-
var _item$
|
|
670
|
+
var _item$_extend16, _item$_extend17, _item$_extend18, _item$_extend20, _item$_extend21, _item$_extend22, _item$_extend23, _item$_extend24, _item$_extend25, _item$_extend26, _item$_extend27, _item$_extend28, _item$_extend29, _resourceItem, _item$_extend30, _item$_extend31, _item$_extend32, _item$_extend33, _item$_extend34;
|
|
667
671
|
var _isDayBookingProduct = isDayBookingProduct(item, state);
|
|
668
|
-
var clientTitle = getHolderName(state, item === null || item === void 0 || (_item$
|
|
669
|
-
var options = formatOptions(item === null || item === void 0 || (_item$
|
|
670
|
-
var bundle = formatBundle(item === null || item === void 0 || (_item$
|
|
672
|
+
var clientTitle = getHolderName(state, item === null || item === void 0 || (_item$_extend16 = item._extend) === null || _item$_extend16 === void 0 ? void 0 : _item$_extend16.holder_id);
|
|
673
|
+
var options = formatOptions(item === null || item === void 0 || (_item$_extend17 = item._extend) === null || _item$_extend17 === void 0 || (_item$_extend17 = _item$_extend17.other) === null || _item$_extend17 === void 0 ? void 0 : _item$_extend17.option);
|
|
674
|
+
var bundle = formatBundle(item === null || item === void 0 || (_item$_extend18 = item._extend) === null || _item$_extend18 === void 0 || (_item$_extend18 = _item$_extend18.other) === null || _item$_extend18 === void 0 ? void 0 : _item$_extend18.bundle);
|
|
671
675
|
// 是否是普通商品
|
|
672
676
|
var isNormalProduct = !appointmentTypes.includes(item === null || item === void 0 ? void 0 : item.extension_type) || (state === null || state === void 0 ? void 0 : state.renderType) === 'eventBooking';
|
|
673
677
|
var resourceItem = {};
|
|
674
678
|
var errorMessage = '';
|
|
675
679
|
if (_isDayBookingProduct || isGeneral) {
|
|
676
|
-
var _item$
|
|
677
|
-
resourceItem = getResourceItem(item === null || item === void 0 || (_item$
|
|
680
|
+
var _item$_extend19;
|
|
681
|
+
resourceItem = getResourceItem(item === null || item === void 0 || (_item$_extend19 = item._extend) === null || _item$_extend19 === void 0 ? void 0 : _item$_extend19.resource, state);
|
|
678
682
|
errorMessage = getErrorMessage(item, resourceItem, isDayBooking(state));
|
|
679
683
|
}
|
|
680
684
|
var generalParams = isGeneral ? getGeneralParams(item, state, !!isParallelResource) : {};
|
|
@@ -684,26 +688,26 @@ export var formatProducts = function formatProducts(lists, state) {
|
|
|
684
688
|
name: item === null || item === void 0 ? void 0 : item.title,
|
|
685
689
|
title: item === null || item === void 0 ? void 0 : item.title,
|
|
686
690
|
// 购物车显示需要 title 字段
|
|
687
|
-
price: item === null || item === void 0 || (_item$
|
|
691
|
+
price: item === null || item === void 0 || (_item$_extend20 = item._extend) === null || _item$_extend20 === void 0 ? void 0 : _item$_extend20.price,
|
|
688
692
|
totalDifference: getProductDiscountProductDiscountDifference(item),
|
|
689
|
-
total: calcAddTimeTotalPrice(item === null || item === void 0 || (_item$
|
|
690
|
-
origin_total: calcAddTimeTotalPrice(item === null || item === void 0 || (_item$
|
|
693
|
+
total: calcAddTimeTotalPrice(item === null || item === void 0 || (_item$_extend21 = item._extend) === null || _item$_extend21 === void 0 ? void 0 : _item$_extend21.total, item === null || item === void 0 || (_item$_extend22 = item._extend) === null || _item$_extend22 === void 0 ? void 0 : _item$_extend22.relation_details),
|
|
694
|
+
origin_total: calcAddTimeTotalPrice(item === null || item === void 0 || (_item$_extend23 = item._extend) === null || _item$_extend23 === void 0 ? void 0 : _item$_extend23.origin_total, item === null || item === void 0 || (_item$_extend24 = item._extend) === null || _item$_extend24 === void 0 ? void 0 : _item$_extend24.relation_details),
|
|
691
695
|
num: item === null || item === void 0 ? void 0 : item._extend.quantity,
|
|
692
696
|
image: item === null || item === void 0 ? void 0 : item.cover,
|
|
693
697
|
isShowNote: true,
|
|
694
|
-
note: (item === null || item === void 0 ? void 0 : item.note) || (item === null || item === void 0 || (_item$
|
|
695
|
-
like_status: item === null || item === void 0 || (_item$
|
|
698
|
+
note: (item === null || item === void 0 ? void 0 : item.note) || (item === null || item === void 0 || (_item$_extend25 = item._extend) === null || _item$_extend25 === void 0 ? void 0 : _item$_extend25.note),
|
|
699
|
+
like_status: item === null || item === void 0 || (_item$_extend26 = item._extend) === null || _item$_extend26 === void 0 ? void 0 : _item$_extend26.like_status,
|
|
696
700
|
bundle: bundle,
|
|
697
701
|
options: options,
|
|
698
702
|
errorMessage: errorMessage,
|
|
699
|
-
product_option_string: item === null || item === void 0 || (_item$
|
|
700
|
-
discount_reason: item === null || item === void 0 || (_item$
|
|
701
|
-
resource_id: isNormalProduct ? 0 : item === null || item === void 0 || (_item$
|
|
703
|
+
product_option_string: item === null || item === void 0 || (_item$_extend27 = item._extend) === null || _item$_extend27 === void 0 || (_item$_extend27 = _item$_extend27.other) === null || _item$_extend27 === void 0 ? void 0 : _item$_extend27.product_option_string,
|
|
704
|
+
discount_reason: item === null || item === void 0 || (_item$_extend28 = item._extend) === null || _item$_extend28 === void 0 ? void 0 : _item$_extend28.discount_reason,
|
|
705
|
+
resource_id: isNormalProduct ? 0 : item === null || item === void 0 || (_item$_extend29 = item._extend) === null || _item$_extend29 === void 0 ? void 0 : _item$_extend29.resource,
|
|
702
706
|
relation_form_name: isNormalProduct ? '' : ((_resourceItem = resourceItem) === null || _resourceItem === void 0 ? void 0 : _resourceItem.labelText) || item.relation_form_name,
|
|
703
707
|
holder_title: clientTitle,
|
|
704
|
-
start_date: !isNormalProduct ? item === null || item === void 0 || (_item$
|
|
705
|
-
end_date: !isNormalProduct ? item === null || item === void 0 || (_item$
|
|
706
|
-
holder_id: (item === null || item === void 0 || (_item$
|
|
708
|
+
start_date: !isNormalProduct ? item === null || item === void 0 || (_item$_extend30 = item._extend) === null || _item$_extend30 === void 0 ? void 0 : _item$_extend30.start_date : '',
|
|
709
|
+
end_date: !isNormalProduct ? item === null || item === void 0 || (_item$_extend31 = item._extend) === null || _item$_extend31 === void 0 ? void 0 : _item$_extend31.end_date : '',
|
|
710
|
+
holder_id: (item === null || item === void 0 || (_item$_extend32 = item._extend) === null || _item$_extend32 === void 0 ? void 0 : _item$_extend32.holder_id) || 0,
|
|
707
711
|
isNormalProduct: isNormalProduct,
|
|
708
712
|
isCustomItem: item === null || item === void 0 ? void 0 : item.isCustomItem,
|
|
709
713
|
// 添加自定义商品标识
|
|
@@ -711,8 +715,8 @@ export var formatProducts = function formatProducts(lists, state) {
|
|
|
711
715
|
// 是否适用优惠券/折扣
|
|
712
716
|
locale: state.locale,
|
|
713
717
|
symbol: state.amountSymbol,
|
|
714
|
-
relation_products: (item === null || item === void 0 || (_item$
|
|
715
|
-
items: isEventBooking(state) ? [] : formItems((item === null || item === void 0 || (_item$
|
|
718
|
+
relation_products: (item === null || item === void 0 || (_item$_extend33 = item._extend) === null || _item$_extend33 === void 0 ? void 0 : _item$_extend33.relation_details) || [],
|
|
719
|
+
items: isEventBooking(state) ? [] : formItems((item === null || item === void 0 || (_item$_extend34 = item._extend) === null || _item$_extend34 === void 0 ? void 0 : _item$_extend34.items) || [])
|
|
716
720
|
}, generalParams), {}, {
|
|
717
721
|
_origin: item
|
|
718
722
|
});
|
|
@@ -726,15 +730,15 @@ export var formatProducts = function formatProducts(lists, state) {
|
|
|
726
730
|
|
|
727
731
|
// 将商品分为组商品和非组商品,并记录索引
|
|
728
732
|
lists.forEach(function (item, index) {
|
|
729
|
-
var _item$
|
|
730
|
-
if (!(item !== null && item !== void 0 && (_item$
|
|
733
|
+
var _item$_extend35;
|
|
734
|
+
if (!(item !== null && item !== void 0 && (_item$_extend35 = item._extend) !== null && _item$_extend35 !== void 0 && _item$_extend35.groupId)) {
|
|
731
735
|
normalItemsWithIndex.push({
|
|
732
736
|
item: item,
|
|
733
737
|
index: index
|
|
734
738
|
});
|
|
735
739
|
} else {
|
|
736
|
-
var _item$
|
|
737
|
-
var groupId = item === null || item === void 0 || (_item$
|
|
740
|
+
var _item$_extend36;
|
|
741
|
+
var groupId = item === null || item === void 0 || (_item$_extend36 = item._extend) === null || _item$_extend36 === void 0 ? void 0 : _item$_extend36.groupId;
|
|
738
742
|
groupItemsWithIndex.push({
|
|
739
743
|
item: item,
|
|
740
744
|
index: index
|
|
@@ -748,9 +752,9 @@ export var formatProducts = function formatProducts(lists, state) {
|
|
|
748
752
|
|
|
749
753
|
// 根据item._extend.groupId 进行分组
|
|
750
754
|
var groups = groupItemsWithIndex.reduce(function (prev, _ref11) {
|
|
751
|
-
var _item$
|
|
755
|
+
var _item$_extend37;
|
|
752
756
|
var item = _ref11.item;
|
|
753
|
-
var groupId = item === null || item === void 0 || (_item$
|
|
757
|
+
var groupId = item === null || item === void 0 || (_item$_extend37 = item._extend) === null || _item$_extend37 === void 0 ? void 0 : _item$_extend37.groupId;
|
|
754
758
|
if (!prev[groupId]) {
|
|
755
759
|
prev[groupId] = [];
|
|
756
760
|
}
|
|
@@ -947,8 +951,8 @@ export var isHasDayAppointmentProduct = function isHasDayAppointmentProduct(stat
|
|
|
947
951
|
// 如果该购物车中没选择任何商品,则不需要验证,所以直接用1来填充
|
|
948
952
|
// services: !holderProducts?.length ? [1] : holderProducts?.filter((d: any) => appointmentTypes.includes(d.extension_type))
|
|
949
953
|
services: services.filter(function (item) {
|
|
950
|
-
var _item$
|
|
951
|
-
return ((_item$
|
|
954
|
+
var _item$_extend38;
|
|
955
|
+
return ((_item$_extend38 = item._extend) === null || _item$_extend38 === void 0 ? void 0 : _item$_extend38.holder_id) == d.form_record_id && checkType(item.extension_type);
|
|
952
956
|
})
|
|
953
957
|
});
|
|
954
958
|
});
|
|
@@ -413,8 +413,10 @@ export var rulesHooks = {
|
|
|
413
413
|
_id: values._id || product._id,
|
|
414
414
|
discount_list: values.discount_list,
|
|
415
415
|
_extend: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, product._extend), {}, {
|
|
416
|
-
other: _objectSpread(_objectSpread({}, product._extend.other), 'bundle' in values ? {
|
|
416
|
+
other: _objectSpread(_objectSpread(_objectSpread({}, product._extend.other), 'bundle' in values ? {
|
|
417
417
|
bundle: values.bundle
|
|
418
|
+
} : {}), Array.isArray(values.options) ? {
|
|
419
|
+
option: values.options
|
|
418
420
|
} : {})
|
|
419
421
|
}, 'total' in values ? {
|
|
420
422
|
total: values.total
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const getRelationDetailsTotal: (relation_details: any) => number;
|
|
2
2
|
export declare const getProductDiscountProductDiscountDifference: (product: any) => any;
|
|
3
|
+
export declare const getOptionDiscountAmount: (discounts: any[]) => number;
|
|
3
4
|
export declare const getIsPriceIncludeTax: (state: any) => any;
|
|
4
5
|
/**
|
|
5
6
|
* 总金额
|
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var amount_exports = {};
|
|
31
31
|
__export(amount_exports, {
|
|
32
32
|
getIsPriceIncludeTax: () => getIsPriceIncludeTax,
|
|
33
|
+
getOptionDiscountAmount: () => getOptionDiscountAmount,
|
|
33
34
|
getProductDiscountProductDiscountDifference: () => getProductDiscountProductDiscountDifference,
|
|
34
35
|
getRelationDetailsTotal: () => getRelationDetailsTotal,
|
|
35
36
|
getSumTotal: () => getSumTotal
|
|
@@ -486,6 +487,12 @@ var getDiscountAmount = (discounts) => {
|
|
|
486
487
|
return total.add(new import_decimal.default(discount.amount || 0));
|
|
487
488
|
}, new import_decimal.default(0)).toNumber();
|
|
488
489
|
};
|
|
490
|
+
var getOptionDiscountAmount = (discounts) => {
|
|
491
|
+
return (discounts || []).reduce((total, discount) => {
|
|
492
|
+
var _a;
|
|
493
|
+
return total.add(new import_decimal.default(((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.optionDiscountAmount) || 0));
|
|
494
|
+
}, new import_decimal.default(0)).toNumber();
|
|
495
|
+
};
|
|
489
496
|
var getMainProductTotal = (item) => {
|
|
490
497
|
var _a, _b, _c, _d, _e, _f;
|
|
491
498
|
let total = new import_decimal.default(((_a = item._extend) == null ? void 0 : _a.main_product_selling_price) ?? ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.main_product_selling_price) ?? item._extend.price ?? 0);
|
|
@@ -493,6 +500,9 @@ var getMainProductTotal = (item) => {
|
|
|
493
500
|
total = total.add((_e = item._extend.other) == null ? void 0 : _e.option.reduce((t, option) => {
|
|
494
501
|
return t.add(new import_decimal.default(option.price || 0).mul(option.num || 1));
|
|
495
502
|
}, new import_decimal.default(0)));
|
|
503
|
+
if (item.booking_id) {
|
|
504
|
+
total = total.sub(getOptionDiscountAmount((item == null ? void 0 : item.discount_list) || []));
|
|
505
|
+
}
|
|
496
506
|
}
|
|
497
507
|
for (let bundleItem of ((_f = item._extend.other) == null ? void 0 : _f.bundle) || []) {
|
|
498
508
|
if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
|
|
@@ -922,6 +932,7 @@ var getSumTotal = (state, options) => {
|
|
|
922
932
|
// Annotate the CommonJS export names for ESM import in node:
|
|
923
933
|
0 && (module.exports = {
|
|
924
934
|
getIsPriceIncludeTax,
|
|
935
|
+
getOptionDiscountAmount,
|
|
925
936
|
getProductDiscountProductDiscountDifference,
|
|
926
937
|
getRelationDetailsTotal,
|
|
927
938
|
getSumTotal
|
|
@@ -56,6 +56,7 @@ var import_materials = require("@pisell/materials");
|
|
|
56
56
|
var import_utils6 = require("../../../../plus/clientName/utils");
|
|
57
57
|
var import_lodash = require("lodash");
|
|
58
58
|
var import_decimal = __toESM(require("decimal.js"));
|
|
59
|
+
var import_amount = require("./amount");
|
|
59
60
|
var formatNote = (data) => {
|
|
60
61
|
var _a;
|
|
61
62
|
return ((_a = data.notes) == null ? void 0 : _a.orderNote) || "";
|
|
@@ -363,6 +364,9 @@ var getMainProductSellingPrice = (item) => {
|
|
|
363
364
|
const currentNum = new import_decimal.default(currentValue.num || 0);
|
|
364
365
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
365
366
|
}, optionPrice);
|
|
367
|
+
if (item == null ? void 0 : item.booking_id) {
|
|
368
|
+
optionPrice = optionPrice.sub((0, import_amount.getOptionDiscountAmount)((item == null ? void 0 : item.discount_list) || []));
|
|
369
|
+
}
|
|
366
370
|
}
|
|
367
371
|
return new import_decimal.default((_f = item._extend) == null ? void 0 : _f.main_product_selling_price).add(optionPrice).toNumber();
|
|
368
372
|
};
|
|
@@ -190,16 +190,17 @@ var handleChangeHolder = (products, currentItem, other) => {
|
|
|
190
190
|
};
|
|
191
191
|
var handleLike = (products, currentItem, other) => {
|
|
192
192
|
return products.map((item) => {
|
|
193
|
-
var _a, _b;
|
|
193
|
+
var _a, _b, _c, _d;
|
|
194
|
+
const isSameGroup = ((_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.groupId) && ((_b = item._extend) == null ? void 0 : _b.groupId) === (currentItem == null ? void 0 : currentItem.serviceId);
|
|
194
195
|
if (currentItem.isParallelResource) {
|
|
195
|
-
if (item._id === currentItem.serviceId) {
|
|
196
|
+
if (item._id === currentItem.serviceId || isSameGroup) {
|
|
196
197
|
return {
|
|
197
198
|
...item,
|
|
198
199
|
_extend: {
|
|
199
200
|
...item._extend,
|
|
200
201
|
resource: {
|
|
201
|
-
...(
|
|
202
|
-
[currentItem.resourceId]: (
|
|
202
|
+
...(_c = item._extend) == null ? void 0 : _c.resource,
|
|
203
|
+
[currentItem.resourceId]: (_d = item._extend) == null ? void 0 : _d.resource[currentItem.resourceId].map((item2) => ({
|
|
203
204
|
...item2,
|
|
204
205
|
like_status: other.like_status
|
|
205
206
|
}))
|
|
@@ -209,7 +210,7 @@ var handleLike = (products, currentItem, other) => {
|
|
|
209
210
|
}
|
|
210
211
|
return item;
|
|
211
212
|
} else {
|
|
212
|
-
if (item._id === currentItem._id) {
|
|
213
|
+
if (item._id === currentItem._id || isSameGroup) {
|
|
213
214
|
return {
|
|
214
215
|
...item,
|
|
215
216
|
_extend: {
|
|
@@ -224,11 +225,12 @@ var handleLike = (products, currentItem, other) => {
|
|
|
224
225
|
};
|
|
225
226
|
var handleChangeResource = (products, currentItem, other, state) => {
|
|
226
227
|
return products.map((item) => {
|
|
227
|
-
var _a;
|
|
228
|
+
var _a, _b, _c, _d, _e;
|
|
228
229
|
const { props, value } = other || {};
|
|
229
230
|
const { isParallelResource, resourceId } = props || {};
|
|
231
|
+
const isSameGroup = ((_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.groupId) && ((_b = item._extend) == null ? void 0 : _b.groupId) === ((_d = (_c = currentItem == null ? void 0 : currentItem._origin) == null ? void 0 : _c._extend) == null ? void 0 : _d.groupId);
|
|
230
232
|
if (isParallelResource) {
|
|
231
|
-
if (item._id === currentItem._id) {
|
|
233
|
+
if (item._id === currentItem._id || isSameGroup) {
|
|
232
234
|
const hasDataItem = (0, import_utils6.getProductExtend)({
|
|
233
235
|
cacheItem: { ...item, new: 0 },
|
|
234
236
|
state
|
|
@@ -238,21 +240,21 @@ var handleChangeResource = (products, currentItem, other, state) => {
|
|
|
238
240
|
return pre;
|
|
239
241
|
}, {}) : {};
|
|
240
242
|
item._extend.resource[resourceId] = value.map((d) => {
|
|
241
|
-
var _a2,
|
|
243
|
+
var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i;
|
|
242
244
|
const currentForm = ((_a2 = hasDataItem._data.resourceMaps) == null ? void 0 : _a2[resourceId]) || {};
|
|
243
245
|
return (
|
|
244
246
|
// maps[d] 为真时, 说明是之前已选择, 否则为新增的值,补充数据
|
|
245
247
|
maps[d] || {
|
|
246
|
-
relation_type: ((
|
|
248
|
+
relation_type: ((_c2 = (_b2 = currentForm.renderListMaps[d]) == null ? void 0 : _b2.usable) == null ? void 0 : _c2.relation_type) || "form",
|
|
247
249
|
form_id: resourceId,
|
|
248
250
|
relation_id: d,
|
|
249
251
|
like_status: "common",
|
|
250
252
|
// 新添加的数据补充错误信息
|
|
251
253
|
errors: (0, import_utilsByBooking.getErrorList)(
|
|
252
|
-
(
|
|
254
|
+
(_d2 = currentForm.renderListMaps) == null ? void 0 : _d2[d],
|
|
253
255
|
hasDataItem
|
|
254
256
|
),
|
|
255
|
-
children: (_f = (
|
|
257
|
+
children: (_f = (_e2 = currentForm.renderListMaps) == null ? void 0 : _e2[d]) == null ? void 0 : _f.children,
|
|
256
258
|
metadata: {
|
|
257
259
|
...(_h = (_g = currentForm.renderListMaps) == null ? void 0 : _g[d]) == null ? void 0 : _h.metadata,
|
|
258
260
|
form_name: currentForm.title,
|
|
@@ -264,9 +266,9 @@ var handleChangeResource = (products, currentItem, other, state) => {
|
|
|
264
266
|
}
|
|
265
267
|
return item;
|
|
266
268
|
} else {
|
|
267
|
-
if (item._id === currentItem._id) {
|
|
269
|
+
if (item._id === currentItem._id || isSameGroup) {
|
|
268
270
|
const resourceItem = currentResource(state, other.id, item);
|
|
269
|
-
const { relation_type, item_id, schedule_id } = ((
|
|
271
|
+
const { relation_type, item_id, schedule_id } = ((_e = resourceItem == null ? void 0 : resourceItem._extend) == null ? void 0 : _e.usableTime) || {};
|
|
270
272
|
return {
|
|
271
273
|
...item,
|
|
272
274
|
_extend: {
|
|
@@ -382,7 +382,9 @@ var rulesHooks = {
|
|
|
382
382
|
...product._extend,
|
|
383
383
|
other: {
|
|
384
384
|
...product._extend.other,
|
|
385
|
-
..."bundle" in values ? { bundle: values.bundle } : {}
|
|
385
|
+
..."bundle" in values ? { bundle: values.bundle } : {},
|
|
386
|
+
// 仅在有有效数组时写入,避免 `options: undefined` 清空 other.option
|
|
387
|
+
...Array.isArray(values.options) ? { option: values.options } : {}
|
|
386
388
|
},
|
|
387
389
|
..."total" in values ? { total: values.total } : {},
|
|
388
390
|
..."main_product_selling_price" in values ? { main_product_selling_price: values.main_product_selling_price } : {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/private-materials",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.53",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"@use-gesture/react": "^10.3.1",
|
|
64
64
|
"@pisell/utils": "3.0.2",
|
|
65
65
|
"@pisell/materials": "6.6.14",
|
|
66
|
-
"@pisell/
|
|
67
|
-
"@pisell/
|
|
66
|
+
"@pisell/date-picker": "3.0.7",
|
|
67
|
+
"@pisell/icon": "0.0.11"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"react": "^18.0.0",
|