fix: persist sms carrier and province

This commit is contained in:
hectorzhao
2026-07-11 21:55:25 +08:00
parent 37048a4c9a
commit 7b8424d9bc
8 changed files with 76 additions and 12 deletions
+8 -2
View File
@@ -1640,6 +1640,8 @@ export class SendChainService implements OnModuleInit, OnModuleDestroy {
where: { id: message.id },
data: {
channelId: channel.id,
carrier: routed.carrier,
province: routed.province,
submitId,
status: 'submit_queued',
submitStatus: 'queued',
@@ -1747,15 +1749,19 @@ export class SendChainService implements OnModuleInit, OnModuleDestroy {
}
private async selectChannelForMessage(
message: { tenantId: string; applicationId?: string | null; phoneNumber: string },
message: { id: string; tenantId: string; applicationId?: string | null; phoneNumber: string },
options: { forceNational?: boolean; excludeChannelIds?: string[] } = {},
): Promise<RoutedChannel> {
if (!message.applicationId) {
throw new BadRequestException('短信应用未配置,无法选择通道组');
}
const carrier = await this.identifyCarrier(message.phoneNumber);
const route = await this.findApplicationRoute(message.tenantId, message.applicationId, carrier);
const province = await this.identifyProvince(message.phoneNumber);
await this.prisma.smsMessageRecord.update({
where: { id: message.id },
data: { carrier, province },
});
const route = await this.findApplicationRoute(message.tenantId, message.applicationId, carrier);
const excluded = new Set(options.excludeChannelIds ?? []);
const items = route.group.items.filter((item) =>
!excluded.has(item.channelId)