@freedom_sky/feige-lib 4.57.0 → 4.58.1
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/order/index.d.ts +21 -0
- package/dist/order/index.js +59 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/order/index.ts +92 -0
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ import * as moment from 'moment';
|
|
|
33
33
|
import Big from 'big.js';
|
|
34
34
|
import { OrderTypeEnum } from './enum/order.enum';
|
|
35
35
|
export * from './buffet/index';
|
|
36
|
+
export * from './order/index';
|
|
36
37
|
export { Order, Process, Content, Checkout, CONST, DishSnapshot, User, UserSafe, CertificatePath, Task, VisitTask, moment, PrintStatusEnum, PrinterDeviceTypeEnum, PrinterWidthEnum, Big, };
|
|
37
38
|
/**
|
|
38
39
|
* 小数转化为金额,去除分位之后的尾数
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Order, Content } from '../index';
|
|
2
|
+
export interface PrinteDishInfo {
|
|
3
|
+
name: string;
|
|
4
|
+
count: number;
|
|
5
|
+
price: number;
|
|
6
|
+
specifications: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare function getDishArrFromContents({ contents, lang, specificationInNewLine, order, showBuffet, text, }: {
|
|
12
|
+
contents: Content[];
|
|
13
|
+
lang: string;
|
|
14
|
+
specificationInNewLine: boolean;
|
|
15
|
+
order: Order;
|
|
16
|
+
showBuffet?: boolean;
|
|
17
|
+
text?: {
|
|
18
|
+
adult: string;
|
|
19
|
+
child: string;
|
|
20
|
+
};
|
|
21
|
+
}): PrinteDishInfo[];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var index_1 = require("../index");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
function getDishArrFromContents(_a) {
|
|
8
|
+
var contents = _a.contents, lang = _a.lang, specificationInNewLine = _a.specificationInNewLine, order = _a.order, showBuffet = _a.showBuffet, text = _a.text;
|
|
9
|
+
var result = contents.map(function (dishGroup) {
|
|
10
|
+
var _a;
|
|
11
|
+
var selectedNames = [];
|
|
12
|
+
dishGroup.dishSnapshot.selectedSpecifications.forEach(function (selectedItems) {
|
|
13
|
+
selectedItems.content.forEach(function (tag) {
|
|
14
|
+
selectedNames.push(tag.name);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var name = index_1.getNameFromNames(dishGroup.dishSnapshot.names, lang, index_1.CONST.DEFALUT_LANGUAGE) || '';
|
|
18
|
+
if (!specificationInNewLine && selectedNames.length > 0) {
|
|
19
|
+
name += "(" + selectedNames.join() + ")";
|
|
20
|
+
}
|
|
21
|
+
if (dishGroup.dishSnapshot.type === index_1.DishType.Weigh) {
|
|
22
|
+
name += "(" + dishGroup.weight + (index_1.getNameFromNames(dishGroup.dishSnapshot.units, lang, index_1.CONST.DEFALUT_LANGUAGE) || '') + ")";
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
name: name,
|
|
26
|
+
count: dishGroup.count,
|
|
27
|
+
price: index_1.calcContentPrice({
|
|
28
|
+
orderContentItem: dishGroup,
|
|
29
|
+
buffetItem: (_a = order.buffet) === null || _a === void 0 ? void 0 : _a.snapshot,
|
|
30
|
+
orderType: order.type,
|
|
31
|
+
adultNum: order.adultNum,
|
|
32
|
+
childNum: order.childNum,
|
|
33
|
+
contents: order.content,
|
|
34
|
+
}) / dishGroup.count,
|
|
35
|
+
specifications: selectedNames,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
if (showBuffet && order.type === index_1.OrderTypeEnum.Buffet) {
|
|
39
|
+
var specifications = [];
|
|
40
|
+
if (specificationInNewLine) {
|
|
41
|
+
if (order.adultNum) {
|
|
42
|
+
specifications.push("" + (text === null || text === void 0 ? void 0 : text.adult) + order.adultNum);
|
|
43
|
+
}
|
|
44
|
+
if (order.childNum) {
|
|
45
|
+
specifications.push("" + (text === null || text === void 0 ? void 0 : text.child) + order.childNum);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
result.unshift({
|
|
49
|
+
name: index_1.getNameFromNames(order.buffet.snapshot.names, lang, index_1.CONST.DEFALUT_LANGUAGE) + specificationInNewLine
|
|
50
|
+
? ''
|
|
51
|
+
: "(" + specifications.join() + ")",
|
|
52
|
+
count: 1,
|
|
53
|
+
price: index_1.calcBuffetTotalPrice(order.buffet.snapshot, order.adultNum, order.childNum),
|
|
54
|
+
specifications: specifications,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
exports.getDishArrFromContents = getDishArrFromContents;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ import { TaxTypeEnum } from './enum/tax.enum';
|
|
|
36
36
|
import { OrderTypeEnum } from './enum/order.enum';
|
|
37
37
|
import { calcBuffetTotalPrice, getDishItemInBuffet, getMaxBuffetDishUpperLimit } from './buffet/index';
|
|
38
38
|
export * from './buffet/index';
|
|
39
|
+
export * from './order/index';
|
|
39
40
|
export {
|
|
40
41
|
Order,
|
|
41
42
|
Process,
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DishType,
|
|
3
|
+
Order,
|
|
4
|
+
CONST,
|
|
5
|
+
getNameFromNames,
|
|
6
|
+
Content,
|
|
7
|
+
calcBuffetTotalPrice,
|
|
8
|
+
calcContentPrice,
|
|
9
|
+
OrderTypeEnum,
|
|
10
|
+
} from '../index';
|
|
11
|
+
|
|
12
|
+
export interface PrinteDishInfo {
|
|
13
|
+
name: string;
|
|
14
|
+
count: number;
|
|
15
|
+
price: number;
|
|
16
|
+
specifications: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export function getDishArrFromContents({
|
|
23
|
+
contents,
|
|
24
|
+
lang,
|
|
25
|
+
specificationInNewLine,
|
|
26
|
+
order,
|
|
27
|
+
showBuffet,
|
|
28
|
+
text,
|
|
29
|
+
}: {
|
|
30
|
+
contents: Content[];
|
|
31
|
+
lang: string;
|
|
32
|
+
specificationInNewLine: boolean;
|
|
33
|
+
order: Order;
|
|
34
|
+
showBuffet?: boolean;
|
|
35
|
+
text?: {
|
|
36
|
+
adult: string;
|
|
37
|
+
child: string;
|
|
38
|
+
};
|
|
39
|
+
}): PrinteDishInfo[] {
|
|
40
|
+
const result = contents.map((dishGroup) => {
|
|
41
|
+
const selectedNames = [];
|
|
42
|
+
dishGroup.dishSnapshot.selectedSpecifications.forEach((selectedItems) => {
|
|
43
|
+
selectedItems.content.forEach((tag) => {
|
|
44
|
+
selectedNames.push(tag.name);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
let name = getNameFromNames(dishGroup.dishSnapshot.names, lang, CONST.DEFALUT_LANGUAGE) || '';
|
|
48
|
+
if (!specificationInNewLine && selectedNames.length > 0) {
|
|
49
|
+
name += `(${selectedNames.join()})`;
|
|
50
|
+
}
|
|
51
|
+
if (dishGroup.dishSnapshot.type === DishType.Weigh) {
|
|
52
|
+
name += `(${dishGroup.weight}${
|
|
53
|
+
getNameFromNames(dishGroup.dishSnapshot.units, lang, CONST.DEFALUT_LANGUAGE) || ''
|
|
54
|
+
})`;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
name,
|
|
58
|
+
count: dishGroup.count,
|
|
59
|
+
price:
|
|
60
|
+
calcContentPrice({
|
|
61
|
+
orderContentItem: dishGroup,
|
|
62
|
+
buffetItem: order.buffet?.snapshot,
|
|
63
|
+
orderType: order.type,
|
|
64
|
+
adultNum: order.adultNum,
|
|
65
|
+
childNum: order.childNum,
|
|
66
|
+
contents: order.content,
|
|
67
|
+
}) / dishGroup.count,
|
|
68
|
+
specifications: selectedNames,
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
if (showBuffet && order.type === OrderTypeEnum.Buffet) {
|
|
72
|
+
const specifications = [];
|
|
73
|
+
if (specificationInNewLine) {
|
|
74
|
+
if (order.adultNum) {
|
|
75
|
+
specifications.push(`${text?.adult}${order.adultNum}`);
|
|
76
|
+
}
|
|
77
|
+
if (order.childNum) {
|
|
78
|
+
specifications.push(`${text?.child}${order.childNum}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
result.unshift({
|
|
82
|
+
name:
|
|
83
|
+
getNameFromNames(order.buffet.snapshot.names, lang, CONST.DEFALUT_LANGUAGE) + specificationInNewLine
|
|
84
|
+
? ''
|
|
85
|
+
: `(${specifications.join()})`,
|
|
86
|
+
count: 1,
|
|
87
|
+
price: calcBuffetTotalPrice(order.buffet.snapshot, order.adultNum, order.childNum),
|
|
88
|
+
specifications: specifications,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|