use of com.kendy.entity.TGTeamModel in project financial by greatkendy123.
the class TGController method getTgTeamHuibaoRate.
/**
* 获取团队的回保比例
* @param teamId
* @return
*/
public double getTgTeamHuibaoRate(String teamId) {
List<TGTeamModel> tgTeams = DBUtil.get_all_tg_team();
if (CollectUtil.isHaveValue(tgTeams)) {
Optional<TGTeamModel> teamInfoOpt = tgTeams.stream().filter(info -> teamId.equals(info.getTgTeamId())).findFirst();
if (teamInfoOpt.isPresent()) {
TGTeamModel teamInfo = teamInfoOpt.get();
String fwfRate = teamInfo.getTgHuiBao();
if (StringUtil.isBlank(fwfRate) || "0%".equals(fwfRate)) {
return 1.0;
} else if ("1".equals(teamInfo.getTgTeamProxy())) {
//
return 1 - NumUtil.getNumByPercent(fwfRate);
}
}
}
return 1.0;
}
use of com.kendy.entity.TGTeamModel in project financial by greatkendy123.
the class TGController method refreshProfitTab.
/**
* 刷新月利润表
* @time 2018年3月17日
*/
public void refreshProfitTab() {
String tgCompany = currentTGCompanyLabel.getText();
if (StringUtil.isBlank(tgCompany)) {
ShowUtil.show("请先选择托管公司!");
return;
}
System.out.println("===========================刷新月利润表");
List<TGLirunInfo> list = new ArrayList<>();
TGLirunInfo lirun = new TGLirunInfo();
// 获取数据库的历史日利润表 TODO
List<TGLirunInfo> liruns = DBUtil.get_all_tg_lirun(tgCompany);
if (CollectUtil.isHaveValue(liruns)) {
// liruns = liruns.stream()
// .filter(info->tgCompany.equals(info.getTgLirunCompanyName())) // 获取当前托管公司的数据,但剔除今天已经保存过的数据,因为下面会重新计算
// .filter(info-> !(TimeUtil.getDateString().equals(info.getTgLirunDate()) && tgCompany.equals(info.getTgLirunCompanyName())))
// .collect(Collectors.toList());
list.addAll(liruns);
String today = getDateString();
boolean isTodayContains = list.stream().anyMatch(info -> today.equals(info.getTgLirunDate()));
if (isTodayContains) {
log.info("刷新月利润表时已经存在了今天" + today + "的数据了!所以不重复计算");
tableTGLirun.setItems(FXCollections.observableArrayList(list));
return;
}
}
// 刷新服务费
refreshFwfTab();
// 获取日期(日期与当前托管公司为主键)
String dateString = getDateString();
lirun.setTgLirunDate(dateString);
lirun.setTgLirunCompanyName(tgCompany);
// 获取总利润(即服务费明细中的总利润)
ObservableList<TypeValueInfo> fwfList = tableTGFwfSum.getItems();
String tgLirunTotalProfit = fwfList.stream().filter(info -> "总利润".equals(info.getType())).map(TypeValueInfo::getValue).findFirst().orElse("0");
lirun.setTgLirunTotalProfit(tgLirunTotalProfit);
// 获取总开销
List<TGKaixiaoInfo> allTGKaixiaos = DBUtil.get_all_tg_kaixiao();
double sumOfKaixiao = allTGKaixiaos.stream().filter(info -> tgCompany.equals(info.getTgKaixiaoCompany())).map(TGKaixiaoInfo::getTgKaixiaoMoney).mapToDouble(NumUtil::getNum).sum();
lirun.setTgLirunTotalKaixiao(NumUtil.digit0(sumOfKaixiao + ""));
// 设置Rest合计
lirun.setTgLirunRestHeji(NumUtil.digit2(NumUtil.getSum(tgLirunTotalProfit, sumOfKaixiao + "")));
// 设置公司占股
TGCompanyModel companyModel = DBUtil.get_tg_company_by_id(tgCompany);
String companyRate = companyModel.getCompanyRate();
companyRate = companyRate.endsWith("%") ? NumUtil.getNumByPercent(companyRate) + "" : NumUtil.getNum(companyRate) / 100.0 + "";
Double atmCompanyProfit = NumUtil.getNumTimes(lirun.getTgLirunRestHeji(), companyRate);
lirun.setTgLirunATMCompany(NumUtil.digit2(atmCompanyProfit + ""));
// 设置托管公司占股
String tgCompanyRate = StringUtil.nvl(companyModel.getTgCompanyRate(), "0%");
tgCompanyRate = tgCompanyRate.endsWith("%") ? NumUtil.getNumByPercent(tgCompanyRate) + "" : NumUtil.getNum(tgCompanyRate) / 100.0 + "";
Double tgCompanyProfit = NumUtil.getNumTimes(lirun.getTgLirunRestHeji(), tgCompanyRate);
lirun.setTgLirunTGCompany(NumUtil.digit2(tgCompanyProfit + ""));
// 设置团队服务费 TODO
Double tgCompanyProxy = 0.0d;
List<TGTeamModel> tgTeamInfos = DBUtil.get_all_tg_team();
Set<String> proxyTeamSet = tgTeamInfos.stream().filter(info -> "1".equals(info.getTgTeamProxy())).map(TGTeamModel::getTgTeamId).collect(Collectors.toSet());
tgCompanyProxy = tableTGFwf.getItems().stream().filter(info -> proxyTeamSet.contains(info.getTgFwfTeamId())).mapToDouble(info -> NumUtil.getNum(info.getTgFwfFanshui()) + NumUtil.getNum(info.getTgFwfFanbao())).sum();
lirun.setTgLirunTeamProfit(NumUtil.digit2(tgCompanyProxy + ""));
// 设置托管公司合计 = 托管公司占股 + 托管公司代理
Double tgCompanyHeji = tgCompanyProfit + tgCompanyProxy;
lirun.setTgLirunHeji(NumUtil.digit2(tgCompanyHeji + ""));
list.add(lirun);
tableTGLirun.setItems(FXCollections.observableArrayList(list));
}
use of com.kendy.entity.TGTeamModel in project financial by greatkendy123.
the class TGController method setTGTeamRateInfo.
/**
* 设置团队的托管回水比例、回保比例、服务费
* @time 2018年3月11日
* @param teamId
*/
private void setTGTeamRateInfo(String teamId) {
TGTeamModel tgTeamModel = DBUtil.get_tg_team_by_id(teamId);
if (tgTeamModel == null) {
// 设置
tgTeamHSRate.setText("0%");
tgTeamHBRate.setText("0%");
tgTeamFwfRate.setText("0%");
tgTeamFwfLabel.setText("0");
teamProxyCheckBox.setSelected(false);
// saveTGTeamAction();
return;
}
// 设置
tgTeamHSRate.setText(tgTeamModel.getTgHuishui());
tgTeamHBRate.setText(tgTeamModel.getTgHuiBao());
tgTeamFwfRate.setText(tgTeamModel.getTgFwfRate());
// TODO
tgTeamFwfLabel.setText(getTGTeamFwf());
boolean isTeamProxy = "1".equals(tgTeamModel.getTgTeamProxy());
teamProxyCheckBox.setSelected(isTeamProxy);
// 其他更新
}
use of com.kendy.entity.TGTeamModel in project financial by greatkendy123.
the class DBUtil method get_all_tg_team.
/**
* 获取所有团队比例
*
* @time 2018年3月4日
* @return
*/
public static List<TGTeamModel> get_all_tg_team() {
List<TGTeamModel> list = new ArrayList<>();
try {
con = DBConnection.getConnection();
String sql = "select * from tg_team";
ps = con.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
// id, tg_date, tg_player_id, tg_player_name, tg_type, tg_id, tg_name, tg_beizhu
TGTeamModel team = new TGTeamModel(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5));
list.add(team);
}
} catch (SQLException e) {
ErrorUtil.err("获取所有团队比例失败", e);
} finally {
close(con, ps);
}
return list;
}
Aggregations