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://www.cnblogs.com/attilax/

Atiend

 

 

posted @ 2016-11-07 23:40  attilaxAti  阅读(228)  评论(0编辑  收藏  举报