IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[order_270_startmessage_3283]') AND type = 'P')
DROP PROCEDURE [dbo].[order_270_startmessage_3283]
GO

-- 生成时间:2018-11-22 18:21:38 by ebs-core  
create  procedure order_270_startmessage_3283(
     @cmpid int, 
     @ordid bigint,
     @jbid bigint
  ) 
  as  
  begin  
set nocount on  
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

------ 给执行人发消息  ----------  

insert into ebs_kernel.dbo.pub_message(msg_cmpid,msg_mpid,msg_text,msg_senddate,msg_type,msg_target,msg_cuid)  
select @cmpid,34,'{first}您好，有一笔新的存费请及时处理.{keyword1}'+ord_sjh+'{keyword2}送费申请{keyword3}'+CONVERT(varchar,ord_date,111)+'{keyword4}'+CONVERT(varchar,ord_date,111)+'{remark}点击消息查看详情{url}/order/biztop.mobile.htm?crmid='+CONVERT(varchar,ord_bizid)+'&ordid='+CONVERT(varchar,ord_id)+'&jbid='+CONVERT(varchar,jb_id),getdate(),'GZH',
case when cu_gzh1 like 'wx56e2528d9665465f%'  then substring(cu_gzh1,20,50) 
when cu_gzh2 like 'wx56e2528d9665465f%'  then substring(cu_gzh2,20,50) 
when cu_gzh3 like 'wx56e2528d9665465f%'  then substring(cu_gzh3,20,50) 
when cu_gzh4 like 'wx56e2528d9665465f%'  then substring(cu_gzh4,20,50) 
when cu_gzh5 like 'wx56e2528d9665465f%'  then substring(cu_gzh5,20,50) end ,cu_id  
from order_270  with(nolock),mps_job  with(nolock) ,mps_login with(nolock) ,mps_job_users  with(nolock) 
where  ord_id=@ordid and  jb_id=@jbid and  jp_type='wrkexecutor' and jp_jbid=@jbid and jp_cuid=cu_id and 
cu_type=0 and (cu_gzh1 like 'wx56e2528d9665465f%' or cu_gzh2 like 'wx56e2528d9665465f%' or cu_gzh3 like 'wx56e2528d9665465f%' or cu_gzh4 like 'wx56e2528d9665465f%' or cu_gzh5 like 'wx56e2528d9665465f%') 

insert into ebs_kernel.dbo.pub_message(msg_cmpid,msg_mpid,msg_text,msg_senddate,msg_type,msg_target,msg_cuid)  
select @cmpid,34,'【'+ ord_creator + '】给你发起了一项新的送费申请任务，请及时处理！'
+'{title}工作提醒:'+ord_type+char(9)+
+'{url}/order/biztop.mobile.htm?crmid='+CONVERT(varchar,ord_bizid)+'&ordid='+CONVERT(varchar,ord_id)+'&jbid='+CONVERT(varchar,jb_id),getdate(),'DING',substring(cu_ding , 22,50)    ,cu_id 
from order_270 with(nolock) ,mps_job with(nolock) ,mps_login with(nolock) ,mps_job_users with(nolock)  
where  ord_id=@ordid and  jb_id=@jbid and  jp_type='wrkexecutor' and jp_jbid=@jbid and jp_cuid=cu_id and 
cu_type=0 and cu_ding>'' 

------ 给监督人发消息  ----------  

------ 给协作人发消息  ----------  

------ 给知会人发消息  ----------  

------ 给日志参与人发消息  ----------  

------ 给员工1发消息  ----------  

------ 给员工2发消息  ----------  

------ 给员工3发消息  ----------  


set nocount off  
end