admin web 修改订单状态
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Put, Query, UseGuards } from '@nestjs/common';
|
||||
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
||||
import { AdminOrdersService } from './admin-orders.service';
|
||||
import { UpdateOrderStatusDto } from './dto/admin-mutate.dto';
|
||||
import { AdminOrdersQueryDto } from './dto/admin-query.dto';
|
||||
|
||||
@Controller('admin/orders')
|
||||
@@ -17,4 +18,10 @@ export class AdminOrdersController {
|
||||
detail(@Param('id') id: string) {
|
||||
return this.ordersService.detail(BigInt(id));
|
||||
}
|
||||
|
||||
/** preV1 调试:直接改订单状态,不走业务校验 */
|
||||
@Put(':id/status')
|
||||
updateStatus(@Param('id') id: string, @Body() dto: UpdateOrderStatusDto) {
|
||||
return this.ordersService.updateStatusDebug(BigInt(id), dto.status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@ import { PrismaService } from '../../common/prisma/prisma.module';
|
||||
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
|
||||
import { orderStatusLogWhere } from '../../common/event/event.helpers';
|
||||
import { mapOrderCompat, mapStatusLogCompat } from '../../common/compat/v31-compat';
|
||||
import { TradeService } from '../trade/trade.service';
|
||||
import type { AdminOrdersQueryDto } from './dto/admin-query.dto';
|
||||
|
||||
@Injectable()
|
||||
export class AdminOrdersService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly tradeService: TradeService,
|
||||
) {}
|
||||
|
||||
async list(query: AdminOrdersQueryDto) {
|
||||
const page = query.page ?? 1;
|
||||
@@ -76,4 +80,11 @@ export class AdminOrdersService {
|
||||
benefitCoupons: order.benefitCoupon ? [order.benefitCoupon] : [],
|
||||
}));
|
||||
}
|
||||
|
||||
async updateStatusDebug(id: bigint, status: string) {
|
||||
const order = await this.prisma.order.findUnique({ where: { id } });
|
||||
if (!order) throw new NotFoundException('订单不存在');
|
||||
await this.tradeService.applyStatusTransition(id, order.status, status, 'HQ_DEBUG');
|
||||
return this.detail(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +270,22 @@ export class UpdateStoreMediaDto {
|
||||
sortOrder?: number;
|
||||
}
|
||||
|
||||
export class UpdateOrderStatusDto {
|
||||
@IsString()
|
||||
@IsIn([
|
||||
'PENDING_PAY',
|
||||
'PENDING_SHIP',
|
||||
'OUT_WAREHOUSE',
|
||||
'SHIPPING',
|
||||
'PENDING_RECEIVE',
|
||||
'COMPLETED',
|
||||
'CANCELLED',
|
||||
'REFUNDING',
|
||||
'REFUNDED',
|
||||
])
|
||||
status: string;
|
||||
}
|
||||
|
||||
export class UpdateDeliveryDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { IamModule } from '../iam/iam.module';
|
||||
import { TradeModule } from '../trade/trade.module';
|
||||
import { AdminDashboardController } from './admin-dashboard.controller';
|
||||
import { AdminDashboardService } from './admin-dashboard.service';
|
||||
import { AdminUsersController } from './admin-users.controller';
|
||||
@@ -23,7 +24,7 @@ import { AdminProductsService } from './admin-products.service';
|
||||
import { SuperAdminGuard } from '../../common/guards/super-admin.guard';
|
||||
|
||||
@Module({
|
||||
imports: [IamModule],
|
||||
imports: [IamModule, TradeModule],
|
||||
controllers: [
|
||||
AdminDashboardController,
|
||||
AdminUsersController,
|
||||
|
||||
Reference in New Issue
Block a user