|
@@ -36,22 +36,22 @@ export class StatisticsService {
|
|
|
|
|
|
// 每个月下单数量
|
|
// 每个月下单数量
|
|
async orderDetail(filter): Promise<Array<any>> {
|
|
async orderDetail(filter): Promise<Array<any>> {
|
|
- const { supplier, time } = filter;
|
|
|
|
|
|
+ const { supplier, time, c_accounting, c_leader } = filter;
|
|
const result = [];
|
|
const result = [];
|
|
|
|
+ const search: any = { status: '10' };
|
|
|
|
+ if (supplier) search.supplier = supplier;
|
|
|
|
+ if (c_leader) search.c_leader = { $elemMatch: { _id: c_leader } };
|
|
|
|
+ else if (c_accounting)
|
|
|
|
+ search.c_accounting = { $elemMatch: { _id: c_accounting } };
|
|
for (let i = 1; i < 13; i++) {
|
|
for (let i = 1; i < 13; i++) {
|
|
let buy_time;
|
|
let buy_time;
|
|
if (i < 10) buy_time = `${time}-0${i}`;
|
|
if (i < 10) buy_time = `${time}-0${i}`;
|
|
else buy_time = `${time}-${i}`;
|
|
else buy_time = `${time}-${i}`;
|
|
|
|
+ search.buy_time = { $regex: buy_time };
|
|
const info: any = { year: '', money: 0 };
|
|
const info: any = { year: '', money: 0 };
|
|
info.year = i + '月';
|
|
info.year = i + '月';
|
|
info.money = 0;
|
|
info.money = 0;
|
|
- const res = await this.orderDetailModel
|
|
|
|
- .find({
|
|
|
|
- supplier: supplier,
|
|
|
|
- buy_time: { $regex: buy_time },
|
|
|
|
- status: '10',
|
|
|
|
- })
|
|
|
|
- .lean();
|
|
|
|
|
|
+ const res = await this.orderDetailModel.find(search).lean();
|
|
for (const val of res) {
|
|
for (const val of res) {
|
|
info.money = info.money + val.total_money;
|
|
info.money = info.money + val.total_money;
|
|
}
|
|
}
|