@freedom_sky/feige-lib 4.54.1 → 4.55.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/index.d.ts
CHANGED
|
@@ -185,6 +185,7 @@ export declare function getLanguageFromCountryCode(countryCode: any): string;
|
|
|
185
185
|
* 根据dishID返回已经下单的数量
|
|
186
186
|
*
|
|
187
187
|
* @param {Order} order 店铺
|
|
188
|
-
* @
|
|
188
|
+
* @param dishId
|
|
189
|
+
* @returns {number} 返回当前数量
|
|
189
190
|
*/
|
|
190
|
-
export declare function getDishCountByIdInAllUncanceledTasks(order: Order, dishId: string):
|
|
191
|
+
export declare function getDishCountByIdInAllUncanceledTasks(order: Order, dishId: string): number;
|
package/dist/index.js
CHANGED
|
@@ -114,6 +114,8 @@ exports.calcTotalPrice = calcTotalPrice;
|
|
|
114
114
|
*/
|
|
115
115
|
function calcContentPrice(_a) {
|
|
116
116
|
var orderContentItem = _a.orderContentItem, buffetItem = _a.buffetItem, orderType = _a.orderType, adultNum = _a.adultNum, childNum = _a.childNum, contents = _a.contents;
|
|
117
|
+
if (orderContentItem.retreated)
|
|
118
|
+
return 0;
|
|
117
119
|
if (orderType === order_enum_1.OrderTypeEnum.Buffet) {
|
|
118
120
|
var buffetDishItem = index_1.getDishItemInBuffet({ dishId: orderContentItem.dishSnapshot._id, buffet: buffetItem });
|
|
119
121
|
if (buffetDishItem) {
|
|
@@ -167,6 +169,7 @@ exports.getOrderedCountByDishId = getOrderedCountByDishId;
|
|
|
167
169
|
*/
|
|
168
170
|
function calcReceivablePrice(order, processArr, noTax) {
|
|
169
171
|
if (noTax === void 0) { noTax = false; }
|
|
172
|
+
var _a;
|
|
170
173
|
var totalDiscountPrice = 0;
|
|
171
174
|
var resultProcessArr = [];
|
|
172
175
|
var totalPrice = calcTotalPrice(order);
|
|
@@ -260,6 +263,16 @@ function calcReceivablePrice(order, processArr, noTax) {
|
|
|
260
263
|
taxObj[taxKey] = (taxObj[taxKey] || 0) + parseMoney(taxFare);
|
|
261
264
|
});
|
|
262
265
|
});
|
|
266
|
+
// buffet price
|
|
267
|
+
if (order.type === order_enum_1.OrderTypeEnum.Buffet) {
|
|
268
|
+
var buffetTotalPrice_1 = index_1.calcBuffetTotalPrice((_a = order.buffet) === null || _a === void 0 ? void 0 : _a.snapshot, order.adultNum, order.childNum);
|
|
269
|
+
var sharedMarkDown_1 = (totalMarkDown * buffetTotalPrice_1) / receivablePriceAfterDiscount;
|
|
270
|
+
order.buffet.taxes.forEach(function (tax) {
|
|
271
|
+
var taxFare = (buffetTotalPrice_1 - sharedMarkDown_1) * tax.rate;
|
|
272
|
+
var taxKey = tax.name + "(" + big_js_1.default(tax.rate).times(100) + "%)";
|
|
273
|
+
taxObj[taxKey] = (taxObj[taxKey] || 0) + parseMoney(taxFare);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
263
276
|
}
|
|
264
277
|
else if (order.taxType === tax_enum_1.TaxTypeEnum.PriceHaveTaxBindOrder && !noTax) {
|
|
265
278
|
var totalTaxRate_1 = 0;
|
|
@@ -519,13 +532,19 @@ exports.getLanguageFromCountryCode = getLanguageFromCountryCode;
|
|
|
519
532
|
* 根据dishID返回已经下单的数量
|
|
520
533
|
*
|
|
521
534
|
* @param {Order} order 店铺
|
|
522
|
-
* @
|
|
535
|
+
* @param dishId
|
|
536
|
+
* @returns {number} 返回当前数量
|
|
523
537
|
*/
|
|
524
538
|
function getDishCountByIdInAllUncanceledTasks(order, dishId) {
|
|
525
539
|
var count = 0;
|
|
526
540
|
if (order.tasks) {
|
|
527
|
-
count = order.tasks
|
|
528
|
-
|
|
541
|
+
count = order.tasks
|
|
542
|
+
.filter(function (task) { return task.status !== const_1.CONST.STATUS.CANCELLED; })
|
|
543
|
+
.reduce(function (count, task) {
|
|
544
|
+
return (count +
|
|
545
|
+
task.content
|
|
546
|
+
.filter(function (item) { return String(item.dishSnapshot._id) === String(dishId); })
|
|
547
|
+
.reduce(function (value, item) { return value + item.count; }, 0));
|
|
529
548
|
}, 0);
|
|
530
549
|
}
|
|
531
550
|
return count;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -144,6 +144,7 @@ export function calcContentPrice({
|
|
|
144
144
|
childNum: number;
|
|
145
145
|
contents: Content[];
|
|
146
146
|
}): number {
|
|
147
|
+
if (orderContentItem.retreated) return 0;
|
|
147
148
|
if (orderType === OrderTypeEnum.Buffet) {
|
|
148
149
|
const buffetDishItem = getDishItemInBuffet({ dishId: orderContentItem.dishSnapshot._id, buffet: buffetItem });
|
|
149
150
|
if (buffetDishItem) {
|
|
@@ -178,10 +179,12 @@ export function calcContentPrice({
|
|
|
178
179
|
*/
|
|
179
180
|
export function getOrderedCountByDishId(dishId, contents: Content[], beforeKey?: string): number {
|
|
180
181
|
let count = 0;
|
|
181
|
-
for (const content of contents.filter(
|
|
182
|
+
for (const content of contents.filter(
|
|
183
|
+
(content) => !content.retreated && String(content.dishSnapshot._id) === String(dishId),
|
|
184
|
+
)) {
|
|
182
185
|
if (beforeKey && String(content._id) === String(beforeKey)) break;
|
|
183
186
|
count += content.count;
|
|
184
|
-
}
|
|
187
|
+
}
|
|
185
188
|
return count;
|
|
186
189
|
}
|
|
187
190
|
|
|
@@ -301,6 +304,16 @@ export function calcReceivablePrice(
|
|
|
301
304
|
taxObj[taxKey] = (taxObj[taxKey] || 0) + parseMoney(taxFare);
|
|
302
305
|
});
|
|
303
306
|
});
|
|
307
|
+
// buffet price
|
|
308
|
+
if (order.type === OrderTypeEnum.Buffet) {
|
|
309
|
+
const buffetTotalPrice = calcBuffetTotalPrice(order.buffet?.snapshot, order.adultNum, order.childNum);
|
|
310
|
+
const sharedMarkDown = (totalMarkDown * buffetTotalPrice) / receivablePriceAfterDiscount;
|
|
311
|
+
order.buffet.taxes.forEach((tax) => {
|
|
312
|
+
const taxFare = (buffetTotalPrice - sharedMarkDown) * tax.rate;
|
|
313
|
+
const taxKey = `${tax.name}(${Big(tax.rate).times(100)}%)`;
|
|
314
|
+
taxObj[taxKey] = (taxObj[taxKey] || 0) + parseMoney(taxFare);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
304
317
|
} else if (order.taxType === TaxTypeEnum.PriceHaveTaxBindOrder && !noTax) {
|
|
305
318
|
let totalTaxRate = 0;
|
|
306
319
|
order.priceHaveTaxBindOrderTaxes.forEach((item) => {
|
|
@@ -565,14 +578,22 @@ export function getLanguageFromCountryCode(countryCode): string {
|
|
|
565
578
|
* 根据dishID返回已经下单的数量
|
|
566
579
|
*
|
|
567
580
|
* @param {Order} order 店铺
|
|
568
|
-
* @
|
|
581
|
+
* @param dishId
|
|
582
|
+
* @returns {number} 返回当前数量
|
|
569
583
|
*/
|
|
570
|
-
export function getDishCountByIdInAllUncanceledTasks(order: Order, dishId: string):
|
|
584
|
+
export function getDishCountByIdInAllUncanceledTasks(order: Order, dishId: string): number {
|
|
571
585
|
let count = 0;
|
|
572
586
|
if (order.tasks) {
|
|
573
|
-
count = order.tasks
|
|
574
|
-
|
|
575
|
-
|
|
587
|
+
count = order.tasks
|
|
588
|
+
.filter((task) => task.status !== CONST.STATUS.CANCELLED)
|
|
589
|
+
.reduce((count, task) => {
|
|
590
|
+
return (
|
|
591
|
+
count +
|
|
592
|
+
task.content
|
|
593
|
+
.filter((item) => String(item.dishSnapshot._id) === String(dishId))
|
|
594
|
+
.reduce((value, item) => value + item.count, 0)
|
|
595
|
+
);
|
|
596
|
+
}, 0);
|
|
576
597
|
}
|
|
577
598
|
return count;
|
|
578
|
-
}
|
|
599
|
+
}
|