解决方案 »
- winform 双缓存局部绘图
- 我想每天自动下载一个文件,求方法
- 使用LINQ TO SQL删除时出现了这样的错误
- 在VS.NET2008开发环境中有没有类似SQL SERVER2000的企业管理器功能,比如能附加数据库、创建数据库等。
- 求 C# Winfrom 界面美化的书
- 在pictureBox里画了一条直线,如何用鼠标去移动它?
- 一点关于C#的问题……拜托大家帮助一下……
- asp访问c#生成的dll,表单问题
- The property named 'addnen' not found in Entity definition.
- xml 读写问题!
- silverlight中可以用GDI+吗
- MVC HTMLHELPER 遇到一个小问题 但是网上没搜到答案
create or replace procedure vip_recharge(in_uid in integer)
is
c_rd_id recharge_detail.rd_id%type;
c_u_id recharge_detail.u_id%type;
c_pay_time recharge_detail.pay_time%type;
c_year_num recharge_detail.year_num%type;
cursor vip_cursor is
select rd_id,u_id,pay_time,year_num
from recharge_detail
where u_id=in_uid
and pay_off='1' --是否付清
order by rd_id;
begin
open vip_cursor;
loop
fetch vip_cursor into c_rd_id,c_u_id,c_pay_time,c_year_num; --loop and fench
exit when vip_cursor%notfound;
merge into user_vip ma
using (select b.u_id,
nvl(a.u_id,0) aid, --用户名编号不存在设为0
case when c_pay_time>nvl(a.end_time,to_date('1970-01-01','yyyy-mm-dd')) then c_pay_time
else a.begin_time --支付时间大于结束时间(结束时间为null时即为1970-01-01)则为支付时间否则为结束时间作为vip的开始时间
end vip_begin_time,
case when sysdate>nvl(a.end_time,to_date('1970-01-01','yyyy-mm-dd')) then add_months(sysdate, 12*c_year_num)
else add_months(a.end_time, 12*c_year_num) --系统当前时间大于结束时间(结束时间为null时即为1970-01-01)则系统当前时间添加年限(12*c_year_num),否则结束时间添加年限作为vip结束时间
end vip_end_time,
b.year_statis
from user_vip a right join
(select u_id,sum(year_num) year_statis
from recharge_detail
where u_id=c_u_id
and pay_off>0 --pay_off 0 1 2
group by u_id)b
on a.u_id=b.u_id) mb
on (ma.u_id=mb.u_id and ma.u_id=mb.aid) --用户会员表中的用户编号和recharge_detail信息变更表中的信息相同时匹配
when matched then
update set ma.begin_time=mb.vip_begin_time,
ma.end_time=mb.vip_end_time,
ma.year_statis=mb.year_statis --设置
when not matched then
insert (u_id,begin_time,end_time,year_statis)
values(c_u_id,sysdate,add_months(sysdate,12*c_year_num),c_year_num); --添加
update recharge_detail set pay_off=2 where rd_id=c_rd_id; --修改
commit;
end loop;
close vip_cursor;end vip_recharge;
--通过用户id