Commit 8098c69b by kangxiaoshan

先回款

parent b997e771
......@@ -137,14 +137,14 @@ public class ContractController {
if(ValidateUtil.isValid(moneyList)){
for (ContractMoney c : moneyList){
sb.append(c.getDs()).append(",")
.append(c.getContractCode()).append(",")
.append(c.getEmail()).append(",")
.append(c.getCompany()).append(",")
.append(c.getPackageName()).append(",")
.append(c.getSalseName()).append(",")
.append(map.get(c.getType())).append(",")
.append(c.getMoney()).append(",")
.append(c.getCreateName()).append("\r\n");
.append(c.getContractCode()==null?"":c.getContractCode()).append(",")
.append(c.getEmail()==null?"":c.getEmail()).append(",")
.append(c.getCompany()==null?"":c.getCompany()).append(",")
.append(c.getPackageName()==null?"":c.getPackageName()).append(",")
.append(c.getSalseName()==null?"":c.getSalseName()).append(",")
.append(map.get(c.getType()==null?"":c.getType())).append(",")
.append(c.getMoney()==null?"":c.getMoney()).append(",")
.append(c.getCreateName()==null?"":c.getCreateName()).append("\r\n");
if("pay".equals(c.getType())){
// 付款
......
......@@ -53,6 +53,8 @@ public class Contract {
private String ds;
private Boolean virtual;
private Long firstBackId;//先回款记录的id
/**
* 新增字段 20190427
*/
......@@ -88,6 +90,14 @@ public class Contract {
this.virtual = virtual;
}
public Long getFirstBackId() {
return firstBackId;
}
public void setFirstBackId(Long firstBackId) {
this.firstBackId = firstBackId;
}
public String getProduct() {
return product;
}
......
......@@ -666,6 +666,14 @@ public class ContractServiceImpl implements ContractService {
resource.setModifyAccount(loginUser.getId());
}
if (ContractStatusEnum.MONEY_BACK_FIRST.getKey().equals(contract.getStatus())) {
ContractMoney contractMoney = contractMoneyRepository.findOne(contract.getFirstBackId());
if (contractMoney != null) {
contractMoney.setContractCode(resource.getContractCode());
contractMoneyRepository.save(contractMoney);
}
}
resource.setId(contract.getId());
return contractRepository.save(resource);
......@@ -887,21 +895,22 @@ public class ContractServiceImpl implements ContractService {
private void dealContractStatus(Contract resource, User loginUser, String type) {
ContractMoney money = new ContractMoney();
if (resource.getPayMoney() != null) {
if (resource.getMoney() == null) {
resource.setMoney(0L);
}
if (ContractStatusEnum.MONEY_BACK_FIRST.getKey().equals(resource.getStatus())) {
resource.setStatus(ContractStatusEnum.MONEY_BACK_FIRST.getKey());
//记录收款记录
ContractMoney money = new ContractMoney();
money.setType("pay");
saveContractMoney(money, loginUser, resource, type);
money.setType("pay");
money = saveContractMoney(money, loginUser, resource, type);
}else if (resource.getPayMoney().longValue() <= 0) {
//未回款
......@@ -912,17 +921,15 @@ public class ContractServiceImpl implements ContractService {
resource.setStatus(ContractStatusEnum.MONEY_BACK_PART.getKey());
//记录收款记录
ContractMoney money = new ContractMoney();
money.setType("pay");
saveContractMoney(money, loginUser, resource, type);
money = saveContractMoney(money, loginUser, resource, type);
} else {
// 已回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_ALL.getKey());
ContractMoney money = new ContractMoney();
money.setType("pay");
saveContractMoney(money, loginUser, resource, type);
money = saveContractMoney(money, loginUser, resource, type);
}
......@@ -931,6 +938,12 @@ public class ContractServiceImpl implements ContractService {
resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey());
}
if(money.getId()!=null){
resource.setFirstBackId(money.getId());
}else{
resource.setFirstBackId(0L);
}
if (resource.getPayMoney() == null) {
resource.setPayMoney(0L);
}
......@@ -939,7 +952,6 @@ public class ContractServiceImpl implements ContractService {
resource.setInvoiceMoney(new BigDecimal(0));
} else {
// 记录发票记录
ContractMoney money = new ContractMoney();
money.setType("invoice");
saveContractMoney(money, loginUser, resource, type);
}
......@@ -967,10 +979,10 @@ public class ContractServiceImpl implements ContractService {
//保存开票收款记录
private void saveContractMoney(ContractMoney money, User loginUser, Contract contract, String type) {
private ContractMoney saveContractMoney(ContractMoney money, User loginUser, Contract contract, String type) {
if (!"save".equals(type)) {
return;
return money;
}
if(ContractStatusEnum.MONEY_BACK_FIRST.getKey().equals(contract.getStatus())){
......@@ -1003,7 +1015,8 @@ public class ContractServiceImpl implements ContractService {
money.setUser(loginUser.getId());
money.setCreateName(loginUser.getName());
money.setDs(new DateTime().toString("yyyy-MM-dd"));
contractMoneyRepository.save(money);
money = contractMoneyRepository.save(money);
return money;
}
// 保存优惠流量 优惠时长 记录
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment