Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
188e3a00b6 |
|
|
@ -20,6 +20,7 @@
|
|||
"bcryptjs": "^2.4.3",
|
||||
"class-transformer": "^0.5.1",
|
||||
"dayjs": "^1.11.13",
|
||||
"exceljs": "^4.4.0",
|
||||
"mysql2": "^3.11.5",
|
||||
"nodemailer": "^7.0.5",
|
||||
"swagger-ui-dist": "^5.18.2",
|
||||
|
|
|
|||
|
|
@ -221,4 +221,18 @@ export class OrderController {
|
|||
return errorResponse(error?.message || '获取失败');
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOkResponse()
|
||||
@Get('/excel/price')
|
||||
async getOrdersPriceInExcel() {
|
||||
try {
|
||||
return successResponse(await this.orderService.getOrdersPriceInExcel({
|
||||
siteId: 0,
|
||||
startDate: 0,
|
||||
endDate: 0
|
||||
}));
|
||||
} catch (error) {
|
||||
return errorResponse(error?.message || '获取失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import { ShipmentItem } from '../entity/shipment_item.entity';
|
|||
import { UpdateStockDTO } from '../dto/stock.dto';
|
||||
import { StockService } from './stock.service';
|
||||
import { OrderSaleOriginal } from '../entity/order_item_original.entity';
|
||||
import { createExcel } from '../utils/files.util';
|
||||
|
||||
@Provide()
|
||||
export class OrderService {
|
||||
|
|
@ -601,6 +602,35 @@ export class OrderService {
|
|||
}
|
||||
}
|
||||
|
||||
async getOrdersPriceInExcel({
|
||||
siteId,
|
||||
startDate,
|
||||
endDate
|
||||
}) {
|
||||
const orders = await this.orderModel.find({where: {
|
||||
status: In([OrderStatus.PROCESSING, OrderStatus.COMPLETED])
|
||||
}});
|
||||
// const orders = await this.orderModel.findBy({
|
||||
// status: OrderStatus.PROCESSING
|
||||
// });
|
||||
const arr = [];
|
||||
arr.push(['id', 'price', 'discount_total', 'site_name', 'date_created', 'date_completed']);
|
||||
console.log('arr', arr);
|
||||
orders.forEach(order => {
|
||||
let site = this.sites.find(site => site.id === order.siteId);
|
||||
arr.push([
|
||||
order.externalOrderId,
|
||||
order.total - order.total_tax - order.shipping_total,
|
||||
order.discount_total,
|
||||
site?.siteName,
|
||||
order.date_created,
|
||||
order.date_completed
|
||||
]);
|
||||
});
|
||||
const path = await createExcel(arr);
|
||||
return path;
|
||||
}
|
||||
|
||||
async getOrders({
|
||||
externalOrderId,
|
||||
siteId,
|
||||
|
|
|
|||
Loading…
Reference in New Issue