8d6c0f9ac0
CI / verify (pull_request) Has been cancelled
Add partner-facing proxy order list/detail; unlock SUPER_ADMIN order delete with cascade cleanup and type filter. Co-authored-by: Cursor <cursoragent@cursor.com>
93 lines
2.8 KiB
TypeScript
93 lines
2.8 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();
|
|
}
|
|
|
|
@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);
|
|
}
|
|
}
|