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
@@ -595,6 +595,10 @@ describe('SendChainService', () => {
expect(prisma.smsSubmitRecord.create).toHaveBeenCalledWith({
data: expect.objectContaining({ messageRecordId: 'record-1', channelId: 'channel-1', submitStatus: 'queued' }),
});
expect(prisma.smsMessageRecord.update).toHaveBeenCalledWith({
where: { id: 'record-1' },
data: expect.objectContaining({ channelId: 'channel-1', carrier: 'mobile', province: '山东', status: 'submit_queued' }),
});
expect(gatewayAdd).toHaveBeenCalledWith(
'submit-command',
expect.objectContaining({
@@ -613,6 +617,23 @@ describe('SendChainService', () => {
expect(service['postGatewayControl']).not.toHaveBeenCalledWith('/upstream/submit', expect.anything());
});
it('persists identified carrier and province before a route lookup fails', async () => {
const { service, prisma } = createService();
prisma.channelRouteRule.findFirst.mockResolvedValueOnce(null);
await expect(service['selectChannelForMessage']({
id: 'record-1',
tenantId: 'tenant-1',
applicationId: 'app-1',
phoneNumber: '13800000001',
})).rejects.toThrow('企业应用未配置对应运营商通道组');
expect(prisma.smsMessageRecord.update).toHaveBeenCalledWith({
where: { id: 'record-1' },
data: { carrier: 'mobile', province: '山东' },
});
});
it('updates submit result status, charges billing, and task progress', async () => {
const { service, prisma, billing } = createService();