IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[cc_update_calllog]') AND type = 'P')
DROP PROCEDURE [dbo].[cc_update_calllog]
GO
-- =============================================
-- Author:LBY
-- Create date: 2018-11-20 17:24
-- Description:更新呼叫历史
-- =============================================
create PROCEDURE [dbo].[cc_update_calllog] (@ordid int,
@mobile nvarchar(50),
@ordno nvarchar(50),
@callid nvarchar(200),
@isAgentDiscnt nvarchar(50),
@recordsrc nvarchar(max),
@stimestamp datetime,--开始时间
@etimestamp datetime,--结束时间
@length nvarchar(50),--通话时长
@isBegin int,--0：结束；1：开始
@isOut int--0：呼入；1：呼出
)
AS
BEGIN
SET NOCOUNT ON;
if(@ordid <> 0)
begin
if(@isBegin = 1)
begin
--开始
if(@isOut = 1)
begin
--呼出开始
update order_274 with(rowlock)
set ord_dhhm = @mobile,
ord_ccwym = @callid,
ord_hjlx = '呼出',
ord_zxgd = @isAgentDiscnt
where ord_id = @ordid
end
else if(@isOut = 0)
begin
--呼入开始
update order_274 with(rowlock)
set ord_dhhm = @mobile,
ord_ccwym = @callid,
ord_hjlx = '呼入',
ord_zxgd = @isAgentDiscnt
where ord_id = @ordid
end
else
begin
--错误：不是呼出的开始也不是结束
select '不是呼出的开始也不是结束' status
end
end
else if(@isBegin = 0)
begin
--呼入呼出结束
update order_274 with(rowlock)
set
ord_no = @ordno,
ord_ly = @recordsrc,
ord_zlsj = @stimestamp,
ord_gjkssj = @etimestamp,
ord_gjjssj = @etimestamp,
ord_thsz = @length
where ord_id = @ordid
end
else
begin
--错误：不是开始也不是结束
select '不是开始也不是结束' status
end
end
SET NOCOUNT OFF;
END