@pisell/pisellos 0.10.37 → 0.10.39
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.
|
@@ -535,7 +535,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
535
535
|
generateIdempotencyToken(): string;
|
|
536
536
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
537
537
|
createOrder(params: CommitOrderParams['query']): {
|
|
538
|
-
type: "
|
|
538
|
+
type: "appointment_booking" | "virtual";
|
|
539
539
|
platform: string;
|
|
540
540
|
sales_channel: string;
|
|
541
541
|
order_sales_channel: string;
|
|
@@ -41,6 +41,7 @@ var LABELS = {
|
|
|
41
41
|
giftCard: 'Gift card',
|
|
42
42
|
pointCard: 'Point card',
|
|
43
43
|
balance: 'Balance',
|
|
44
|
+
validity: 'Validity',
|
|
44
45
|
remainingAmount: 'Remaining amount',
|
|
45
46
|
redeemPoints: 'Redeem points',
|
|
46
47
|
remainingPoints: 'Points balance',
|
|
@@ -79,6 +80,7 @@ var LABELS = {
|
|
|
79
80
|
giftCard: '礼品卡',
|
|
80
81
|
pointCard: '积分卡',
|
|
81
82
|
balance: '余额',
|
|
83
|
+
validity: '有效期',
|
|
82
84
|
remainingAmount: '剩余金额',
|
|
83
85
|
redeemPoints: '本次使用积分',
|
|
84
86
|
remainingPoints: '积分余额',
|
|
@@ -117,6 +119,7 @@ var LABELS = {
|
|
|
117
119
|
giftCard: '禮品卡',
|
|
118
120
|
pointCard: '積分卡',
|
|
119
121
|
balance: '餘額',
|
|
122
|
+
validity: '有效期',
|
|
120
123
|
remainingAmount: '剩餘金額',
|
|
121
124
|
redeemPoints: '本次使用積分',
|
|
122
125
|
remainingPoints: '積分餘額',
|
|
@@ -153,6 +156,7 @@ var LABELS = {
|
|
|
153
156
|
giftCard: 'ギフトカード',
|
|
154
157
|
pointCard: 'ポイントカード',
|
|
155
158
|
balance: '残高',
|
|
159
|
+
validity: '有効期限',
|
|
156
160
|
remainingAmount: '残高',
|
|
157
161
|
redeemPoints: '利用ポイント',
|
|
158
162
|
remainingPoints: 'ポイント残高',
|
|
@@ -190,6 +194,7 @@ var LABELS = {
|
|
|
190
194
|
giftCard: 'Cartão-presente',
|
|
191
195
|
pointCard: 'Cartão de pontos',
|
|
192
196
|
balance: 'Saldo',
|
|
197
|
+
validity: 'Validade',
|
|
193
198
|
remainingAmount: 'Saldo restante',
|
|
194
199
|
redeemPoints: 'Pontos utilizados',
|
|
195
200
|
remainingPoints: 'Saldo de pontos',
|
|
@@ -671,7 +676,7 @@ function normalizeProductCombinations(params) {
|
|
|
671
676
|
parentProduct = params.parentProduct;
|
|
672
677
|
var bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
673
678
|
return bundles.map(function (bundle) {
|
|
674
|
-
var _ref26, _bundle$num
|
|
679
|
+
var _ref26, _bundle$num;
|
|
675
680
|
var combinationsOptions = normalizeProductOptions({
|
|
676
681
|
product: {},
|
|
677
682
|
locale: locale,
|
|
@@ -690,7 +695,7 @@ function normalizeProductCombinations(params) {
|
|
|
690
695
|
var quantity = toNumber((_ref26 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref26 !== void 0 ? _ref26 : 1, 1);
|
|
691
696
|
var formattedPrice = formatBundlePrice(bundle, currencySymbol);
|
|
692
697
|
var optionsTotal = sumNormalizedOptionTotals(combinationsOptions, currencySymbol);
|
|
693
|
-
var explicitBasePrice =
|
|
698
|
+
var explicitBasePrice = resolveCombinationBasePrice(bundle);
|
|
694
699
|
var basePrice = isPresentId(explicitBasePrice) ? explicitBasePrice : 0;
|
|
695
700
|
var extensionList = buildProductExtensionList({
|
|
696
701
|
product: bundle,
|
|
@@ -747,7 +752,7 @@ function normalizeExistingCombinations(combinations, locale, currencySymbol) {
|
|
|
747
752
|
var optionsAmount = sumMoneyValues(normalizedOptions.map(function (option) {
|
|
748
753
|
return option.total_price;
|
|
749
754
|
}));
|
|
750
|
-
var explicitBasePrice =
|
|
755
|
+
var explicitBasePrice = resolveCombinationBasePrice(combination, true);
|
|
751
756
|
var basePrice = isPresentId(explicitBasePrice) ? explicitBasePrice : 0;
|
|
752
757
|
var extensionList = buildProductExtensionList({
|
|
753
758
|
product: combination,
|
|
@@ -784,6 +789,12 @@ function sumMoneyValues(values) {
|
|
|
784
789
|
return sum.plus(toMoneyNumber(value));
|
|
785
790
|
}, new Decimal(0));
|
|
786
791
|
}
|
|
792
|
+
function resolveCombinationBasePrice(combination) {
|
|
793
|
+
var _combination$metadata;
|
|
794
|
+
var preferOriginalPrice = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
795
|
+
var fallbackPrices = preferOriginalPrice ? [combination.original_price, combination.product_price, combination.price] : [combination.price, combination.original_price, combination.product_price];
|
|
796
|
+
return firstPresentValue.apply(void 0, [combination.base_price, (_combination$metadata = combination.metadata) === null || _combination$metadata === void 0 ? void 0 : _combination$metadata.source_product_price].concat(fallbackPrices));
|
|
797
|
+
}
|
|
787
798
|
function sumNormalizedOptionTotals(options, currencySymbol) {
|
|
788
799
|
return formatCalculatedMoney(sumMoneyValues(options.map(function (option) {
|
|
789
800
|
return option.total_price;
|
|
@@ -1058,12 +1069,6 @@ function buildFees(params) {
|
|
|
1058
1069
|
});
|
|
1059
1070
|
var isPriceIncludeTax = firstPresentValue(summary.is_price_include_tax, order.is_price_include_tax, shopInfo.is_price_include_tax);
|
|
1060
1071
|
var roundingAmount = firstPresentValue(summary.rounding_amount, order.rounding_amount);
|
|
1061
|
-
if (isNonZero(roundingAmount)) {
|
|
1062
|
-
fees.push({
|
|
1063
|
-
item: label(locale, 'rounding'),
|
|
1064
|
-
value: formatMoney(roundingAmount, currencySymbol)
|
|
1065
|
-
});
|
|
1066
|
-
}
|
|
1067
1072
|
var payProcessingFee = financials.payProcessingFee;
|
|
1068
1073
|
if (isNonZero(payProcessingFee)) {
|
|
1069
1074
|
fees.push({
|
|
@@ -1539,18 +1544,34 @@ function getPointCardSnapshotRemainingPoints(snapshot) {
|
|
|
1539
1544
|
}
|
|
1540
1545
|
function buildVoucherAssets(params) {
|
|
1541
1546
|
var seenVoucherKeys = new Set();
|
|
1547
|
+
var fallbackAssetTime = firstPresentValue(params.order.updated_at, params.order.created_at);
|
|
1542
1548
|
return normalizeArray(params.order.vouchers).flatMap(function (voucher, index) {
|
|
1543
1549
|
if (!voucher || _typeof(voucher) !== 'object' || Array.isArray(voucher)) return [];
|
|
1544
1550
|
var voucherKey = getVoucherAssetKey(voucher, index);
|
|
1545
1551
|
if (seenVoucherKeys.has(voucherKey)) return [];
|
|
1546
1552
|
seenVoucherKeys.add(voucherKey);
|
|
1547
1553
|
var name = getVoucherAssetName(voucher, params.locale);
|
|
1554
|
+
var assetTime = firstPresentValue(voucher.updated_at, voucher.created_at, voucher.collection_time, fallbackAssetTime);
|
|
1555
|
+
var timeRow = isPresentId(assetTime) ? {
|
|
1556
|
+
item: formatDateTime(assetTime, params.locale),
|
|
1557
|
+
value: ''
|
|
1558
|
+
} : null;
|
|
1559
|
+
if (isTicketVoucher(voucher)) {
|
|
1560
|
+
var validity = getVoucherValidity(voucher, params.locale);
|
|
1561
|
+
return [[{
|
|
1562
|
+
item: name,
|
|
1563
|
+
value: ''
|
|
1564
|
+
}].concat(_toConsumableArray(validity ? [{
|
|
1565
|
+
item: label(params.locale, 'validity'),
|
|
1566
|
+
value: validity
|
|
1567
|
+
}] : []))];
|
|
1568
|
+
}
|
|
1548
1569
|
var percent = getVoucherDiscountPercent(voucher);
|
|
1549
1570
|
if (percent) {
|
|
1550
1571
|
return [[{
|
|
1551
1572
|
item: appendPercentToVoucherName(name, percent),
|
|
1552
1573
|
value: formatVoucherDiscount(percent, params.locale)
|
|
1553
|
-
}]];
|
|
1574
|
+
}].concat(_toConsumableArray(timeRow ? [timeRow] : []))];
|
|
1554
1575
|
}
|
|
1555
1576
|
var balance = getVoucherBalance(voucher);
|
|
1556
1577
|
return [[{
|
|
@@ -1559,9 +1580,87 @@ function buildVoucherAssets(params) {
|
|
|
1559
1580
|
}, {
|
|
1560
1581
|
item: label(params.locale, 'balance'),
|
|
1561
1582
|
value: formatMoney(balance, params.currencySymbol)
|
|
1562
|
-
}]];
|
|
1583
|
+
}].concat(_toConsumableArray(timeRow ? [timeRow] : []))];
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
function isTicketVoucher(voucher) {
|
|
1587
|
+
return stringify(voucher.tag).trim().toLowerCase() === 'ticket';
|
|
1588
|
+
}
|
|
1589
|
+
function getVoucherValidity(voucher, locale) {
|
|
1590
|
+
var _voucher$metadata, _voucher$metadata2, _voucher$metadata3, _voucher$metadata4, _voucher$metadata5, _voucher$metadata6, _voucher$metadata7, _voucher$metadata8, _voucher$metadata9, _voucher$metadata10, _voucher$start_time, _voucher$metadata11, _voucher$end_time, _voucher$metadata12;
|
|
1591
|
+
var availableTime = firstPresentValue(voucher.available_time, voucher.avaliable_time, (_voucher$metadata = voucher.metadata) === null || _voucher$metadata === void 0 ? void 0 : _voucher$metadata.available_time, (_voucher$metadata2 = voucher.metadata) === null || _voucher$metadata2 === void 0 ? void 0 : _voucher$metadata2.avaliable_time);
|
|
1592
|
+
var availableTimeText = formatVoucherAvailableTime(availableTime, locale);
|
|
1593
|
+
if (availableTimeText) return availableTimeText;
|
|
1594
|
+
var startDate = firstPresentValue(voucher.valid_from, voucher.start_at, voucher.start_date_time, voucher.start_date, (_voucher$metadata3 = voucher.metadata) === null || _voucher$metadata3 === void 0 ? void 0 : _voucher$metadata3.valid_from, (_voucher$metadata4 = voucher.metadata) === null || _voucher$metadata4 === void 0 ? void 0 : _voucher$metadata4.start_at, (_voucher$metadata5 = voucher.metadata) === null || _voucher$metadata5 === void 0 ? void 0 : _voucher$metadata5.start_date);
|
|
1595
|
+
var endDate = firstPresentValue(voucher.valid_to, voucher.end_at, voucher.end_date_time, voucher.expire_date, voucher.end_date, voucher.expire_time, (_voucher$metadata6 = voucher.metadata) === null || _voucher$metadata6 === void 0 ? void 0 : _voucher$metadata6.valid_to, (_voucher$metadata7 = voucher.metadata) === null || _voucher$metadata7 === void 0 ? void 0 : _voucher$metadata7.end_at, (_voucher$metadata8 = voucher.metadata) === null || _voucher$metadata8 === void 0 ? void 0 : _voucher$metadata8.expire_date, (_voucher$metadata9 = voucher.metadata) === null || _voucher$metadata9 === void 0 ? void 0 : _voucher$metadata9.end_date, (_voucher$metadata10 = voucher.metadata) === null || _voucher$metadata10 === void 0 ? void 0 : _voucher$metadata10.expire_time);
|
|
1596
|
+
return formatVoucherValidityRange(startDate, endDate, locale, {
|
|
1597
|
+
startTime: (_voucher$start_time = voucher.start_time) !== null && _voucher$start_time !== void 0 ? _voucher$start_time : (_voucher$metadata11 = voucher.metadata) === null || _voucher$metadata11 === void 0 ? void 0 : _voucher$metadata11.start_time,
|
|
1598
|
+
endTime: (_voucher$end_time = voucher.end_time) !== null && _voucher$end_time !== void 0 ? _voucher$end_time : (_voucher$metadata12 = voucher.metadata) === null || _voucher$metadata12 === void 0 ? void 0 : _voucher$metadata12.end_time
|
|
1563
1599
|
});
|
|
1564
1600
|
}
|
|
1601
|
+
function formatVoucherAvailableTime(value, locale) {
|
|
1602
|
+
if (!isPresentId(value)) return '';
|
|
1603
|
+
if (Array.isArray(value)) {
|
|
1604
|
+
return value.map(function (item) {
|
|
1605
|
+
return formatVoucherAvailableTime(item, locale);
|
|
1606
|
+
}).filter(Boolean).join(', ');
|
|
1607
|
+
}
|
|
1608
|
+
if (_typeof(value) !== 'object') return stringify(value).trim();
|
|
1609
|
+
var start = firstPresentValue(value.start, value.start_at, value.start_date_time, value.start_date);
|
|
1610
|
+
var end = firstPresentValue(value.end, value.end_at, value.end_date_time, value.expire_time, value.expire_date, value.end_date);
|
|
1611
|
+
if (isPresentId(start) || isPresentId(end)) {
|
|
1612
|
+
return formatVoucherValidityRange(start, end, locale, {
|
|
1613
|
+
startTime: value.start_time,
|
|
1614
|
+
endTime: value.end_time
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
return getLocalizedValue(value, locale).trim();
|
|
1618
|
+
}
|
|
1619
|
+
function formatVoucherValidityRange(startValue, endValue, locale) {
|
|
1620
|
+
var times = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1621
|
+
var start = combineVoucherDateAndTime(startValue, times.startTime);
|
|
1622
|
+
var end = combineVoucherDateAndTime(endValue, times.endTime);
|
|
1623
|
+
var startPart = formatVoucherValidityDate(start, locale);
|
|
1624
|
+
var endPart = formatVoucherValidityDate(end, locale);
|
|
1625
|
+
if (startPart.text && endPart.text) {
|
|
1626
|
+
var parsedStart = dayjs(start);
|
|
1627
|
+
var parsedEnd = dayjs(end);
|
|
1628
|
+
var sameDay = parsedStart.isValid() && parsedEnd.isValid() && parsedStart.isSame(parsedEnd, 'day');
|
|
1629
|
+
if (sameDay && startPart.time && endPart.time) {
|
|
1630
|
+
return "".concat(startPart.time, " - ").concat(endPart.time, " ").concat(startPart.date);
|
|
1631
|
+
}
|
|
1632
|
+
return "".concat(startPart.text, " - ").concat(endPart.text);
|
|
1633
|
+
}
|
|
1634
|
+
return startPart.text || endPart.text;
|
|
1635
|
+
}
|
|
1636
|
+
function combineVoucherDateAndTime(dateValue, timeValue) {
|
|
1637
|
+
if (!isPresentId(dateValue) || !isPresentId(timeValue)) return dateValue;
|
|
1638
|
+
var dateText = stringify(dateValue).trim();
|
|
1639
|
+
if (/\d{1,2}:\d{2}/.test(dateText)) return dateValue;
|
|
1640
|
+
return "".concat(dateText, " ").concat(stringify(timeValue).trim());
|
|
1641
|
+
}
|
|
1642
|
+
function formatVoucherValidityDate(value, locale) {
|
|
1643
|
+
if (!isPresentId(value)) return {
|
|
1644
|
+
date: '',
|
|
1645
|
+
time: '',
|
|
1646
|
+
text: ''
|
|
1647
|
+
};
|
|
1648
|
+
var source = stringify(value).trim();
|
|
1649
|
+
var parsed = dayjs(source);
|
|
1650
|
+
if (!parsed.isValid()) return {
|
|
1651
|
+
date: '',
|
|
1652
|
+
time: '',
|
|
1653
|
+
text: source
|
|
1654
|
+
};
|
|
1655
|
+
var hasTime = /\d{1,2}:\d{2}/.test(source);
|
|
1656
|
+
var date = parsed.format(locale === 'en' ? 'DD/MM/YYYY' : 'YYYY/MM/DD');
|
|
1657
|
+
var time = hasTime ? parsed.format(/\d{1,2}:\d{2}:\d{2}/.test(source) ? 'HH:mm:ss' : 'HH:mm') : '';
|
|
1658
|
+
return {
|
|
1659
|
+
date: date,
|
|
1660
|
+
time: time,
|
|
1661
|
+
text: time ? "".concat(time, " ").concat(date) : date
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1565
1664
|
function getVoucherAssetKey(voucher, index) {
|
|
1566
1665
|
var identity = firstPresentValue(voucher.voucher_id, voucher.id, voucher.code, voucher.encoded);
|
|
1567
1666
|
return identity === undefined ? "voucher-index:".concat(index) : "voucher:".concat(String(identity));
|
|
@@ -1570,8 +1669,8 @@ function getVoucherAssetName(voucher, locale) {
|
|
|
1570
1669
|
return getLocalizedValue(voucher.product_name || voucher.name || voucher.title, locale) || stringify(voucher.encoded || voucher.code || label(locale, 'giftCard'));
|
|
1571
1670
|
}
|
|
1572
1671
|
function getVoucherDiscountPercent(voucher) {
|
|
1573
|
-
var _voucher$
|
|
1574
|
-
var discountType = stringify(((_voucher$
|
|
1672
|
+
var _voucher$metadata13;
|
|
1673
|
+
var discountType = stringify(((_voucher$metadata13 = voucher.metadata) === null || _voucher$metadata13 === void 0 ? void 0 : _voucher$metadata13.discount_card_type) || voucher.discount_card_type).toLowerCase();
|
|
1575
1674
|
if (discountType !== 'percent' && discountType !== 'percentage') return null;
|
|
1576
1675
|
var percent = new Decimal(toMoneyNumber(voucher.par_value));
|
|
1577
1676
|
if (!percent.isFinite() || percent.lte(0) || percent.gt(100)) return null;
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -535,7 +535,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
535
535
|
generateIdempotencyToken(): string;
|
|
536
536
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
537
537
|
createOrder(params: CommitOrderParams['query']): {
|
|
538
|
-
type: "
|
|
538
|
+
type: "appointment_booking" | "virtual";
|
|
539
539
|
platform: string;
|
|
540
540
|
sales_channel: string;
|
|
541
541
|
order_sales_channel: string;
|
|
@@ -29,6 +29,7 @@ const LABELS = {
|
|
|
29
29
|
giftCard: 'Gift card',
|
|
30
30
|
pointCard: 'Point card',
|
|
31
31
|
balance: 'Balance',
|
|
32
|
+
validity: 'Validity',
|
|
32
33
|
remainingAmount: 'Remaining amount',
|
|
33
34
|
redeemPoints: 'Redeem points',
|
|
34
35
|
remainingPoints: 'Points balance',
|
|
@@ -67,6 +68,7 @@ const LABELS = {
|
|
|
67
68
|
giftCard: '礼品卡',
|
|
68
69
|
pointCard: '积分卡',
|
|
69
70
|
balance: '余额',
|
|
71
|
+
validity: '有效期',
|
|
70
72
|
remainingAmount: '剩余金额',
|
|
71
73
|
redeemPoints: '本次使用积分',
|
|
72
74
|
remainingPoints: '积分余额',
|
|
@@ -105,6 +107,7 @@ const LABELS = {
|
|
|
105
107
|
giftCard: '禮品卡',
|
|
106
108
|
pointCard: '積分卡',
|
|
107
109
|
balance: '餘額',
|
|
110
|
+
validity: '有效期',
|
|
108
111
|
remainingAmount: '剩餘金額',
|
|
109
112
|
redeemPoints: '本次使用積分',
|
|
110
113
|
remainingPoints: '積分餘額',
|
|
@@ -141,6 +144,7 @@ const LABELS = {
|
|
|
141
144
|
giftCard: 'ギフトカード',
|
|
142
145
|
pointCard: 'ポイントカード',
|
|
143
146
|
balance: '残高',
|
|
147
|
+
validity: '有効期限',
|
|
144
148
|
remainingAmount: '残高',
|
|
145
149
|
redeemPoints: '利用ポイント',
|
|
146
150
|
remainingPoints: 'ポイント残高',
|
|
@@ -178,6 +182,7 @@ const LABELS = {
|
|
|
178
182
|
giftCard: 'Cartão-presente',
|
|
179
183
|
pointCard: 'Cartão de pontos',
|
|
180
184
|
balance: 'Saldo',
|
|
185
|
+
validity: 'Validade',
|
|
181
186
|
remainingAmount: 'Saldo restante',
|
|
182
187
|
redeemPoints: 'Pontos utilizados',
|
|
183
188
|
remainingPoints: 'Saldo de pontos',
|
|
@@ -658,7 +663,7 @@ function normalizeProductCombinations(params) {
|
|
|
658
663
|
const quantity = toNumber(bundle.num ?? bundle.quantity ?? 1, 1);
|
|
659
664
|
const formattedPrice = formatBundlePrice(bundle, currencySymbol);
|
|
660
665
|
const optionsTotal = sumNormalizedOptionTotals(combinationsOptions, currencySymbol);
|
|
661
|
-
const explicitBasePrice =
|
|
666
|
+
const explicitBasePrice = resolveCombinationBasePrice(bundle);
|
|
662
667
|
const basePrice = isPresentId(explicitBasePrice) ? explicitBasePrice : 0;
|
|
663
668
|
const extensionList = buildProductExtensionList({
|
|
664
669
|
product: bundle,
|
|
@@ -719,7 +724,7 @@ function normalizeExistingCombinations(combinations, locale, currencySymbol) {
|
|
|
719
724
|
const quantity = toNumber(combination.product_quantity ?? combination.num ?? combination.quantity ?? 1, 1);
|
|
720
725
|
const unitPrice = firstPresentValue(combination.selling_price, combination.price, combination.original_price) ?? 0;
|
|
721
726
|
const optionsAmount = sumMoneyValues(normalizedOptions.map(option => option.total_price));
|
|
722
|
-
const explicitBasePrice =
|
|
727
|
+
const explicitBasePrice = resolveCombinationBasePrice(combination, true);
|
|
723
728
|
const basePrice = isPresentId(explicitBasePrice) ? explicitBasePrice : 0;
|
|
724
729
|
const extensionList = buildProductExtensionList({
|
|
725
730
|
product: combination,
|
|
@@ -762,6 +767,10 @@ function normalizeExistingCombinations(combinations, locale, currencySymbol) {
|
|
|
762
767
|
function sumMoneyValues(values) {
|
|
763
768
|
return values.reduce((sum, value) => sum.plus(toMoneyNumber(value)), new _decimal.default(0));
|
|
764
769
|
}
|
|
770
|
+
function resolveCombinationBasePrice(combination, preferOriginalPrice = false) {
|
|
771
|
+
const fallbackPrices = preferOriginalPrice ? [combination.original_price, combination.product_price, combination.price] : [combination.price, combination.original_price, combination.product_price];
|
|
772
|
+
return firstPresentValue(combination.base_price, combination.metadata?.source_product_price, ...fallbackPrices);
|
|
773
|
+
}
|
|
765
774
|
function sumNormalizedOptionTotals(options, currencySymbol) {
|
|
766
775
|
return formatCalculatedMoney(sumMoneyValues(options.map(option => option.total_price)), currencySymbol);
|
|
767
776
|
}
|
|
@@ -998,12 +1007,6 @@ function buildFees(params) {
|
|
|
998
1007
|
});
|
|
999
1008
|
const isPriceIncludeTax = firstPresentValue(summary.is_price_include_tax, order.is_price_include_tax, shopInfo.is_price_include_tax);
|
|
1000
1009
|
const roundingAmount = firstPresentValue(summary.rounding_amount, order.rounding_amount);
|
|
1001
|
-
if (isNonZero(roundingAmount)) {
|
|
1002
|
-
fees.push({
|
|
1003
|
-
item: label(locale, 'rounding'),
|
|
1004
|
-
value: formatMoney(roundingAmount, currencySymbol)
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
1010
|
const payProcessingFee = financials.payProcessingFee;
|
|
1008
1011
|
if (isNonZero(payProcessingFee)) {
|
|
1009
1012
|
fees.push({
|
|
@@ -1428,18 +1431,34 @@ function getPointCardSnapshotRemainingPoints(snapshot) {
|
|
|
1428
1431
|
}
|
|
1429
1432
|
function buildVoucherAssets(params) {
|
|
1430
1433
|
const seenVoucherKeys = new Set();
|
|
1434
|
+
const fallbackAssetTime = firstPresentValue(params.order.updated_at, params.order.created_at);
|
|
1431
1435
|
return normalizeArray(params.order.vouchers).flatMap((voucher, index) => {
|
|
1432
1436
|
if (!voucher || typeof voucher !== 'object' || Array.isArray(voucher)) return [];
|
|
1433
1437
|
const voucherKey = getVoucherAssetKey(voucher, index);
|
|
1434
1438
|
if (seenVoucherKeys.has(voucherKey)) return [];
|
|
1435
1439
|
seenVoucherKeys.add(voucherKey);
|
|
1436
1440
|
const name = getVoucherAssetName(voucher, params.locale);
|
|
1441
|
+
const assetTime = firstPresentValue(voucher.updated_at, voucher.created_at, voucher.collection_time, fallbackAssetTime);
|
|
1442
|
+
const timeRow = isPresentId(assetTime) ? {
|
|
1443
|
+
item: formatDateTime(assetTime, params.locale),
|
|
1444
|
+
value: ''
|
|
1445
|
+
} : null;
|
|
1446
|
+
if (isTicketVoucher(voucher)) {
|
|
1447
|
+
const validity = getVoucherValidity(voucher, params.locale);
|
|
1448
|
+
return [[{
|
|
1449
|
+
item: name,
|
|
1450
|
+
value: ''
|
|
1451
|
+
}, ...(validity ? [{
|
|
1452
|
+
item: label(params.locale, 'validity'),
|
|
1453
|
+
value: validity
|
|
1454
|
+
}] : [])]];
|
|
1455
|
+
}
|
|
1437
1456
|
const percent = getVoucherDiscountPercent(voucher);
|
|
1438
1457
|
if (percent) {
|
|
1439
1458
|
return [[{
|
|
1440
1459
|
item: appendPercentToVoucherName(name, percent),
|
|
1441
1460
|
value: formatVoucherDiscount(percent, params.locale)
|
|
1442
|
-
}]];
|
|
1461
|
+
}, ...(timeRow ? [timeRow] : [])]];
|
|
1443
1462
|
}
|
|
1444
1463
|
const balance = getVoucherBalance(voucher);
|
|
1445
1464
|
return [[{
|
|
@@ -1448,9 +1467,83 @@ function buildVoucherAssets(params) {
|
|
|
1448
1467
|
}, {
|
|
1449
1468
|
item: label(params.locale, 'balance'),
|
|
1450
1469
|
value: formatMoney(balance, params.currencySymbol)
|
|
1451
|
-
}]];
|
|
1470
|
+
}, ...(timeRow ? [timeRow] : [])]];
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
function isTicketVoucher(voucher) {
|
|
1474
|
+
return stringify(voucher.tag).trim().toLowerCase() === 'ticket';
|
|
1475
|
+
}
|
|
1476
|
+
function getVoucherValidity(voucher, locale) {
|
|
1477
|
+
const availableTime = firstPresentValue(voucher.available_time, voucher.avaliable_time, voucher.metadata?.available_time, voucher.metadata?.avaliable_time);
|
|
1478
|
+
const availableTimeText = formatVoucherAvailableTime(availableTime, locale);
|
|
1479
|
+
if (availableTimeText) return availableTimeText;
|
|
1480
|
+
const startDate = firstPresentValue(voucher.valid_from, voucher.start_at, voucher.start_date_time, voucher.start_date, voucher.metadata?.valid_from, voucher.metadata?.start_at, voucher.metadata?.start_date);
|
|
1481
|
+
const endDate = firstPresentValue(voucher.valid_to, voucher.end_at, voucher.end_date_time, voucher.expire_date, voucher.end_date, voucher.expire_time, voucher.metadata?.valid_to, voucher.metadata?.end_at, voucher.metadata?.expire_date, voucher.metadata?.end_date, voucher.metadata?.expire_time);
|
|
1482
|
+
return formatVoucherValidityRange(startDate, endDate, locale, {
|
|
1483
|
+
startTime: voucher.start_time ?? voucher.metadata?.start_time,
|
|
1484
|
+
endTime: voucher.end_time ?? voucher.metadata?.end_time
|
|
1452
1485
|
});
|
|
1453
1486
|
}
|
|
1487
|
+
function formatVoucherAvailableTime(value, locale) {
|
|
1488
|
+
if (!isPresentId(value)) return '';
|
|
1489
|
+
if (Array.isArray(value)) {
|
|
1490
|
+
return value.map(item => formatVoucherAvailableTime(item, locale)).filter(Boolean).join(', ');
|
|
1491
|
+
}
|
|
1492
|
+
if (typeof value !== 'object') return stringify(value).trim();
|
|
1493
|
+
const start = firstPresentValue(value.start, value.start_at, value.start_date_time, value.start_date);
|
|
1494
|
+
const end = firstPresentValue(value.end, value.end_at, value.end_date_time, value.expire_time, value.expire_date, value.end_date);
|
|
1495
|
+
if (isPresentId(start) || isPresentId(end)) {
|
|
1496
|
+
return formatVoucherValidityRange(start, end, locale, {
|
|
1497
|
+
startTime: value.start_time,
|
|
1498
|
+
endTime: value.end_time
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
return getLocalizedValue(value, locale).trim();
|
|
1502
|
+
}
|
|
1503
|
+
function formatVoucherValidityRange(startValue, endValue, locale, times = {}) {
|
|
1504
|
+
const start = combineVoucherDateAndTime(startValue, times.startTime);
|
|
1505
|
+
const end = combineVoucherDateAndTime(endValue, times.endTime);
|
|
1506
|
+
const startPart = formatVoucherValidityDate(start, locale);
|
|
1507
|
+
const endPart = formatVoucherValidityDate(end, locale);
|
|
1508
|
+
if (startPart.text && endPart.text) {
|
|
1509
|
+
const parsedStart = (0, _dayjs.default)(start);
|
|
1510
|
+
const parsedEnd = (0, _dayjs.default)(end);
|
|
1511
|
+
const sameDay = parsedStart.isValid() && parsedEnd.isValid() && parsedStart.isSame(parsedEnd, 'day');
|
|
1512
|
+
if (sameDay && startPart.time && endPart.time) {
|
|
1513
|
+
return `${startPart.time} - ${endPart.time} ${startPart.date}`;
|
|
1514
|
+
}
|
|
1515
|
+
return `${startPart.text} - ${endPart.text}`;
|
|
1516
|
+
}
|
|
1517
|
+
return startPart.text || endPart.text;
|
|
1518
|
+
}
|
|
1519
|
+
function combineVoucherDateAndTime(dateValue, timeValue) {
|
|
1520
|
+
if (!isPresentId(dateValue) || !isPresentId(timeValue)) return dateValue;
|
|
1521
|
+
const dateText = stringify(dateValue).trim();
|
|
1522
|
+
if (/\d{1,2}:\d{2}/.test(dateText)) return dateValue;
|
|
1523
|
+
return `${dateText} ${stringify(timeValue).trim()}`;
|
|
1524
|
+
}
|
|
1525
|
+
function formatVoucherValidityDate(value, locale) {
|
|
1526
|
+
if (!isPresentId(value)) return {
|
|
1527
|
+
date: '',
|
|
1528
|
+
time: '',
|
|
1529
|
+
text: ''
|
|
1530
|
+
};
|
|
1531
|
+
const source = stringify(value).trim();
|
|
1532
|
+
const parsed = (0, _dayjs.default)(source);
|
|
1533
|
+
if (!parsed.isValid()) return {
|
|
1534
|
+
date: '',
|
|
1535
|
+
time: '',
|
|
1536
|
+
text: source
|
|
1537
|
+
};
|
|
1538
|
+
const hasTime = /\d{1,2}:\d{2}/.test(source);
|
|
1539
|
+
const date = parsed.format(locale === 'en' ? 'DD/MM/YYYY' : 'YYYY/MM/DD');
|
|
1540
|
+
const time = hasTime ? parsed.format(/\d{1,2}:\d{2}:\d{2}/.test(source) ? 'HH:mm:ss' : 'HH:mm') : '';
|
|
1541
|
+
return {
|
|
1542
|
+
date,
|
|
1543
|
+
time,
|
|
1544
|
+
text: time ? `${time} ${date}` : date
|
|
1545
|
+
};
|
|
1546
|
+
}
|
|
1454
1547
|
function getVoucherAssetKey(voucher, index) {
|
|
1455
1548
|
const identity = firstPresentValue(voucher.voucher_id, voucher.id, voucher.code, voucher.encoded);
|
|
1456
1549
|
return identity === undefined ? `voucher-index:${index}` : `voucher:${String(identity)}`;
|