@freedom_sky/feige-lib 4.53.2 → 4.54.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 +7 -0
- package/dist/index.js +16 -0
- package/package.json +1 -1
- package/src/index.ts +16 -0
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 getDishCountById(order: Order, dishId: string): Number;
|
package/dist/index.js
CHANGED
|
@@ -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 getDishCountById(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.getDishCountById = getDishCountById;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -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 getDishCountById(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
|
+
}
|