use of com.code.server.constant.db.ChildCost in project summer by foxsugar.
the class DemoAction method testClear.
// 清除返利
public void testClear() {
AgentUser agentUser1 = agentUserDao.findOne(17);
AgentInfo agentInfo = agentUser1.getAgentInfo();
for (String key : agentInfo.getEveryDayCost().keySet()) {
ChildCost childCost = agentInfo.getEveryDayCost().get(key);
childCost.setPartner(1);
}
agentUserDao.save(agentUser1);
}
use of com.code.server.constant.db.ChildCost in project summer by foxsugar.
the class DemoAction method testTest.
public void testTest() {
AgentUser agentUser1 = agentUserDao.findOne(17);
AgentInfo agentInfo = agentUser1.getAgentInfo();
// 计算累计收入
double totalMoney = 0;
double firstLevel = 0;
double secondLevel = 0;
for (String key : agentInfo.getEveryDayCost().keySet()) {
ChildCost childCost = agentInfo.getEveryDayCost().get(key);
if (childCost.getPartner() - 0d == 1d) {
totalMoney += childCost.firstLevel;
totalMoney += childCost.secondLevel;
} else {
firstLevel += childCost.getFirstLevel();
secondLevel += childCost.getSecondLevel();
}
}
}
use of com.code.server.constant.db.ChildCost in project summer by foxsugar.
the class DemoAction method testRecord.
public void testRecord() {
AgentUser agentUser1 = agentUserDao.findOne(17);
AgentInfo agentInfo = agentUser1.getAgentInfo();
Map<String, ChildCost> rs = new HashMap<>();
List<Map<String, ChildCost>> list = new ArrayList<>();
for (String key : agentInfo.getEveryDayCost().keySet()) {
ChildCost childCost = agentInfo.getEveryDayCost().get(key);
if (childCost.getPartner() - 0d == 1d) {
rs.put(key, childCost);
list.add(rs);
}
}
System.out.println("====");
System.out.println(list);
}
use of com.code.server.constant.db.ChildCost in project summer by foxsugar.
the class TodayChargeAction method showCost.
@AuthChecker
@RequestMapping("/dCost")
public AgentResponse showCost(String start, String end) {
// 转化为标准字符串
logger.info("dCost==========start:{},end:{}", start, end);
start = DateUtil.becomeStandardSTime(start);
end = DateUtil.becomeStandardSTime(end);
logger.info("dCost==========start:{},end:{}", start, end);
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
long agentId = AgentUtil.getAgentByRequest(request);
List<String> list = DateUtil.getDateListIn(end, start);
AgentBean agentBean = RedisManager.getAgentRedisService().getAgentBean(agentId);
AgentInfo agentInfo = agentBean.getAgentInfo();
List<DChildCostVo> li = new ArrayList<>();
double oneLevel = 0d;
double twoLevel = 0d;
double threeLevel = 0d;
for (String dateStr : list) {
ChildCost childCost = agentInfo.getEveryDayCost().get(dateStr);
DChildCostVo dChildCostVo = new DChildCostVo();
if (childCost != null) {
BeanUtils.copyProperties(childCost, dChildCostVo);
}
dChildCostVo.setDateStr(dateStr);
li.add(dChildCostVo);
oneLevel += dChildCostVo.getFirstLevel();
twoLevel += dChildCostVo.getSecondLevel();
threeLevel += dChildCostVo.getThirdLevel();
}
// double total = oneLevel * 0.2 * 0.01 + twoLevel * 0.1 * 0.01 + threeLevel *0.1 * 0.01;
double total = (oneLevel + twoLevel + threeLevel) * 0.01;
Map<String, Object> result = new HashMap<>();
result.put("li", li);
result.put("total", total);
// result.put("oneLevel", oneLevel * 0.2 * 0.01);
// result.put("twoLevel", twoLevel * 0.1 * 0.01);
// result.put("threeLevel", threeLevel *0.1 * 0.01);
result.put("oneLevel", oneLevel * 0.01);
result.put("twoLevel", twoLevel * 0.01);
result.put("threeLevel", threeLevel * 0.01);
result.put("start", list.get(list.size() - 1));
result.put("end", list.get(0));
double income = oneLevel * 0.2 * 0.01 + twoLevel * 0.1 * 0.01 + threeLevel * 0.1 * 0.01;
result.put("income", income);
AgentResponse agentResponse = new AgentResponse(200, result);
return agentResponse;
}
use of com.code.server.constant.db.ChildCost in project summer by foxsugar.
the class AgentRedisService method addChildCost.
public void addChildCost(long agentId, double cost, int level, String date, String deleteDay) {
AgentBean agentBean = getAgentBean(agentId);
if (agentBean != null) {
if (cost > 0) {
if (agentBean.getAgentInfo().getEveryDayCost() == null) {
agentBean.getAgentInfo().setEveryDayCost(new HashMap<>());
}
ChildCost childCost = agentBean.getAgentInfo().getEveryDayCost().getOrDefault(date, new ChildCost());
switch(level) {
case 0:
childCost.partner += cost;
break;
case 1:
childCost.firstLevel += cost;
break;
case 2:
childCost.secondLevel += cost;
break;
case 3:
childCost.thirdLevel += cost;
break;
}
agentBean.getAgentInfo().getEveryDayCost().put(date, childCost);
agentBean.getAgentInfo().getEveryDayRebate().remove(deleteDay);
//
// //历史总返利
// double allRebate = agentBean.getAgentInfo().getAllRebate();
// allRebate += rebate;
// agentBean.getAgentInfo().setAllRebate(allRebate);
// //每日返利
// Map<String,Double> everyDayRebate = agentBean.getAgentInfo().getEveryDayRebate();
//
// double todayRebate = everyDayRebate.getOrDefault(date, 0D);
// todayRebate += rebate;
// everyDayRebate.putIfAbsent(date, todayRebate);
// //删除记录
// everyDayRebate.remove(deleteDay);
updateAgentBean(agentBean);
}
}
}
Aggregations