积分计算方法(带过期时间)

-- 获取用户积分信息 procedure SS_UserIntegral_List( v_9YOUACCOUNT varchar2, cur_Result out rc_class ) is begin open cur_Result for select d.intergral, d.collectdate, d.expdate from tgs_userintergral_detail d where lower(d.user_id)=lower(v_9YOUACCOUNT) order by d.expdate; end SS_UserIntegral_List; -- 获取用户兑换消费积分 procedure SS_UserIntergralExchange_List( v_9YOUACCOUNT varchar2, cur_Result out rc_class ) is begin open cur_Result for select * from( select v.costintegral, v.exchangetime from tgs_exchangeitem v where lower(v.you9id)=lower(v_9YOUACCOUNT) and v.status=1 union all select r.costintegral, r.exchangetime from tgs_exchangerealitem r where lower(r.you9id)=lower(v_9YOUACCOUNT) ) order by exchangetime; end SS_UserIntergralExchange_List; end SS_SITE_POINT_PACK;

 

程序代码:

// 计算积分 // TGS_SITE_POINT_PACK.TGS_UserIntegral_List // TGS_SITE_POINT_PACK.TGS_UserIntergralExchange_List private UserIntegral UserIntegralDS(string you9Account) { decimal all = 0; List<PointChange> plist = ScoreDAL.SS_UserIntegral_List(you9Account); List<ExchangeDetails> exlist = ScoreDAL.SS_UserIntergralExchange_List(you9Account); foreach (var pc in plist) { decimal lst = pc.INTERGRAL; foreach (var el in exlist) { if (el.EXCHANGETIME >= pc.COLLECTDATE && el.EXCHANGETIME <= pc.EXPDATE && lst >=0) { lst -= el.COSTINTEGRAL; if (lst < 0) { pc.INTERGRAL = 0; el.COSTINTEGRAL = -lst; } else if (lst == 0) { pc.INTERGRAL = 0; el.COSTINTEGRAL = 0; } else { pc.INTERGRAL = lst; el.COSTINTEGRAL = 0; } } } } DateTime now = DateTime.Now; foreach (var pc in plist) { if (pc.EXPDATE >= now) { all += pc.INTERGRAL; } } return new UserIntegral() { INTERGRAL_NOW = all, INTERGRAL_TOTAL = 0, TYPENAME = "普通用户", UKEY = 0, }; } // 获得积分日志 // TGS_SITE_POINT_PACK.TGS_UserIntegralDetail_QUERY // 兑换记录 // 虚拟 TGS_SITE_ITEM_PACK.TGS_ExchangeItem_Query // 实物 TGS_SITE_ITEM_PACK.TGS_ExchangeRealItem_Query

你可能感兴趣的:(list,String,query,Class)