还款界面交互完成

master
jyx 7 years ago
parent 649c00f275
commit 412213ab36

@ -8,8 +8,8 @@ import java.util.List;
@Mapper
public interface auditMapper {
// @Select("select * from audit where checkNum = #{checkNum}")
// public Audit selectAudioByCheckNum(long checkNum);
@Select("select * from audit where checkNum = #{checkNum}")
public Audit selectAudioByCheckNum(long checkNum);
@Select("select * from audit where userNum = #{userNum}")
public List<Audit> selectAuditByUserNum(long userNum);

@ -11,7 +11,7 @@ public interface paymentMapper {
@Select("select * from repayment where checkNum = #{checkNum}")
public Repayment selectPepaymentBycheckNum(long checkNum);
@Update("update repayment set repAmount = {#repAmount} ,repSum = #{repSum} where checkNum = #{checkNum}")
@Update("update repayment set repAmount = #{repAmount} ,repSum = #{repSum} where checkNum = #{checkNum}")
public void updateRepayment(Repayment repayment);
@Insert(" insert into repayment(checkNum,repAmount,repSum) values (#{checkNum},#{repAmount}," +

@ -10,6 +10,8 @@ public interface transMapper {
@Select("select * from transaction where transactionNum = #{transactionNum}")
public Transaction selectAudioByCheckNum(long transactionNum);
@Select("select count(*) from transaction")
public int selectCount();
@Select("select * from transaction")
public List<Transaction> select();

@ -34,11 +34,9 @@ public class PayCirController {
String json = JSONObject.toJSONString(map);
response.getWriter().print(json);
}else if(result==-2){
//return"/未贷款该业务!";
// return;
}else if(result==-3){
//return "/无此业务";
// return;
}
//return "/还款失败";
}
}

@ -1,20 +1,14 @@
package com.example.demo.circulator.service;
import com.example.demo.Dao.paymentMapper;
import com.example.demo.Dao.productMapper;
import com.example.demo.Dao.transMapper;
import com.example.demo.Dao.usageDateMapper;
import com.example.demo.bean.Product;
import com.example.demo.bean.Repayment;
import com.example.demo.bean.Transaction;
import com.example.demo.bean.UsageDate;
import com.example.demo.Dao.*;
import com.example.demo.bean.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class PayCirService {
@Autowired
private usageDateMapper usageDateMapper;
private auditMapper auditMapper;
@Autowired
private paymentMapper paymentMapper;
@Autowired
@ -26,12 +20,11 @@ public class PayCirService {
public int pay_EPR_AmountCirculator(long checkNum,long userNum,double pay) {
try {
Repayment repayment = paymentMapper.selectPepaymentBycheckNum(checkNum);
UsageDate usageDate = usageDateMapper.selectUsageDateByCheckNum(checkNum);
Audit audit = auditMapper.selectAudioByCheckNum(checkNum);
double repamount = 0;
long productNum = usageDate.getProductNum();
long userNum2 = usageDate.getUserNum();
long bankNum = usageDate.getBankNum();
double amount = usageDate.getAmount();
long productNum = audit.getProductNum();
long userNum2 = audit.getUserNum();
double amount = audit.getAmount();
if(userNum2!=userNum)return -1;
if (repayment != null)
@ -39,14 +32,21 @@ public class PayCirService {
Product product = productMapper.selectProductByProductNum(productNum);
if (product == null)
return -3;
Transaction transaction = new Transaction(checkNum, userNum, bankNum, pay);
long bankNum = product.getBankNum();
int count = transMapper.selectCount()+1;
Transaction transaction = new Transaction();
transaction.setCheckNum(checkNum);
transaction.setTransactionNum(count);
transaction.setPayer(userNum);
transaction.setPayee(bankNum);
transaction.setTransactionAmount(pay);
transMapper.addTransaction(transaction);
double intrate = product.getIntrate();
double rep_amount = repayment.getRepSum();
repamount = pay - (amount - repamount) * intrate;
repayment.setRepAmount(repamount);
repayment.setCheckNum(checkNum);
repayment.setRepSum(pay + rep_amount);
if (repayment != null) {
paymentMapper.updateRepayment(repayment);
@ -63,10 +63,10 @@ public class PayCirService {
public int pay_EPAIR_AmountCirculator(long checkNum,long userNum,double pay){
try{
UsageDate usageDate = usageDateMapper.selectUsageDateByCheckNum(checkNum);
int year = usageDate.getYear();
double amount = usageDate.getAmount();
long productNum = usageDate.getProductNum();
Audit audit= auditMapper.selectAudioByCheckNum(checkNum);
int year = audit.getYear();
double amount = audit.getAmount();
long productNum = audit.getProductNum();
Product product = productMapper.selectProductByProductNum(productNum);
if(product==null)return -3;
@ -79,11 +79,17 @@ public class PayCirService {
double rep = Math.pow((1+intrate),month)/(Math.pow((1+intrate),month)-1);
double next_principal_and_interest = rep * intrate * amount;
long userNum2 = usageDate.getUserNum();
long bankNum = usageDate.getBankNum();
long userNum2 = audit.getUserNum();
long bankNum = product.getBankNum();
if(userNum2!=userNum)return -1;
Transaction transaction = new Transaction(checkNum,userNum,bankNum,next_principal_and_interest);
int count = transMapper.selectCount()+1;
Transaction transaction = new Transaction();
transaction.setCheckNum(checkNum);
transaction.setTransactionNum(count);
transaction.setPayer(userNum);
transaction.setPayee(bankNum);
transaction.setTransactionAmount(pay);
transMapper.addTransaction(transaction);
Repayment repayment = paymentMapper.selectPepaymentBycheckNum(checkNum);
@ -91,9 +97,13 @@ public class PayCirService {
if(repayment!=null){
repSum += repayment.getRepSum();
repayment.setRepSum(repSum);
repayment.setCheckNum(checkNum);
paymentMapper.updateRepayment(repayment);
}else{
paymentMapper.addRepayment(repayment);
Repayment repayment1 = new Repayment();
repayment1.setRepSum(repSum);
repayment1.setCheckNum(checkNum);
paymentMapper.addRepayment(repayment1);
}
return 1;
}catch(Exception e){
@ -106,9 +116,9 @@ public class PayCirService {
public int payAmountCirculator(long checkNum,long userNum,double pay){
try{
UsageDate usageDate = usageDateMapper.selectUsageDateByCheckNum(checkNum);
if(usageDate==null){return -2;}
int equation = usageDate.getEquation();
Audit audit = auditMapper.selectAudioByCheckNum(checkNum);
if(audit==null){return -2;}
int equation = audit.getEquation();
if(equation == 1){
return pay_EPAIR_AmountCirculator(checkNum,userNum,pay);
}else if(equation == 2){

@ -37,6 +37,7 @@ public class messageController extends HttpServlet {
Audit audit=new Audit();
audit.setUserNum(num);
audit.setAmount(Double.parseDouble(request.getParameter("amount")));
audit.setProductNum(Long.parseLong(request.getParameter("productNum")));
audit.setYear(Integer.parseInt(request.getParameter("year")));
audit.setBankAccount(request.getParameter("bankAccount"));
audit.setEquation(Integer.parseInt(request.getParameter("equation")));

@ -22,6 +22,7 @@
async: false,
success: function (data) {
alert("还款成功");
window.location.href="index.html";
},
error: function (msg) {
alert("还款失败" );

@ -244,6 +244,16 @@ box-shadow:inset 0px 1px 1px rgba(0,0,0,0.5);*/
<body sroll="no" onclick="onload">
<form id="form1" onSubmit="return checkreg()" action="/loan" method="post">
<div class="div_f">
<div class="div_col" id="pro">
<div class="div_c_l"><span>产品名</span>
</div>
<div class="div_c_r"><input type="cardNum" name="productNum" id="" onKeyDown="" value="" placeholder="卡号">
<span style="float: right;margin-top: -30px;background:#fff"></span></input>
</div>
</div>
<div style="clear:both"></div>
</div>
<div class="div_f">
<div class="div_col" id="wegb">
<div class="div_c_l"><span> 贷款金额</span>

Loading…
Cancel
Save