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