Atitit  代理与分销系统(1)  子代理 充值总额功能设计概览 sum() groubpy subagt

Atitit  代理与分销系统(1)  子代理 充值总额功能设计概览 sum() groubpy subagt

 

 

Keyword

分组与聚合操作。

一个for做分组。。。里面的做聚合。。。

数据g操作查询api sql

etRchgTotal_groupby_SubAgent_where_ParentAgentId(

 

 

http://localhost:8080/agentNrecharge/sub_total_overview.htm?begindate=2016-06-09&enddate=2016-06-09&cnn=3&parent_id=888888

 

 

 

 

http://localhost:8080/wrmiServletV3?iocx=com.attilax.ioc.Ioc4agent&$rdm=0.5026763516943902&$code=new(com.attilax.agent.AgentRechargeService).getSubAgentNtotalsByParentAgentId(888888)

 

 

[ { "uid":"200005", "total":0 }, { "uid":"20002422", "total":0 }, { "uid":"200024", "total":0 }, { "uid":"200025", "total":0 } ]

 

 

00001. 

$code:

00002. 

new(com.attilax.orm.AtiOrmV2).queryAsRzt("select sum(rmb) sumx from recharge where status=1 and accountId in ( select id as uid from account where promoter=888888 )")

00003. 

 

http://localhost:8080/wrmiServletV3?iocx=com.attilax.ioc.Ioc4agent&$rdm=0.8521046019159257&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATEGENERATOR=735FCFCE&hid_cDate=2016-06-09&hid_cDate2=2016-06-09&mylist%24ctl00%24hid_Agentuid=111755&$code=new(com.attilax.orm.AtiOrmV2).queryAsRzt("select%20sum(rmb)%20sumx%20from%20recharge%20%20where%20status%3D1%20and%20accountId%20in%20(%20%20select%20id%20as%20uid%20from%20account%20where%20promoter%3D888888%20)")&$utype=agent

 

 

 

/atiplat_cms/src/com/attilax/agent/AgentRechargeService.java

分组

public List getRchgTotal_groupby_SubAgent_where_ParentAgentId(String pid) {

String sql = " select uid from  agent where  parent_id=$pid$";

sql = sql.replace("$pid$", pid);

List<Map> li = dbsvr.findBySql(sql);

for (Map map : li) {

String subAgentId = (String) map.get("uid");

Map m = Maps.newLinkedHashMap();

m.put("promoter", subAgentId);

BigDecimal money = getRchgTotalsRecycleByAgentId(subAgentId);

map.put("total", money);

}

 

return li;

 

}

 

 

聚合

 

/**

 * sub mem ,self ,and subagt

attilax    2016年11月7日  下午5:14:57

 * @param subAgentId

 * @return

 */

public BigDecimal getRchgTotalsRecycleByAgentId(String subAgentId) {

//Map m

BigDecimal SubMemTotal= getSubMemTotalByAgentId(subAgentId,Maps.newConcurrentMap());

String agent_id=subAgentId;

BigDecimal self=getSelfTotalByUid(subAgentId);

SubMemTotal=SubMemTotal.add(self);

//calc sub agent 's  member recharge

String sql = " select uid from  agent where  parent_id=$pid$";

sql = sql.replace("$pid$", agent_id);

List<Map> li = dbsvr.findBySql(sql);

for (Map map : li) {

String sub_id=(String) map.get("uid");

//Map m2=Maps.newLinkedHashMap();

//m2.putAll(subAgentId);

//m2.put("promoter",sub_id);

BigDecimal SubMemTotal2=getRchgTotalsRecycleByAgentId(sub_id);

SubMemTotal=SubMemTotal.add(SubMemTotal2);

}

return SubMemTotal; 

 

}

 

作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 

汉字名:艾提拉(艾龙)   EMAIL:1466519819@qq.com

转载请注明来源: http://blog.csdn.net/attilax

Atiend

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值