Commit 93dbab6b by kangxiaoshan

大后台更新

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