@pisell/pisellos 2.3.189 → 2.3.191
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +1100 -974
- package/dist/shared/receipt/small-ticket.js +33 -5
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/index.js +8 -5
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.d.ts +3 -0
- package/lib/server/index.js +81 -4
- package/lib/shared/receipt/small-ticket.js +30 -5
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +8 -2
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/package.json +1 -1
|
@@ -85,6 +85,7 @@ const LABELS = {
|
|
|
85
85
|
cashReceived: 'Cash received',
|
|
86
86
|
changeDue: 'Change due',
|
|
87
87
|
eftpos: 'Eftpos',
|
|
88
|
+
creditCard: 'Credit card',
|
|
88
89
|
wallet: 'Wallet',
|
|
89
90
|
giftCard: 'Gift card',
|
|
90
91
|
pointCard: 'Point card',
|
|
@@ -131,6 +132,7 @@ const LABELS = {
|
|
|
131
132
|
cashReceived: '收取现金',
|
|
132
133
|
changeDue: '找零',
|
|
133
134
|
eftpos: '刷卡支付',
|
|
135
|
+
creditCard: '信用卡',
|
|
134
136
|
wallet: '钱包支付',
|
|
135
137
|
giftCard: '礼品卡',
|
|
136
138
|
pointCard: '积分卡',
|
|
@@ -177,6 +179,7 @@ const LABELS = {
|
|
|
177
179
|
cashReceived: '收取現金',
|
|
178
180
|
changeDue: '找零',
|
|
179
181
|
eftpos: '刷卡支付',
|
|
182
|
+
creditCard: '信用卡',
|
|
180
183
|
wallet: '錢包支付',
|
|
181
184
|
giftCard: '禮品卡',
|
|
182
185
|
pointCard: '積分卡',
|
|
@@ -221,6 +224,7 @@ const LABELS = {
|
|
|
221
224
|
asap: 'できるだけ早く',
|
|
222
225
|
cash: '現金',
|
|
223
226
|
eftpos: 'カード',
|
|
227
|
+
creditCard: 'クレジットカード',
|
|
224
228
|
wallet: 'ウォレット',
|
|
225
229
|
giftCard: 'ギフトカード',
|
|
226
230
|
pointCard: 'ポイントカード',
|
|
@@ -266,6 +270,7 @@ const LABELS = {
|
|
|
266
270
|
asap: 'Assim que possível',
|
|
267
271
|
cash: 'Dinheiro',
|
|
268
272
|
eftpos: 'Cartão',
|
|
273
|
+
creditCard: 'Cartão de crédito',
|
|
269
274
|
wallet: 'Carteira',
|
|
270
275
|
giftCard: 'Cartão-presente',
|
|
271
276
|
pointCard: 'Cartão de pontos',
|
|
@@ -2438,12 +2443,30 @@ function appendMaskedCardCode(name, code) {
|
|
|
2438
2443
|
function trimDecimal(value) {
|
|
2439
2444
|
return value.toDecimalPlaces(2).toFixed(2).replace(/\.?0+$/, '');
|
|
2440
2445
|
}
|
|
2446
|
+
function getLocalizedPaymentName(value, locale) {
|
|
2447
|
+
if (typeof value === 'string') return value.trim();
|
|
2448
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return '';
|
|
2449
|
+
const candidates = [value[locale], value[locale.replace('_', '-')], value[locale.replace('-', '_')], value.original, value.auto, value.default, value.en];
|
|
2450
|
+
for (const candidate of candidates) {
|
|
2451
|
+
if (typeof candidate === 'string' && candidate.trim()) return candidate.trim();
|
|
2452
|
+
}
|
|
2453
|
+
return '';
|
|
2454
|
+
}
|
|
2455
|
+
function getExplicitPaymentName(payment, locale) {
|
|
2456
|
+
// Cloud order snapshots retain the localized name in metadata after reload.
|
|
2457
|
+
const candidates = [payment.name, payment.title, payment.payment_method_name, payment.method_name, payment.metadata?.custom_payment_name];
|
|
2458
|
+
for (const candidate of candidates) {
|
|
2459
|
+
const name = getLocalizedPaymentName(candidate, locale);
|
|
2460
|
+
if (name) return name;
|
|
2461
|
+
}
|
|
2462
|
+
return '';
|
|
2463
|
+
}
|
|
2441
2464
|
function getFundRecordPaymentName(payment, locale) {
|
|
2442
2465
|
const fundRecord = getFundRecord(payment);
|
|
2443
2466
|
if (!fundRecord) return '';
|
|
2444
|
-
const name =
|
|
2467
|
+
const name = getLocalizedPaymentName(fundRecord.wallet_pass_name, locale);
|
|
2445
2468
|
if (!name && !maskMachineCode(fundRecord.code)) return '';
|
|
2446
|
-
const fallbackName =
|
|
2469
|
+
const fallbackName = getExplicitPaymentName(payment, locale) || getLocalizedPaymentName(payment.code, locale);
|
|
2447
2470
|
return appendMaskedCardCode(name || fallbackName, fundRecord.code);
|
|
2448
2471
|
}
|
|
2449
2472
|
function appendMachineCodeToName(name, payment) {
|
|
@@ -2453,13 +2476,15 @@ function appendMachineCodeToName(name, payment) {
|
|
|
2453
2476
|
function paymentMethodName(payment, locale) {
|
|
2454
2477
|
const fundRecordName = getFundRecordPaymentName(payment, locale);
|
|
2455
2478
|
if (fundRecordName) return fundRecordName;
|
|
2456
|
-
const
|
|
2457
|
-
if (
|
|
2479
|
+
const name = getExplicitPaymentName(payment, locale);
|
|
2480
|
+
if (name) return appendMachineCodeToName(name, payment);
|
|
2458
2481
|
const code = stringify(payment.code || payment.type || payment.payment_method || payment.method).toLowerCase();
|
|
2459
2482
|
if (code.includes('cash')) return label(locale, 'cash');
|
|
2460
|
-
if (code.includes('eftpos')
|
|
2483
|
+
if (code.includes('eftpos')) return label(locale, 'eftpos');
|
|
2461
2484
|
if (code.includes('wallet')) return label(locale, 'wallet');
|
|
2462
2485
|
if (code.includes('gift')) return label(locale, 'giftCard');
|
|
2486
|
+
if (code === 'credit_card' || code.startsWith('credit_card_')) return label(locale, 'creditCard');
|
|
2487
|
+
if (code.includes('card')) return label(locale, 'eftpos');
|
|
2463
2488
|
return stringify(payment.code || payment.type || payment.payment_method || payment.method);
|
|
2464
2489
|
}
|
|
2465
2490
|
function getSummary(order) {
|
|
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
328
328
|
date: string;
|
|
329
329
|
status: string;
|
|
330
330
|
week: string;
|
|
331
|
-
weekNum: 0 | 2 | 1 |
|
|
331
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
375
375
|
};
|
|
376
376
|
setOtherData(key: string, value: any): void;
|
|
377
377
|
getOtherData(key: string): any;
|
|
378
|
-
getProductTypeById(id: number): Promise<"
|
|
378
|
+
getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
|
|
379
379
|
/**
|
|
380
380
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
381
381
|
*
|
|
@@ -2222,11 +2222,17 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2222
2222
|
start_at: (0, _dayjs.default)(item.start),
|
|
2223
2223
|
end_at: (0, _dayjs.default)(item.end)
|
|
2224
2224
|
})) {
|
|
2225
|
-
mSet.set(m.id,
|
|
2225
|
+
mSet.set(m.id, {
|
|
2226
|
+
...m,
|
|
2227
|
+
pax: m.pax ?? 1
|
|
2228
|
+
});
|
|
2226
2229
|
}
|
|
2227
2230
|
});
|
|
2228
2231
|
});
|
|
2229
|
-
acc += Array.from(mSet.values())
|
|
2232
|
+
acc += (0, _resources.getPeakConcurrentPax)(Array.from(mSet.values()), {
|
|
2233
|
+
start_at: (0, _dayjs.default)(item.start),
|
|
2234
|
+
end_at: (0, _dayjs.default)(item.end)
|
|
2235
|
+
});
|
|
2230
2236
|
return acc;
|
|
2231
2237
|
}, 0);
|
|
2232
2238
|
// 如果已使用容量超过了当前类型资源的容量,则不可用
|
|
@@ -7,6 +7,11 @@ import { CartItem, ProductData } from '../../../modules';
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
type DateType = Dayjs;
|
|
10
|
+
interface EventItem {
|
|
11
|
+
pax: number;
|
|
12
|
+
start_at: DateType;
|
|
13
|
+
end_at: DateType;
|
|
14
|
+
}
|
|
10
15
|
export interface TimeSliceItem {
|
|
11
16
|
start_time: string;
|
|
12
17
|
end_time: string;
|
|
@@ -20,6 +25,11 @@ export interface ResourceItem {
|
|
|
20
25
|
interface BookingItem {
|
|
21
26
|
[key: string]: any;
|
|
22
27
|
}
|
|
28
|
+
/** 计算目标区间内的最大同时占用人数;事件去重由调用方负责。 */
|
|
29
|
+
export declare const getPeakConcurrentPax: (eventList: EventItem[], timeSlice: {
|
|
30
|
+
start_at: DateType;
|
|
31
|
+
end_at: DateType;
|
|
32
|
+
}) => number;
|
|
23
33
|
/**
|
|
24
34
|
* @title: 判断两个时间段是否有重叠
|
|
25
35
|
* @description:
|
|
@@ -7,7 +7,7 @@ exports.checkSessionProductLeadTime = checkSessionProductLeadTime;
|
|
|
7
7
|
exports.checkTwoResourcesIntersection = checkTwoResourcesIntersection;
|
|
8
8
|
exports.filterResourcesByFormItem = filterResourcesByFormItem;
|
|
9
9
|
exports.filterScheduleByDateRange = filterScheduleByDateRange;
|
|
10
|
-
exports.getResourcesByProduct = exports.getResourcesByIds = exports.getOthersSelectedResources = exports.getOthersCartSelectedResources = exports.getIsUsableByTimeItem = exports.formatResources = void 0;
|
|
10
|
+
exports.getResourcesByProduct = exports.getResourcesByIds = exports.getPeakConcurrentPax = exports.getOthersSelectedResources = exports.getOthersCartSelectedResources = exports.getIsUsableByTimeItem = exports.formatResources = void 0;
|
|
11
11
|
exports.getResourcesIdsByProduct = getResourcesIdsByProduct;
|
|
12
12
|
exports.mergeSubResourcesTimeSlices = exports.isConflict = exports.getTimesIntersection = exports.getTimeSlicesByResources = exports.getTimeSlicesByResource = void 0;
|
|
13
13
|
exports.sortCombinedResources = sortCombinedResources;
|
|
@@ -20,18 +20,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
/** 计算目标区间内的最大同时占用人数;事件去重由调用方负责。 */
|
|
24
|
+
const getPeakConcurrentPax = (eventList, timeSlice) => {
|
|
25
|
+
const start = (0, _dayjs.default)(timeSlice.start_at).valueOf();
|
|
26
|
+
const end = (0, _dayjs.default)(timeSlice.end_at).valueOf();
|
|
27
|
+
const changes = new Map();
|
|
28
|
+
for (const event of eventList || []) {
|
|
29
|
+
const eventStart = Math.max(start, (0, _dayjs.default)(event.start_at).valueOf());
|
|
30
|
+
const eventEnd = Math.min(end, (0, _dayjs.default)(event.end_at).valueOf());
|
|
31
|
+
if (!(eventStart < eventEnd)) continue;
|
|
32
|
+
const pax = Number(event.pax);
|
|
33
|
+
changes.set(eventStart, (changes.get(eventStart) ?? 0) + pax);
|
|
34
|
+
changes.set(eventEnd, (changes.get(eventEnd) ?? 0) - pax);
|
|
35
|
+
}
|
|
36
|
+
let current = 0;
|
|
37
|
+
let peak = 0;
|
|
38
|
+
// 同一时刻合并增减量,保持 [start, end) 语义,首尾相接不叠加。
|
|
39
|
+
for (const [, change] of [...changes].sort(([a], [b]) => a - b)) {
|
|
40
|
+
current += change;
|
|
41
|
+
peak = Math.max(peak, current);
|
|
42
|
+
}
|
|
43
|
+
return peak;
|
|
35
44
|
};
|
|
36
45
|
|
|
37
46
|
/**
|
|
@@ -42,6 +51,7 @@ const getUseableEventCount = (eventList, current) => {
|
|
|
42
51
|
* @return {*}
|
|
43
52
|
* @Author: zhiwei.Wang
|
|
44
53
|
*/
|
|
54
|
+
exports.getPeakConcurrentPax = getPeakConcurrentPax;
|
|
45
55
|
const isConflict = (event, current) => {
|
|
46
56
|
const eventStart = (0, _dayjs.default)(event.start_at);
|
|
47
57
|
const eventEnd = (0, _dayjs.default)(event.end_at);
|
|
@@ -132,8 +142,8 @@ const checkCapacity = ({
|
|
|
132
142
|
});
|
|
133
143
|
});
|
|
134
144
|
|
|
135
|
-
//
|
|
136
|
-
|
|
145
|
+
// 多人预约按同时占用峰值扣减,不能把先后到访的所有人数相加。
|
|
146
|
+
const conflictCount = resource.resourceType === 'single' ? conflict.reduce((remaining, event) => remaining - event.pax, resource.capacity || 0) : (resource.capacity || 0) - getPeakConcurrentPax(conflict, timeSlice);
|
|
137
147
|
|
|
138
148
|
// 同一时间段内只能进行一个预约,无论容量是否已满。
|
|
139
149
|
if (resource.resourceType === 'single') {
|