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

create procedure pr_up_rm_payflow
(
   @flow_no varchar(18),
   @flow_id int,
   @sale_amount numeric(16,4),
   @branch_no varchar(6),
   @pay_way varchar(3),
   @sell_way varchar(1),
   @card_no varchar(20),
   @card_id varchar(20),
   @vip_no varchar(20),
   @coin_no varchar(3),
   @coin_rate numeric(16,4),
   @pay_amount numeric(16,4),
   @oper_date DateTime,
   @oper_id	varchar(4),
   @sale_man varchar(4),
   @cashier_no varchar(4),
   @memo varchar(40),
   @voucher_no varchar(18),
   @shift_no varchar(9),
   @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_payflow where (flow_no=@flow_no or flow_no=@temp_flow_no) and flow_id=@flow_id and CONVERT(VARCHAR(19),oper_date,121)=CONVERT(VARCHAR(19),@oper_date,121))
    BEGIN
      insert into t_rm_payflow(flow_no,flow_id,sale_amount,branch_no,pay_way,sell_way,card_no,card_id,vip_no,coin_no,coin_rate,
                                pay_amount,oper_date,oper_id,sale_man,cashier_no,memo,voucher_no,shift_no)
                         values (@flow_no,@flow_id,@sale_amount,@branch_no,@pay_way,@sell_way,@card_no,@card_id,@vip_no,@coin_no,@coin_rate,
                                @pay_amount,@oper_date,@oper_id,@sale_man,@cashier_no,@memo,@voucher_no,@shift_no)
	 set @outParam=''
    END
end
go