@pisell/pisellos 2.3.116 → 2.3.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/utils/small-ticket.js +455 -65
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/server/utils/small-ticket.js +343 -52
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 6 | 5 | 1 | 2 | 3 | 4;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -347,7 +347,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
347
347
|
* 获取当前的客户搜索条件
|
|
348
348
|
* @returns 当前搜索条件
|
|
349
349
|
*/
|
|
350
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
350
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
351
351
|
/**
|
|
352
352
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
353
353
|
* @returns 客户状态
|
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
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; }
|
|
@@ -9,15 +9,31 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
|
9
9
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
const DEFAULT_LOCALES = ['en', 'zh_CN'];
|
|
12
|
+
const SERVICE_TYPE_LABEL_KEYS = {
|
|
13
|
+
takeaway: 'takeAway',
|
|
14
|
+
pick_up: 'pickUp',
|
|
15
|
+
table_service: 'tableService',
|
|
16
|
+
delivery: 'delivery',
|
|
17
|
+
room_service: 'roomService',
|
|
18
|
+
dine_in: 'dineIn',
|
|
19
|
+
delivery_by_uber: 'deliveryByUber',
|
|
20
|
+
delivery_by_panda: 'deliveryByPanda',
|
|
21
|
+
delivery_by_merchant: 'deliveryByMerchant'
|
|
22
|
+
};
|
|
12
23
|
const LABELS = {
|
|
13
24
|
en: {
|
|
14
25
|
contactName: 'Contact name',
|
|
15
26
|
contactMobile: 'Contact Mobile',
|
|
16
27
|
email: 'email',
|
|
17
|
-
dineIn: 'Dine
|
|
18
|
-
takeAway: '
|
|
28
|
+
dineIn: 'Dine in',
|
|
29
|
+
takeAway: 'Takeaway',
|
|
19
30
|
delivery: 'Delivery',
|
|
20
|
-
pickUp: '
|
|
31
|
+
pickUp: 'Pickup',
|
|
32
|
+
tableService: 'Table Service',
|
|
33
|
+
roomService: 'Room Service',
|
|
34
|
+
deliveryByUber: 'Uber Eats Delivery',
|
|
35
|
+
deliveryByPanda: 'HungryPanda Delivery',
|
|
36
|
+
deliveryByMerchant: 'Merchant Delivery',
|
|
21
37
|
shopService: 'Dine-in',
|
|
22
38
|
pickUpTime: 'Pick-up time',
|
|
23
39
|
asap: 'ASAP',
|
|
@@ -33,6 +49,7 @@ const LABELS = {
|
|
|
33
49
|
remainingAmount: 'Remaining amount',
|
|
34
50
|
redeemPoints: 'Redeem points',
|
|
35
51
|
remainingPoints: 'Points balance',
|
|
52
|
+
entitlementRemaining: 'Remaining',
|
|
36
53
|
table: 'Table',
|
|
37
54
|
bookingId: 'Booking ID',
|
|
38
55
|
bookingDateTime: 'Date & time',
|
|
@@ -56,7 +73,12 @@ const LABELS = {
|
|
|
56
73
|
dineIn: '堂食',
|
|
57
74
|
takeAway: '外带',
|
|
58
75
|
delivery: '配送',
|
|
59
|
-
pickUp: '
|
|
76
|
+
pickUp: '自取',
|
|
77
|
+
tableService: '送餐到桌',
|
|
78
|
+
roomService: '客房服务',
|
|
79
|
+
deliveryByUber: 'Uber 配送',
|
|
80
|
+
deliveryByPanda: '熊猫外卖配送',
|
|
81
|
+
deliveryByMerchant: '商家配送',
|
|
60
82
|
shopService: '堂食',
|
|
61
83
|
pickUpTime: '取餐时间',
|
|
62
84
|
asap: '尽快',
|
|
@@ -72,6 +94,7 @@ const LABELS = {
|
|
|
72
94
|
remainingAmount: '剩余金额',
|
|
73
95
|
redeemPoints: '本次使用积分',
|
|
74
96
|
remainingPoints: '积分余额',
|
|
97
|
+
entitlementRemaining: '剩余次数',
|
|
75
98
|
table: '桌台',
|
|
76
99
|
bookingId: '预约编号',
|
|
77
100
|
bookingDateTime: '日期和时间',
|
|
@@ -96,6 +119,11 @@ const LABELS = {
|
|
|
96
119
|
takeAway: '外帶',
|
|
97
120
|
delivery: '配送',
|
|
98
121
|
pickUp: '自取',
|
|
122
|
+
tableService: '送餐到桌',
|
|
123
|
+
roomService: '客房服務',
|
|
124
|
+
deliveryByUber: 'Uber 配送',
|
|
125
|
+
deliveryByPanda: '熊貓外賣配送',
|
|
126
|
+
deliveryByMerchant: '商家配送',
|
|
99
127
|
shopService: '堂食',
|
|
100
128
|
pickUpTime: '取餐時間',
|
|
101
129
|
asap: '盡快',
|
|
@@ -111,6 +139,7 @@ const LABELS = {
|
|
|
111
139
|
remainingAmount: '剩餘金額',
|
|
112
140
|
redeemPoints: '本次使用積分',
|
|
113
141
|
remainingPoints: '積分餘額',
|
|
142
|
+
entitlementRemaining: '剩餘次數',
|
|
114
143
|
table: '桌台',
|
|
115
144
|
bookingId: '預約編號',
|
|
116
145
|
bookingDateTime: '日期和時間',
|
|
@@ -135,6 +164,11 @@ const LABELS = {
|
|
|
135
164
|
takeAway: 'テイクアウト',
|
|
136
165
|
delivery: '配達',
|
|
137
166
|
pickUp: '受け取り',
|
|
167
|
+
tableService: 'テーブルサービス',
|
|
168
|
+
roomService: 'ルームサービス',
|
|
169
|
+
deliveryByUber: 'Uber Eats 配達',
|
|
170
|
+
deliveryByPanda: 'HungryPanda 配達',
|
|
171
|
+
deliveryByMerchant: '店舗による配達',
|
|
138
172
|
shopService: '店内飲食',
|
|
139
173
|
pickUpTime: '受取時間',
|
|
140
174
|
asap: 'できるだけ早く',
|
|
@@ -148,6 +182,7 @@ const LABELS = {
|
|
|
148
182
|
remainingAmount: '残高',
|
|
149
183
|
redeemPoints: '利用ポイント',
|
|
150
184
|
remainingPoints: 'ポイント残高',
|
|
185
|
+
entitlementRemaining: '残り回数',
|
|
151
186
|
table: 'テーブル',
|
|
152
187
|
bookingId: '予約ID',
|
|
153
188
|
bookingDateTime: '日時',
|
|
@@ -173,6 +208,11 @@ const LABELS = {
|
|
|
173
208
|
takeAway: 'Para levar',
|
|
174
209
|
delivery: 'Entrega',
|
|
175
210
|
pickUp: 'Recolha',
|
|
211
|
+
tableService: 'Serviço à mesa',
|
|
212
|
+
roomService: 'Serviço de quarto',
|
|
213
|
+
deliveryByUber: 'Entrega pela Uber Eats',
|
|
214
|
+
deliveryByPanda: 'Entrega pela HungryPanda',
|
|
215
|
+
deliveryByMerchant: 'Entrega pelo comerciante',
|
|
176
216
|
shopService: 'Consumo no local',
|
|
177
217
|
pickUpTime: 'Hora de recolha',
|
|
178
218
|
asap: 'Assim que possível',
|
|
@@ -186,6 +226,7 @@ const LABELS = {
|
|
|
186
226
|
remainingAmount: 'Saldo restante',
|
|
187
227
|
redeemPoints: 'Pontos utilizados',
|
|
188
228
|
remainingPoints: 'Saldo de pontos',
|
|
229
|
+
entitlementRemaining: 'Utilizações restantes',
|
|
189
230
|
table: 'Mesa',
|
|
190
231
|
bookingId: 'ID da reserva',
|
|
191
232
|
bookingDateTime: 'Data e hora',
|
|
@@ -486,7 +527,8 @@ function normalizeProductDiscounts(params) {
|
|
|
486
527
|
const title = resolveDiscountTitleWithPercent(discount, locale);
|
|
487
528
|
const amount = discount.amount ?? discount.value ?? discount.discount_amount;
|
|
488
529
|
const isMarkup = isManualMarkup(discount);
|
|
489
|
-
const
|
|
530
|
+
const isAggregatedBundleDiscount = Boolean(getReceiptDiscountBundleMapId(discount));
|
|
531
|
+
const totalAmount = new _decimal.default(toMoneyNumber(amount)).mul(isAggregatedBundleDiscount ? 1 : quantity);
|
|
490
532
|
const formattedAmount = isMarkup ? formatMoney(totalAmount.abs(), currencySymbol) : formatNegativeMoney(totalAmount, currencySymbol);
|
|
491
533
|
return {
|
|
492
534
|
item: title,
|
|
@@ -579,6 +621,9 @@ function buildProductQuantityPriceText(params) {
|
|
|
579
621
|
}
|
|
580
622
|
function resolveDiscountTitleWithPercent(discount, locale) {
|
|
581
623
|
const title = resolveDiscountTitle(discount, locale);
|
|
624
|
+
if (getProductWalletDiscountType(discount) === 'entitlement_pass') {
|
|
625
|
+
return title;
|
|
626
|
+
}
|
|
582
627
|
const percentRaw = discount.discount?.percent;
|
|
583
628
|
const cardType = discount.discount?.discount_card_type ?? 'percent';
|
|
584
629
|
const percent = percentRaw !== undefined && percentRaw !== null ? Math.trunc(Number(percentRaw)) : NaN;
|
|
@@ -1128,9 +1173,8 @@ function normalizeCustomerDisplayValue(value) {
|
|
|
1128
1173
|
return text;
|
|
1129
1174
|
}
|
|
1130
1175
|
function buildDelivery(order, locale) {
|
|
1131
|
-
const
|
|
1132
|
-
const
|
|
1133
|
-
const serviceTypeLabelKey = resolveServiceTypeLabelKey(serviceType, order);
|
|
1176
|
+
const serviceType = stringify(order.metadata?.shop_service_data?.service_type).trim();
|
|
1177
|
+
const serviceTypeLabelKey = resolveServiceTypeLabelKey(serviceType);
|
|
1134
1178
|
if (!serviceTypeLabelKey) return [];
|
|
1135
1179
|
const items = [{
|
|
1136
1180
|
item: '',
|
|
@@ -1392,42 +1436,244 @@ function buildWallets(params) {
|
|
|
1392
1436
|
virtualCurrencyUnit: virtualCurrencySnapshot ? getVirtualCurrencySnapshotUnit(virtualCurrencySnapshot, params.locale) : undefined
|
|
1393
1437
|
});
|
|
1394
1438
|
});
|
|
1395
|
-
const
|
|
1396
|
-
|
|
1439
|
+
const displayedWalletAssetIdentities = collectDisplayedWalletAssetIdentities(displayedWalletPayments);
|
|
1440
|
+
const voucherWallets = buildVoucherAssets({
|
|
1441
|
+
...params,
|
|
1442
|
+
displayedWalletAssetIdentities
|
|
1443
|
+
});
|
|
1444
|
+
const productDiscountWallets = buildProductDiscountAssets({
|
|
1445
|
+
...params,
|
|
1446
|
+
displayedWalletAssetIdentities
|
|
1447
|
+
});
|
|
1448
|
+
return [...paymentWallets, ...voucherWallets, ...productDiscountWallets, ...buildPointCardSnapshotAssets({
|
|
1397
1449
|
order: params.order,
|
|
1398
1450
|
locale: params.locale,
|
|
1399
|
-
|
|
1451
|
+
displayedWalletAssetIdentities
|
|
1400
1452
|
}), ...buildVirtualCurrencySnapshotAssets({
|
|
1401
1453
|
snapshots: virtualCurrencySnapshots.items,
|
|
1402
1454
|
order: params.order,
|
|
1403
1455
|
locale: params.locale,
|
|
1404
|
-
|
|
1456
|
+
displayedWalletAssetIdentities
|
|
1405
1457
|
})];
|
|
1406
1458
|
}
|
|
1407
|
-
function
|
|
1408
|
-
const
|
|
1459
|
+
function collectDisplayedWalletAssetIdentities(payments) {
|
|
1460
|
+
const identities = [];
|
|
1409
1461
|
payments.forEach(payment => {
|
|
1410
1462
|
const fundRecord = getFundRecord(payment);
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1463
|
+
const ids = Array.from(new Set([fundRecord?.voucher_id, payment.voucher_id].map(value => normalizeWalletPassId(value)).filter(value => !!value)));
|
|
1464
|
+
const codes = normalizeWalletAssetCodes(fundRecord?.code, fundRecord?.encoded);
|
|
1465
|
+
if (!ids.length) {
|
|
1466
|
+
registerWalletAssetIdentity(identities, {
|
|
1467
|
+
id: null,
|
|
1468
|
+
codes
|
|
1469
|
+
});
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
ids.forEach(id => {
|
|
1473
|
+
registerWalletAssetIdentity(identities, {
|
|
1474
|
+
id,
|
|
1475
|
+
codes
|
|
1476
|
+
});
|
|
1414
1477
|
});
|
|
1415
1478
|
});
|
|
1416
|
-
return
|
|
1479
|
+
return identities;
|
|
1480
|
+
}
|
|
1481
|
+
const PRODUCT_WALLET_DISCOUNT_TYPES = new Set(['good_pass', 'discount_card', 'product_discount_card', 'entitlement_pass']);
|
|
1482
|
+
function buildProductDiscountAssets(params) {
|
|
1483
|
+
const fallbackAssetTime = firstPresentValue(params.order.updated_at, params.order.created_at);
|
|
1484
|
+
return collectProductWalletDiscountAssets(params.order).flatMap(asset => {
|
|
1485
|
+
if (!claimWalletAssetIdentity(params.displayedWalletAssetIdentities, {
|
|
1486
|
+
id: asset.id,
|
|
1487
|
+
codes: asset.codes
|
|
1488
|
+
})) return [];
|
|
1489
|
+
const name = getProductWalletDiscountName(asset, params.locale);
|
|
1490
|
+
const assetTime = getProductWalletDiscountTime(asset) ?? fallbackAssetTime;
|
|
1491
|
+
const timeRow = isPresentId(assetTime) ? {
|
|
1492
|
+
item: formatDateTime(assetTime, params.locale),
|
|
1493
|
+
value: ''
|
|
1494
|
+
} : null;
|
|
1495
|
+
if (asset.type === 'entitlement_pass') {
|
|
1496
|
+
const remaining = getProductEntitlementBalance(asset);
|
|
1497
|
+
return [[{
|
|
1498
|
+
item: name,
|
|
1499
|
+
value: ''
|
|
1500
|
+
}, ...(remaining ? [{
|
|
1501
|
+
item: label(params.locale, 'entitlementRemaining'),
|
|
1502
|
+
value: formatEntitlementUses(remaining, params.locale)
|
|
1503
|
+
}] : []), ...(timeRow ? [timeRow] : [])]];
|
|
1504
|
+
}
|
|
1505
|
+
const percent = getProductWalletDiscountPercent(asset);
|
|
1506
|
+
if (percent) {
|
|
1507
|
+
return [[{
|
|
1508
|
+
item: appendPercentToVoucherName(name, percent),
|
|
1509
|
+
value: formatVoucherDiscount(percent, params.locale)
|
|
1510
|
+
}, ...(timeRow ? [timeRow] : [])]];
|
|
1511
|
+
}
|
|
1512
|
+
const balance = getProductWalletMoneyBalance(asset);
|
|
1513
|
+
return [[{
|
|
1514
|
+
item: name,
|
|
1515
|
+
value: ''
|
|
1516
|
+
}, ...(balance ? [{
|
|
1517
|
+
item: label(params.locale, 'balance'),
|
|
1518
|
+
value: formatMoney(balance, params.currencySymbol)
|
|
1519
|
+
}] : []), ...(timeRow ? [timeRow] : [])]];
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
function collectProductWalletDiscountAssets(order) {
|
|
1523
|
+
const assets = [];
|
|
1524
|
+
const assetsById = new Map();
|
|
1525
|
+
normalizeArray(order.products).forEach(rawProduct => {
|
|
1526
|
+
if (!rawProduct || typeof rawProduct !== 'object') return;
|
|
1527
|
+
visitProductWalletDiscounts(restoreReceiptDiscountHierarchy(rawProduct), assets, assetsById);
|
|
1528
|
+
});
|
|
1529
|
+
return assets;
|
|
1530
|
+
}
|
|
1531
|
+
function visitProductWalletDiscounts(product, assets, assetsById) {
|
|
1532
|
+
normalizeArray(product.discount_list).forEach(record => {
|
|
1533
|
+
if (!record || typeof record !== 'object' || Array.isArray(record)) return;
|
|
1534
|
+
const type = getProductWalletDiscountType(record);
|
|
1535
|
+
if (!type) return;
|
|
1536
|
+
const id = getProductWalletDiscountAssetId(record);
|
|
1537
|
+
if (!id) return;
|
|
1538
|
+
const codes = getProductWalletDiscountCodes(record);
|
|
1539
|
+
const existing = assetsById.get(id);
|
|
1540
|
+
if (existing) {
|
|
1541
|
+
existing.records.push(record);
|
|
1542
|
+
existing.codes = Array.from(new Set([...existing.codes, ...codes]));
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
const asset = {
|
|
1546
|
+
id,
|
|
1547
|
+
type,
|
|
1548
|
+
codes,
|
|
1549
|
+
records: [record]
|
|
1550
|
+
};
|
|
1551
|
+
assetsById.set(id, asset);
|
|
1552
|
+
assets.push(asset);
|
|
1553
|
+
});
|
|
1554
|
+
for (const childKey of ['combinations', 'product_bundle', 'bundle']) {
|
|
1555
|
+
normalizeArray(product[childKey]).forEach(child => {
|
|
1556
|
+
if (!child || typeof child !== 'object' || Array.isArray(child)) return;
|
|
1557
|
+
visitProductWalletDiscounts(child, assets, assetsById);
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
function getProductWalletDiscountType(record) {
|
|
1562
|
+
for (const value of [record.tag, record.type, record.discount?.tag, record.discount?.type]) {
|
|
1563
|
+
const type = stringify(value).trim().toLowerCase();
|
|
1564
|
+
if (PRODUCT_WALLET_DISCOUNT_TYPES.has(type)) return type;
|
|
1565
|
+
}
|
|
1566
|
+
return null;
|
|
1567
|
+
}
|
|
1568
|
+
function getProductWalletDiscountAssetId(record) {
|
|
1569
|
+
for (const value of [record.discount?.resource_id, record.resource_id, record.id, record.discount_id]) {
|
|
1570
|
+
const id = normalizeWalletPassId(value);
|
|
1571
|
+
if (id && id !== '0') return id;
|
|
1572
|
+
}
|
|
1573
|
+
return null;
|
|
1574
|
+
}
|
|
1575
|
+
function getProductWalletDiscountCodes(record) {
|
|
1576
|
+
return normalizeWalletAssetCodes(record.code, record.encoded, record.discount?.code, record.discount?.encoded);
|
|
1577
|
+
}
|
|
1578
|
+
function getProductWalletDiscountName(asset, locale) {
|
|
1579
|
+
for (const record of asset.records) {
|
|
1580
|
+
for (const value of [record.discount?.title, record.discount?.name, record.discount?.message, record.product_name, record.format_title, record.title, record.name, record.message]) {
|
|
1581
|
+
const name = getLocalizedValue(value, locale).trim();
|
|
1582
|
+
if (name) return name;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
return asset.codes[0] || label(locale, 'giftCard');
|
|
1586
|
+
}
|
|
1587
|
+
function getProductWalletDiscountTime(asset) {
|
|
1588
|
+
for (const field of ['updated_at', 'created_at', 'collection_time']) {
|
|
1589
|
+
for (const record of asset.records) {
|
|
1590
|
+
const value = firstPresentValue(record[field], record.discount?.[field]);
|
|
1591
|
+
if (isPresentId(value)) return value;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
return undefined;
|
|
1595
|
+
}
|
|
1596
|
+
function getProductEntitlementBalance(asset) {
|
|
1597
|
+
for (const record of asset.records) {
|
|
1598
|
+
const balance = getProductDiscountEntitlementBalance(record);
|
|
1599
|
+
if (balance) return balance;
|
|
1600
|
+
}
|
|
1601
|
+
return null;
|
|
1602
|
+
}
|
|
1603
|
+
function getProductDiscountEntitlementBalance(record) {
|
|
1604
|
+
return getEntitlementBalance(record.metadata?.balance, record.balance, record.discount?.metadata?.balance, record.discount?.balance);
|
|
1605
|
+
}
|
|
1606
|
+
function getEntitlementBalance(...values) {
|
|
1607
|
+
for (const value of values) {
|
|
1608
|
+
if (!isNumericAmount(value)) continue;
|
|
1609
|
+
const balance = new _decimal.default(value);
|
|
1610
|
+
if (balance.isFinite() && balance.isInteger() && balance.gte(0)) {
|
|
1611
|
+
return balance;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
return null;
|
|
1615
|
+
}
|
|
1616
|
+
function formatEntitlementUses(value, locale) {
|
|
1617
|
+
const count = value.toFixed(0);
|
|
1618
|
+
switch (normalizeLocaleKey(locale)) {
|
|
1619
|
+
case 'zh_CN':
|
|
1620
|
+
case 'zh_HK':
|
|
1621
|
+
return `${count}次`;
|
|
1622
|
+
case 'ja':
|
|
1623
|
+
return `${count}回`;
|
|
1624
|
+
case 'pt':
|
|
1625
|
+
return `${count} ${value.eq(1) ? 'utilização' : 'utilizações'}`;
|
|
1626
|
+
default:
|
|
1627
|
+
return `${count} ${value.eq(1) ? 'use' : 'uses'}`;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
function getProductWalletDiscountPercent(asset) {
|
|
1631
|
+
if (asset.type !== 'discount_card' && asset.type !== 'product_discount_card') return null;
|
|
1632
|
+
for (const record of asset.records) {
|
|
1633
|
+
const discountType = stringify(firstPresentValue(record.discount_card_type, record.metadata?.discount_card_type, record.discount?.discount_card_type, record.discount?.metadata?.discount_card_type)).trim().toLowerCase();
|
|
1634
|
+
if (discountType && discountType !== 'percent' && discountType !== 'percentage') continue;
|
|
1635
|
+
const candidates = [record.percent, record.discount?.percent];
|
|
1636
|
+
if (discountType === 'percent' || discountType === 'percentage') {
|
|
1637
|
+
candidates.push(record.par_value, record.discount?.par_value);
|
|
1638
|
+
}
|
|
1639
|
+
for (const value of candidates) {
|
|
1640
|
+
if (!isNumericAmount(value)) continue;
|
|
1641
|
+
const percent = new _decimal.default(value);
|
|
1642
|
+
if (percent.isFinite() && percent.gt(0) && percent.lte(100)) {
|
|
1643
|
+
return percent;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
return null;
|
|
1648
|
+
}
|
|
1649
|
+
function getProductWalletMoneyBalance(asset) {
|
|
1650
|
+
for (const record of asset.records) {
|
|
1651
|
+
for (const value of [record.metadata?.balance, record.balance, record.discount?.metadata?.balance, record.discount?.balance]) {
|
|
1652
|
+
if (!isNumericAmount(value)) continue;
|
|
1653
|
+
return _decimal.default.max(new _decimal.default(value), 0);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
for (const record of asset.records) {
|
|
1657
|
+
const parValue = firstPresentValue(record.par_value, record.discount?.par_value);
|
|
1658
|
+
const usedParValue = firstPresentValue(record.used_par_value, record.discount?.used_par_value);
|
|
1659
|
+
if (!isNumericAmount(parValue) || !isNumericAmount(usedParValue)) continue;
|
|
1660
|
+
return _decimal.default.max(new _decimal.default(parValue).minus(new _decimal.default(usedParValue)), 0);
|
|
1661
|
+
}
|
|
1662
|
+
return null;
|
|
1417
1663
|
}
|
|
1418
1664
|
function buildPointCardSnapshotAssets(params) {
|
|
1419
1665
|
const snapshots = params.order.order_meta_list?.point_cards_snapshot;
|
|
1420
1666
|
if (!Array.isArray(snapshots)) return [];
|
|
1421
1667
|
const snapshotTime = firstPresentValue(params.order.updated_at, params.order.created_at);
|
|
1422
|
-
const seenSnapshotIds = new Set();
|
|
1423
1668
|
return snapshots.flatMap(snapshot => {
|
|
1424
1669
|
if (!snapshot || typeof snapshot !== 'object' || Array.isArray(snapshot)) return [];
|
|
1425
1670
|
const pointCard = snapshot;
|
|
1426
1671
|
if (stringify(pointCard.tag).trim().toLowerCase() !== 'point_card') return [];
|
|
1427
|
-
const
|
|
1428
|
-
if (!
|
|
1429
|
-
|
|
1430
|
-
|
|
1672
|
+
const assetId = normalizeWalletPassId(pointCard.id);
|
|
1673
|
+
if (!assetId || !claimWalletAssetIdentity(params.displayedWalletAssetIdentities, {
|
|
1674
|
+
id: assetId,
|
|
1675
|
+
codes: []
|
|
1676
|
+
})) return [];
|
|
1431
1677
|
const rows = [{
|
|
1432
1678
|
item: stringify(pointCard.product_name).trim() || label(params.locale, 'pointCard'),
|
|
1433
1679
|
value: ''
|
|
@@ -1483,8 +1729,11 @@ function findVirtualCurrencySnapshotForPayment(payment, snapshotsById) {
|
|
|
1483
1729
|
function buildVirtualCurrencySnapshotAssets(params) {
|
|
1484
1730
|
const snapshotTime = firstPresentValue(params.order.updated_at, params.order.created_at);
|
|
1485
1731
|
return params.snapshots.flatMap(virtualCurrency => {
|
|
1486
|
-
const
|
|
1487
|
-
if (!
|
|
1732
|
+
const assetId = normalizeWalletPassId(virtualCurrency.id);
|
|
1733
|
+
if (!assetId || !claimWalletAssetIdentity(params.displayedWalletAssetIdentities, {
|
|
1734
|
+
id: assetId,
|
|
1735
|
+
codes: []
|
|
1736
|
+
})) return [];
|
|
1488
1737
|
const rows = [{
|
|
1489
1738
|
item: stringify(virtualCurrency.product_name).trim(),
|
|
1490
1739
|
value: ''
|
|
@@ -1535,6 +1784,49 @@ function normalizeWalletPassId(value) {
|
|
|
1535
1784
|
if (typeof value !== 'string') return null;
|
|
1536
1785
|
return value.trim() || null;
|
|
1537
1786
|
}
|
|
1787
|
+
function firstNormalizedWalletAssetId(...values) {
|
|
1788
|
+
for (const value of values) {
|
|
1789
|
+
const id = normalizeWalletPassId(value);
|
|
1790
|
+
if (id) return id;
|
|
1791
|
+
}
|
|
1792
|
+
return null;
|
|
1793
|
+
}
|
|
1794
|
+
function normalizeWalletAssetCodes(...values) {
|
|
1795
|
+
return Array.from(new Set(values.map(value => normalizeWalletPassId(value)).filter(value => !!value)));
|
|
1796
|
+
}
|
|
1797
|
+
function registerWalletAssetIdentity(identities, candidate) {
|
|
1798
|
+
if (!candidate.id && !candidate.codes.length) return;
|
|
1799
|
+
const existing = identities.find(identity => isSameWalletAssetIdentity(identity, candidate));
|
|
1800
|
+
if (existing) {
|
|
1801
|
+
mergeWalletAssetIdentity(existing, candidate);
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
identities.push({
|
|
1805
|
+
id: candidate.id,
|
|
1806
|
+
codes: [...candidate.codes]
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
function claimWalletAssetIdentity(identities, candidate) {
|
|
1810
|
+
if (!candidate.id && !candidate.codes.length) return true;
|
|
1811
|
+
const existing = identities.find(identity => isSameWalletAssetIdentity(identity, candidate));
|
|
1812
|
+
if (existing) {
|
|
1813
|
+
mergeWalletAssetIdentity(existing, candidate);
|
|
1814
|
+
return false;
|
|
1815
|
+
}
|
|
1816
|
+
identities.push({
|
|
1817
|
+
id: candidate.id,
|
|
1818
|
+
codes: [...candidate.codes]
|
|
1819
|
+
});
|
|
1820
|
+
return true;
|
|
1821
|
+
}
|
|
1822
|
+
function isSameWalletAssetIdentity(left, right) {
|
|
1823
|
+
if (left.id && right.id) return left.id === right.id;
|
|
1824
|
+
return left.codes.some(code => right.codes.includes(code));
|
|
1825
|
+
}
|
|
1826
|
+
function mergeWalletAssetIdentity(target, source) {
|
|
1827
|
+
if (!target.id && source.id) target.id = source.id;
|
|
1828
|
+
target.codes = Array.from(new Set([...target.codes, ...source.codes]));
|
|
1829
|
+
}
|
|
1538
1830
|
function getPointCardSnapshotRemainingPoints(snapshot) {
|
|
1539
1831
|
if (!isNumericAmount(snapshot.par_value) || !isNumericAmount(snapshot.used_par_value)) {
|
|
1540
1832
|
return null;
|
|
@@ -1542,19 +1834,26 @@ function getPointCardSnapshotRemainingPoints(snapshot) {
|
|
|
1542
1834
|
return _decimal.default.max(new _decimal.default(snapshot.par_value).minus(new _decimal.default(snapshot.used_par_value)), 0);
|
|
1543
1835
|
}
|
|
1544
1836
|
function buildVoucherAssets(params) {
|
|
1545
|
-
const seenVoucherKeys = new Set();
|
|
1546
1837
|
const fallbackAssetTime = firstPresentValue(params.order.updated_at, params.order.created_at);
|
|
1547
|
-
return normalizeArray(params.order.vouchers).flatMap(
|
|
1838
|
+
return normalizeArray(params.order.vouchers).flatMap(voucher => {
|
|
1548
1839
|
if (!voucher || typeof voucher !== 'object' || Array.isArray(voucher)) return [];
|
|
1549
|
-
|
|
1550
|
-
if (seenVoucherKeys.has(voucherKey)) return [];
|
|
1551
|
-
seenVoucherKeys.add(voucherKey);
|
|
1840
|
+
if (!claimWalletAssetIdentity(params.displayedWalletAssetIdentities, getVoucherAssetIdentity(voucher))) return [];
|
|
1552
1841
|
const name = getVoucherAssetName(voucher, params.locale);
|
|
1553
1842
|
const assetTime = firstPresentValue(voucher.updated_at, voucher.created_at, voucher.collection_time, fallbackAssetTime);
|
|
1554
1843
|
const timeRow = isPresentId(assetTime) ? {
|
|
1555
1844
|
item: formatDateTime(assetTime, params.locale),
|
|
1556
1845
|
value: ''
|
|
1557
1846
|
} : null;
|
|
1847
|
+
if (isEntitlementVoucher(voucher)) {
|
|
1848
|
+
const remaining = getEntitlementBalance(voucher.metadata?.balance, voucher.balance);
|
|
1849
|
+
return [[{
|
|
1850
|
+
item: name,
|
|
1851
|
+
value: ''
|
|
1852
|
+
}, ...(remaining ? [{
|
|
1853
|
+
item: label(params.locale, 'entitlementRemaining'),
|
|
1854
|
+
value: formatEntitlementUses(remaining, params.locale)
|
|
1855
|
+
}] : []), ...(timeRow ? [timeRow] : [])]];
|
|
1856
|
+
}
|
|
1558
1857
|
if (isTicketVoucher(voucher)) {
|
|
1559
1858
|
const validity = getVoucherValidity(voucher, params.locale);
|
|
1560
1859
|
return [[{
|
|
@@ -1583,6 +1882,9 @@ function buildVoucherAssets(params) {
|
|
|
1583
1882
|
});
|
|
1584
1883
|
}
|
|
1585
1884
|
const TICKET_VOUCHER_TAGS = new Set(['ticket', 'product_package_ticket', 'appointment_ticket', 'session_ticket']);
|
|
1885
|
+
function isEntitlementVoucher(voucher) {
|
|
1886
|
+
return [voucher.tag, voucher.type].some(value => stringify(value).trim().toLowerCase() === 'entitlement_pass');
|
|
1887
|
+
}
|
|
1586
1888
|
function isTicketVoucher(voucher) {
|
|
1587
1889
|
return TICKET_VOUCHER_TAGS.has(stringify(voucher.tag).trim().toLowerCase());
|
|
1588
1890
|
}
|
|
@@ -1657,9 +1959,11 @@ function formatVoucherValidityDate(value, locale) {
|
|
|
1657
1959
|
text: time ? `${time} ${date}` : date
|
|
1658
1960
|
};
|
|
1659
1961
|
}
|
|
1660
|
-
function
|
|
1661
|
-
|
|
1662
|
-
|
|
1962
|
+
function getVoucherAssetIdentity(voucher) {
|
|
1963
|
+
return {
|
|
1964
|
+
id: firstNormalizedWalletAssetId(voucher.voucher_id, voucher.id),
|
|
1965
|
+
codes: normalizeWalletAssetCodes(voucher.code, voucher.encoded)
|
|
1966
|
+
};
|
|
1663
1967
|
}
|
|
1664
1968
|
function getVoucherAssetName(voucher, locale) {
|
|
1665
1969
|
return getLocalizedValue(voucher.product_name || voucher.name || voucher.title, locale) || stringify(voucher.encoded || voucher.code || label(locale, 'giftCard'));
|
|
@@ -1685,6 +1989,10 @@ function formatVoucherDiscount(percent, locale) {
|
|
|
1685
1989
|
return normalizedLocale === 'en' ? `Discount ${trimDecimal(percent)}% OFF` : `${trimDecimal(percent)}% OFF`;
|
|
1686
1990
|
}
|
|
1687
1991
|
function getVoucherBalance(voucher) {
|
|
1992
|
+
for (const value of [voucher.metadata?.balance, voucher.balance]) {
|
|
1993
|
+
if (!isNumericAmount(value)) continue;
|
|
1994
|
+
return _decimal.default.max(new _decimal.default(value), 0);
|
|
1995
|
+
}
|
|
1688
1996
|
const parValue = new _decimal.default(toMoneyNumber(voucher.par_value));
|
|
1689
1997
|
const usedParValue = new _decimal.default(toMoneyNumber(voucher.used_par_value));
|
|
1690
1998
|
return _decimal.default.max(parValue.minus(usedParValue), 0);
|
|
@@ -1896,25 +2204,8 @@ function getLocalizedValue(value, locale) {
|
|
|
1896
2204
|
const underscoredLocale = locale.replace('-', '_');
|
|
1897
2205
|
return stringify(value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? value.default ?? value.en ?? '');
|
|
1898
2206
|
}
|
|
1899
|
-
function resolveServiceTypeLabelKey(serviceType
|
|
1900
|
-
|
|
1901
|
-
if (['', 'nil', 'none', 'unknown'].includes(normalized)) return null;
|
|
1902
|
-
if (['pickup', 'pick_up', 'self_pickup'].includes(normalized)) return 'pickUp';
|
|
1903
|
-
if (['delivery', 'shipping', 'local_delivery'].includes(normalized)) return 'delivery';
|
|
1904
|
-
if (['takeaway', 'take_away'].includes(normalized)) return 'takeAway';
|
|
1905
|
-
if (['dine_in', 'dinein'].includes(normalized)) return 'dineIn';
|
|
1906
|
-
if (['shop_service', 'shop_server'].includes(normalized)) {
|
|
1907
|
-
return resolveShopServiceLabelKey(order);
|
|
1908
|
-
}
|
|
1909
|
-
return null;
|
|
1910
|
-
}
|
|
1911
|
-
function resolveShopServiceLabelKey(order) {
|
|
1912
|
-
const rawShopServiceType = firstPresentValue(order.metadata?.shop_service_type?.server_type, order.shop_service_type?.server_type, typeof order.shop_service_type === 'string' ? order.shop_service_type : undefined);
|
|
1913
|
-
if (!isPresentId(rawShopServiceType)) return 'dineIn';
|
|
1914
|
-
const normalized = stringify(rawShopServiceType).trim().toLowerCase().replace(/[\s-]+/g, '_');
|
|
1915
|
-
if (['takeaway', 'take_away'].includes(normalized)) return 'takeAway';
|
|
1916
|
-
if (['dine_in', 'dinein'].includes(normalized)) return 'dineIn';
|
|
1917
|
-
return null;
|
|
2207
|
+
function resolveServiceTypeLabelKey(serviceType) {
|
|
2208
|
+
return SERVICE_TYPE_LABEL_KEYS[serviceType] || null;
|
|
1918
2209
|
}
|
|
1919
2210
|
function normalizeBooleanFlag(value) {
|
|
1920
2211
|
if (value === true || value === 1 || stringify(value).trim() === '1') return 1;
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 6 | 5 | 1 | 2 | 3 | 4;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -347,7 +347,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
347
347
|
* 获取当前的客户搜索条件
|
|
348
348
|
* @returns 当前搜索条件
|
|
349
349
|
*/
|
|
350
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
350
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
351
351
|
/**
|
|
352
352
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
353
353
|
* @returns 客户状态
|