<pre name="code" class="java"> public void executefullloan(String loanid,List<User> users,Integer investn){
int index=investn%users.size();
User user=users.get(index);
double remainMoney = 0;
try {
remainMoney = loanCalculator.calculateMoneyNeedRaised1(loanid);
} catch (NoMatchingObjectsException e) {
e.printStackTrace();
}
if(investn==1){
Invest investSys=new Invest();
investSys.setId(IdGenerator.randomUUID());
investSys.setMoney(0D);
investSys.setInvestMoney(remainMoney);
investSys.setLoan(ht.get(Loan.class,loanid));
investSys.setUser(ht.get(User.class,user.getId()));
investSys.setStatus(InvestConstants.InvestStatus.REPAYING);
investSys.setTime(new Date());
ht.save(investSys);
// 项目募集完成
Loan loan = ht.get(Loan.class, loanid);
loan.setStatus(LoanConstants.LoanStatus.REPAYING);
ht.update(loan);
}else{
double m=0;
if(Math.floor(remainMoney/(investn*10000))>0){
m=Math.floor(remainMoney/(investn*10000))*10000;
}else if(Math.floor(remainMoney/(investn*1000))>0){
m=Math.floor(remainMoney/(investn*1000))*1000;
}else if(Math.floor(remainMoney/(investn*100))>0){
m=Math.floor(remainMoney/(investn*100))*100;
}
Invest investSys=new Invest();
investSys.setId(IdGenerator.randomUUID());
investSys.setMoney(0D);
investSys.setInvestMoney(m);
investSys.setLoan(ht.get(Loan.class,loanid));
investSys.setUser(ht.get(User.class,user.getId()));
investSys.setStatus(InvestConstants.InvestStatus.REPAYING);
investSys.setTime(new Date());
ht.save(investSys);
executefullloan(loanid,users,investn-1);
}
}