Commit 507ba850 by kangxiaoshan

大后台

parent ae9ee6ae
......@@ -19,6 +19,7 @@ public class Contract {
private String customerBody;
private String email; //客户主账号
private String contractCode;
private int codeNum;
//是否首次签约
private String contractType; // 0 首次签约 1 续签 2 合同变更
private String startDate;
......@@ -63,8 +64,6 @@ public class Contract {
private String customerThird;// 三方客户
private int tradeType; // 行业id
private Long relationContract;// 关联合同id
private String relationCode;// 关联合同编号
private String hasDiscount;// 是否有优惠
......@@ -264,10 +263,6 @@ public class Contract {
return invoice;
}
// public BigDecimal getRebateMoney() {
// return rebateMoney;
// }
public BigDecimal getInvoiceMoney() {
return invoiceMoney;
}
......@@ -276,10 +271,6 @@ public class Contract {
this.invoiceMoney = invoiceMoney;
}
// public void setRebateMoney(BigDecimal rebateMoney) {
// this.rebateMoney = rebateMoney;
// }
public void setInvoice(Long invoice) {
this.invoice = invoice;
}
......@@ -308,6 +299,14 @@ public class Contract {
this.old = old;
}
public int getCodeNum() {
return codeNum;
}
public void setCodeNum(int codeNum) {
this.codeNum = codeNum;
}
@Transient
public Long getPriceName() {
return priceName;
......@@ -330,7 +329,6 @@ public class Contract {
return priceLevelName;
}
@Transient
public String getRelationCode() {
return relationCode;
}
......
......@@ -68,4 +68,8 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value = "select new map( c.id as id, c.contractCode as contractCode ) from Contract c where c.platform in ?1 and c.contractCode is not null and c.contractCode <> 'null' ")
List<Contract> contractCodePlatformNot(List<String> plats, List<Long> ids);
@Query(value = "select contract_code from contract where my_body_code = ?1 order by code_num desc limit 1",nativeQuery = true)
String findLastCode(String code);
}
......@@ -188,22 +188,47 @@ public class ContractServiceImpl implements ContractService {
@Override
public String getContractCode(String code, String platform, String company) {
BigInteger countContract = contractRepository.findcountContract(code);
// BigInteger countContract = contractRepository.findcountContract(code);
//
// String lastCode;
//
// if("fake".equals(platform)){
// platform = "FZBWS";
// }
//
// int codeInt = countContract.intValue();
//
// if (codeInt < 9) {
// lastCode = "0" + (codeInt + 1);
// } else {
// lastCode = "" + (codeInt + 1);
// }
// return code + "-" + platform.toUpperCase() + "-" + DateUtil.getDays2(0) + "-" + lastCode;
String lastCode;
String codeName = contractRepository.findLastCode(code);
if("fake".equals(platform)){
platform = "FZBWS";
}
int codeInt = countContract.intValue();
int codeInt = 0;
if(!StringUtils.isEmpty(codeName)){
codeInt = Integer.parseInt(codeName.split("-")[3]);
}
String lastCode;
if (codeInt < 9) {
lastCode = "0" + (codeInt + 1);
} else {
lastCode = "" + (codeInt + 1);
}
return code + "-" + platform.toUpperCase() + "-" + DateUtil.getDays2(0) + "-" + lastCode;
}
@Override
......@@ -327,9 +352,6 @@ public class ContractServiceImpl implements ContractService {
resource.setCreateName(loginUser.getName());
}
resource.setCreateTime(new Date());
//同步修改trackingio的数据
......@@ -389,20 +411,13 @@ public class ContractServiceImpl implements ContractService {
Contract contract = contractRepository.findOne(resource.getRelationContract());
if (contract.getRelationContract() == null || contract.getRelationContract() == -1) {
contract.setRelationContract(contractId);
contract.setRelationCode(resource.getContractCode());
contractRepository.save(contract);
}
// ContractRelation relationOrigNext = contractRelationRepository.findByRelationData(relation.getRelationId(), relation.getMainContract(), resource.getPlatform());
//
// if (relationOrigNext == null) {
// // 主动关联
// ContractRelation relation2 = new ContractRelation();
// relation2.setCreateTime(new Date());
// relation2.setMainContract(resource.getRelationContract());
// relation2.setRelationId(contractId);
// relation2.setPlatform(resource.getPlatform());
// contractRelationRepository.save(relation2);
// }
//设置关联编号
resource.setRelationCode(contract.getContractCode());
contractRepository.save(resource);
}
}
......@@ -786,6 +801,10 @@ public class ContractServiceImpl implements ContractService {
//记录优惠信息
saveFlowChange(resource,loginUser,type, resource.getDiscountTimeLong(), resource.getExtraFlow());
}
//处理合同编号
resource.setCodeNum(Integer.parseInt(resource.getContractCode().split("-")[3]));
}
......@@ -797,9 +816,9 @@ public class ContractServiceImpl implements ContractService {
}
if (money.getType().equals("pay")) {
contract.setPayMoney(contract.getMoney());
money.setMoney(contract.getMoney());
} else {
contract.setInvoice(contract.getInvoiceMoney().longValue());
money.setMoney(contract.getInvoiceMoney().longValue());
}
money.setCompany(contract.getMyBodyName());
......@@ -1333,7 +1352,7 @@ public class ContractServiceImpl implements ContractService {
for(ContractRelation relation : ids){
if(contract!=null && !relation.getRelationId().equals(contract.getRelationContract())){
filterMap.put(relation.getRelationId()+"_","");
filterMap.put(relation.getRelationId()+"_","");
}
}
......
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