Commit 93dbab6b by kangxiaoshan

大后台更新

parent 3f152851
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
<office.username>root</office.username> <office.username>root</office.username>
<office.password>reyun.123</office.password> <office.password>reyun.123</office.password>
<tkio.url>jdbc:mysql://10.3.20.32:3306/trackingio_test?characterEncoding=utf-8</tkio.url> <tkio.url>jdbc:mysql://10.3.20.32:3306/trackingio_trans?characterEncoding=utf-8</tkio.url>
<tkio.username>root</tkio.username> <tkio.username>root</tkio.username>
<tkio.password>reyun.123</tkio.password> <tkio.password>reyun.123</tkio.password>
......
...@@ -63,9 +63,15 @@ public class Contract { ...@@ -63,9 +63,15 @@ public class Contract {
private String customerThird;// 三方客户 private String customerThird;// 三方客户
private int tradeType; // 行业id private int tradeType; // 行业id
private Long relationContract;// 关联合同id private Long relationContract;// 关联合同id
private String createrName; // 录入人 private String createrName; // 录入人
private String relationCode;// 关联合同编号
private String hasDiscount;// 是否有优惠
@Id @Id
@GeneratedValue @GeneratedValue
public Long getId() { public Long getId() {
...@@ -314,6 +320,24 @@ public class Contract { ...@@ -314,6 +320,24 @@ public class Contract {
return priceLevelName; return priceLevelName;
} }
@Transient
public String getRelationCode() {
return relationCode;
}
public void setRelationCode(String relationCode) {
this.relationCode = relationCode;
}
@Transient
public String getHasDiscount() {
return hasDiscount;
}
public void setHasDiscount(String hasDiscount) {
this.hasDiscount = hasDiscount;
}
public void setPriceLevelName(String priceLevelName) { public void setPriceLevelName(String priceLevelName) {
this.priceLevelName = priceLevelName; this.priceLevelName = priceLevelName;
} }
......
...@@ -12,6 +12,6 @@ import java.util.List; ...@@ -12,6 +12,6 @@ import java.util.List;
*/ */
public interface ContractRelationRepository extends JpaRepository<ContractRelation, Long> { public interface ContractRelationRepository extends JpaRepository<ContractRelation, Long> {
@Query(value = "select relation_id from contract_relation where main_contract = ?1",nativeQuery = true) @Query(value = "select main_contract from contract_relation where relation_id = ?1",nativeQuery = true)
List<Long> findRelationIds(String contractId); List<Long> findRelationIds(String contractId);
} }
...@@ -39,13 +39,13 @@ import java.util.*; ...@@ -39,13 +39,13 @@ import java.util.*;
* Created by mxq on 2018/1/16. * Created by mxq on 2018/1/16.
*/ */
@Service @Service
public class ContractServiceImpl implements ContractService{ public class ContractServiceImpl implements ContractService {
private static final Map<String,String> CONTRACT_TYPE = new HashMap(){{ private static final Map<String, String> CONTRACT_TYPE = new HashMap() {{
put("0","首次签约"); put("0", "首次签约");
put("1","续约"); put("1", "续约");
put("2","合同变更"); put("2", "合同变更");
}}; }};
...@@ -95,36 +95,35 @@ public class ContractServiceImpl implements ContractService{ ...@@ -95,36 +95,35 @@ public class ContractServiceImpl implements ContractService{
ContractRelationRepository contractRelationRepository; ContractRelationRepository contractRelationRepository;
@Override @Override
public Map<String, Object> checkAccount(String email, String platfrom) { public Map<String, Object> checkAccount(String email, String platfrom) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
Account4Web account4Web = null; Account4Web account4Web = null;
IOAccount4Web ioAccount4Web = null; IOAccount4Web ioAccount4Web = null;
ADIUser adiUser =null; ADIUser adiUser = null;
if("tkio".equals(platfrom)){ if ("tkio".equals(platfrom)) {
account4Web = account4WebRepository.findByEmail(email); account4Web = account4WebRepository.findByEmail(email);
}else if("io".equals(platfrom)){ } else if ("io".equals(platfrom)) {
ioAccount4Web = ioAccount4WebRepository.findByEmail(email); ioAccount4Web = ioAccount4WebRepository.findByEmail(email);
}else if("adi".equals(platfrom)){ } else if ("adi".equals(platfrom)) {
adiUser = adiAccountService.findOne(email); adiUser = adiAccountService.findOne(email);
} }
if(null == account4Web && null == ioAccount4Web && null ==adiUser){ if (null == account4Web && null == ioAccount4Web && null == adiUser) {
map.put("result", 0); map.put("result", 0);
}else{ } else {
BigInteger integer = contractRepository.countNumByEmail(email,platfrom); BigInteger integer = contractRepository.countNumByEmail(email, platfrom);
map.put("result", 1); map.put("result", 1);
if(platfrom.equals("adi")){ if (platfrom.equals("adi")) {
map.put("company", adiUser.getCompany()); map.put("company", adiUser.getCompany());
}else{ } else {
map.put("company", null == account4Web ? ioAccount4Web.getCompany() : account4Web.getCompany()); map.put("company", null == account4Web ? ioAccount4Web.getCompany() : account4Web.getCompany());
} }
map.put("num", integer.intValue()); map.put("num", integer.intValue());
Contract contract = contractRepository.findByPlatformAndEmailLimitVaild(platfrom, email); Contract contract = contractRepository.findByPlatformAndEmailLimitVaild(platfrom, email);
if(null == contract){ if (null == contract) {
map.put("status", false); map.put("status", false);
}else{ } else {
map.put("status", true); map.put("status", true);
} }
} }
...@@ -135,25 +134,25 @@ public class ContractServiceImpl implements ContractService{ ...@@ -135,25 +134,25 @@ public class ContractServiceImpl implements ContractService{
@Override @Override
public Boolean checkTime(String email, String platfrom, String type, String product) { public Boolean checkTime(String email, String platfrom, String type, String product) {
Boolean flag = false; Boolean flag = false;
if(ContractTypeEnum.MAIN.getKey().equals(type)){ if (ContractTypeEnum.MAIN.getKey().equals(type)) {
Contract contract = contractRepository.findByPlatformAndEmailLimit1(platfrom, email, type); Contract contract = contractRepository.findByPlatformAndEmailLimit1(platfrom, email, type);
if (null == contract){ if (null == contract) {
flag = true; flag = true;
}else{ } else {
String beforeDay = DateUtil.getBeforeDays(180); String beforeDay = DateUtil.getBeforeDays(180);
if(beforeDay.compareTo(contract.getEndDate()) > 0){ if (beforeDay.compareTo(contract.getEndDate()) > 0) {
flag = true; flag = true;
} }
} }
}else{ } else {
ContractIncrement increment = contractIncrementRepository.findByCode(product); ContractIncrement increment = contractIncrementRepository.findByCode(product);
Contract contract = contractRepository.findByPlatformAndEmailAndPricelevelLimit1(platfrom, email, type, increment.getId()); Contract contract = contractRepository.findByPlatformAndEmailAndPricelevelLimit1(platfrom, email, type, increment.getId());
if (null == contract){ if (null == contract) {
flag = true; flag = true;
}else{ } else {
String beforeDay = DateUtil.getBeforeDays(180); String beforeDay = DateUtil.getBeforeDays(180);
String endDate = contract.getEndDate() == null ? contract.getDs() : contract.getEndDate(); String endDate = contract.getEndDate() == null ? contract.getDs() : contract.getEndDate();
if(beforeDay.compareTo(endDate) > 0){ if (beforeDay.compareTo(endDate) > 0) {
flag = true; flag = true;
} }
} }
...@@ -170,9 +169,9 @@ public class ContractServiceImpl implements ContractService{ ...@@ -170,9 +169,9 @@ public class ContractServiceImpl implements ContractService{
public String getContractCode(String code) { public String getContractCode(String code) {
BigInteger integer = contractRepository.countNumByDs(DateUtil.getBeforeDays(0)); BigInteger integer = contractRepository.countNumByDs(DateUtil.getBeforeDays(0));
String lastCode = ""; String lastCode = "";
if(integer.intValue() < 9){ if (integer.intValue() < 9) {
lastCode = "0" + (integer.intValue() + 1); lastCode = "0" + (integer.intValue() + 1);
}else{ } else {
lastCode = "" + (integer.intValue() + 1); lastCode = "" + (integer.intValue() + 1);
} }
String re = code + "-" + DateUtil.getDays2(0) + lastCode; String re = code + "-" + DateUtil.getDays2(0) + lastCode;
...@@ -184,6 +183,8 @@ public class ContractServiceImpl implements ContractService{ ...@@ -184,6 +183,8 @@ public class ContractServiceImpl implements ContractService{
BigInteger countContract = contractRepository.findcountContract(platform); BigInteger countContract = contractRepository.findcountContract(platform);
// BigInteger countContract = contractRepository.countNumByDs(DateUtil.getBeforeDays(0));
String lastCode; String lastCode;
int codeInt = countContract.intValue(); int codeInt = countContract.intValue();
...@@ -199,30 +200,31 @@ public class ContractServiceImpl implements ContractService{ ...@@ -199,30 +200,31 @@ public class ContractServiceImpl implements ContractService{
@Override @Override
public List findSetmeal(String platform) { public List findSetmeal(String platform) {
List list = new ArrayList(); List list = new ArrayList();
if("adi".equals(platform)){ if ("adi".equals(platform)) {
for(int i = 1; i < 3; i++) { for (int i = 1; i < 3; i++) {
Map<String, String> packageMap = new HashMap<>(); Map<String, String> packageMap = new HashMap<>();
packageMap.put("id", i + ""); packageMap.put("id", i + "");
if(i == 1){ if (i == 1) {
packageMap.put("packageName", PackageEnum.PROBATION.getValue()); packageMap.put("packageName", PackageEnum.PROBATION.getValue());
}else{ } else {
packageMap.put("packageName", PackageEnum.FORMAL.getValue()); packageMap.put("packageName", PackageEnum.FORMAL.getValue());
} }
list.add(packageMap); list.add(packageMap);
} }
}else { } else {
if("tkio".equals(platform) || "io".equals(platform)){ if ("tkio".equals(platform) || "io".equals(platform)) {
List<PackageType> packageTypeList = packageTypeRepository.findAll(); // List<PackageType> packageTypeList = packageTypeRepository.findAll();
for(PackageType p : packageTypeList){ List<PackageType> packageTypeList = packageTypeRepository.findIsNewAll();
p.setType("main"); for (PackageType p : packageTypeList) {
list.add(p); p.setType("main");
list.add(p);
}
// 增值套餐
List<ContractIncrement> increments = contractIncrementRepository.findAll();
list.addAll(increments);
} else if ("userdesk".equals(platform) || "dmp".equals(platform) || "fake".equals(platform)) {
list = bpuContractRepository.findByProduct(platform);
} }
// 增值套餐
List<ContractIncrement> increments = contractIncrementRepository.findAll();
list.addAll(increments);
}else if("userdesk".equals(platform) || "dmp".equals(platform) || "fake".equals(platform)) {
list = bpuContractRepository.findByProduct(platform);
}
} }
return list; return list;
...@@ -236,10 +238,10 @@ public class ContractServiceImpl implements ContractService{ ...@@ -236,10 +238,10 @@ public class ContractServiceImpl implements ContractService{
@Override @Override
public Double getRebat(String product, Integer level, Long money) { public Double getRebat(String product, Integer level, Long money) {
Double rebat = 1d; Double rebat = 1d;
try{ try {
PriceLevelMoney levelMoney = priceLevelMoneyRepository.getOne(product, level); PriceLevelMoney levelMoney = priceLevelMoneyRepository.getOne(product, level);
rebat = money * 1.0 / levelMoney.getMoney(); rebat = money * 1.0 / levelMoney.getMoney();
} catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return rebat; return rebat;
...@@ -249,10 +251,11 @@ public class ContractServiceImpl implements ContractService{ ...@@ -249,10 +251,11 @@ public class ContractServiceImpl implements ContractService{
public List<User> getSales() { public List<User> getSales() {
return userRepository.findSales(); return userRepository.findSales();
} }
@Override @Override
public Contract build(Contract contract) { public Contract build(Contract contract) {
User user = userRepository.findByEmail(contract.getSaleName()); User user = userRepository.findByEmail(contract.getSaleName());
if(null != user){ if (null != user) {
contract.setSale(user.getId()); contract.setSale(user.getId());
} }
contract.setVirtual(true); contract.setVirtual(true);
...@@ -266,36 +269,126 @@ public class ContractServiceImpl implements ContractService{ ...@@ -266,36 +269,126 @@ public class ContractServiceImpl implements ContractService{
Contract contract1 = create(null, contract); Contract contract1 = create(null, contract);
return contract1; return contract1;
} }
@Override @Override
public Contract create(User loginUser, Contract resource) { public Contract create(User loginUser, Contract resource) {
if(resource ==null){ if (resource == null) {
return null; return null;
} }
Contract contractExist = contractRepository.findByCodePlatform(resource.getContractCode(),resource.getPlatform()); Contract contractExist = contractRepository.findByCodePlatform(resource.getContractCode(), resource.getPlatform());
if(contractExist!=null){ if (contractExist != null) {
// 合同编号已存在
return null;
}
resource.setPayMoney(0L);
resource.setInvoice(0L);
Long extraFlow = resource.getExtraFlow();
resource.setDs(DateUtil.getBeforeDays(0));
if (resource.getType().equals("main")) {
if (resource.getPlatform().equals("tkio")) {
if (!(extraFlow.longValue() == 0)) {
if (resource.getPlatform().equals("tkio")) {
IncrementFlow flow = new IncrementFlow();
Account account = accountRepository.findByEmail(resource.getEmail());
flow.setAccount(account.getId());
flow.setFlow(extraFlow);
flow.setEndDate(resource.getEndDate());
flow.setStartDate(resource.getStartDate());
flow.setContractCode(resource.getContractCode());
incrementFlowRepository.save(flow);
}
}
}
}
if (resource.getRebateMoney() <= 0) {
//未回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey());
} else if (resource.getRebateMoney() < resource.getMoney()) {
// 部分回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_PART.getKey());
} else {
// 已回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_ALL.getKey());
}
if("0".equals(resource.getContractType())){
// 首次签约 无关联合同
resource.setRelationContract(-1L);
}
if (null != loginUser) {
resource.setCreateAccount(loginUser.getId());
resource.setCreaterName(loginUser.getName());
}
resource.setCreateTime(new Date());
//同步修改trackingio的数据
if (resource.getPlatform().equals("tkio") && resource.getType().equals("main")) {
accountService.update(resource);
}
if (resource.getPlatform().equals("io") && resource.getType().equals("main")) {
accountIOService.update(resource);
}
if (resource.getPlatform().equals("adi")) {
adiAccountService.updateAccount(resource);
}
resource = contractRepository.save(resource);
if (resource.getRelationContract() != null && resource.getRelationContract() > 0) {
//保存关联合同信息
ContractRelation relation = new ContractRelation();
relation.setCreateTime(new Date());
relation.setMainContract(resource.getId());
relation.setRelationId(resource.getRelationContract());
relation.setPlatform(resource.getPlatform());
contractRelationRepository.save(relation);
}
return resource;
}
public Contract create_bak(User loginUser, Contract resource) {
if (resource == null) {
return null;
}
Contract contractExist = contractRepository.findByCodePlatform(resource.getContractCode(), resource.getPlatform());
if (contractExist != null) {
// 合同编号已存在 // 合同编号已存在
return null; return null;
} }
// 老的逻辑 // 老的逻辑
// String contractCode = getContractCode(resource.getMyBodyCode()); String contractCode = getContractCode(resource.getMyBodyCode());
//
// if(!contractCode.equals(resource.getContractCode())){ if (!contractCode.equals(resource.getContractCode())) {
// resource.setContractCode(contractCode); resource.setContractCode(contractCode);
// } }
resource.setPayMoney(0L); resource.setPayMoney(0L);
resource.setInvoice(0L); resource.setInvoice(0L);
Long extraFlow = resource.getExtraFlow(); Long extraFlow = resource.getExtraFlow();
resource.setDs(DateUtil.getBeforeDays(0));
if(resource.getType().equals("main")) { if (resource.getType().equals("main")) {
if(resource.getPlatform().equals("tkio")){ if (resource.getPlatform().equals("tkio")) {
if(!(extraFlow.longValue() == 0)){ if (!(extraFlow.longValue() == 0)) {
if(resource.getPlatform().equals("tkio")){ if (resource.getPlatform().equals("tkio")) {
IncrementFlow flow = new IncrementFlow(); IncrementFlow flow = new IncrementFlow();
Account account = accountRepository.findByEmail(resource.getEmail()); Account account = accountRepository.findByEmail(resource.getEmail());
flow.setAccount(account.getId()); flow.setAccount(account.getId());
flow.setFlow(extraFlow); flow.setFlow(extraFlow);
...@@ -313,49 +406,62 @@ public class ContractServiceImpl implements ContractService{ ...@@ -313,49 +406,62 @@ public class ContractServiceImpl implements ContractService{
resource.setDs(DateUtil.getBeforeDays(0)); resource.setDs(DateUtil.getBeforeDays(0));
resource.setStatus("executing"); resource.setStatus("executing");
} }
}else{ } else {
resource.setDs(DateUtil.getBeforeDays(0)); // resource.setDs(DateUtil.getBeforeDays(0));
resource.setStatus("wait"); // resource.setStatus("wait");
} }
// Double rebat = null;
// if(null != resource.getPriceLevel()){ if (resource.getRebateMoney() <= 0) {
// rebat = getRebat(resource.getProduct(), resource.getPriceLevel().intValue(), resource.getMoney()); //未回款
// }else{ resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey());
// rebat = getRebat(resource.getProduct(), 0, resource.getMoney()); } else if (resource.getRebateMoney() < resource.getMoney()) {
// } // 部分回款
// resource.setStatus(ContractStatusEnum.MONEY_BACK_PART.getKey());
// BigDecimal bg = new BigDecimal(rebat); } else {
// double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); // 已回款
// resource.setRebate(f1); resource.setStatus(ContractStatusEnum.MONEY_BACK_ALL.getKey());
}
if(null != loginUser) {
Double rebat = null;
if (null != resource.getPriceLevel()) {
rebat = getRebat(resource.getProduct(), resource.getPriceLevel().intValue(), resource.getMoney());
} else {
rebat = getRebat(resource.getProduct(), 0, resource.getMoney());
}
BigDecimal bg = new BigDecimal(rebat);
double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
resource.setRebate(f1);
if (null != loginUser) {
resource.setCreateAccount(loginUser.getId()); resource.setCreateAccount(loginUser.getId());
resource.setCreaterName(loginUser.getName()); resource.setCreaterName(loginUser.getName());
} }
resource.setCreateTime(new Date()); resource.setCreateTime(new Date());
//同步修改trackingio的数据 //同步修改trackingio的数据
if(resource.getPlatform().equals("tkio") && resource.getType().equals("main")){ if (resource.getPlatform().equals("tkio") && resource.getType().equals("main")) {
accountService.update(resource); accountService.update(resource);
} }
if(resource.getPlatform().equals("io") && resource.getType().equals("main")){ if (resource.getPlatform().equals("io") && resource.getType().equals("main")) {
accountIOService.update(resource); accountIOService.update(resource);
} }
if(resource.getPlatform().equals("adi")){ if (resource.getPlatform().equals("adi")) {
adiAccountService.updateAccount(resource); adiAccountService.updateAccount(resource);
} }
if(resource.getType().equals(ContractTypeEnum.MAIN.getKey()) if (resource.getType().equals(ContractTypeEnum.MAIN.getKey())
|| (resource.getType().equals(ContractTypeEnum.INCREMENT.getKey()) && resource.getPriceLevel().equals(1L))){ || (resource.getType().equals(ContractTypeEnum.INCREMENT.getKey()) && resource.getPriceLevel().equals(1L))) {
List<Contract> contractList = contractRepository.findByPlatformAndEmail(resource.getPlatform(), resource.getEmail(),resource.getType()); List<Contract> contractList = contractRepository.findByPlatformAndEmail(resource.getPlatform(), resource.getEmail(), resource.getType());
if(ValidateUtil.isValid(contractList)){ if (ValidateUtil.isValid(contractList)) {
List<Contract> list = new ArrayList<>(); List<Contract> list = new ArrayList<>();
for(Contract contract : contractList){ for (Contract contract : contractList) {
if(contract.getType().equals(ContractTypeEnum.MAIN.getKey()) if (contract.getType().equals(ContractTypeEnum.MAIN.getKey())
|| (contract.getType().equals(ContractTypeEnum.INCREMENT.getKey()) && contract.getPriceLevel().equals(1L))){ || (contract.getType().equals(ContractTypeEnum.INCREMENT.getKey()) && contract.getPriceLevel().equals(1L))) {
if(contract.getStatus().equals(ContractStatusEnum.EXECUTING.getKey()) if (contract.getStatus().equals(ContractStatusEnum.EXECUTING.getKey())
|| contract.getStatus().equals(ContractStatusEnum.WAIT.getKey())){ || contract.getStatus().equals(ContractStatusEnum.WAIT.getKey())) {
contract.setStatus(ContractStatusEnum.CANCEL.getKey()); contract.setStatus(ContractStatusEnum.CANCEL.getKey());
} }
list.add(contract); list.add(contract);
...@@ -366,10 +472,10 @@ public class ContractServiceImpl implements ContractService{ ...@@ -366,10 +472,10 @@ public class ContractServiceImpl implements ContractService{
} }
} }
resource = contractRepository.save(resource); resource = contractRepository.save(resource);
if(resource.getRelationContract()!=null && resource.getRelationContract()>0){ if (resource.getRelationContract() != null && resource.getRelationContract() > 0) {
//保存关联合同信息 //保存关联合同信息
ContractRelation relation = new ContractRelation(); ContractRelation relation = new ContractRelation();
relation.setCreateTime(new Date()); relation.setCreateTime(new Date());
...@@ -398,63 +504,74 @@ public class ContractServiceImpl implements ContractService{ ...@@ -398,63 +504,74 @@ public class ContractServiceImpl implements ContractService{
cc.setCompany(contract.getCustomerBody()); cc.setCompany(contract.getCustomerBody());
cc.setContractCode(contract.getContractCode()); cc.setContractCode(contract.getContractCode());
if (resource.getRebateMoney() <= 0) {
//未回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey());
} else if (resource.getRebateMoney() < resource.getMoney()) {
// 部分回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_PART.getKey());
} else {
// 已回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_ALL.getKey());
}
if(!resource.getStartDate().equals(contract.getStartDate())){ if (!resource.getStartDate().equals(contract.getStartDate())) {
cc.setContent(cc.getContent() + "开始时间变更 : " + contract.getStartDate() + "-->" + resource.getStartDate()); cc.setContent(cc.getContent() + "开始时间变更 : " + contract.getStartDate() + "-->" + resource.getStartDate());
contract.setStartDate(resource.getStartDate()); contract.setStartDate(resource.getStartDate());
if(DateUtil.getBeforeDays(0).compareTo(resource.getStartDate()) < 0){ // if(DateUtil.getBeforeDays(0).compareTo(resource.getStartDate()) < 0){
contract.setStatus("wait"); // contract.setStatus("wait");
}else{ // }else{
contract.setStatus("executing"); // contract.setStatus("executing");
} // }
} }
if(!resource.getEndDate().equals(contract.getEndDate())){ if (!resource.getEndDate().equals(contract.getEndDate())) {
cc.setContent(cc.getContent() + " 结束时间变更 : " + contract.getEndDate() + "-->" + resource.getEndDate()); cc.setContent(cc.getContent() + " 结束时间变更 : " + contract.getEndDate() + "-->" + resource.getEndDate());
contract.setEndDate(resource.getEndDate()); contract.setEndDate(resource.getEndDate());
} }
boolean newRebat = false; boolean newRebat = false;
if(contract.getType().equals(ContractTypeEnum.MAIN.getKey()) && null != resource.getPriceLevel()){ if (contract.getType().equals(ContractTypeEnum.MAIN.getKey()) && null != resource.getPriceLevel()) {
if(!resource.getPriceLevel().equals(contract.getPriceLevel())){ if (!resource.getPriceLevel().equals(contract.getPriceLevel())) {
cc.setContent(cc.getContent() + " 套餐变更:" + packageMap.get(contract.getPriceLevel()) + "-->" + packageMap.get(resource.getPriceLevel())); cc.setContent(cc.getContent() + " 套餐变更:" + packageMap.get(contract.getPriceLevel()) + "-->" + packageMap.get(resource.getPriceLevel()));
newRebat = true; newRebat = true;
contract.setPriceLevel(resource.getPriceLevel()); contract.setPriceLevel(resource.getPriceLevel());
} }
} }
if(!resource.getMoney().equals(contract.getMoney())){ if (!resource.getMoney().equals(contract.getMoney())) {
cc.setContent(cc.getContent() + " 金额变更: " + contract.getMoney() + "-->" + resource.getMoney()); cc.setContent(cc.getContent() + " 金额变更: " + contract.getMoney() + "-->" + resource.getMoney());
newRebat = true; newRebat = true;
contract.setMoney(resource.getMoney()); contract.setMoney(resource.getMoney());
} }
if(!resource.getSale().equals(contract.getSale())){ if (!resource.getSale().equals(contract.getSale())) {
cc.setContent(cc.getContent() + "销售变更:" + saleMap.get(contract.getSale()) + "-->" + saleMap.get(resource.getSale())); cc.setContent(cc.getContent() + "销售变更:" + saleMap.get(contract.getSale()) + "-->" + saleMap.get(resource.getSale()));
contract.setSale(resource.getSale()); contract.setSale(resource.getSale());
} }
if(newRebat && !"adi".equals(contract.getPlatform())){ if (newRebat && !"adi".equals(contract.getPlatform())) {
Double rebat = getRebat(contract.getProduct(), contract.getPriceLevel().intValue(), contract.getMoney()); Double rebat = getRebat(contract.getProduct(), contract.getPriceLevel().intValue(), contract.getMoney());
BigDecimal bg = new BigDecimal(rebat); BigDecimal bg = new BigDecimal(rebat);
double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
contract.setRebate(f1); // contract.setRebate(f1);
} }
cc.setPlatform(contract.getPlatform()); cc.setPlatform(contract.getPlatform());
contractChangeRepository.save(cc); contractChangeRepository.save(cc);
//同步修改trackingio的数据 //同步修改trackingio的数据
if(contract.getPlatform().equals("tkio") && resource.getType().equals("main")){ if (contract.getPlatform().equals("tkio") && resource.getType().equals("main")) {
accountService.update(contract); accountService.update(contract);
} }
if(contract.getPlatform().equals("io") && resource.getType().equals("main")){ if (contract.getPlatform().equals("io") && resource.getType().equals("main")) {
accountIOService.update(contract); accountIOService.update(contract);
} }
if(contract.getPlatform().equals("adi")){ if (contract.getPlatform().equals("adi")) {
adiAccountService.updateAccount(contract); adiAccountService.updateAccount(contract);
} }
if(contract.getPlatform().equals("tkio")){ if (contract.getPlatform().equals("tkio")) {
if(contract.getType().equals("main")) { if (contract.getType().equals("main")) {
IncrementFlow flow = incrementFlowRepository.findOne(resource.getContractCode()); IncrementFlow flow = incrementFlowRepository.findOne(resource.getContractCode());
if (null != flow) { if (null != flow) {
flow.setEndDate(resource.getEndDate()); flow.setEndDate(resource.getEndDate());
...@@ -482,79 +599,102 @@ public class ContractServiceImpl implements ContractService{ ...@@ -482,79 +599,102 @@ public class ContractServiceImpl implements ContractService{
} }
/**
*
* @param loginAccount
* @param startDate
* @param endDate
* @param platform
* @param contractId 用于 获取关联合同列表
* @return
*/
@Override @Override
public List<Contract> findAll(User loginAccount, String startDate, String endDate, String platform,String contractId) { public List<Contract> findAll(User loginAccount, String startDate, String endDate, String platform, String contractId) {
List<Contract> result = new ArrayList<>(); List<Contract> result = new ArrayList<>();
List<User> sales = userRepository.findAll(); List<User> sales = userRepository.findAll();
Map<Long, String> saleMap = new HashMap<>(); Map<Long, String> saleMap = new HashMap<>();
if(ValidateUtil.isValid(sales)){ if (ValidateUtil.isValid(sales)) {
for(User s: sales){ for (User s : sales) {
saleMap.put(s.getId(), s.getName()); saleMap.put(s.getId(), s.getName());
} }
} }
List<PackageType> typeList = packageTypeRepository.findAll(); List<PackageType> typeList = packageTypeRepository.findAll();
Map<Long, String> typeMap = new HashMap<>(); Map<Long, String> typeMap = new HashMap<>();
if(ValidateUtil.isValid(typeList)){ if (ValidateUtil.isValid(typeList)) {
for(PackageType s: typeList){ for (PackageType s : typeList) {
typeMap.put(s.getId(), s.getPackageName()); typeMap.put(s.getId(), s.getPackageName());
} }
} }
List<ContractIncrement> incrementList = contractIncrementRepository.findAll(); List<ContractIncrement> incrementList = contractIncrementRepository.findAll();
Map<Long, String> incremenMap = new HashMap<>(); Map<Long, String> incremenMap = new HashMap<>();
if(ValidateUtil.isValid(incrementList)){ if (ValidateUtil.isValid(incrementList)) {
for(ContractIncrement s: incrementList){ for (ContractIncrement s : incrementList) {
incremenMap.put(s.getId(), s.getPackageName()); incremenMap.put(s.getId(), s.getPackageName());
} }
} }
List<BPUContract> bpuContractList = bpuContractRepository.findAll(); List<BPUContract> bpuContractList = bpuContractRepository.findAll();
Map<Long, String> bpuMap = new HashMap<>(); Map<Long, String> bpuMap = new HashMap<>();
if(ValidateUtil.isValid(bpuContractList)){ if (ValidateUtil.isValid(bpuContractList)) {
for(BPUContract s: bpuContractList){ for (BPUContract s : bpuContractList) {
bpuMap.put(s.getId(), s.getPackageName()); bpuMap.put(s.getId(), s.getPackageName());
} }
} }
List<Long> contractIds =null; List<Long> contractIds = null;
if(!StringUtils.isEmpty(contractId)){ if (!StringUtils.isEmpty(contractId)) {
//获取 关联合同列表 //获取 关联合同列表
contractIds = contractRelationRepository.findRelationIds(contractId); contractIds = contractRelationRepository.findRelationIds(contractId);
} }
List<Contract> contractList = null; List<Contract> contractList = null;
if(loginAccount.getRole().equals(RoleEnum.SOUTH_BUSSINUSS.getKey()) || loginAccount.getRole().equals(RoleEnum.NORTH_BUSSINUSS.getKey())){
if (loginAccount.getRole().equals(RoleEnum.SOUTH_BUSSINUSS.getKey()) || loginAccount.getRole().equals(RoleEnum.NORTH_BUSSINUSS.getKey())) {
List<User> userList = userService.findAllSons(loginAccount.getId()); List<User> userList = userService.findAllSons(loginAccount.getId());
List<Long> idList = new ArrayList<>(); List<Long> idList = new ArrayList<>();
idList.add(loginAccount.getId()); idList.add(loginAccount.getId());
for(User u : userList){ for (User u : userList) {
idList.add(u.getId()); idList.add(u.getId());
} }
// contractList = contractRepository.findByDsAndRoile(startDate, endDate, platfrom, idList); // contractList = contractRepository.findByDsAndRoile(startDate, endDate, platfrom, idList);
if(contractIds!=null && contractIds.size()>0){ if (contractIds != null && contractIds.size() > 0) {
contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platform, idList,contractIds); contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platform, idList, contractIds);
}else{ } else {
contractList = contractRepository.findByDsAndRoile(startDate, endDate, platform, idList); contractList = contractRepository.findByDsAndRoile(startDate, endDate, platform, idList);
} }
}else{ } else {
// contractList = contractRepository.findByDs(startDate, endDate, platform); // contractList = contractRepository.findByDs(startDate, endDate, platform);
if(contractIds!=null && contractIds.size()>0){ if (contractIds != null && contractIds.size() > 0) {
contractList = contractRepository.findByDsRelation(startDate, endDate, platform,contractIds); contractList = contractRepository.findByDsRelation(startDate, endDate, platform, contractIds);
}else{ } else {
contractList = contractRepository.findByDs(startDate, endDate, platform); contractList = contractRepository.findByDs(startDate, endDate, platform);
} }
} }
if(ValidateUtil.isValid(contractList)){ if (ValidateUtil.isValid(contractList)) {
for(Contract c : contractList){ for (Contract c : contractList) {
if ((c.getDiscountFlow() != null && c.getDiscountFlow() > 0) ||
(c.getDiscountTimeLong() != null && c.getDiscountTimeLong() > 0)) {
c.setHasDiscount("有");
} else {
c.setHasDiscount("无");
}
c.setSaleName(saleMap.containsKey(c.getSale()) ? saleMap.get(c.getSale()) : ""); c.setSaleName(saleMap.containsKey(c.getSale()) ? saleMap.get(c.getSale()) : "");
if(c.getType().equals(ContractTypeEnum.MAIN.getKey()) && platform.contains("io")){ if (c.getType().equals(ContractTypeEnum.MAIN.getKey()) && platform.contains("io")) {
c.setPriceLevelName(typeMap.containsKey(c.getPriceLevel()) ? typeMap.get(c.getPriceLevel()) : ""); c.setPriceLevelName(typeMap.containsKey(c.getPriceLevel()) ? typeMap.get(c.getPriceLevel()) : "");
} else if (c.getType().equals(ContractTypeEnum.MAIN.getKey())){ } else if (c.getType().equals(ContractTypeEnum.MAIN.getKey())) {
c.setPriceLevelName(bpuMap.containsKey(c.getPriceLevel()) ? bpuMap.get(c.getPriceLevel()) : ""); c.setPriceLevelName(bpuMap.containsKey(c.getPriceLevel()) ? bpuMap.get(c.getPriceLevel()) : "");
} else{ } else {
c.setPriceLevelName(incremenMap.containsKey(c.getPriceLevel()) ? incremenMap.get(c.getPriceLevel()) : ""); c.setPriceLevelName(incremenMap.containsKey(c.getPriceLevel()) ? incremenMap.get(c.getPriceLevel()) : "");
} }
...@@ -568,55 +708,54 @@ public class ContractServiceImpl implements ContractService{ ...@@ -568,55 +708,54 @@ public class ContractServiceImpl implements ContractService{
@Override @Override
public List<Contract> findAllContract(User loginAccount, String startDate, String endDate, String platform, String contractId) { public List<Contract> findAllContract(User loginAccount, String startDate, String endDate, String platform, String contractId) {
List<Long> contractIds =null; List<Long> contractIds = null;
if(!StringUtils.isEmpty(contractId)){ if (!StringUtils.isEmpty(contractId)) {
//获取 关联合同列表 //获取 关联合同列表
contractIds = contractRelationRepository.findRelationIds(contractId); contractIds = contractRelationRepository.findRelationIds(contractId);
} }
List<Contract> contractList ; List<Contract> contractList;
if(!loginAccount.getRole().equals(RoleEnum.MANAGER.getKey())){ if (!loginAccount.getRole().equals(RoleEnum.MANAGER.getKey())) {
//非 管理员 //非 管理员
List<User> userList = userService.findAllSons(loginAccount.getId()); List<User> userList = userService.findAllSons(loginAccount.getId());
List<Long> idList = new ArrayList<>(); List<Long> idList = new ArrayList<>();
idList.add(loginAccount.getId()); idList.add(loginAccount.getId());
for(User u : userList){ for (User u : userList) {
idList.add(u.getId()); idList.add(u.getId());
} }
if(contractIds!=null && contractIds.size()>0){ if (contractIds != null && contractIds.size() > 0) {
contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platform, idList,contractIds); contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platform, idList, contractIds);
}else{ } else {
contractList = contractRepository.findByDsAndRoile(startDate, endDate, platform, idList); contractList = contractRepository.findByDsAndRoile(startDate, endDate, platform, idList);
} }
}else{ } else {
if(contractIds!=null && contractIds.size()>0){ if (contractIds != null && contractIds.size() > 0) {
contractList = contractRepository.findByDsRelation(startDate, endDate, platform,contractIds); contractList = contractRepository.findByDsRelation(startDate, endDate, platform, contractIds);
}else{ } else {
contractList = contractRepository.findByDs(startDate, endDate, platform); contractList = contractRepository.findByDs(startDate, endDate, platform);
} }
} }
return contractList; return contractList;
} }
@Override @Override
public Contract contractStatusUpdate(String platform, String contractId, String status) { public Contract contractStatusUpdate(String platform, String contractId, String status) {
if(StringUtils.isEmpty(contractId)){ if (StringUtils.isEmpty(contractId)) {
return null; return null;
} }
Contract contract = contractRepository.findOne(Long.parseLong(contractId)); Contract contract = contractRepository.findOne(Long.parseLong(contractId));
if(ContractStatusEnum.CANCEL.getKey().equals(status)){ if (ContractStatusEnum.CANCEL.getKey().equals(status)) {
contract.setStatus(status); contract.setStatus(status);
}else{ } else {
contract.setStatus(ContractStatusEnum.DELETE.getKey()); contract.setStatus(ContractStatusEnum.DELETE.getKey());
} }
...@@ -629,36 +768,36 @@ public class ContractServiceImpl implements ContractService{ ...@@ -629,36 +768,36 @@ public class ContractServiceImpl implements ContractService{
List<Contract> result = new ArrayList<>(); List<Contract> result = new ArrayList<>();
List<User> sales = userRepository.findAll(); List<User> sales = userRepository.findAll();
Map<Long, String> saleMap = new HashMap<>(); Map<Long, String> saleMap = new HashMap<>();
if(ValidateUtil.isValid(sales)){ if (ValidateUtil.isValid(sales)) {
for(User s: sales){ for (User s : sales) {
saleMap.put(s.getId(), s.getName()); saleMap.put(s.getId(), s.getName());
} }
} }
List<PackageType> typeList = packageTypeRepository.findAll(); List<PackageType> typeList = packageTypeRepository.findAll();
Map<Long, String> typeMap = new HashMap<>(); Map<Long, String> typeMap = new HashMap<>();
if(ValidateUtil.isValid(typeList)){ if (ValidateUtil.isValid(typeList)) {
for(PackageType s: typeList){ for (PackageType s : typeList) {
typeMap.put(s.getId(), s.getPackageName()); typeMap.put(s.getId(), s.getPackageName());
} }
} }
List<ContractIncrement> incrementList = contractIncrementRepository.findAll(); List<ContractIncrement> incrementList = contractIncrementRepository.findAll();
Map<Long, String> incremenMap = new HashMap<>(); Map<Long, String> incremenMap = new HashMap<>();
if(ValidateUtil.isValid(incrementList)){ if (ValidateUtil.isValid(incrementList)) {
for(ContractIncrement s: incrementList){ for (ContractIncrement s : incrementList) {
incremenMap.put(s.getId(), s.getPackageName()); incremenMap.put(s.getId(), s.getPackageName());
} }
} }
Contract contract = contractRepository.findByCode(code); Contract contract = contractRepository.findByCode(code);
contract.setSaleName(saleMap.containsKey(contract.getSale()) ? saleMap.get(contract.getSale()) : ""); contract.setSaleName(saleMap.containsKey(contract.getSale()) ? saleMap.get(contract.getSale()) : "");
if(contract.getType().equals(ContractTypeEnum.MAIN.getKey())){ if (contract.getType().equals(ContractTypeEnum.MAIN.getKey())) {
contract.setPriceLevelName(typeMap.containsKey(contract.getPriceLevel()) ? typeMap.get(contract.getPriceLevel()) : ""); contract.setPriceLevelName(typeMap.containsKey(contract.getPriceLevel()) ? typeMap.get(contract.getPriceLevel()) : "");
} else{ } else {
contract.setPriceLevelName(incremenMap.containsKey(contract.getPriceLevel()) ? incremenMap.get(contract.getPriceLevel()) : ""); contract.setPriceLevelName(incremenMap.containsKey(contract.getPriceLevel()) ? incremenMap.get(contract.getPriceLevel()) : "");
} }
contract.setCreateName(saleMap.containsKey(contract.getCreateAccount()) ? saleMap.get(contract.getCreateAccount()) : ""); contract.setCreateName(saleMap.containsKey(contract.getCreateAccount()) ? saleMap.get(contract.getCreateAccount()) : "");
Boolean flag = null; Boolean flag = null;
if(!contract.getType().equals(ContractTypeEnum.MAIN.getKey())) { if (!contract.getType().equals(ContractTypeEnum.MAIN.getKey())) {
//人群分析 //人群分析
if (null == contract.getEndDate()) { if (null == contract.getEndDate()) {
flag = checkTime(contract.getEmail(), contract.getPlatform(), contract.getType(), "black"); flag = checkTime(contract.getEmail(), contract.getPlatform(), contract.getType(), "black");
...@@ -678,13 +817,13 @@ public class ContractServiceImpl implements ContractService{ ...@@ -678,13 +817,13 @@ public class ContractServiceImpl implements ContractService{
@Override @Override
public ContractMoney pay(User loginUser, ContractMoney resource) { public ContractMoney pay(User loginUser, ContractMoney resource) {
Contract contract = contractRepository.findByCode(resource.getContractCode()); Contract contract = contractRepository.findByCode(resource.getContractCode());
if(resource.getType().equals("pay")){ if (resource.getType().equals("pay")) {
contract.setPayMoney(contract.getPayMoney() + resource.getMoney()); contract.setPayMoney(contract.getPayMoney() + resource.getMoney());
} else { } else {
contract.setInvoice(contract.getInvoice() + resource.getMoney()); contract.setInvoice(contract.getInvoice() + resource.getMoney());
} }
if(contract.getType().equals(ContractTypeEnum.INCREMENT.getKey())){ if (contract.getType().equals(ContractTypeEnum.INCREMENT.getKey())) {
contract.setStatus("end"); contract.setStatus("end");
} }
contractRepository.save(contract); contractRepository.save(contract);
...@@ -694,9 +833,9 @@ public class ContractServiceImpl implements ContractService{ ...@@ -694,9 +833,9 @@ public class ContractServiceImpl implements ContractService{
resource.setCreateTime(new Date()); resource.setCreateTime(new Date());
resource.setUser(loginUser.getId()); resource.setUser(loginUser.getId());
if(resource.getType().equals("pay") && contract.getPlatform().equals("tkio")){ if (resource.getType().equals("pay") && contract.getPlatform().equals("tkio")) {
tkioAccountService.contractPay(loginUser, resource); tkioAccountService.contractPay(loginUser, resource);
}else if(resource.getType().equals("pay") && contract.getPlatform().equals("io")){ } else if (resource.getType().equals("pay") && contract.getPlatform().equals("io")) {
ioAccountService.contractPay(loginUser, resource); ioAccountService.contractPay(loginUser, resource);
} }
return contractMoneyRepository.save(resource); return contractMoneyRepository.save(resource);
...@@ -707,9 +846,9 @@ public class ContractServiceImpl implements ContractService{ ...@@ -707,9 +846,9 @@ public class ContractServiceImpl implements ContractService{
Map<Long, String> packageMap = getPackageMap(); Map<Long, String> packageMap = getPackageMap();
Map<Long, String> saleMap = getSaleMap(); Map<Long, String> saleMap = getSaleMap();
Contract contract = contractRepository.findByCode(resource.getContractCode()); Contract contract = contractRepository.findByCode(resource.getContractCode());
if(resource.getType().equals("price")){ if (resource.getType().equals("price")) {
resource.setContent("套餐变更 :" + packageMap.get(contract.getPriceLevel()) + "-->" + packageMap.get(resource.getLevel()) resource.setContent("套餐变更 :" + packageMap.get(contract.getPriceLevel()) + "-->" + packageMap.get(resource.getLevel())
+ " 金额变更 :" + contract.getMoney() + "-->" +(resource.getMoney() + contract.getMoney())); + " 金额变更 :" + contract.getMoney() + "-->" + (resource.getMoney() + contract.getMoney()));
contract.setMoney(resource.getMoney() + contract.getMoney()); contract.setMoney(resource.getMoney() + contract.getMoney());
contract.setPriceLevel(resource.getLevel()); contract.setPriceLevel(resource.getLevel());
...@@ -719,16 +858,16 @@ public class ContractServiceImpl implements ContractService{ ...@@ -719,16 +858,16 @@ public class ContractServiceImpl implements ContractService{
contract.setRebate(f1); contract.setRebate(f1);
//同步修改trackingio的数据 //同步修改trackingio的数据
if(contract.getPlatform().equals("tkio")){ if (contract.getPlatform().equals("tkio")) {
accountService.update(contract); accountService.update(contract);
}else if(contract.getPlatform().equals("io")){ } else if (contract.getPlatform().equals("io")) {
accountIOService.update(contract); accountIOService.update(contract);
} }
}else{ } else {
//同步修改trackingio的数据 //同步修改trackingio的数据
if(contract.getPlatform().equals("tkio") && contract.getType().equals("main")){ if (contract.getPlatform().equals("tkio") && contract.getType().equals("main")) {
accountService.forbiden(contract); accountService.forbiden(contract);
}else if(contract.getPlatform().equals("io") && contract.getType().equals("main")){ } else if (contract.getPlatform().equals("io") && contract.getType().equals("main")) {
accountIOService.update(contract); accountIOService.update(contract);
} }
contract.setStatus("cancel"); contract.setStatus("cancel");
...@@ -747,16 +886,16 @@ public class ContractServiceImpl implements ContractService{ ...@@ -747,16 +886,16 @@ public class ContractServiceImpl implements ContractService{
public List<ContractMoney> findPay(String startDate, String endDate, String code) { public List<ContractMoney> findPay(String startDate, String endDate, String code) {
List<User> sales = userRepository.findAll(); List<User> sales = userRepository.findAll();
Map<Long, String> saleMap = new HashMap<>(); Map<Long, String> saleMap = new HashMap<>();
if(ValidateUtil.isValid(sales)){ if (ValidateUtil.isValid(sales)) {
for(User s: sales){ for (User s : sales) {
saleMap.put(s.getId(), s.getName()); saleMap.put(s.getId(), s.getName());
} }
} }
List<ContractMoney> result = new ArrayList<>(); List<ContractMoney> result = new ArrayList<>();
List<ContractMoney> list = contractMoneyRepository.findByDs(startDate, endDate,code); List<ContractMoney> list = contractMoneyRepository.findByDs(startDate, endDate, code);
if(ValidateUtil.isValid(list)){ if (ValidateUtil.isValid(list)) {
for(ContractMoney cm : list){ for (ContractMoney cm : list) {
cm.setCreateName(saleMap.containsKey(cm.getUser()) ? saleMap.get(cm.getUser()) : ""); cm.setCreateName(saleMap.containsKey(cm.getUser()) ? saleMap.get(cm.getUser()) : "");
result.add(cm); result.add(cm);
} }
...@@ -769,16 +908,16 @@ public class ContractServiceImpl implements ContractService{ ...@@ -769,16 +908,16 @@ public class ContractServiceImpl implements ContractService{
List<User> sales = userRepository.findAll(); List<User> sales = userRepository.findAll();
Map<Long, String> saleMap = new HashMap<>(); Map<Long, String> saleMap = new HashMap<>();
if(ValidateUtil.isValid(sales)){ if (ValidateUtil.isValid(sales)) {
for(User s: sales){ for (User s : sales) {
saleMap.put(s.getId(), s.getName()); saleMap.put(s.getId(), s.getName());
} }
} }
List<ContractChange> result = new ArrayList<>(); List<ContractChange> result = new ArrayList<>();
List<ContractChange> list = contractChangeRepository.findByDs(startDate, endDate,code); List<ContractChange> list = contractChangeRepository.findByDs(startDate, endDate, code);
if(ValidateUtil.isValid(list)){ if (ValidateUtil.isValid(list)) {
for(ContractChange cm : list){ for (ContractChange cm : list) {
cm.setCreateName(saleMap.containsKey(cm.getUser()) ? saleMap.get(cm.getUser()) : ""); cm.setCreateName(saleMap.containsKey(cm.getUser()) ? saleMap.get(cm.getUser()) : "");
result.add(cm); result.add(cm);
} }
...@@ -790,7 +929,7 @@ public class ContractServiceImpl implements ContractService{ ...@@ -790,7 +929,7 @@ public class ContractServiceImpl implements ContractService{
public Contract updatePay(User loginUser, ContractMoney resource) { public Contract updatePay(User loginUser, ContractMoney resource) {
ContractMoney contractMoney = contractMoneyRepository.findOne(resource.getId()); ContractMoney contractMoney = contractMoneyRepository.findOne(resource.getId());
Contract contract = contractRepository.findByCode(resource.getContractCode()); Contract contract = contractRepository.findByCode(resource.getContractCode());
if(contractMoney.getType().equals("pay")){ if (contractMoney.getType().equals("pay")) {
contract.setPayMoney(contract.getPayMoney() + resource.getMoney() - contractMoney.getMoney()); contract.setPayMoney(contract.getPayMoney() + resource.getMoney() - contractMoney.getMoney());
} else { } else {
contract.setInvoice(contract.getInvoice() + resource.getMoney() - contractMoney.getMoney()); contract.setInvoice(contract.getInvoice() + resource.getMoney() - contractMoney.getMoney());
...@@ -805,15 +944,15 @@ public class ContractServiceImpl implements ContractService{ ...@@ -805,15 +944,15 @@ public class ContractServiceImpl implements ContractService{
List<User> sales = userRepository.findAll(); List<User> sales = userRepository.findAll();
Map<Long, String> saleMap = new HashMap<>(); Map<Long, String> saleMap = new HashMap<>();
if(ValidateUtil.isValid(sales)){ if (ValidateUtil.isValid(sales)) {
for(User s: sales){ for (User s : sales) {
saleMap.put(s.getId(), s.getName()); saleMap.put(s.getId(), s.getName());
} }
} }
List<PackageType> typeList = packageTypeRepository.findAll(); List<PackageType> typeList = packageTypeRepository.findAll();
Map<Long, String> typeMap = new HashMap<>(); Map<Long, String> typeMap = new HashMap<>();
if(ValidateUtil.isValid(typeList)){ if (ValidateUtil.isValid(typeList)) {
for(PackageType s: typeList){ for (PackageType s : typeList) {
typeMap.put(s.getId(), s.getPackageName()); typeMap.put(s.getId(), s.getPackageName());
} }
} }
...@@ -828,16 +967,16 @@ public class ContractServiceImpl implements ContractService{ ...@@ -828,16 +967,16 @@ public class ContractServiceImpl implements ContractService{
public List<ContractMoney> findPayAll(String startDate, String endDate, String platfrom) { public List<ContractMoney> findPayAll(String startDate, String endDate, String platfrom) {
List<User> sales = userRepository.findAll(); List<User> sales = userRepository.findAll();
Map<Long, String> saleMap = new HashMap<>(); Map<Long, String> saleMap = new HashMap<>();
if(ValidateUtil.isValid(sales)){ if (ValidateUtil.isValid(sales)) {
for(User s: sales){ for (User s : sales) {
saleMap.put(s.getId(), s.getName()); saleMap.put(s.getId(), s.getName());
} }
} }
List<ContractMoney> result = new ArrayList<>(); List<ContractMoney> result = new ArrayList<>();
List<ContractMoney> list = contractMoneyRepository.findByDsAll(startDate, endDate, platfrom); List<ContractMoney> list = contractMoneyRepository.findByDsAll(startDate, endDate, platfrom);
if(ValidateUtil.isValid(list)){ if (ValidateUtil.isValid(list)) {
for(ContractMoney cm : list){ for (ContractMoney cm : list) {
cm.setCreateName(saleMap.containsKey(cm.getUser()) ? saleMap.get(cm.getUser()) : ""); cm.setCreateName(saleMap.containsKey(cm.getUser()) ? saleMap.get(cm.getUser()) : "");
result.add(cm); result.add(cm);
} }
...@@ -855,35 +994,35 @@ public class ContractServiceImpl implements ContractService{ ...@@ -855,35 +994,35 @@ public class ContractServiceImpl implements ContractService{
return contractRepository.contractCodePlatform(platform); return contractRepository.contractCodePlatform(platform);
} }
public Map<Long, String> getPackageMap(){ public Map<Long, String> getPackageMap() {
List<PackageType> typeList = packageTypeRepository.findAll(); List<PackageType> typeList = packageTypeRepository.findAll();
Map<Long, String> typeMap = new HashMap<>(); Map<Long, String> typeMap = new HashMap<>();
if(ValidateUtil.isValid(typeList)){ if (ValidateUtil.isValid(typeList)) {
for(PackageType s: typeList){ for (PackageType s : typeList) {
typeMap.put(s.getId(), s.getPackageName()); typeMap.put(s.getId(), s.getPackageName());
} }
} }
return typeMap; return typeMap;
} }
public Map<Long, String> getSaleMap(){ public Map<Long, String> getSaleMap() {
List<User> sales = userRepository.findAll(); List<User> sales = userRepository.findAll();
Map<Long, String> saleMap = new HashMap<>(); Map<Long, String> saleMap = new HashMap<>();
if(ValidateUtil.isValid(sales)){ if (ValidateUtil.isValid(sales)) {
for(User s: sales){ for (User s : sales) {
saleMap.put(s.getId(), s.getName()); saleMap.put(s.getId(), s.getName());
} }
} }
return saleMap; return saleMap;
} }
public static Map<String,String> convertBean(Object bean) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { public static Map<String, String> convertBean(Object bean) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Class type = bean.getClass(); Class type = bean.getClass();
Map<String,String> returnMap = new HashMap<String,String>(); Map<String, String> returnMap = new HashMap<String, String>();
BeanInfo beanInfo = Introspector.getBeanInfo(type); BeanInfo beanInfo = Introspector.getBeanInfo(type);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (int i = 0; i< propertyDescriptors.length; i++) { for (int i = 0; i < propertyDescriptors.length; i++) {
PropertyDescriptor descriptor = propertyDescriptors[i]; PropertyDescriptor descriptor = propertyDescriptors[i];
String propertyName = descriptor.getName(); String propertyName = descriptor.getName();
if (!propertyName.equals("class")) { if (!propertyName.equals("class")) {
......
...@@ -8,8 +8,12 @@ public enum ContractStatusEnum { ...@@ -8,8 +8,12 @@ public enum ContractStatusEnum {
WAIT("wait","未执行"), WAIT("wait","未执行"),
EXECUTING("executing", "执行中"), EXECUTING("executing", "执行中"),
CANCEL("cancel", "作废"),
END("end", "已结束"), END("end", "已结束"),
MONEY_BACK_ALL("backall","已回款"),
MONEY_BACK_NONE("backnone","未回款"),
MONEY_BACK_PART("backpart","部分回款"),
CANCEL("cancel", "作废"),
DELETE("del", "已删除"); DELETE("del", "已删除");
private String key; private String key;
......
...@@ -53,8 +53,8 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { ...@@ -53,8 +53,8 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
System.out.println("-----"+requestURL.contains("findSaleInfo")); System.out.println("-----"+requestURL.contains("findSaleInfo"));
return true; return true;
} }
System.out.println("============="+requestURL); // System.out.println("============="+requestURL);
System.out.println(requestURL.indexOf("accountmng/findSaleInfo")); // System.out.println(requestURL.indexOf("accountmng/findSaleInfo"));
if (requestURL.indexOf("login/login") != -1 if (requestURL.indexOf("login/login") != -1
|| requestURL.indexOf("update/pwd") != -1 || requestURL.indexOf("update/pwd") != -1
|| requestURL.indexOf("user/forget") != -1 || requestURL.indexOf("user/forget") != -1
......
...@@ -4,10 +4,15 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -4,10 +4,15 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import tkio.model.PackageType; import tkio.model.PackageType;
import java.util.List;
public interface PackageTypeRepository extends JpaRepository<PackageType, Long> { public interface PackageTypeRepository extends JpaRepository<PackageType, Long> {
@Query(value = "select * from package_type where id=(select pricelevel from account where id=?1)", nativeQuery = true) @Query(value = "select * from package_type where id=(select pricelevel from account where id=?1)", nativeQuery = true)
PackageType findPackageTypeByRootParent(Long rootParent); PackageType findPackageTypeByRootParent(Long rootParent);
@Query(value = "select * from package_type where id=?1", nativeQuery = true) @Query(value = "select * from package_type where id=?1", nativeQuery = true)
PackageType findPackageTypeByID(Long ID); PackageType findPackageTypeByID(Long ID);
@Query(value = " select * from package_type where is_new is true ", nativeQuery = true)
List<PackageType> findIsNewAll();
} }
...@@ -73,6 +73,8 @@ public class AccountServiceImpl implements AccountService { ...@@ -73,6 +73,8 @@ public class AccountServiceImpl implements AccountService {
@Override @Override
public Account forbiden(Contract contract) { public Account forbiden(Contract contract) {
// 注释功能
if(true) return null;
Account account = accountRepository.findByEmail(contract.getEmail()); Account account = accountRepository.findByEmail(contract.getEmail());
account.setStatus(0); account.setStatus(0);
return accountRepository.save(account); return accountRepository.save(account);
......
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