Commit fe3bbb9d by kangxiaoshan

adi 套餐

parent 11866301
...@@ -168,8 +168,8 @@ public class ContractController { ...@@ -168,8 +168,8 @@ public class ContractController {
@RequestMapping(value = "find/body", method = RequestMethod.GET) @RequestMapping(value = "find/body", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public ResultModel findBody(@CurrentAccount User loginAccount) { public ResultModel findBody(@CurrentAccount User loginAccount,@PathVariable String platform) {
return ResultModel.OK(service.findBody()); return ResultModel.OK(service.findBody(platform));
} }
@RequestMapping(value = "find/code", method = RequestMethod.GET) @RequestMapping(value = "find/code", method = RequestMethod.GET)
......
...@@ -12,6 +12,7 @@ public class ContractBody { ...@@ -12,6 +12,7 @@ public class ContractBody {
private Long id; private Long id;
private String name; private String name;
private String code; private String code;
private String platform;
@Id @Id
@GeneratedValue @GeneratedValue
...@@ -38,4 +39,12 @@ public class ContractBody { ...@@ -38,4 +39,12 @@ public class ContractBody {
public void setCode(String code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
} }
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class PackageBase {
private Long id;
private String packageName;
private String platform;
private int sort;
private int status;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public int getSort() {
return sort;
}
public void setSort(int sort) {
this.sort = sort;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
...@@ -3,9 +3,14 @@ package common.repository; ...@@ -3,9 +3,14 @@ package common.repository;
import common.model.Contract; import common.model.Contract;
import common.model.ContractBody; import common.model.ContractBody;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Transactional @Transactional
public interface ContractBodyRepository extends JpaRepository<ContractBody, Long> { public interface ContractBodyRepository extends JpaRepository<ContractBody, Long> {
@Query(value = "select * from contract_body where platform = ?1 ",nativeQuery = true)
List<ContractBody> findByPlatform(String platform);
} }
package common.repository;
import common.model.PackageBase;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Transactional
public interface PackageBaseRepository extends JpaRepository<PackageBase, Long> {
@Query(value = "select * from package_base where platform =?1 and status =?2",nativeQuery = true)
List<PackageBase> findByPlatAndStatus(String platform, int status);
}
...@@ -15,7 +15,7 @@ public interface ContractService { ...@@ -15,7 +15,7 @@ public interface ContractService {
Boolean checkTime(String email, String platfrom, String type, String product); Boolean checkTime(String email, String platfrom, String type, String product);
List<ContractBody> findBody(); List<ContractBody> findBody(String platform);
String getContractCode(String code); String getContractCode(String code);
......
package common.service.impl; package common.service.impl;
import adi.dic.PackageEnum;
import adi.model.ADIUser; import adi.model.ADIUser;
import adi.service.ADIAccountService; import adi.service.ADIAccountService;
import common.model.*; import common.model.*;
...@@ -116,6 +115,10 @@ public class ContractServiceImpl implements ContractService { ...@@ -116,6 +115,10 @@ public class ContractServiceImpl implements ContractService {
SalesRepository salesRepository; SalesRepository salesRepository;
@Autowired
PackageBaseRepository packageBaseRepository;
@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<>();
...@@ -184,8 +187,13 @@ public class ContractServiceImpl implements ContractService { ...@@ -184,8 +187,13 @@ public class ContractServiceImpl implements ContractService {
} }
@Override @Override
public List<ContractBody> findBody() { public List<ContractBody> findBody(String platform) {
return contractBodyRepository.findAll();
List<ContractBody> common = contractBodyRepository.findByPlatform("common");
List<ContractBody> byPlatform = contractBodyRepository.findByPlatform(platform);
common.addAll(byPlatform);
return common;
} }
@Override @Override
...@@ -256,37 +264,55 @@ public class ContractServiceImpl implements ContractService { ...@@ -256,37 +264,55 @@ public class ContractServiceImpl implements ContractService {
@Override @Override
public List findSetmeal(String platform) { public List findSetmeal(String platform) {
platform = "tkio"; // platform = "tkio";
//
// List list = new ArrayList();
// if ("adi".equals(platform)) {
// for (int i = 1; i < 3; i++) {
// Map<String, String> packageMap = new HashMap<>();
// packageMap.put("id", i + "");
// if (i == 1) {
// packageMap.put("packageName", PackageEnum.PROBATION.getValue());
// } else {
// packageMap.put("packageName", PackageEnum.FORMAL.getValue());
// }
// list.add(packageMap);
// }
// } 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 list = new ArrayList(); List list = new ArrayList();
if ("adi".equals(platform)) {
for (int i = 1; i < 3; i++) {
Map<String, String> packageMap = new HashMap<>();
packageMap.put("id", i + "");
if (i == 1) {
packageMap.put("packageName", PackageEnum.PROBATION.getValue());
} else {
packageMap.put("packageName", PackageEnum.FORMAL.getValue());
}
list.add(packageMap);
}
} else {
if ("tkio".equals(platform) || "io".equals(platform)) { if ("tkio".equals(platform) || "io".equals(platform)) {
// List<PackageType> packageTypeList = packageTypeRepository.findAll();
List<PackageType> packageTypeList = packageTypeRepository.findIsNewAll(); List<PackageType> packageTypeList = packageTypeRepository.findIsNewAll();
for (PackageType p : packageTypeList) { for (PackageType p : packageTypeList) {
p.setType("main"); p.setType("main");
list.add(p); 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);
}
}
return list; return list;
}else{
List<PackageBase> packageBases = packageBaseRepository.findByPlatAndStatus(platform,1);
return packageBases;
}
} }
@Override @Override
...@@ -1023,6 +1049,15 @@ public class ContractServiceImpl implements ContractService { ...@@ -1023,6 +1049,15 @@ public class ContractServiceImpl implements ContractService {
} }
} }
List<PackageBase> packageBases = packageBaseRepository.findByPlatAndStatus(platform,1);
Map<Long,PackageBase> packageBaseMap = new HashMap<>();
for(PackageBase base:packageBases){
packageBaseMap.put(base.getId(),base);
}
List<String> platforms = new ArrayList<>(); List<String> platforms = new ArrayList<>();
Map<String,String> idsDic = new HashMap<>(); Map<String,String> idsDic = new HashMap<>();
platforms.add(platform); platforms.add(platform);
...@@ -1094,8 +1129,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -1094,8 +1129,7 @@ public class ContractServiceImpl implements ContractService {
c.setRelationContract(-1L); c.setRelationContract(-1L);
} }
c.setSaleName(saleMap.containsKey(c.getSale()) ? saleMap.get(c.getSale()) : "");
c.setPriceLevelName(typeMap.containsKey(c.getPriceLevel()) ? typeMap.get(c.getPriceLevel()) : "");
// if (c.getType().equals(ContractTypeEnum.MAIN.getKey()) && platform.contains("io")) { // if (c.getType().equals(ContractTypeEnum.MAIN.getKey()) && platform.contains("io")) {
// //
// } else if (c.getType().equals(ContractTypeEnum.MAIN.getKey())) { // } else if (c.getType().equals(ContractTypeEnum.MAIN.getKey())) {
...@@ -1104,6 +1138,15 @@ public class ContractServiceImpl implements ContractService { ...@@ -1104,6 +1138,15 @@ public class ContractServiceImpl implements ContractService {
// c.setPriceLevelName(incremenMap.containsKey(c.getPriceLevel()) ? incremenMap.get(c.getPriceLevel()) : ""); // c.setPriceLevelName(incremenMap.containsKey(c.getPriceLevel()) ? incremenMap.get(c.getPriceLevel()) : "");
// } // }
c.setSaleName(saleMap.containsKey(c.getSale()) ? saleMap.get(c.getSale()) : "");
if("tkio".equals(platform)){
c.setPriceLevelName(typeMap.containsKey(c.getPriceLevel()) ? typeMap.get(c.getPriceLevel()) : "");
}else{
c.setPriceLevelName(packageBaseMap.get(c.getPriceLevel())==null?"":packageBaseMap.get(c.getPriceLevel()).getPackageName());
}
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);
} }
......
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