feat: 迭代

This commit is contained in:
2026-05-11 17:59:19 +08:00
parent 2d5598dcad
commit 554bb702a2
24 changed files with 2539 additions and 2494 deletions
@@ -19,6 +19,9 @@ export class Merchant {
@Column({ length: 500, default: '', comment: '店铺Logo' })
logo: string;
@Column({ name: 'cover_image', length: 500, default: '', comment: '店铺封面图片' })
coverImage: string;
@Column({ name: 'hotel_images', type: 'text', nullable: true, comment: '酒店照片,多张URL用逗号分隔' })
hotelImages: string;
@@ -119,6 +122,10 @@ export class Merchant {
@Column({ name: 'review_count', type: 'int', unsigned: true, default: 0, comment: '评价数' })
reviewCount: number;
@Index()
@Column({ name: 'sales_count', type: 'int', unsigned: true, default: 0, comment: '销量统计' })
salesCount: number;
@Column({ name: 'auto_confirm', type: 'boolean', default: false, comment: '是否自动接单' })
autoConfirm: boolean;
@@ -39,6 +39,10 @@ export class ApplyMerchantDto {
@IsString()
hotelImages?: string;
@IsOptional()
@IsString()
coverImage?: string;
@IsString()
@IsNotEmpty({ message: '签约类型不能为空' })
@IsEnum(['personal', 'company'], { message: '签约类型必须是personal或company' })
@@ -115,6 +119,10 @@ export class UpdateMerchantDto {
@IsString()
logo?: string;
@IsOptional()
@IsString()
coverImage?: string;
@IsOptional()
@IsString()
phone?: string;
@@ -4,6 +4,7 @@ import { Repository, Between, LessThan } from 'typeorm';
import { Order } from '@/entities/order.entity';
import { Room } from '@/entities/room.entity';
import { RoomCalendar } from '@/entities/room-calendar.entity';
import { Merchant } from '@/entities/merchant.entity';
import { CreateOrderDto, QueryOrderDto, ConfirmOrderDto } from './dto/order.dto';
import { ActivityService } from '@/modules/activity/activity.service';
import { ConfigService } from '@/modules/config/config.service';
@@ -17,6 +18,8 @@ export class OrderService {
private roomRepo: Repository<Room>,
@InjectRepository(RoomCalendar)
private calendarRepo: Repository<RoomCalendar>,
@InjectRepository(Merchant)
private merchantRepo: Repository<Merchant>,
private readonly activityService: ActivityService,
private readonly configService: ConfigService,
) {}
@@ -226,6 +229,9 @@ export class OrderService {
checkoutAt: new Date(),
});
// 增加商家销量
await this.incrementMerchantSalesCount(order.merchantId);
// 触发邀请返现
this.activityService.handleOrderCompleted(id).catch(() => {});
@@ -243,6 +249,9 @@ export class OrderService {
checkoutAt: new Date(),
});
// 增加商家销量
await this.incrementMerchantSalesCount(order.merchantId);
// 触发邀请返现
this.activityService.handleOrderCompleted(id).catch(() => {});
@@ -419,4 +428,13 @@ export class OrderService {
totalServiceFee: parseFloat(totalResult?.totalServiceFee || '0'),
};
}
/**
* 增加商家销量
*/
private async incrementMerchantSalesCount(merchantId: number): Promise<void> {
await this.merchantRepo.increment({ id: merchantId }, 'salesCount', 1);
}
}
}
}
+3 -3
View File
@@ -31,7 +31,7 @@ export class RoomService {
async findByIdAndMerchant(id: number, merchantId: number) {
const room = await this.findById(id);
if (room.merchantId !== merchantId) {
if (Number(room.merchantId) !== Number(merchantId)) {
throw new ForbiddenException('无权操作此房源');
}
return room;
@@ -39,7 +39,7 @@ export class RoomService {
async update(id: number, merchantId: number, dto: UpdateRoomDto) {
const room = await this.findById(id);
if (room.merchantId !== merchantId) {
if (Number(room.merchantId) !== Number(merchantId)) {
throw new ForbiddenException('无权操作此房源');
}
// 审核通过或拒绝后修改,需要重新审核
@@ -53,7 +53,7 @@ export class RoomService {
async remove(id: number, merchantId: number) {
const room = await this.findById(id);
if (room.merchantId !== merchantId) {
if (Number(room.merchantId) !== Number(merchantId)) {
throw new ForbiddenException('无权操作此房源');
}
await this.roomRepo.update(id, { status: 'off_sale' });