[dbo].[MssWebGetConversationListByOrder]
CREATE procedure [dbo].[MssWebGetConversationListByOrder]
@inSysUserId int,
@inOrderId int
as
begin
set nocount on
select
AccountId = SakariAccount.AccountID,
SakariAccountPriKey = SakariAccount.SakariAccountID,
ContactName = SakariContact.ContactName,
ContactPhone = SakariContact.PhoneNumber,
contactPriKey = SakariContact.SakariContactID,
UpdateCount = Data.UpdateCount ,
ScheduledMessageCount = Data.ScheduledMessageCount,
LastUpdatedAt = SakariContact.LastUpdatedAt
from UdfGetUnreadAndScheduledMessageCount(@inSysUserId) Data
inner join SakariContact on Data.ContactID = SakariContact.SakariContactID
left outer join SakariContactOrderMap on Data.ContactID = SakariContactOrderMap.SakariContactFID
inner join SakariAccount on SakariContact.SakariAccountFID = SakariAccount.SakariAccountID
inner join Orders on SakariContactOrderMap.OrderFID = Orders.PriKey
where SakariContactOrderMap.OrderFID = @inOrderId
order by LastUpdatedAt desc
end
GO
GRANT EXECUTE ON [dbo].[MssWebGetConversationListByOrder] TO [MssExec]
GO