@freedom_sky/feige-lib 4.51.6 → 4.52.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/.eslintrc.js CHANGED
@@ -9,5 +9,8 @@
9
9
  parserOptions: {
10
10
  ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
11
11
  sourceType: "module" // Allows for the use of imports
12
- }
12
+ },
13
+ rules: {
14
+ '@typescript-eslint/no-use-before-define': 'off',
15
+ },
13
16
  };
@@ -0,0 +1,11 @@
1
+ export declare enum AnnouncementType {
2
+ Text = "text",
3
+ Image = "image"
4
+ }
5
+ export declare enum AnnouncementTarget {
6
+ Table = "table",
7
+ Buffet = "buffet",
8
+ Serial = "serial",
9
+ PickUp = "pickup",
10
+ Delivery = "delivery"
11
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var AnnouncementType;
4
+ (function (AnnouncementType) {
5
+ AnnouncementType["Text"] = "text";
6
+ AnnouncementType["Image"] = "image";
7
+ })(AnnouncementType = exports.AnnouncementType || (exports.AnnouncementType = {}));
8
+ var AnnouncementTarget;
9
+ (function (AnnouncementTarget) {
10
+ AnnouncementTarget["Table"] = "table";
11
+ AnnouncementTarget["Buffet"] = "buffet";
12
+ AnnouncementTarget["Serial"] = "serial";
13
+ AnnouncementTarget["PickUp"] = "pickup";
14
+ AnnouncementTarget["Delivery"] = "delivery";
15
+ })(AnnouncementTarget = exports.AnnouncementTarget || (exports.AnnouncementTarget = {}));
@@ -1,22 +1,36 @@
1
- import { BuffetCombosItems, BuffetDishItem } from "../index";
1
+ import { BuffetCombosItems, BuffetDishItem } from '../index';
2
2
  /**
3
3
  * 计算自助餐总价
4
4
  */
5
- export declare function calcBuffetTotalPrice(buffetCombosItem: BuffetCombosItems, adultNum: number, childNum: number): number;
6
- export declare function dishShowPriceWithBuffet({ dishPrice, dishId, buffet, orderedCound, adultNum, childNum }: {
7
- dishPrice: number;
5
+ /**
6
+ *
7
+ */
8
+ export declare function getDishItemInBuffet({ dishId, buffet, }: {
8
9
  dishId: string;
9
10
  buffet?: BuffetCombosItems;
10
- orderedCound: number;
11
+ }): BuffetDishItem | undefined;
12
+ /**
13
+ *
14
+ */
15
+ export declare function getMaxBuffetDishUpperLimit({ buffetDishItem, adultNum, childNum, }: {
16
+ buffetDishItem: BuffetDishItem;
11
17
  adultNum: number;
12
18
  childNum: number;
13
19
  }): number;
14
- export declare function getDishItemInBuffet({ dishId, buffet }: {
20
+ /**
21
+ * @param buffetCombosItem
22
+ * @param adultNum
23
+ * @param childNum
24
+ */
25
+ export declare function calcBuffetTotalPrice(buffetCombosItem: BuffetCombosItems, adultNum: number, childNum: number): number;
26
+ /**
27
+ *
28
+ */
29
+ export declare function dishShowPriceWithBuffet({ dishPrice, dishId, buffet, orderedCound, adultNum, childNum, }: {
30
+ dishPrice: number;
15
31
  dishId: string;
16
32
  buffet?: BuffetCombosItems;
17
- }): BuffetDishItem | undefined;
18
- export declare function getMaxBuffetDishUpperLimit({ buffetDishItem, adultNum, childNum }: {
19
- buffetDishItem: BuffetDishItem;
33
+ orderedCound: number;
20
34
  adultNum: number;
21
35
  childNum: number;
22
36
  }): number;
@@ -3,10 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /**
4
4
  * 计算自助餐总价
5
5
  */
6
+ /**
7
+ *
8
+ */
9
+ function getDishItemInBuffet(_a) {
10
+ var dishId = _a.dishId, buffet = _a.buffet;
11
+ return buffet === null || buffet === void 0 ? void 0 : buffet.dishes.find(function (item) { return String(item.dishId) === String(dishId); });
12
+ }
13
+ exports.getDishItemInBuffet = getDishItemInBuffet;
14
+ /**
15
+ *
16
+ */
17
+ function getMaxBuffetDishUpperLimit(_a) {
18
+ var buffetDishItem = _a.buffetDishItem, adultNum = _a.adultNum, childNum = _a.childNum;
19
+ if (!buffetDishItem)
20
+ throw 'No buffet dish item';
21
+ if (!buffetDishItem.upperLimit.enable)
22
+ return Infinity;
23
+ return Math.ceil(buffetDishItem.upperLimit.adult * adultNum + buffetDishItem.upperLimit.child * childNum);
24
+ }
25
+ exports.getMaxBuffetDishUpperLimit = getMaxBuffetDishUpperLimit;
26
+ /**
27
+ * @param buffetCombosItem
28
+ * @param adultNum
29
+ * @param childNum
30
+ */
6
31
  function calcBuffetTotalPrice(buffetCombosItem, adultNum, childNum) {
7
32
  return buffetCombosItem.price.adult * adultNum + buffetCombosItem.price.child * childNum;
8
33
  }
9
34
  exports.calcBuffetTotalPrice = calcBuffetTotalPrice;
35
+ /**
36
+ *
37
+ */
10
38
  function dishShowPriceWithBuffet(_a) {
11
39
  var dishPrice = _a.dishPrice, dishId = _a.dishId, buffet = _a.buffet, orderedCound = _a.orderedCound, adultNum = _a.adultNum, childNum = _a.childNum;
12
40
  var buffetDishItem = getDishItemInBuffet({ dishId: dishId, buffet: buffet });
@@ -23,17 +51,3 @@ function dishShowPriceWithBuffet(_a) {
23
51
  }
24
52
  }
25
53
  exports.dishShowPriceWithBuffet = dishShowPriceWithBuffet;
26
- function getDishItemInBuffet(_a) {
27
- var dishId = _a.dishId, buffet = _a.buffet;
28
- return buffet === null || buffet === void 0 ? void 0 : buffet.dishes.find(function (item) { return String(item.dishId) === String(dishId); });
29
- }
30
- exports.getDishItemInBuffet = getDishItemInBuffet;
31
- function getMaxBuffetDishUpperLimit(_a) {
32
- var buffetDishItem = _a.buffetDishItem, adultNum = _a.adultNum, childNum = _a.childNum;
33
- if (!buffetDishItem)
34
- throw 'No buffet dish item';
35
- if (!buffetDishItem.upperLimit.enable)
36
- return Infinity;
37
- return Math.ceil(buffetDishItem.upperLimit.adult * adultNum + buffetDishItem.upperLimit.child * childNum);
38
- }
39
- exports.getMaxBuffetDishUpperLimit = getMaxBuffetDishUpperLimit;
@@ -26,6 +26,7 @@ export declare enum TimeZoneEnum {
26
26
  'UTC+8' = 8,
27
27
  'UTC+9' = 9,
28
28
  'UTC+9.5' = 9.5,
29
+ 'UTC+10.5' = 10.5,
29
30
  'UTC+10' = 10,
30
31
  'UTC+11' = 11,
31
32
  'UTC+12' = 12
@@ -29,6 +29,7 @@ var TimeZoneEnum;
29
29
  TimeZoneEnum[TimeZoneEnum["UTC+8"] = 8] = "UTC+8";
30
30
  TimeZoneEnum[TimeZoneEnum["UTC+9"] = 9] = "UTC+9";
31
31
  TimeZoneEnum[TimeZoneEnum["UTC+9.5"] = 9.5] = "UTC+9.5";
32
+ TimeZoneEnum[TimeZoneEnum["UTC+10.5"] = 10.5] = "UTC+10.5";
32
33
  TimeZoneEnum[TimeZoneEnum["UTC+10"] = 10] = "UTC+10";
33
34
  TimeZoneEnum[TimeZoneEnum["UTC+11"] = 11] = "UTC+11";
34
35
  TimeZoneEnum[TimeZoneEnum["UTC+12"] = 12] = "UTC+12";
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export * from './enum/visit-task.enum';
21
21
  export * from './enum/receptionist.enum';
22
22
  export * from './enum/from.enum';
23
23
  export * from './enum/role.enum';
24
+ export * from './announcement/enum/announcement.enum';
24
25
  export * from './interfaces/member/member.interface';
25
26
  export * from './interfaces/member/member-transaction.interface';
26
27
  export * from './interfaces/store/store.interface';
@@ -56,7 +57,10 @@ export declare function calcDishFinalPrice(conent: Content): number;
56
57
  *
57
58
  */
58
59
  export declare function calcTotalPrice(order: Order): number;
59
- export declare function calcContentPrice({ orderContentItem, buffetItem, orderType, adultNum, childNum, contents }: {
60
+ /**
61
+ *
62
+ */
63
+ export declare function calcContentPrice({ orderContentItem, buffetItem, orderType, adultNum, childNum, contents, }: {
60
64
  orderContentItem: Content;
61
65
  buffetItem: BuffetCombosItems;
62
66
  orderType: OrderTypeEnum;
@@ -64,6 +68,11 @@ export declare function calcContentPrice({ orderContentItem, buffetItem, orderTy
64
68
  childNum: number;
65
69
  contents: Content[];
66
70
  }): number;
71
+ /**
72
+ * @param dishId
73
+ * @param contents
74
+ * @param beforeKey
75
+ */
67
76
  export declare function getOrderedCountByDishId(dishId: any, contents: Content[], beforeKey?: string): number;
68
77
  /**
69
78
  * 计算处理后的应收金额
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ __export(require("./enum/visit-task.enum"));
26
26
  __export(require("./enum/receptionist.enum"));
27
27
  __export(require("./enum/from.enum"));
28
28
  __export(require("./enum/role.enum"));
29
+ __export(require("./announcement/enum/announcement.enum"));
29
30
  var pay_company_enum_1 = require("./enum/pay-company.enum");
30
31
  exports.PayCompanyEnum = pay_company_enum_1.PayCompanyEnum;
31
32
  var moment = require("moment");
@@ -96,7 +97,7 @@ function calcTotalPrice(order) {
96
97
  orderType: order.type,
97
98
  adultNum: order.adultNum,
98
99
  childNum: order.childNum,
99
- contents: order.content
100
+ contents: order.content,
100
101
  });
101
102
  });
102
103
  if (order.deliveryFee && !order.selfPickUp) {
@@ -108,12 +109,19 @@ function calcTotalPrice(order) {
108
109
  return parseMoney(totalPrice);
109
110
  }
110
111
  exports.calcTotalPrice = calcTotalPrice;
112
+ /**
113
+ *
114
+ */
111
115
  function calcContentPrice(_a) {
112
116
  var orderContentItem = _a.orderContentItem, buffetItem = _a.buffetItem, orderType = _a.orderType, adultNum = _a.adultNum, childNum = _a.childNum, contents = _a.contents;
113
117
  if (orderType === order_enum_1.OrderTypeEnum.Buffet) {
114
118
  var buffetDishItem = index_1.getDishItemInBuffet({ dishId: orderContentItem.dishSnapshot._id, buffet: buffetItem });
115
119
  if (buffetDishItem) {
116
- var maxUpperLimit = index_1.getMaxBuffetDishUpperLimit({ buffetDishItem: buffetDishItem, adultNum: adultNum, childNum: childNum });
120
+ var maxUpperLimit = index_1.getMaxBuffetDishUpperLimit({
121
+ buffetDishItem: buffetDishItem,
122
+ adultNum: adultNum,
123
+ childNum: childNum,
124
+ });
117
125
  var beforeCount = getOrderedCountByDishId(orderContentItem.dishSnapshot._id, contents, orderContentItem._id);
118
126
  var maxUpperLimitForThisItem = Math.max(maxUpperLimit - beforeCount, 0);
119
127
  if (maxUpperLimitForThisItem >= orderContentItem.count) {
@@ -132,6 +140,11 @@ function calcContentPrice(_a) {
132
140
  }
133
141
  }
134
142
  exports.calcContentPrice = calcContentPrice;
143
+ /**
144
+ * @param dishId
145
+ * @param contents
146
+ * @param beforeKey
147
+ */
135
148
  function getOrderedCountByDishId(dishId, contents, beforeKey) {
136
149
  var count = 0;
137
150
  for (var _i = 0, _a = contents.filter(function (content) { return String(content.dishSnapshot._id) === String(dishId); }); _i < _a.length; _i++) {
@@ -173,7 +186,14 @@ function calcReceivablePrice(order, processArr, noTax) {
173
186
  if (orderContentItem.dishSnapshot.noFullOrderDiscount) {
174
187
  return;
175
188
  }
176
- var dishTotalPrice = calcContentPrice({ orderContentItem: orderContentItem, buffetItem: (_a = order.buffet) === null || _a === void 0 ? void 0 : _a.snapshot, orderType: order.type, adultNum: order.adultNum, childNum: order.childNum, contents: order.content });
189
+ var dishTotalPrice = calcContentPrice({
190
+ orderContentItem: orderContentItem,
191
+ buffetItem: (_a = order.buffet) === null || _a === void 0 ? void 0 : _a.snapshot,
192
+ orderType: order.type,
193
+ adultNum: order.adultNum,
194
+ childNum: order.childNum,
195
+ contents: order.content,
196
+ });
177
197
  totalDiscountPrice += dishTotalPrice;
178
198
  volume_1 += dishTotalPrice * rate_1;
179
199
  });
@@ -221,7 +241,14 @@ function calcReceivablePrice(order, processArr, noTax) {
221
241
  return;
222
242
  }
223
243
  var discountValue = (_a = sortedProcessArr.find(function (process) { return process.type === const_1.CONST.RECEIVABLE_PROCESSING_TYPE.DISCOUNT.TYPE; })) === null || _a === void 0 ? void 0 : _a.value;
224
- var dishTotalPrice = calcContentPrice({ orderContentItem: orderContentItem, buffetItem: (_b = order.buffet) === null || _b === void 0 ? void 0 : _b.snapshot, orderType: order.type, adultNum: order.adultNum, childNum: order.childNum, contents: order.content });
244
+ var dishTotalPrice = calcContentPrice({
245
+ orderContentItem: orderContentItem,
246
+ buffetItem: (_b = order.buffet) === null || _b === void 0 ? void 0 : _b.snapshot,
247
+ orderType: order.type,
248
+ adultNum: order.adultNum,
249
+ childNum: order.childNum,
250
+ contents: order.content,
251
+ });
225
252
  if (discountValue && !orderContentItem.dishSnapshot.noFullOrderDiscount) {
226
253
  var rate = -(10 - discountValue) / 10;
227
254
  dishTotalPrice += dishTotalPrice * rate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freedom_sky/feige-lib",
3
- "version": "4.51.6",
3
+ "version": "4.52.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,12 @@
1
+ export enum AnnouncementType {
2
+ Text = 'text',
3
+ Image = 'image',
4
+ }
5
+
6
+ export enum AnnouncementTarget {
7
+ Table = 'table',
8
+ Buffet = 'buffet',
9
+ Serial = 'serial',
10
+ PickUp = 'pickup',
11
+ Delivery = 'delivery',
12
+ }
@@ -1,15 +1,68 @@
1
- import {BuffetCombosItems, BuffetDishItem} from "../index"
1
+ import { BuffetCombosItems, BuffetDishItem } from '../index';
2
2
  /**
3
3
  * 计算自助餐总价
4
4
  */
5
- export function calcBuffetTotalPrice(buffetCombosItem:BuffetCombosItems, adultNum: number, childNum: number): number {
6
- return buffetCombosItem.price.adult*adultNum + buffetCombosItem.price.child* childNum
5
+
6
+ /**
7
+ *
8
+ */
9
+ export function getDishItemInBuffet({
10
+ dishId,
11
+ buffet,
12
+ }: {
13
+ dishId: string;
14
+ buffet?: BuffetCombosItems;
15
+ }): BuffetDishItem | undefined {
16
+ return buffet?.dishes.find((item) => String(item.dishId) === String(dishId));
17
+ }
18
+
19
+ /**
20
+ *
21
+ */
22
+ export function getMaxBuffetDishUpperLimit({
23
+ buffetDishItem,
24
+ adultNum,
25
+ childNum,
26
+ }: {
27
+ buffetDishItem: BuffetDishItem;
28
+ adultNum: number;
29
+ childNum: number;
30
+ }): number {
31
+ if (!buffetDishItem) throw 'No buffet dish item';
32
+ if (!buffetDishItem.upperLimit.enable) return Infinity;
33
+ return Math.ceil(buffetDishItem.upperLimit.adult * adultNum + buffetDishItem.upperLimit.child * childNum);
34
+ }
35
+
36
+ /**
37
+ * @param buffetCombosItem
38
+ * @param adultNum
39
+ * @param childNum
40
+ */
41
+ export function calcBuffetTotalPrice(buffetCombosItem: BuffetCombosItems, adultNum: number, childNum: number): number {
42
+ return buffetCombosItem.price.adult * adultNum + buffetCombosItem.price.child * childNum;
7
43
  }
8
44
 
9
- export function dishShowPriceWithBuffet({dishPrice, dishId, buffet, orderedCound, adultNum, childNum}:{dishPrice:number, dishId:string, buffet?: BuffetCombosItems, orderedCound: number, adultNum: number, childNum: number}) {
10
- const buffetDishItem = getDishItemInBuffet({dishId, buffet})
11
- if(buffetDishItem) {
12
- if(orderedCound<getMaxBuffetDishUpperLimit({buffetDishItem, adultNum, childNum})) {
45
+ /**
46
+ *
47
+ */
48
+ export function dishShowPriceWithBuffet({
49
+ dishPrice,
50
+ dishId,
51
+ buffet,
52
+ orderedCound,
53
+ adultNum,
54
+ childNum,
55
+ }: {
56
+ dishPrice: number;
57
+ dishId: string;
58
+ buffet?: BuffetCombosItems;
59
+ orderedCound: number;
60
+ adultNum: number;
61
+ childNum: number;
62
+ }) {
63
+ const buffetDishItem = getDishItemInBuffet({ dishId, buffet });
64
+ if (buffetDishItem) {
65
+ if (orderedCound < getMaxBuffetDishUpperLimit({ buffetDishItem, adultNum, childNum })) {
13
66
  return 0;
14
67
  } else {
15
68
  return dishPrice;
@@ -18,13 +71,3 @@ export function dishShowPriceWithBuffet({dishPrice, dishId, buffet, orderedCound
18
71
  return dishPrice;
19
72
  }
20
73
  }
21
-
22
- export function getDishItemInBuffet({dishId, buffet}:{dishId:string, buffet?: BuffetCombosItems}):BuffetDishItem|undefined {
23
- return buffet?.dishes.find((item)=>String(item.dishId)===String(dishId))
24
- }
25
-
26
- export function getMaxBuffetDishUpperLimit({buffetDishItem, adultNum, childNum}:{buffetDishItem:BuffetDishItem, adultNum: number, childNum: number}):number {
27
- if(!buffetDishItem) throw 'No buffet dish item'
28
- if(!buffetDishItem.upperLimit.enable) return Infinity;
29
- return Math.ceil(buffetDishItem.upperLimit.adult*adultNum + buffetDishItem.upperLimit.child*childNum);
30
- }
@@ -26,6 +26,7 @@ export enum TimeZoneEnum {
26
26
  'UTC+8' = 8,
27
27
  'UTC+9' = 9,
28
28
  'UTC+9.5' = 9.5,
29
+ 'UTC+10.5' = 10.5,
29
30
  'UTC+10' = 10,
30
31
  'UTC+11' = 11,
31
32
  'UTC+12' = 12,
package/src/index.ts CHANGED
@@ -22,6 +22,7 @@ export * from './enum/visit-task.enum';
22
22
  export * from './enum/receptionist.enum';
23
23
  export * from './enum/from.enum';
24
24
  export * from './enum/role.enum';
25
+ export * from './announcement/enum/announcement.enum';
25
26
  export * from './interfaces/member/member.interface';
26
27
  export * from './interfaces/member/member-transaction.interface';
27
28
  export * from './interfaces/store/store.interface';
@@ -107,54 +108,83 @@ export function calcDishFinalPrice(conent: Content): number {
107
108
  export function calcTotalPrice(order: Order): number {
108
109
  let totalPrice = 0;
109
110
  order.content.forEach((orderContentItem) => {
110
- totalPrice+=calcContentPrice({
111
+ totalPrice += calcContentPrice({
111
112
  orderContentItem,
112
113
  buffetItem: order.buffet?.snapshot,
113
114
  orderType: order.type,
114
115
  adultNum: order.adultNum,
115
116
  childNum: order.childNum,
116
- contents: order.content
117
- })
117
+ contents: order.content,
118
+ });
118
119
  });
119
120
  if (order.deliveryFee && !order.selfPickUp) {
120
121
  totalPrice += order.deliveryFee;
121
122
  }
122
- if(order.type === OrderTypeEnum.Buffet) {
123
- totalPrice += calcBuffetTotalPrice(order.buffet.snapshot, order.adultNum, order.childNum)
123
+ if (order.type === OrderTypeEnum.Buffet) {
124
+ totalPrice += calcBuffetTotalPrice(order.buffet.snapshot, order.adultNum, order.childNum);
124
125
  }
125
126
  return parseMoney(totalPrice);
126
127
  }
127
128
 
128
- export function calcContentPrice({orderContentItem,buffetItem, orderType, adultNum, childNum,contents}:{orderContentItem:Content, buffetItem: BuffetCombosItems, orderType: OrderTypeEnum, adultNum: number, childNum: number, contents:Content[]}): number {
129
- if(orderType === OrderTypeEnum.Buffet) {
130
- const buffetDishItem = getDishItemInBuffet({dishId:orderContentItem.dishSnapshot._id, buffet: buffetItem});
131
- if(buffetDishItem) {
132
- const maxUpperLimit = getMaxBuffetDishUpperLimit({buffetDishItem, adultNum: adultNum, childNum: childNum});
133
- const beforeCount = getOrderedCountByDishId(orderContentItem.dishSnapshot._id, contents, orderContentItem._id);
134
- const maxUpperLimitForThisItem = Math.max(maxUpperLimit - beforeCount, 0)
135
- if(maxUpperLimitForThisItem>=orderContentItem.count) {
136
- return 0;
137
- } else {
138
- return (orderContentItem.count-maxUpperLimitForThisItem) * calcDishFinalPrice(orderContentItem);
139
- }
140
- }else {
141
- return orderContentItem.count * calcDishFinalPrice(orderContentItem);
129
+ /**
130
+ *
131
+ */
132
+ export function calcContentPrice({
133
+ orderContentItem,
134
+ buffetItem,
135
+ orderType,
136
+ adultNum,
137
+ childNum,
138
+ contents,
139
+ }: {
140
+ orderContentItem: Content;
141
+ buffetItem: BuffetCombosItems;
142
+ orderType: OrderTypeEnum;
143
+ adultNum: number;
144
+ childNum: number;
145
+ contents: Content[];
146
+ }): number {
147
+ if (orderType === OrderTypeEnum.Buffet) {
148
+ const buffetDishItem = getDishItemInBuffet({ dishId: orderContentItem.dishSnapshot._id, buffet: buffetItem });
149
+ if (buffetDishItem) {
150
+ const maxUpperLimit = getMaxBuffetDishUpperLimit({
151
+ buffetDishItem,
152
+ adultNum: adultNum,
153
+ childNum: childNum,
154
+ });
155
+ const beforeCount = getOrderedCountByDishId(
156
+ orderContentItem.dishSnapshot._id,
157
+ contents,
158
+ orderContentItem._id,
159
+ );
160
+ const maxUpperLimitForThisItem = Math.max(maxUpperLimit - beforeCount, 0);
161
+ if (maxUpperLimitForThisItem >= orderContentItem.count) {
162
+ return 0;
163
+ } else {
164
+ return (orderContentItem.count - maxUpperLimitForThisItem) * calcDishFinalPrice(orderContentItem);
142
165
  }
143
166
  } else {
144
167
  return orderContentItem.count * calcDishFinalPrice(orderContentItem);
145
168
  }
169
+ } else {
170
+ return orderContentItem.count * calcDishFinalPrice(orderContentItem);
171
+ }
146
172
  }
147
173
 
148
- export function getOrderedCountByDishId(dishId, contents:Content[], beforeKey?:string): number{
174
+ /**
175
+ * @param dishId
176
+ * @param contents
177
+ * @param beforeKey
178
+ */
179
+ export function getOrderedCountByDishId(dishId, contents: Content[], beforeKey?: string): number {
149
180
  let count = 0;
150
- for(let content of contents.filter(content=>String(content.dishSnapshot._id)===String(dishId))) {
151
- if(beforeKey && String(content._id) === String(beforeKey)) break;
152
- count += content.count
181
+ for (const content of contents.filter((content) => String(content.dishSnapshot._id) === String(dishId))) {
182
+ if (beforeKey && String(content._id) === String(beforeKey)) break;
183
+ count += content.count;
153
184
  }
154
- return count
185
+ return count;
155
186
  }
156
187
 
157
-
158
188
  /**
159
189
  * 计算处理后的应收金额
160
190
  *
@@ -198,12 +228,19 @@ export function calcReceivablePrice(
198
228
  if (orderContentItem.dishSnapshot.noFullOrderDiscount) {
199
229
  return;
200
230
  }
201
- const dishTotalPrice = calcContentPrice({orderContentItem, buffetItem:order.buffet?.snapshot, orderType: order.type, adultNum:order.adultNum,childNum:order.childNum, contents: order.content})
231
+ const dishTotalPrice = calcContentPrice({
232
+ orderContentItem,
233
+ buffetItem: order.buffet?.snapshot,
234
+ orderType: order.type,
235
+ adultNum: order.adultNum,
236
+ childNum: order.childNum,
237
+ contents: order.content,
238
+ });
202
239
  totalDiscountPrice += dishTotalPrice;
203
240
  volume += dishTotalPrice * rate;
204
241
  });
205
- if(order.type === OrderTypeEnum.Buffet) {
206
- const buffetTotalPrice = calcBuffetTotalPrice(order.buffet.snapshot, order.adultNum, order.childNum)
242
+ if (order.type === OrderTypeEnum.Buffet) {
243
+ const buffetTotalPrice = calcBuffetTotalPrice(order.buffet.snapshot, order.adultNum, order.childNum);
207
244
  totalDiscountPrice += buffetTotalPrice;
208
245
  volume += buffetTotalPrice * rate;
209
246
  }
@@ -245,7 +282,14 @@ export function calcReceivablePrice(
245
282
  const discountValue = sortedProcessArr.find(
246
283
  (process) => process.type === CONST.RECEIVABLE_PROCESSING_TYPE.DISCOUNT.TYPE,
247
284
  )?.value;
248
- let dishTotalPrice = calcContentPrice({orderContentItem, buffetItem:order.buffet?.snapshot, orderType: order.type, adultNum:order.adultNum,childNum:order.childNum, contents: order.content});
285
+ let dishTotalPrice = calcContentPrice({
286
+ orderContentItem,
287
+ buffetItem: order.buffet?.snapshot,
288
+ orderType: order.type,
289
+ adultNum: order.adultNum,
290
+ childNum: order.childNum,
291
+ contents: order.content,
292
+ });
249
293
  if (discountValue && !orderContentItem.dishSnapshot.noFullOrderDiscount) {
250
294
  const rate = -(10 - discountValue) / 10;
251
295
  dishTotalPrice += dishTotalPrice * rate;
@@ -46,8 +46,8 @@ export interface Order {
46
46
  name: string;
47
47
  volume: number;
48
48
  }[];
49
- readonly buffet?:{
50
- snapshot: BuffetCombosItems,
49
+ readonly buffet?: {
50
+ snapshot: BuffetCombosItems;
51
51
  };
52
52
  readonly adultNum?: number;
53
53
  readonly childNum?: number;