Commit d9bd5723 by kangxiaoshan

大后台更新

parent 33e33b10
...@@ -200,9 +200,9 @@ public class ContractController { ...@@ -200,9 +200,9 @@ public class ContractController {
Contract contract1 = service.create(loginAccount, contract); Contract contract1 = service.create(loginAccount, contract);
NewUserLogThread userlog = new NewUserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), contract1.getContractCode(), "新建合同","",contract1.toString(), request, platform); NewUserLogThread userlog = new NewUserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), contract1.getContractCode(), "新建合同","",contract1.toString(), request, platform);
userlog.start(); userlog.start();
//
ContractSendEmailThread email = new ContractSendEmailThread(contract); // ContractSendEmailThread email = new ContractSendEmailThread(contract);
email.start(); // email.start();
return ResultModel.OK(contract1); return ResultModel.OK(contract1);
} }
...@@ -281,9 +281,9 @@ public class ContractController { ...@@ -281,9 +281,9 @@ public class ContractController {
@RequestMapping(value = "code/all", method = RequestMethod.GET) @RequestMapping(value = "code/all", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public ResultModel contractCodeAll( @PathVariable String platform) { public ResultModel contractCodeAll( @PathVariable String platform,String contractId) {
return ResultModel.OK(service.contractCodeAll(platform)); return ResultModel.OK(service.contractCodeAll(platform,contractId));
} }
......
...@@ -55,7 +55,7 @@ public class Contract { ...@@ -55,7 +55,7 @@ public class Contract {
/** /**
* 新增字段 20190427 * 新增字段 20190427
*/ */
private Long discountFlow; // 优惠流量 // private Long discountFlow; // 优惠流量
private Long discountTimeLong; // 优惠时长 private Long discountTimeLong; // 优惠时长
private BigDecimal rebateMoney; //回款金额 private BigDecimal rebateMoney; //回款金额
...@@ -355,13 +355,13 @@ public class Contract { ...@@ -355,13 +355,13 @@ public class Contract {
this.createName = createName; this.createName = createName;
} }
public Long getDiscountFlow() { // public Long getDiscountFlow() {
return discountFlow; // return discountFlow;
} // }
//
public void setDiscountFlow(Long discountFlow) { // public void setDiscountFlow(Long discountFlow) {
this.discountFlow = discountFlow; // this.discountFlow = discountFlow;
} // }
public Long getDiscountTimeLong() { public Long getDiscountTimeLong() {
return discountTimeLong; return discountTimeLong;
......
...@@ -12,6 +12,12 @@ import java.util.List; ...@@ -12,6 +12,12 @@ 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 relation_id id from contract_relation where main_contract = ?1 union all select main_contract id from contract_relation where relation_id = ?1",nativeQuery = true)
List<Long> findRelationIds(String contractId); List<Long> findRelationIds(String contractId);
@Query(value = "select * from contract_relation where main_contract = ?1 and relation_id = ?2 and platform = ?3",nativeQuery = true)
ContractRelation findByRelationData(Long mainContract, Long relationId, String platform);
@Query(value = "select * from contract_relation where main_contract = ?1 ",nativeQuery = true)
List<ContractRelation> findRelationIdsMain(String contractId);
} }
...@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Query; ...@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -19,10 +20,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> { ...@@ -19,10 +20,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value="select count(*) from contract where email = ?1 and platform = ?2",nativeQuery=true) @Query(value="select count(*) from contract where email = ?1 and platform = ?2",nativeQuery=true)
BigInteger countNumByEmail(String email, String platfrom); BigInteger countNumByEmail(String email, String platfrom);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 order by ds desc",nativeQuery=true) @Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and status!='del' order by ds desc",nativeQuery=true)
List<Contract> findByDs(String startDate, String endDate, String platfrom); List<Contract> findByDs(String startDate, String endDate, String platfrom);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and create_account in ?4 order by ds desc",nativeQuery=true) @Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and create_account in ?4 and status!='del' order by ds desc",nativeQuery=true)
List<Contract> findByDsAndRoile(String startDate, String endDate, String platfrom, List<Long> userids); List<Contract> findByDsAndRoile(String startDate, String endDate, String platfrom, List<Long> userids);
@Query(value="select * from contract where contract_code = ?1",nativeQuery=true) @Query(value="select * from contract where contract_code = ?1",nativeQuery=true)
...@@ -52,15 +53,19 @@ public interface ContractRepository extends JpaRepository<Contract, Long> { ...@@ -52,15 +53,19 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value = "select count(*) from contract where my_body_code = ?1",nativeQuery = true) @Query(value = "select count(*) from contract where my_body_code = ?1",nativeQuery = true)
BigInteger findcountContract(String platform); BigInteger findcountContract(String platform);
@Query(value = "select new map( c.id as id, c.contractCode as contractCode ) from Contract c where c.platform = ?1 and c.contractCode is not null and c.contractCode <> 'null'") @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<Map> contractCodePlatform(String platform); List<Map> contractCodePlatform(List<String> platform);
@Query(value = "select * from contract where platform = ?1 and contract_code = ?2",nativeQuery = true) @Query(value = "select * from contract where platform = ?1 and contract_code = ?2",nativeQuery = true)
Contract findByCodePlatform(String contractCode, String platform); Contract findByCodePlatform(String contractCode, String platform);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and id in ?4 order by ds desc",nativeQuery=true) @Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and id in ?4 and status!='del' order by ds desc",nativeQuery=true)
List<Contract> findByDsRelation(String startDate, String endDate, String platform, List<Long> contractIds); List<Contract> findByDsRelation(String startDate, String endDate, List<String> platform, List<Long> contractIds);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and create_account in ?4 and id in ?5 order by ds desc",nativeQuery=true) @Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and create_account in ?4 and id in ?5 and status!='del' order by ds desc",nativeQuery=true)
List<Contract> findByDsAndRoileRelation(String startDate, String endDate, String platform, List<Long> create_account, List<Long> contractIds); List<Contract> findByDsAndRoileRelation(String startDate, String endDate, List<String> platform, List<Long> create_account, List<Long> contractIds);
@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);
} }
...@@ -53,9 +53,9 @@ public interface ContractService { ...@@ -53,9 +53,9 @@ public interface ContractService {
List<TradeType> getTradeData(String platform); List<TradeType> getTradeData(String platform);
List<Map> contractCodeAll(String platform); List<Map> contractCodeAll(String platform, String contractId);
List<Contract> findAllContract(User loginAccount, String startDate, String endDate, String platform, String contractId); // List<Contract> findAllContract(User loginAccount, String startDate, String endDate, String platform, String contractId);
Contract contractStatusUpdate(String platform, String contractId, String status); Contract contractStatusUpdate(String platform, String contractId, String status);
} }
\ No newline at end of file
...@@ -29,7 +29,6 @@ import java.beans.BeanInfo; ...@@ -29,7 +29,6 @@ import java.beans.BeanInfo;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.beans.Introspector; import java.beans.Introspector;
import java.beans.PropertyDescriptor; import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -102,6 +101,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -102,6 +101,8 @@ public class ContractServiceImpl implements ContractService {
Account4Web account4Web = null; Account4Web account4Web = null;
IOAccount4Web ioAccount4Web = null; IOAccount4Web ioAccount4Web = null;
ADIUser adiUser = null; ADIUser adiUser = null;
platfrom = "tkio";
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)) {
...@@ -184,10 +185,12 @@ public class ContractServiceImpl implements ContractService { ...@@ -184,10 +185,12 @@ public class ContractServiceImpl implements ContractService {
BigInteger countContract = contractRepository.findcountContract(code); BigInteger countContract = contractRepository.findcountContract(code);
// BigInteger countContract = contractRepository.countNumByDs(DateUtil.getBeforeDays(0));
String lastCode; String lastCode;
if("fake".equals(platform)){
platform = "FZBWS";
}
int codeInt = countContract.intValue(); int codeInt = countContract.intValue();
if (codeInt < 9) { if (codeInt < 9) {
...@@ -200,6 +203,9 @@ public class ContractServiceImpl implements ContractService { ...@@ -200,6 +203,9 @@ public class ContractServiceImpl implements ContractService {
@Override @Override
public List findSetmeal(String platform) { public List findSetmeal(String platform) {
platform = "tkio";
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++) {
...@@ -295,22 +301,22 @@ public class ContractServiceImpl implements ContractService { ...@@ -295,22 +301,22 @@ public class ContractServiceImpl implements ContractService {
resource.setDs(DateUtil.getBeforeDays(0)); 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);
flow.setEndDate(resource.getEndDate()); // flow.setEndDate(resource.getEndDate());
flow.setStartDate(resource.getStartDate()); // flow.setStartDate(resource.getStartDate());
flow.setContractCode(resource.getContractCode()); // flow.setContractCode(resource.getContractCode());
incrementFlowRepository.save(flow); // incrementFlowRepository.save(flow);
} // }
} // }
} // }
} // }
this.dealContractStatus(resource); this.dealContractStatus(resource);
...@@ -323,6 +329,9 @@ public class ContractServiceImpl implements ContractService { ...@@ -323,6 +329,9 @@ public class ContractServiceImpl implements ContractService {
resource.setCreateName(loginUser.getName()); resource.setCreateName(loginUser.getName());
} }
resource.setCreateTime(new Date()); resource.setCreateTime(new Date());
//同步修改trackingio的数据 //同步修改trackingio的数据
...@@ -338,18 +347,46 @@ public class ContractServiceImpl implements ContractService { ...@@ -338,18 +347,46 @@ public class ContractServiceImpl implements ContractService {
resource = contractRepository.save(resource); resource = contractRepository.save(resource);
this.saveContractRelations(resource,resource.getId());
return resource;
}
private void saveContractRelations(Contract resource,Long contractId){
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());
relation.setMainContract(resource.getId()); relation.setMainContract(contractId);
relation.setRelationId(resource.getRelationContract()); relation.setRelationId(resource.getRelationContract());
relation.setPlatform(resource.getPlatform()); relation.setPlatform(resource.getPlatform());
contractRelationRepository.save(relation);
} ContractRelation relationOrig = contractRelationRepository.findByRelationData(relation.getMainContract(),relation.getRelationId(),resource.getPlatform());
if(relationOrig==null){
contractRelationRepository.save(relation);
}
return resource; //处理被关联 合同
Contract contract = contractRepository.findOne(resource.getRelationContract());
if (contract.getRelationContract() == null || contract.getRelationContract() == -1) {
contract.setRelationContract(contractId);
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);
// }
}
} }
...@@ -405,27 +442,27 @@ public class ContractServiceImpl implements ContractService { ...@@ -405,27 +442,27 @@ public class ContractServiceImpl implements ContractService {
// resource.setStatus("wait"); // resource.setStatus("wait");
} }
if (resource.getRebateMoney() != null) { // if (resource.getRebateMoney() != null) {
if (resource.getMoney() == null) { // if (resource.getMoney() == null) {
resource.setMoney(0L); // resource.setMoney(0L);
} // }
//
if (resource.getRebateMoney().compareTo(BigDecimal.ZERO) < 0) { // if (resource.getRebateMoney().compareTo(BigDecimal.ZERO) < 0) {
//未回款 // //未回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey()); // resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey());
//
}else if(resource.getRebateMoney().compareTo(new BigDecimal(resource.getMoney()+""))< 0){ // }else if(resource.getRebateMoney().compareTo(new BigDecimal(resource.getMoney()+""))< 0){
// 部分回款 // // 部分回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_PART.getKey()); // resource.setStatus(ContractStatusEnum.MONEY_BACK_PART.getKey());
}else{ // }else{
// 已回款 // // 已回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_ALL.getKey()); // resource.setStatus(ContractStatusEnum.MONEY_BACK_ALL.getKey());
} // }
//
} else { // } else {
//未回款 // //未回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey()); // resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey());
} // }
Double rebat = null; Double rebat = null;
if (null != resource.getPriceLevel()) { if (null != resource.getPriceLevel()) {
...@@ -579,35 +616,45 @@ public class ContractServiceImpl implements ContractService { ...@@ -579,35 +616,45 @@ public class ContractServiceImpl implements ContractService {
// 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());
flow.setStartDate(resource.getStartDate()); // flow.setStartDate(resource.getStartDate());
if (contract.getExtraFlow() != resource.getExtraFlow()) { // if (contract.getExtraFlow() != resource.getExtraFlow()) {
flow.setFlow(resource.getExtraFlow()); // flow.setFlow(resource.getExtraFlow());
incrementFlowRepository.save(flow); // incrementFlowRepository.save(flow);
} // }
} else if (resource.getExtraFlow().longValue() > 0) { // } else if (resource.getExtraFlow().longValue() > 0) {
IncrementFlow flow1 = new IncrementFlow(); // IncrementFlow flow1 = new IncrementFlow();
Account account = accountRepository.findByEmail(contract.getEmail()); // Account account = accountRepository.findByEmail(contract.getEmail());
flow1.setAccount(account.getId()); // flow1.setAccount(account.getId());
flow1.setFlow(resource.getExtraFlow()); // flow1.setFlow(resource.getExtraFlow());
flow1.setEndDate(resource.getEndDate()); // flow1.setEndDate(resource.getEndDate());
flow1.setStartDate(resource.getStartDate()); // flow1.setStartDate(resource.getStartDate());
flow1.setContractCode(resource.getContractCode()); // flow1.setContractCode(resource.getContractCode());
incrementFlowRepository.save(flow1); // incrementFlowRepository.save(flow1);
} // }
} // }
//
// }
} contract.setStatus(resource.getStatus());
contract.setExtraFlow(resource.getExtraFlow()); contract.setExtraFlow(resource.getExtraFlow());
contract.setTradeType(resource.getTradeType()); contract.setTradeType(resource.getTradeType());
contract.setInvoiceMoney(resource.getInvoiceMoney()); contract.setInvoiceMoney(resource.getInvoiceMoney());
contract.setRelationContract(resource.getRelationContract()); contract.setRelationContract(resource.getRelationContract());
contract.setRebateMoney(resource.getRebateMoney());
contract.setDiscountTimeLong(resource.getDiscountTimeLong()); contract.setDiscountTimeLong(resource.getDiscountTimeLong());
contract.setModifyTime(new Date());
if (null != loginUser) {
resource.setModifyAccount(loginUser.getId());
}
this.saveContractRelations(resource,contract.getId());
return contractRepository.save(contract); return contractRepository.save(contract);
} }
...@@ -619,7 +666,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -619,7 +666,7 @@ public class ContractServiceImpl implements ContractService {
resource.setMoney(0L); resource.setMoney(0L);
} }
if (resource.getRebateMoney().compareTo(BigDecimal.ZERO) < 0) { if (resource.getRebateMoney().compareTo(BigDecimal.ZERO) <= 0) {
//未回款 //未回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey()); resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey());
...@@ -635,31 +682,23 @@ public class ContractServiceImpl implements ContractService { ...@@ -635,31 +682,23 @@ public class ContractServiceImpl implements ContractService {
//未回款 //未回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey()); resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey());
} }
}
// private Map dealContractChangeMap(Contract resource, Contract contract) throws IllegalAccessException { if (resource.getRebateMoney() == null) {
// resource.setRebateMoney(new BigDecimal(0));
// Map data = new HashMap(); }
//
// Class contractClass = contract.getClass(); if (resource.getInvoiceMoney() == null) {
// Field[] files = contractClass.getDeclaredFields(); resource.setInvoiceMoney(new BigDecimal(0));
// }
// for(Field f :files){
// String fieldName = f.getName(); if (resource.getDiscountTimeLong() == null) {
// f.setAccessible(true); resource.setDiscountTimeLong(0L);
// data.put(fieldName, f.get(fieldName)); }
// }
// Class resourcec = resource.getClass(); if (resource.getExtraFlow() == null) {
// Field[] resourcecFields = resourcec.getDeclaredFields(); resource.setExtraFlow(0L);
// for(Field f :resourcecFields){ }
// String fieldName = f.getName(); }
// f.setAccessible(true);
// data.put(fieldName+"_new", f.get(fieldName));
// }
//
// return data;
//
// }
/** /**
...@@ -708,12 +747,20 @@ public class ContractServiceImpl implements ContractService { ...@@ -708,12 +747,20 @@ public class ContractServiceImpl implements ContractService {
List<Long> contractIds = null; List<Long> contractIds = null;
List<String> platforms = new ArrayList<>();
platforms.add(platform);
if (!StringUtils.isEmpty(contractId)) { if (!StringUtils.isEmpty(contractId)) {
//获取 关联合同列表 //获取 关联合同列表
contractIds = contractRelationRepository.findRelationIds(contractId); contractIds = contractRelationRepository.findRelationIds(contractId);
if("fake".equals(platform)){
platforms.add("tkio");
}
} }
List<Contract> contractList = null; List<Contract> contractList = new ArrayList<>();
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())) {
...@@ -726,24 +773,35 @@ public class ContractServiceImpl implements ContractService { ...@@ -726,24 +773,35 @@ public class ContractServiceImpl implements ContractService {
// contractList = contractRepository.findByDsAndRoile(startDate, endDate, platfrom, idList); // contractList = contractRepository.findByDsAndRoile(startDate, endDate, platfrom, idList);
if (contractIds != null && contractIds.size() > 0) {
contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platform, idList, contractIds); if(!StringUtils.isEmpty(contractId)){
} else { //查看关联合同
if (contractIds != null && contractIds.size() > 0) {
contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platforms, idList, contractIds);
}
}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) {
contractList = contractRepository.findByDsRelation(startDate, endDate, platform, contractIds); if(!StringUtils.isEmpty(contractId)){
} else { if (contractIds != null && contractIds.size() > 0) {
contractList = contractRepository.findByDsRelation(startDate, endDate, platforms, contractIds);
}
}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) || if ((c.getExtraFlow() != null && c.getExtraFlow() > 0) ||
(c.getDiscountTimeLong() != null && c.getDiscountTimeLong() > 0)) { (c.getDiscountTimeLong() != null && c.getDiscountTimeLong() > 0)) {
c.setHasDiscount("有"); c.setHasDiscount("有");
...@@ -753,13 +811,14 @@ public class ContractServiceImpl implements ContractService { ...@@ -753,13 +811,14 @@ public class ContractServiceImpl implements ContractService {
} }
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")) { c.setPriceLevelName(typeMap.containsKey(c.getPriceLevel()) ? typeMap.get(c.getPriceLevel()) : "");
c.setPriceLevelName(typeMap.containsKey(c.getPriceLevel()) ? typeMap.get(c.getPriceLevel()) : ""); // if (c.getType().equals(ContractTypeEnum.MAIN.getKey()) && platform.contains("io")) {
} else if (c.getType().equals(ContractTypeEnum.MAIN.getKey())) { //
c.setPriceLevelName(bpuMap.containsKey(c.getPriceLevel()) ? bpuMap.get(c.getPriceLevel()) : ""); // } else if (c.getType().equals(ContractTypeEnum.MAIN.getKey())) {
} else { // c.setPriceLevelName(bpuMap.containsKey(c.getPriceLevel()) ? bpuMap.get(c.getPriceLevel()) : "");
c.setPriceLevelName(incremenMap.containsKey(c.getPriceLevel()) ? incremenMap.get(c.getPriceLevel()) : ""); // } else {
} // c.setPriceLevelName(incremenMap.containsKey(c.getPriceLevel()) ? incremenMap.get(c.getPriceLevel()) : "");
// }
c.setCreateName(saleMap.containsKey(c.getCreateAccount()) ? saleMap.get(c.getCreateAccount()) : ""); c.setCreateName(saleMap.containsKey(c.getCreateAccount()) ? saleMap.get(c.getCreateAccount()) : "");
result.add(c); result.add(c);
...@@ -768,44 +827,44 @@ public class ContractServiceImpl implements ContractService { ...@@ -768,44 +827,44 @@ public class ContractServiceImpl implements ContractService {
return result; return result;
} }
@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) {
...@@ -1053,7 +1112,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -1053,7 +1112,7 @@ public class ContractServiceImpl implements ContractService {
} }
@Override @Override
public List<Map> contractCodeAll(String platform) { public List<Map> contractCodeAll(String platform, String contractId) {
Map<String,String> data = new HashMap<>(); Map<String,String> data = new HashMap<>();
data.put("id","-1"); data.put("id","-1");
...@@ -1061,7 +1120,40 @@ public class ContractServiceImpl implements ContractService { ...@@ -1061,7 +1120,40 @@ public class ContractServiceImpl implements ContractService {
List result = new ArrayList(); List result = new ArrayList();
result.add(data); result.add(data);
result.addAll(contractRepository.contractCodePlatform(platform));
List<String> plats = new ArrayList<>();
plats.add(platform);
if("fake".equals(platform)){
plats.add("tkio");
}
List<ContractRelation> ids = null;
if(!StringUtils.isEmpty(contractId)){
ids = contractRelationRepository.findRelationIdsMain(contractId);
}
if (ids != null) {
Map<String,String> filterMap = new HashMap();
for(ContractRelation relation : ids){
filterMap.put(relation.getRelationId()+"_","");
}
List<Map> resultBefore = contractRepository.contractCodePlatform(plats);
for (Map m : resultBefore) {
String m_id = m.get("id").toString() + "_";
if (filterMap.get(m_id) == null && !m_id.equals(contractId+"_")) {
result.add(m);
}
}
} else {
result.addAll(contractRepository.contractCodePlatform(plats));
}
return result; return result;
} }
......
...@@ -2,7 +2,6 @@ package tkio.task; ...@@ -2,7 +2,6 @@ package tkio.task;
import common.model.Account4Web; import common.model.Account4Web;
import common.repository.Account4WebRepository; import common.repository.Account4WebRepository;
import common.task.SyncAppDataTask;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
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