城市合伙人去掉订单补发功能,酒的订单如果没有配置仓库应该是看不到的
CI / verify (pull_request) Has been cancelled

This commit is contained in:
2026-07-17 08:04:53 +08:00
parent b36f2ea63a
commit 608e405468
11 changed files with 124 additions and 26 deletions
@@ -103,10 +103,16 @@ export class PartnerCityService {
if (!primary.cityId) return { id: -1n };
const warehouseIds = await this.resolveManagedWarehouseIds(primary.id);
if (warehouseIds.length > 0) {
return { fulfillmentWarehouseId: { in: warehouseIds } };
// 未配置管仓:不推送/不展示酒订单(同城无仓由总部履约)
if (warehouseIds.length === 0) {
return { id: -1n };
}
return { cityId: primary.cityId };
return { fulfillmentWarehouseId: { in: warehouseIds } };
}
async hasManagedWarehouse(partnerAccountId: bigint): Promise<boolean> {
const ids = await this.resolveManagedWarehouseIds(partnerAccountId);
return ids.length > 0;
}
/** 合伙人可管仓库:主账号 managedWarehouseId + 绑定为管仓合伙人的仓 */
@@ -9,6 +9,7 @@ import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
import { HqOperation } from '../../common/hq-operation/hq-operation.decorator';
import { HqOperationAction } from '../../common/hq-operation/hq-operation.constants';
import { PrismaService } from '../../common/prisma/prisma.module';
import { PartnerCityService } from '../city-scope/partner-city.service';
class UpdatePartnerMeDto {
@IsOptional()
@@ -243,7 +244,10 @@ export class AdminWineryBillController {
@Controller('partner/me')
@UseGuards(JwtAuthGuard)
export class PartnerMeController {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly partnerCityService: PartnerCityService,
) {}
@Get()
async me(@CurrentUser() user: AuthUser) {
@@ -274,6 +278,7 @@ export class PartnerMeController {
where: { id: account.parentAccountId },
});
}
const hasWarehouseAccess = await this.partnerCityService.hasManagedWarehouse(primary.id);
return {
id: account.id.toString(),
name: account.name,
@@ -288,6 +293,8 @@ export class PartnerMeController {
hasWechat: !!account.wxOpenId,
wxNickname: account.wxNickname ?? undefined,
wxAvatarUrl: account.wxAvatarUrl ?? undefined,
managedWarehouseId: primary.managedWarehouseId?.toString() ?? null,
hasWarehouseAccess,
};
}
}
@@ -509,6 +509,7 @@ export class TradeService {
async listPartnerOrders(partnerAccountId: bigint, page = 1, pageSize = 20) {
const primary = await this.partnerCityService.resolvePrimaryAccount(partnerAccountId);
const hasWarehouseAccess = await this.partnerCityService.hasManagedWarehouse(primary.id);
const where = await this.partnerCityService.buildPartnerOrderWhere(primary.id);
const [list, total] = await Promise.all([
this.prisma.order.findMany({
@@ -520,7 +521,14 @@ export class TradeService {
}),
this.prisma.order.count({ where }),
]);
return { list: serializeBigInt(list.map(mapOrderCompat)), total, page, pageSize };
return {
list: serializeBigInt(list.map(mapOrderCompat)),
total,
page,
pageSize,
hasWarehouseAccess,
message: hasWarehouseAccess ? undefined : '未配置仓库管理权限,购酒订单由总部履约',
};
}
async getPartnerOrder(partnerAccountId: bigint, orderId: bigint) {