@freedom_sky/feige-lib 5.5.2 → 5.6.0
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/buffet/index.d.ts +1 -1
- package/dist/buffet/index.js +5 -2
- package/dist/const/const.js +12 -0
- package/package.json +1 -1
- package/src/buffet/index.ts +27 -19
- package/src/const/const.ts +12 -0
package/dist/buffet/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare function dishShowPriceWithBuffet({ dishPrice, dishId, buffet, ord
|
|
|
37
37
|
/**
|
|
38
38
|
*
|
|
39
39
|
*/
|
|
40
|
-
export declare function getRoundCoundAndSecondsToNextTurn({ order }: {
|
|
40
|
+
export declare function getRoundCoundAndSecondsToNextTurn({ order, }: {
|
|
41
41
|
order: Order;
|
|
42
42
|
}): {
|
|
43
43
|
roundCount?: number;
|
package/dist/buffet/index.js
CHANGED
|
@@ -63,7 +63,6 @@ function getRoundCoundAndSecondsToNextTurn(_a) {
|
|
|
63
63
|
if (!((_c = buffetCombosItems.orderingByTurns) === null || _c === void 0 ? void 0 : _c.enable)) {
|
|
64
64
|
throw 'Buffet ordering by turns is not enabled';
|
|
65
65
|
}
|
|
66
|
-
;
|
|
67
66
|
var _d = buffetCombosItems.orderingByTurns, interval = _d.interval, maxRounds = _d.maxRounds;
|
|
68
67
|
var previousBuffetSubmitTasks = order.tasks.filter(function (task) {
|
|
69
68
|
return (task.type === index_1.CONST.TASK_TYPE.CHECK || task.type === index_1.CONST.TASK_TYPE.APPEND) &&
|
|
@@ -82,10 +81,14 @@ function getRoundCoundAndSecondsToNextTurn(_a) {
|
|
|
82
81
|
return {
|
|
83
82
|
roundCount: previousBuffetSubmitTasks.length,
|
|
84
83
|
secondsToNextTurn: secondsToNextTurn,
|
|
85
|
-
maxRounds: maxRounds
|
|
84
|
+
maxRounds: maxRounds,
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
87
|
exports.getRoundCoundAndSecondsToNextTurn = getRoundCoundAndSecondsToNextTurn;
|
|
88
|
+
/**
|
|
89
|
+
* @param arr1
|
|
90
|
+
* @param arr2
|
|
91
|
+
*/
|
|
89
92
|
function _haveAtLeastOneSameItem(arr1, arr2) {
|
|
90
93
|
var set1 = new Set(arr1);
|
|
91
94
|
return arr2.some(function (item) { return set1.has(item); });
|
package/dist/const/const.js
CHANGED
|
@@ -492,6 +492,18 @@ var Const = /** @class */ (function () {
|
|
|
492
492
|
codepage: 'cp1253',
|
|
493
493
|
defaultPrintEncodeType: printer_enum_1.EncodeTypeEnum.IMG,
|
|
494
494
|
},
|
|
495
|
+
{
|
|
496
|
+
name: 'العربية',
|
|
497
|
+
img: '',
|
|
498
|
+
code: 'ar',
|
|
499
|
+
speechCode: 'ar-AE',
|
|
500
|
+
speechLang: 'ar',
|
|
501
|
+
dateFormat: common_enum_1.DateFormat.YEAR_MONTH_DAY,
|
|
502
|
+
defaultAreaCode: '971',
|
|
503
|
+
rtl: true,
|
|
504
|
+
codepage: 'utf-8',
|
|
505
|
+
defaultPrintEncodeType: printer_enum_1.EncodeTypeEnum.IMG
|
|
506
|
+
}
|
|
495
507
|
];
|
|
496
508
|
this.DATE_FORMAT = {
|
|
497
509
|
YEAR_MONTH_DAY: {
|
package/package.json
CHANGED
package/src/buffet/index.ts
CHANGED
|
@@ -76,40 +76,48 @@ export function dishShowPriceWithBuffet({
|
|
|
76
76
|
*
|
|
77
77
|
*/
|
|
78
78
|
export function getRoundCoundAndSecondsToNextTurn({
|
|
79
|
-
order
|
|
79
|
+
order,
|
|
80
80
|
}: {
|
|
81
|
-
order: Order
|
|
81
|
+
order: Order;
|
|
82
82
|
}): {
|
|
83
|
-
roundCount?: number
|
|
84
|
-
maxRounds?: number
|
|
85
|
-
secondsToNextTurn: number
|
|
83
|
+
roundCount?: number;
|
|
84
|
+
maxRounds?: number;
|
|
85
|
+
secondsToNextTurn: number;
|
|
86
86
|
} {
|
|
87
87
|
let secondsToNextTurn = 0;
|
|
88
88
|
const buffetCombosItems = order.buffet?.snapshot;
|
|
89
89
|
if (!buffetCombosItems.orderingByTurns?.enable) {
|
|
90
90
|
throw 'Buffet ordering by turns is not enabled';
|
|
91
|
-
}
|
|
91
|
+
}
|
|
92
92
|
const { interval, maxRounds } = buffetCombosItems.orderingByTurns;
|
|
93
|
-
const previousBuffetSubmitTasks = order.tasks.filter(
|
|
94
|
-
(task
|
|
95
|
-
|
|
93
|
+
const previousBuffetSubmitTasks = order.tasks.filter(
|
|
94
|
+
(task) =>
|
|
95
|
+
(task.type === CONST.TASK_TYPE.CHECK || task.type === CONST.TASK_TYPE.APPEND) &&
|
|
96
|
+
_haveAtLeastOneSameItem(
|
|
97
|
+
task.content.map((content) => String(content.dishSnapshot._id)),
|
|
98
|
+
buffetCombosItems.dishes.map((dish) => String(dish.dishId)),
|
|
99
|
+
),
|
|
96
100
|
);
|
|
97
|
-
if(previousBuffetSubmitTasks.length === 0) {
|
|
98
|
-
secondsToNextTurn = 0
|
|
99
|
-
}else if(previousBuffetSubmitTasks.length >= maxRounds) {
|
|
100
|
-
secondsToNextTurn = Infinity
|
|
101
|
-
}else {
|
|
102
|
-
const lastBuffetSubmitTime = previousBuffetSubmitTasks[previousBuffetSubmitTasks.length -1].date;
|
|
101
|
+
if (previousBuffetSubmitTasks.length === 0) {
|
|
102
|
+
secondsToNextTurn = 0;
|
|
103
|
+
} else if (previousBuffetSubmitTasks.length >= maxRounds) {
|
|
104
|
+
secondsToNextTurn = Infinity;
|
|
105
|
+
} else {
|
|
106
|
+
const lastBuffetSubmitTime = previousBuffetSubmitTasks[previousBuffetSubmitTasks.length - 1].date;
|
|
103
107
|
secondsToNextTurn = interval * 60 - Math.floor((Date.now() - new Date(lastBuffetSubmitTime).getTime()) / 1000);
|
|
104
108
|
}
|
|
105
109
|
return {
|
|
106
110
|
roundCount: previousBuffetSubmitTasks.length,
|
|
107
111
|
secondsToNextTurn,
|
|
108
|
-
maxRounds
|
|
109
|
-
}
|
|
112
|
+
maxRounds,
|
|
113
|
+
};
|
|
110
114
|
}
|
|
111
115
|
|
|
116
|
+
/**
|
|
117
|
+
* @param arr1
|
|
118
|
+
* @param arr2
|
|
119
|
+
*/
|
|
112
120
|
function _haveAtLeastOneSameItem<T>(arr1: T[], arr2: T[]): boolean {
|
|
113
121
|
const set1 = new Set(arr1);
|
|
114
|
-
return arr2.some(item => set1.has(item));
|
|
115
|
-
}
|
|
122
|
+
return arr2.some((item) => set1.has(item));
|
|
123
|
+
}
|
package/src/const/const.ts
CHANGED
|
@@ -490,6 +490,18 @@ class Const {
|
|
|
490
490
|
codepage: 'cp1253',
|
|
491
491
|
defaultPrintEncodeType: EncodeTypeEnum.IMG,
|
|
492
492
|
},
|
|
493
|
+
{
|
|
494
|
+
name: 'العربية',
|
|
495
|
+
img: '',
|
|
496
|
+
code: 'ar',
|
|
497
|
+
speechCode: 'ar-AE',
|
|
498
|
+
speechLang: 'ar',
|
|
499
|
+
dateFormat: DateFormat.YEAR_MONTH_DAY,
|
|
500
|
+
defaultAreaCode: '971',
|
|
501
|
+
rtl: true,
|
|
502
|
+
codepage: 'utf-8',
|
|
503
|
+
defaultPrintEncodeType: EncodeTypeEnum.IMG
|
|
504
|
+
}
|
|
493
505
|
];
|
|
494
506
|
DATE_FORMAT = {
|
|
495
507
|
YEAR_MONTH_DAY: {
|