create procedure scoreRule()
begin
declare v_count int default 0 ;
declare has_row int default 0;
declare v_agency_id int default 0;
declare v_static_time varchar(20);
declare v_oper_type int default 1;
declare v_money float default 0;
declare v_rate float ;
declare v_score_rule int;
declare v_create_time datetime ;
declare v_score int default 0;
declare v_total_score int default 0;
declare v_old_score int default 0;
declare vc_agency_id int default 0;
declare vc_create_time varchar(10);
declare vc_consume_type int default 0;
declare vc_area_id int default 0;
declare cur_agency_trans cursor for select min(f.agency_id) as agencyID
from t_ebiz_fund_transaction r ,t_ebiz_fund f where r.fund_inst_id = f.fund_inst_id and f.fund_type =2 and r.oper_type in ('1','2','7' ) and
DATE_FORMAT(r.create_Time,'%Y%m%d') =DATE_FORMAT(STR_TO_DATE(vc_create_time,'%Y%m%d'),'%Y%m%d') group by f.agency_id order by f.agency_id desc;
declare continue handler for not found set has_row = 1;
set v_create_time = now() ;
set vc_create_time =DATE_FORMAT(date_add(now(),interval -1 day),'%Y%m%d');
-- set vc_create_time='20120320';
/*遍历代理商钱包流水表的代理商钱包数据,往表t_ebiz_score_info中插入数据*/
open cur_agency_trans ;
agency_rec:loop
fetch cur_agency_trans into vc_agency_id ;
/* 如果没有找到记录,就跳出循环*/
if has_row =1 then
leave agency_rec;
end if;
/*计算下一个代理商,重置总积分和网点最近日期的积分值*/
set v_total_score = 0;
set v_old_score =0;
/*根据代理商iID,获取代理商的地市ID,增加地市ID选取积分规则*/
select t.area_id into vc_area_id from t_ebiz_agency_info t where t.agency_id = vc_agency_id ;
begin
declare has_detail_row int default 0;
declare cur_detail_trans cursor for select min(r.oper_type) as operType,-1*sum(r.amount) as money
from t_ebiz_fund_transaction r ,t_ebiz_fund f where r.fund_inst_id = f.fund_inst_id and f.fund_type =2 and r.oper_type in ('1','2','7' ) and f.agency_id = vc_agency_id and DATE_FORMAT(r.create_Time,'%Y%m%d') = vc_create_time group by
DATE_FORMAT(r.create_Time,'%Y%m%d'),f.agency_id ,r.oper_type;
declare continue handler for not found set has_detail_row =1;
/* 通过指定的代理商和日期,遍历代理商钱包流水记录表,往获取积分明细表插入数据*/
open cur_detail_trans;
detail_rec:loop
fetch cur_detail_trans into v_oper_type,v_money;
/* 如果没有找到记录,就跳出循环*/
if has_detail_row =1 then
leave detail_rec;
end if;
set v_count = v_count + 1;
/*根据钱包的类型,获取积分计算规则的类型*/
if v_oper_type =1 || v_oper_type =7 then
set vc_consume_type = 1 ;
end if;
if v_oper_type =2 then
set vc_consume_type =2;
end if;
/*获取积分比率和积分规则ID,地市id根据网点的地市id为先,要是网点对应的地市没有配置规则,就用默认的地市规则area_id =1 */
select r.rate,r.score_rule_seq into v_rate,v_score_rule from t_ebiz_score_rule r where r.consume_type = vc_consume_type and( abs(v_money)/100 between r.section_start and r.section_end) and r.area_id in( vc_area_id,'1') order by r.area_id desc limit 1;
set v_score = v_money * v_rate / 100;
insert into t_ebiz_get_score_detail (score_rule_seq,agency_id,create_time,create_staff,consume,score_amount)VALUES (v_score_rule,vc_agency_id,v_create_time,"system",v_money,v_score);
set v_total_score = v_total_score + v_score;
commit;
end loop detail_rec;
close cur_detail_trans;
end;
/*往表代理商积分信息表中插入记录 其中网点的积分值=网点最近日期的积分值 + 当天获取的积分值*/
select t.current_score into v_old_score from t_ebiz_score_info t where t.agency_id = vc_agency_id order by t.static_time desc limit 1;
insert into t_ebiz_score_info(agency_id,static_time,total_score,current_score) values(vc_agency_id,v_create_time,v_total_score,v_total_score+v_old_score);
commit;
end loop agency_rec;
close cur_agency_trans;
end
分享到:
相关推荐
开发商店积分管理系统为商店带来了巨大的改变,它具有强大的数据存储和计算能力,可以方便地进行经营管理的数据分析,并且能够加强商店与顾客之间的联系,提高顾客的忠诚度。因此,开发一个有效的商店积分管理系统...
开发商店积分管理系统为商店带来了巨大的改变,它具有强大的数据存储和计算能力,可以方便地进行经营管理的数据分析,并且能够加强商店与顾客之间的联系,提高顾客的忠诚度。因此,开发一个有效的商店积分管理系统...
我们还将使用MySQL数据库来存储用户的历史记录和结果。最后,我们将进行测试和调试,以确保程序的稳定性和正确性。 本毕设将利用Sofee米表程序的基础,开发一个新的应用程序,该程序将为用户提供更多的数学计算功能...
3. **数据库设计优化**:系统采用MySQL数据库进行数据存储,通过合理的表结构设计,确保数据的安全性和高效性。 4. **用户界面友好**:系统采用简洁直观的图形化界面,降低用户操作难度,提高工作效率。 5. **二次...
业务逻辑处理:处理积分计算、数据更新、积分兑换等业务逻辑。 数据接口:提供RESTful API,供前端调用,实现数据的增删改查等操作。 数据库模块: 技术选型:MySQL 功能: 数据存储:存储用户信息、交易数据、积分...
- 数据库: 使用MySQL或其他数据库存储电影、影厅、座位以及订单信息 2. 主要功能模块 - 影片管理: 管理员可以添加、修改、删除影片信息,如电影名称、上映时间等 - 影厅管理: 管理员可以设置影厅的基本信息,如...
DZX1.5积分计算规则: 总积分=发帖数+精华帖数*5+威望*2+金钱+贡献,因此本系统实际是通过增加或减少金钱来使总积分增加或减少 这插件用的积分是论坛自己的积分吧? 答:恩 新版本 怎么连接不了数据库 由于目标...
数据库管理系统 (DBMS):如Oracle、MySQL、SQL Server,用于创建、维护和查询结构化数据。 企业资源计划 (ERP):整合企业的财务、供应链、人力资源、生产等多方面管理功能的综合性信息系统。 客户关系管理 (CRM)...
在该系统中,我们存储了商家商品及用户的所有信息。用户在我们的网站注册登录后可以按照喜好选择称心的商品,也可通过查询功能准确索引到所需商品。在添加订单并完成结算后商品信息将即刻传输到相应商家以便商品发出...
- 数据库选用MySQL,保证了数据的稳定存储和高效访问。 2. **功能模块**: - 商品管理:包括商品信息的添加、修改、删除和查询等功能。 - 库存管理:实时监控商品库存,方便补货和库存预警。 - 销售管理:处理销售...
无需 Cookie 且不用 PHP Session 也可正常登录和使用,附件采用文件存储,节约数据库空间,加快存取速度,高效智能后台管理程序,提供标准插件接,有效防止各种恶意代码和页面破坏,完善的积分与发帖计算方
无需 Cookie 且不用 PHP Session 也可正常登录和使用,附件采用文件存储,节约数据库空间,加快存取速度,高效智能后台管理程序,提供标准插件接,有效防止各种恶意代码和页面破坏,完善的积分与发帖计算方
- 数据库选用MySQL,保证了数据的稳定存储和高效访问。 2. **功能模块**: - 系统提供了帖子发布、评论互动、用户管理等基础论坛功能,满足用户在数码领域的讨论和信息交流需求。 - 可能还包括了搜索、分类浏览、...
系统采用了MySQL作为数据库存储,通过Maven进行依赖管理和打包部署。 在系统设计上,我们充分考虑了用户体验和营销效果。例如,在商品管理时采用了多图上传和智能推荐等技术,提高了商品的展示效果和销售量;在营销...
- 数据库技术:如MySQL、PostgreSQL或MongoDB,用于存储历史大气数据和预测结果。 - 统计和机器学习库:如Pandas、NumPy、Statsmodels、Scikit-learn等,用于数据分析和模型构建。 部署方式可能包括: - 本地部署...
- 数据库技术:如SQLite、MySQL、PostgreSQL或MongoDB,用于存储历史降雨数据和预测结果。 部署方式可能包括: - 本地部署:在气象研究机构或个人研究者的工作站上配置环境运行系统。 - 云服务部署:将系统部署到...
2、在商品展示页增加商品积分,经验等信息的展示。 3、增加贝宝国际支付接口。 4、增加了快递单打印功能模块。 5、CSV导入导出并兼容淘宝。 6、优化了购物车模块的数据存储结构,使购物车中可存放的商品种类...