|
|
@ -1,8 +1,10 @@
|
|
|
|
package com.example.demo.circulator.service;
|
|
|
|
package com.example.demo.circulator.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.example.demo.Dao.paymentMapper;
|
|
|
|
import com.example.demo.Dao.productMapper;
|
|
|
|
import com.example.demo.Dao.productMapper;
|
|
|
|
import com.example.demo.Dao.usageDateMapper;
|
|
|
|
import com.example.demo.Dao.usageDateMapper;
|
|
|
|
import com.example.demo.bean.Product;
|
|
|
|
import com.example.demo.bean.Product;
|
|
|
|
|
|
|
|
import com.example.demo.bean.Repayment;
|
|
|
|
import com.example.demo.bean.UsageDate;
|
|
|
|
import com.example.demo.bean.UsageDate;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@ -12,25 +14,36 @@ import javax.annotation.PostConstruct;
|
|
|
|
public class EPR_CirService extends CirService{
|
|
|
|
public class EPR_CirService extends CirService{
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private usageDateMapper usageDateMapper;
|
|
|
|
private usageDateMapper usageDateMapper;
|
|
|
|
|
|
|
|
private paymentMapper paymentMapper;
|
|
|
|
private productMapper productMapper;
|
|
|
|
private productMapper productMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional //数据库与事物的一致性
|
|
|
|
@Transactional //数据库与事物的一致性
|
|
|
|
public double NextCirculator(long checkNum){
|
|
|
|
public double NextCirculator(long checkNum){
|
|
|
|
|
|
|
|
try{
|
|
|
|
UsageDate usageDate = usageDateMapper.selectUsageDateByCheckNum(checkNum);
|
|
|
|
UsageDate usageDate = usageDateMapper.selectUsageDateByCheckNum(checkNum);
|
|
|
|
|
|
|
|
Repayment repayment = paymentMapper.selectPepaymentBycheckNum(checkNum);
|
|
|
|
int year = usageDate.getYear();
|
|
|
|
int year = usageDate.getYear();
|
|
|
|
double amount = usageDate.getAmount();
|
|
|
|
double amount = usageDate.getAmount();
|
|
|
|
long productNum = usageDate.getProductNum();
|
|
|
|
long productNum = usageDate.getProductNum();
|
|
|
|
|
|
|
|
|
|
|
|
Product product = productMapper.selectProductByProductNum(productNum);
|
|
|
|
Product product = productMapper.selectProductByProductNum(productNum);
|
|
|
|
float intrate = product.getIntrate();
|
|
|
|
float intrate = product.getIntrate();
|
|
|
|
double rep_amount = 0;
|
|
|
|
double rep_amount = repayment.getRepAmount();
|
|
|
|
intrate /= 12;
|
|
|
|
intrate /= 12;
|
|
|
|
int month = year*12;
|
|
|
|
int month = year*12;
|
|
|
|
double next_principal_and_interest = amount/month + (amount - rep_amount) * intrate;
|
|
|
|
double next_principal_and_interest = amount/month + (amount - rep_amount) * intrate;
|
|
|
|
return next_principal_and_interest;
|
|
|
|
return next_principal_and_interest;
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double SumCirculator(long productNum,double amount,int year){
|
|
|
|
public double SumCirculator(long productNum,double amount,int year){
|
|
|
|
|
|
|
|
try{
|
|
|
|
Product product = productMapper.selectProductByProductNum(productNum);
|
|
|
|
Product product = productMapper.selectProductByProductNum(productNum);
|
|
|
|
float intrate = product.getIntrate();
|
|
|
|
float intrate = product.getIntrate();
|
|
|
|
intrate /= 12;
|
|
|
|
intrate /= 12;
|
|
|
@ -39,5 +52,11 @@ public class EPR_CirService extends CirService{
|
|
|
|
double last_principal_and_interest = amount/month + amount*(1-(month-1)/month)*intrate;
|
|
|
|
double last_principal_and_interest = amount/month + amount*(1-(month-1)/month)*intrate;
|
|
|
|
double principal_and_interest = (first_principal_and_interest + last_principal_and_interest)*month/2;
|
|
|
|
double principal_and_interest = (first_principal_and_interest + last_principal_and_interest)*month/2;
|
|
|
|
return principal_and_interest;
|
|
|
|
return principal_and_interest;
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|