10fa361983
Co-authored-by: Cursor <cursoragent@cursor.com>
99 lines
3.0 KiB
TypeScript
99 lines
3.0 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Post, Put, Query, UseGuards } from '@nestjs/common';
|
||
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
||
import {
|
||
HqPermissionGuard,
|
||
RequireHqPermissions,
|
||
} from '../../common/guards/hq-permission.guard';
|
||
import { HqOperation } from '../../common/hq-operation/hq-operation.decorator';
|
||
import { HqOperationAction } from '../../common/hq-operation/hq-operation.constants';
|
||
import { AdminOrdersService } from './admin-orders.service';
|
||
import { AdminShipOrderDto, BatchDeleteOrdersDto, HqLogisticsShipDto, UpdateOrderStatusDto } from './dto/admin-mutate.dto';
|
||
import { AdminOrdersQueryDto } from './dto/admin-query.dto';
|
||
|
||
@Controller('admin/orders')
|
||
@UseGuards(HqAuthGuard)
|
||
export class AdminOrdersController {
|
||
constructor(private readonly ordersService: AdminOrdersService) {}
|
||
|
||
@Get()
|
||
list(@Query() query: AdminOrdersQueryDto) {
|
||
return this.ordersService.list(query);
|
||
}
|
||
|
||
@Post('batch-delete')
|
||
@UseGuards(HqPermissionGuard)
|
||
@RequireHqPermissions('orders_delete')
|
||
@HqOperation({
|
||
action: HqOperationAction.ORDER_BATCH_DELETE,
|
||
refType: 'ORDER',
|
||
batch: true,
|
||
includeBody: true,
|
||
})
|
||
batchDelete(@Body() dto: BatchDeleteOrdersDto) {
|
||
return this.ordersService.batchDeleteOrders(dto.ids.map((id) => BigInt(id)));
|
||
}
|
||
|
||
@Get('ship-defaults')
|
||
shipDefaults() {
|
||
return this.ordersService.getShipDefaults();
|
||
}
|
||
|
||
/** 物流路由(小飞侠实时轨迹,对齐 C 端 GET /trade/orders/:id/track) */
|
||
@Get(':id/track')
|
||
track(@Param('id') id: string) {
|
||
return this.ordersService.getOrderTrack(BigInt(id));
|
||
}
|
||
|
||
@Get(':id')
|
||
detail(@Param('id') id: string) {
|
||
return this.ordersService.detail(BigInt(id));
|
||
}
|
||
|
||
@Delete(':id')
|
||
@UseGuards(HqPermissionGuard)
|
||
@RequireHqPermissions('orders_delete')
|
||
@HqOperation({
|
||
action: HqOperationAction.ORDER_DELETE,
|
||
refType: 'ORDER',
|
||
refIdParam: 'id',
|
||
})
|
||
remove(@Param('id') id: string) {
|
||
return this.ordersService.deleteOrder(BigInt(id));
|
||
}
|
||
|
||
/** HQ 发货:调用小飞侠创建运单并更新配送信息 */
|
||
@Post(':id/ship')
|
||
@HqOperation({
|
||
action: HqOperationAction.ORDER_SHIP,
|
||
refType: 'ORDER',
|
||
refIdParam: 'id',
|
||
includeBody: true,
|
||
})
|
||
ship(@Param('id') id: string, @Body() dto: AdminShipOrderDto) {
|
||
return this.ordersService.shipOrder(BigInt(id), dto);
|
||
}
|
||
|
||
@Post(':id/logistics-ship')
|
||
@HqOperation({
|
||
action: HqOperationAction.ORDER_SHIP,
|
||
refType: 'ORDER',
|
||
refIdParam: 'id',
|
||
includeBody: true,
|
||
})
|
||
shipLogistics(@Param('id') id: string, @Body() dto: HqLogisticsShipDto) {
|
||
return this.ordersService.shipLogistics(BigInt(id), dto);
|
||
}
|
||
|
||
/** preV1 调试:直接改订单状态,不走业务校验 */
|
||
@Put(':id/status')
|
||
@HqOperation({
|
||
action: HqOperationAction.ORDER_STATUS_DEBUG,
|
||
refType: 'ORDER',
|
||
refIdParam: 'id',
|
||
includeBody: true,
|
||
})
|
||
updateStatus(@Param('id') id: string, @Body() dto: UpdateOrderStatusDto) {
|
||
return this.ordersService.updateStatusDebug(BigInt(id), dto.status);
|
||
}
|
||
}
|