use wtht
go

---------审核库存调整单
/*
DECLARE @sheet_no varchar(100)
DECLARE cur CURSOR FOR
	select distinct  sheet_no from t_im_sheet_master  where memo = '初始库存导入' and approve_flag = '0' and trans_no = 'oo'
OPEN cur 
FETCH NEXT from cur into @sheet_no
while(@@fetch_status = 0)
BEGIN
		UPDATE  t_im_sheet_master 
		SET   approve_flag ='1', confirm_man = '1001', work_date = GETDATE()
		where   sheet_no =  @sheet_no and trans_no = 'OO' AND  approve_flag  = 0 

	FETCH NEXT from cur into @sheet_no
END
close cur 
DEALLOCATE  cur 
*/


-----------审核成本价
/*
GO

DECLARE @sheet_no varchar(100)
DECLARE cur CURSOR FOR
	select distinct  sheet_no from t_pc_price_flow_master  where approve_flag = '0' and trans_no = 'PC'
OPEN cur 
FETCH NEXT from cur into @sheet_no
while(@@fetch_status = 0)
BEGIN
		UPDATE  t_pc_price_flow_master 
		SET   approve_flag ='1', confirm_man = '1001', work_date = GETDATE()
		where   sheet_no =  @sheet_no and  approve_flag = '0' and trans_no = 'PC'

	FETCH NEXT from cur into @sheet_no
END
close cur 
DEALLOCATE  cur 
*/


-----------审核商品调价单
/*
GO

DECLARE @sheet_no varchar(100)
DECLARE cur CURSOR FOR
	select distinct  sheet_no from t_pc_price_flow_master  where approve_flag = '0' and trans_no = 'PX'
OPEN cur 
FETCH NEXT from cur into @sheet_no
while(@@fetch_status = 0)
BEGIN
		UPDATE  t_pc_price_flow_master 
		SET   approve_flag ='1', confirm_man = '1001', work_date = GETDATE()
		where   sheet_no =  @sheet_no and  approve_flag = '0' and trans_no = 'PX'

	    FETCH NEXT from cur into @sheet_no
END
close cur 
DEALLOCATE  cur 
*/


use wtht
go
---删除所有券
--truncate table t_rm_gift_certificate
 
use wtht
go
/*插入券
insert into t_rm_gift_certificate(
giftcert_no,
cert_code,
gift_type,
gift_money,
oper_id,
oper_date,
status,
begin_date,
end_date,
send_branch,
flow_no,
pay_oper,
pay_date,
pay_branch,
--branchlist,
--datatype,
--datalist,
--cert_code,
card_id,
--usecard_id,
--send_flowno,
--plan_no,
--used_type,
memo
--certbags_id,
--Flow_id
)
select 
giftcert_no,
'0'+gift_type,
'0'+gift_type,
gift_money,
oper_id,
oper_date,
status,
begin_date,
end_date,
send_branch,
flow_no,
pay_oper,
pay_date,
pay_branch,
--branchlist,
--datatype,
--datalist,
--cert_code,
card_id,
--usecard_id,
--send_flowno,
--plan_no,
--used_type,
memo
--certbags_id,
--Flow_id
from [isszmv10].dbo.t_rm_gift_certificate 
 where status IN ( '1' ) 
 AND gift_type IN ( '807', '323', '058', '231', '025', '051', '321', '322', '211', '232', '050', '212' ) 
 AND end_date> '2023-01-01'--查询券导入数据

use wtht
go
----券更新仓库
update t_rm_gift_certificate
set   send_branch = Now_branchno
from  t_sys_branchconversion_record
where send_branch = Source_branchno 
*/


-----删除调整单不存在的商品
--delete t_im_sheet_detail where item_no not in (select item_no from t_bd_item_info)

-----删除调价单不存在的商品
--delete t_pc_price_flow_detail where item_no not in (select item_no from t_bd_item_info)

 
/*
 ----PLSU方案修改
update t_rm_vip_plusinfo 
set   Plus_no = '现系统方案'
where Plus_no = '原系统方案'
update t_rm_vip_plusflow 
set   Plus_no = '现系统方案'
where Plus_no = '原系统方案'
*/