@pisell/pisellos 1.0.120 → 1.0.122
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.
|
@@ -473,14 +473,18 @@ var processItemsTax = function processItemsTax(items, _ref2, options) {
|
|
|
473
473
|
* @returns 精确的税费值(Decimal类型)
|
|
474
474
|
*/
|
|
475
475
|
var getProductItemTax = function getProductItemTax(item, state, options) {
|
|
476
|
-
var _bookingDetail$tax_ra,
|
|
476
|
+
var _ref4, _item$quantity, _bookingDetail$tax_ra, _ref5, _bookingDetail$is_pri;
|
|
477
477
|
var bookingDetail = state.bookingDetail;
|
|
478
478
|
var tax_rate = options.tax_rate,
|
|
479
479
|
is_price_include_tax = options.is_price_include_tax;
|
|
480
480
|
|
|
481
481
|
// 折扣后的金额 = 商品金额 - 商品折扣
|
|
482
482
|
var productDiscountPrice = new Decimal(item.total || 0);
|
|
483
|
-
|
|
483
|
+
/**
|
|
484
|
+
* 注意:该函数被多处以“单件税费”方式调用(调用方会显式传入 quantity: 1),
|
|
485
|
+
* 因此这里必须优先使用 `item.quantity`,否则会出现数量被重复相乘(外层再乘一次 num)的情况。
|
|
486
|
+
*/
|
|
487
|
+
var quantity = new Decimal((_ref4 = (_item$quantity = item.quantity) !== null && _item$quantity !== void 0 ? _item$quantity : item.num) !== null && _ref4 !== void 0 ? _ref4 : 1);
|
|
484
488
|
|
|
485
489
|
// 如果商品金额小于或等于0,不计算税费
|
|
486
490
|
if (productDiscountPrice.lte(0)) {
|
|
@@ -490,7 +494,7 @@ var getProductItemTax = function getProductItemTax(item, state, options) {
|
|
|
490
494
|
// 优先从 bookingDetail 取税率和是否含税设置,取不到则从 options 中取(兼容新增模式)
|
|
491
495
|
// 注意:bookingDetail中的tax_rate不需要除以100,options 中的tax_rate需要除以100
|
|
492
496
|
var currentTaxRate = new Decimal((_bookingDetail$tax_ra = bookingDetail === null || bookingDetail === void 0 ? void 0 : bookingDetail.tax_rate) !== null && _bookingDetail$tax_ra !== void 0 ? _bookingDetail$tax_ra : tax_rate ? tax_rate / 100 : 0);
|
|
493
|
-
var currentIsPriceIncludeTax = (
|
|
497
|
+
var currentIsPriceIncludeTax = (_ref5 = (_bookingDetail$is_pri = bookingDetail === null || bookingDetail === void 0 ? void 0 : bookingDetail.is_price_include_tax) !== null && _bookingDetail$is_pri !== void 0 ? _bookingDetail$is_pri : is_price_include_tax) !== null && _ref5 !== void 0 ? _ref5 : 0;
|
|
494
498
|
var singleItemTax = new Decimal(0);
|
|
495
499
|
|
|
496
500
|
// 计算单个商品税费, 一次性商品 is_charge_tax 可能为空
|
|
@@ -566,9 +570,9 @@ export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
|
|
|
566
570
|
if (!(items !== null && items !== void 0 && items.length)) {
|
|
567
571
|
return '0.00';
|
|
568
572
|
}
|
|
569
|
-
var
|
|
570
|
-
is_price_include_tax =
|
|
571
|
-
tax_rate =
|
|
573
|
+
var _ref6 = shopInfo || {},
|
|
574
|
+
is_price_include_tax = _ref6.is_price_include_tax,
|
|
575
|
+
tax_rate = _ref6.tax_rate;
|
|
572
576
|
var totalTaxFee = items.reduce(function (sum, item) {
|
|
573
577
|
var cartItemTotalPrice = new Decimal(item.summaryTotal || 0);
|
|
574
578
|
var taxRate = new Decimal(tax_rate || 0).div(100);
|
|
@@ -630,9 +634,9 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
630
634
|
* @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
|
|
631
635
|
* @returns 订单附加费金额(number,金额单位与商品价格一致)
|
|
632
636
|
*/
|
|
633
|
-
export var getSurchargeAmount = function getSurchargeAmount(
|
|
634
|
-
var bookingDetail =
|
|
635
|
-
bookingId =
|
|
637
|
+
export var getSurchargeAmount = function getSurchargeAmount(_ref7, surcharge, options) {
|
|
638
|
+
var bookingDetail = _ref7.bookingDetail,
|
|
639
|
+
bookingId = _ref7.bookingId;
|
|
636
640
|
var isEdit = options.isEdit;
|
|
637
641
|
// 订单未变更过
|
|
638
642
|
if (!isEdit) {
|
|
@@ -677,9 +681,9 @@ var getDiscountAmount = function getDiscountAmount(discounts) {
|
|
|
677
681
|
* 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
|
|
678
682
|
*/
|
|
679
683
|
var getMainProductTotal = function getMainProductTotal(item) {
|
|
680
|
-
var
|
|
681
|
-
var total = new Decimal((
|
|
682
|
-
var discount = (item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData
|
|
684
|
+
var _ref8, _ref9, _item$main_product_se, _item$metadata, _item$_origin3, _item$_originData;
|
|
685
|
+
var total = new Decimal((_ref8 = (_ref9 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref9 !== void 0 ? _ref9 : item.price) !== null && _ref8 !== void 0 ? _ref8 : 0);
|
|
686
|
+
var discount = (item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData = item._originData) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.product) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.discount_list) === null || _item$_originData === void 0 ? void 0 : _item$_originData.filter(function (item) {
|
|
683
687
|
var _item$metadata2;
|
|
684
688
|
return !(item !== null && item !== void 0 && (_item$metadata2 = item.metadata) !== null && _item$metadata2 !== void 0 && _item$metadata2.custom_product_bundle_map_id);
|
|
685
689
|
})) || [];
|
|
@@ -698,11 +702,11 @@ var getMainProductTotal = function getMainProductTotal(item) {
|
|
|
698
702
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
699
703
|
var bundleItem = _step4.value;
|
|
700
704
|
if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
|
|
701
|
-
var
|
|
705
|
+
var _ref10, _bundleItem$bundle_se2;
|
|
702
706
|
// 子商品折扣金额
|
|
703
707
|
var discountAmount = getDiscountAmount(bundleItem.discount_list);
|
|
704
708
|
// 子商品价格
|
|
705
|
-
var bundleItemPrice = new Decimal((
|
|
709
|
+
var bundleItemPrice = new Decimal((_ref10 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref10 !== void 0 ? _ref10 : 0);
|
|
706
710
|
// todo: 套餐子商品后不需要处理 子商品价格 - 子商品折扣金额
|
|
707
711
|
var bundleItemTotal = bundleItemPrice.minus(discountAmount);
|
|
708
712
|
total = total.add(bundleItemTotal);
|
|
@@ -825,11 +829,11 @@ var isProductMatchSurchargeCondition = function isProductMatchSurchargeCondition
|
|
|
825
829
|
* @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
|
|
826
830
|
* @returns 附加费列表(仅返回金额 > 0 的项)
|
|
827
831
|
*/
|
|
828
|
-
export var getSurcharge = function getSurcharge(
|
|
829
|
-
var service =
|
|
830
|
-
addons =
|
|
831
|
-
bookingDetail =
|
|
832
|
-
bookingId =
|
|
832
|
+
export var getSurcharge = function getSurcharge(_ref11, options) {
|
|
833
|
+
var service = _ref11.service,
|
|
834
|
+
addons = _ref11.addons,
|
|
835
|
+
bookingDetail = _ref11.bookingDetail,
|
|
836
|
+
bookingId = _ref11.bookingId;
|
|
833
837
|
var isEdit = options.isEdit,
|
|
834
838
|
isInScheduleByDate = options.isInScheduleByDate,
|
|
835
839
|
surcharge_list = options.surcharge_list,
|
|
@@ -941,11 +945,11 @@ export var getSurcharge = function getSurcharge(_ref10, options) {
|
|
|
941
945
|
scheduleById: scheduleById || {},
|
|
942
946
|
isInScheduleByDate: isInScheduleByDate
|
|
943
947
|
})) {
|
|
944
|
-
var
|
|
948
|
+
var _ref12, _bundleItem$bundle_se3;
|
|
945
949
|
var _mainQuantity = item.num || 1;
|
|
946
950
|
matchedItems.push({
|
|
947
951
|
isMain: false,
|
|
948
|
-
total: Number((
|
|
952
|
+
total: Number((_ref12 = (_bundleItem$bundle_se3 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se3 !== void 0 ? _bundleItem$bundle_se3 : bundleItem.price) !== null && _ref12 !== void 0 ? _ref12 : 0),
|
|
949
953
|
quantity: bundleItem.num || bundleItem.quantity || 1,
|
|
950
954
|
item: bundleItem,
|
|
951
955
|
mainQuantity: _mainQuantity // 子商品的mainQuantity是所属主商品的quantity
|
|
@@ -1159,9 +1163,9 @@ export var getSurcharge = function getSurcharge(_ref10, options) {
|
|
|
1159
1163
|
}
|
|
1160
1164
|
return surchargeWithAmount;
|
|
1161
1165
|
};
|
|
1162
|
-
function resetItemsSurchargeSideEffects(
|
|
1163
|
-
var service =
|
|
1164
|
-
addons =
|
|
1166
|
+
function resetItemsSurchargeSideEffects(_ref13) {
|
|
1167
|
+
var service = _ref13.service,
|
|
1168
|
+
addons = _ref13.addons;
|
|
1165
1169
|
var resetItem = function resetItem(item) {
|
|
1166
1170
|
if (!item) return;
|
|
1167
1171
|
item.surcharge_fee = 0;
|
|
@@ -293,7 +293,7 @@ var getProductItemTax = (item, state, options) => {
|
|
|
293
293
|
const { bookingDetail } = state;
|
|
294
294
|
const { tax_rate, is_price_include_tax } = options;
|
|
295
295
|
const productDiscountPrice = new import_decimal.default(item.total || 0);
|
|
296
|
-
const quantity = new import_decimal.default(item.num
|
|
296
|
+
const quantity = new import_decimal.default(item.quantity ?? item.num ?? 1);
|
|
297
297
|
if (productDiscountPrice.lte(0)) {
|
|
298
298
|
return new import_decimal.default(0);
|
|
299
299
|
}
|
|
@@ -408,9 +408,9 @@ var getDiscountAmount = (discounts) => {
|
|
|
408
408
|
}, new import_decimal.default(0)).toNumber();
|
|
409
409
|
};
|
|
410
410
|
var getMainProductTotal = (item) => {
|
|
411
|
-
var _a, _b, _c, _d, _e;
|
|
411
|
+
var _a, _b, _c, _d, _e, _f;
|
|
412
412
|
let total = new import_decimal.default((item == null ? void 0 : item.main_product_selling_price) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.main_product_selling_price) ?? item.price ?? 0);
|
|
413
|
-
const discount = ((_c = (_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.discount_list) || ((_e = (_d = item == null ? void 0 : item._originData.product) == null ? void 0 :
|
|
413
|
+
const discount = ((_c = (_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.discount_list) || ((_f = (_e = (_d = item == null ? void 0 : item._originData) == null ? void 0 : _d.product) == null ? void 0 : _e.discount_list) == null ? void 0 : _f.filter((item2) => {
|
|
414
414
|
var _a2;
|
|
415
415
|
return !((_a2 = item2 == null ? void 0 : item2.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id);
|
|
416
416
|
})) || [];
|