@freedom_sky/feige-lib 4.53.2 → 4.54.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 +7 -0
- package/dist/index.js +17 -1
- package/package.json +1 -1
- package/src/index.ts +18 -2
package/dist/index.d.ts
CHANGED
|
@@ -181,3 +181,10 @@ export declare function getOrderByLanguage(order: Order, currentLang: string, de
|
|
|
181
181
|
* @returns {string} 语言代码的小写格式
|
|
182
182
|
*/
|
|
183
183
|
export declare function getLanguageFromCountryCode(countryCode: any): string;
|
|
184
|
+
/**
|
|
185
|
+
* 根据dishID返回已经下单的数量
|
|
186
|
+
*
|
|
187
|
+
* @param {Order} order 店铺
|
|
188
|
+
* @returns {Number} 返回当前数量
|
|
189
|
+
*/
|
|
190
|
+
export declare function getDishCountByIdInAllUncanceledTasks(order: Order, dishId: string): Number;
|
package/dist/index.js
CHANGED
|
@@ -147,7 +147,7 @@ exports.calcContentPrice = calcContentPrice;
|
|
|
147
147
|
*/
|
|
148
148
|
function getOrderedCountByDishId(dishId, contents, beforeKey) {
|
|
149
149
|
var count = 0;
|
|
150
|
-
for (var _i = 0, _a = contents.filter(function (content) { return String(content.dishSnapshot._id) === String(dishId); }); _i < _a.length; _i++) {
|
|
150
|
+
for (var _i = 0, _a = contents.filter(function (content) { return !content.retreated && String(content.dishSnapshot._id) === String(dishId); }); _i < _a.length; _i++) {
|
|
151
151
|
var content = _a[_i];
|
|
152
152
|
if (beforeKey && String(content._id) === String(beforeKey))
|
|
153
153
|
break;
|
|
@@ -515,3 +515,19 @@ function getLanguageFromCountryCode(countryCode) {
|
|
|
515
515
|
return languageCode;
|
|
516
516
|
}
|
|
517
517
|
exports.getLanguageFromCountryCode = getLanguageFromCountryCode;
|
|
518
|
+
/**
|
|
519
|
+
* 根据dishID返回已经下单的数量
|
|
520
|
+
*
|
|
521
|
+
* @param {Order} order 店铺
|
|
522
|
+
* @returns {Number} 返回当前数量
|
|
523
|
+
*/
|
|
524
|
+
function getDishCountByIdInAllUncanceledTasks(order, dishId) {
|
|
525
|
+
var count = 0;
|
|
526
|
+
if (order.tasks) {
|
|
527
|
+
count = order.tasks.filter(function (task) { return task.status !== const_1.CONST.STATUS.CANCELLED; }).reduce(function (count, task) {
|
|
528
|
+
return count + task.content.filter(function (item) { return String(item.dishSnapshot._id) === String(dishId); }).reduce(function (value, item) { return value + item.count; }, 0);
|
|
529
|
+
}, 0);
|
|
530
|
+
}
|
|
531
|
+
return count;
|
|
532
|
+
}
|
|
533
|
+
exports.getDishCountByIdInAllUncanceledTasks = getDishCountByIdInAllUncanceledTasks;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -178,10 +178,10 @@ export function calcContentPrice({
|
|
|
178
178
|
*/
|
|
179
179
|
export function getOrderedCountByDishId(dishId, contents: Content[], beforeKey?: string): number {
|
|
180
180
|
let count = 0;
|
|
181
|
-
for (const content of contents.filter((content) => String(content.dishSnapshot._id) === String(dishId))) {
|
|
181
|
+
for (const content of contents.filter((content) => !content.retreated && String(content.dishSnapshot._id) === String(dishId))) {
|
|
182
182
|
if (beforeKey && String(content._id) === String(beforeKey)) break;
|
|
183
183
|
count += content.count;
|
|
184
|
-
}
|
|
184
|
+
}
|
|
185
185
|
return count;
|
|
186
186
|
}
|
|
187
187
|
|
|
@@ -560,3 +560,19 @@ export function getLanguageFromCountryCode(countryCode): string {
|
|
|
560
560
|
const languageCode = data[String(countryCode)] || 'en';
|
|
561
561
|
return languageCode;
|
|
562
562
|
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* 根据dishID返回已经下单的数量
|
|
566
|
+
*
|
|
567
|
+
* @param {Order} order 店铺
|
|
568
|
+
* @returns {Number} 返回当前数量
|
|
569
|
+
*/
|
|
570
|
+
export function getDishCountByIdInAllUncanceledTasks(order: Order, dishId: string): Number {
|
|
571
|
+
let count = 0;
|
|
572
|
+
if (order.tasks) {
|
|
573
|
+
count = order.tasks.filter(task=>task.status!==CONST.STATUS.CANCELLED).reduce((count, task) => {
|
|
574
|
+
return count + task.content.filter(item=>String(item.dishSnapshot._id)===String(dishId)).reduce((value, item) => value+item.count,0);
|
|
575
|
+
},0);
|
|
576
|
+
}
|
|
577
|
+
return count;
|
|
578
|
+
}
|