if exists(select 1 from sysobjects where name='pr_up_rm_savelist')
  drop procedure pr_up_rm_savelist
go

create procedure pr_up_rm_savelist
(
   @flow_no varchar(18),
   @card_id varchar(20),
   @card_no varchar(20),
   @card_type varchar(2),
   @branch_no varchar(10),
   @oper_type varchar(1),
   @oper_id	varchar(4),
   @ope_date DateTime,
   @consume_amt numeric(16,4),
   @acc_num numeric(16,4),
   @oper_des varchar(250),
   @memo     varchar(40),
   @real_amt numeric(16,4),
   @outParam varchar(20) output
)
as
begin
	--上传储值卡充值、消费记录
	--liuw,150609,加入重复验证
	declare @temp_flow_no varchar(20)
    set @temp_flow_no=Replace(@flow_no,'T','')
    if not exists (select 1 from t_rm_vip_savelist where (flow_no=@flow_no or flow_no=@temp_flow_no) and card_id=@card_id and CONVERT(VARCHAR(19),ope_date,121)=CONVERT(VARCHAR(19),@ope_date,121))
    BEGIN
      insert into t_rm_vip_savelist(flow_no,card_id,card_no,card_type,branch_no,oper_type,oper_id,ope_date,consum_amt,acc_num,oper_des,memo,real_amt)
                           values (@flow_no,@card_id,@card_no,@card_type,@branch_no,@oper_type,@oper_id,@ope_date,@consume_amt,@acc_num,@oper_des,@memo,@real_amt)
    END

	select @outParam=''
end
go


