100 lines
2.7 KiB
TypeScript
100 lines
2.7 KiB
TypeScript
import { Body, Controller, Get, Inject, Post, Query } from '@midwayjs/core';
|
|
import { StatisticsService } from '../service/statistics.service';
|
|
import { OrderStatisticsParams } from '../dto/statistics.dto';
|
|
import { errorResponse, successResponse } from '../utils/response.util';
|
|
import { ApiOkResponse } from '@midwayjs/swagger';
|
|
|
|
@Controller('/statistics')
|
|
export class StatisticsController {
|
|
@Inject()
|
|
statisticsService: StatisticsService;
|
|
|
|
@ApiOkResponse()
|
|
@Post('/order')
|
|
async getOrderStatistics(@Body() params: OrderStatisticsParams) {
|
|
try {
|
|
return successResponse(
|
|
await this.statisticsService.getOrderStatistics(params)
|
|
);
|
|
} catch (error) {
|
|
return errorResponse(error?.message || '获取失败');
|
|
}
|
|
}
|
|
|
|
@ApiOkResponse()
|
|
@Post('/orderByDate')
|
|
async getOrderByDate(@Body('date') date: string) {
|
|
try {
|
|
return successResponse(await this.statisticsService.getOrderByDate(date));
|
|
} catch (error) {
|
|
return errorResponse(error?.message || '获取失败');
|
|
}
|
|
}
|
|
|
|
@ApiOkResponse()
|
|
@Post('/orderByEmail')
|
|
async getOrderByEmail(@Body('email') email: string) {
|
|
try {
|
|
return successResponse(
|
|
await this.statisticsService.getOrderByEmail(email)
|
|
);
|
|
} catch (error) {
|
|
return errorResponse(error?.message || '获取失败');
|
|
}
|
|
}
|
|
|
|
@ApiOkResponse()
|
|
@Post('/getCustomerOrders')
|
|
async getCustomerOrders(@Body('month') month) {
|
|
try {
|
|
return successResponse(
|
|
await this.statisticsService.getCustomerOrders(month)
|
|
);
|
|
} catch (error) {
|
|
return errorResponse(error?.message || '获取失败');
|
|
}
|
|
}
|
|
|
|
@ApiOkResponse()
|
|
@Post('/stockForecast')
|
|
async stockForecast(@Body() params) {
|
|
try {
|
|
return successResponse(
|
|
await this.statisticsService.stockForecast(params)
|
|
);
|
|
} catch (error) {
|
|
return errorResponse(error?.message || '获取失败');
|
|
}
|
|
}
|
|
|
|
@ApiOkResponse()
|
|
@Post('/restocking')
|
|
async restocking(@Body() params) {
|
|
try {
|
|
return successResponse(await this.statisticsService.restocking(params));
|
|
} catch (error) {
|
|
return errorResponse(error?.message || '获取失败');
|
|
}
|
|
}
|
|
|
|
@ApiOkResponse()
|
|
@Get('/orderSource')
|
|
async getOrderSorce(@Query() params) {
|
|
try {
|
|
return successResponse(await this.statisticsService.getOrderSorce(params));
|
|
} catch (error) {
|
|
return errorResponse(error?.message || '获取失败');
|
|
}
|
|
}
|
|
|
|
@ApiOkResponse()
|
|
@Get('/inactiveUsersByMonth')
|
|
async getInativeUsersByMonth(@Query('month') month: string) {
|
|
try {
|
|
return successResponse(await this.statisticsService.getInativeUsersByMonth(month));
|
|
} catch (error) {
|
|
return errorResponse(error?.message || '获取失败');
|
|
}
|
|
}
|
|
}
|