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

-- 生成时间:2018-04-12 10:38:10 by ebs-core  
CREATE  procedure order_140_1911_wrklink_after(
     @cmpid int, 
     @useruid int,
     @bizid int, 
     @ordid bigint, 
     @wrkid int, 
     @jbid bigint, 
     @wsid int, 
     @wsstatus nvarchar(50) 
  ) 
as  
begin  
set nocount on  
declare @nonedate datetime 
set @nonedate = CONVERT(datetime,'1910-1-1')
declare @ord2group2 nvarchar(50) 
set @ord2group2 = '' 
declare @sys_recid bigint 
set @sys_recid = 0 
  
 --- 以下是预处理事件中的临时表
 
exec drop_temp_table '#romaster' 
select * into #romaster from order_140 where ord_id=@ordid 
 ---- 以下是开发人员写的 before link job 事件 --------------
 /*通过转店类型判断转店后的店铺类型*/
declare @dplx nvarchar(10)
select @dplx = ord_zdlx from #romaster
if @dplx='加盟-加盟'
begin
update r
set r.ord_dplx='加盟',
    r.ord_dpbh=n.ord_dpbh1,
    r.ord_dpmc=n.ord_dpmc1,
    r.ord_jmsmc=n.ord_jdr,
    r.ord_jmsdh=n.ord_lxdh1,
    r.ord_dpfzr=n.ord_jdr,
    r.ord_kdsj= n.ord_kyrq
from #romaster n,order_188 r
where r.ord_dpbh=n.ord_dpbh
end
else
if @dplx='加盟-直营'
begin
update r
set r.ord_dplx='直营',
    r.ord_dpbh=n.ord_dpbh1,
    r.ord_dpmc=n.ord_dpmc1,
    r.ord_jmsmc=n.ord_jdr,
    r.ord_jmsdh=n.ord_lxdh1,
    r.ord_dpfzr=n.ord_jdr
from #romaster n,order_188 r
where r.ord_dpbh=n.ord_dpbh
end
else
if @dplx='直营-加盟'
begin
update r
set r.ord_dplx='加盟',
    r.ord_dpbh=n.ord_dpbh1,
    r.ord_dpmc=n.ord_dpmc1,
    r.ord_jmsmc=n.ord_jdr,
    r.ord_jmsdh=n.ord_lxdh1,
    r.ord_dpfzr=n.ord_jdr,
    r.ord_kdsj= n.ord_kyrq
from #romaster n,order_188 r
where r.ord_dpbh=n.ord_dpbh
end


 ---- 以上是开发人员写的 before libk job 事件 --------------
 
  
 
 
--- 清除临时表 
exec drop_temp_table '#romaster' 

set nocount off 
end