Commit f1e98245 by manxiaoqiang

合同

parent 5fc737e7
......@@ -117,4 +117,6 @@ public class ContractController {
@RequestParam String endDate) {
return ResultModel.OK(service.findPay(startDate, endDate));
}
}
......@@ -27,6 +27,8 @@ public class TrackAccount4Web {
private Boolean ioStatus;
private Boolean trackStatus;
private Boolean remStatus;
private String contractStatus;
private Integer contractTime;
@Id
@GeneratedValue
......@@ -182,6 +184,22 @@ public class TrackAccount4Web {
this.remStatus = remStatus;
}
public String getContractStatus() {
return contractStatus;
}
public void setContractStatus(String contractStatus) {
this.contractStatus = contractStatus;
}
public Integer getContractTime() {
return contractTime;
}
public void setContractTime(Integer contractTime) {
this.contractTime = contractTime;
}
@Override
public String toString() {
return "Account4Web{" +
......
......@@ -19,4 +19,7 @@ public interface BackVisitRepository extends JpaRepository<BackVisit, Long> {
@Query(value = "select * from back_visit where platform = ?1", nativeQuery = true)
List<BackVisit> findAllByPlatform(String platform);
@Query(value = "select * from back_visit where platform = ?1 and email = ?2", nativeQuery = true)
List<BackVisit> findAllByPlatformAndEmail(String platform, String email);
}
......@@ -18,6 +18,9 @@ public interface ContractMoneyRepository extends JpaRepository<ContractMoney, Lo
@Query(value="select * from contract_money where ds >= ?1 and ds <= ?2 order by ds desc",nativeQuery=true)
List<ContractMoney> findByDs(String startDate, String endDate);
@Query(value="select * from contract_money where ds >= ?1 and ds <= ?2 and email = ?3 and platform = ?4 order by ds desc",nativeQuery=true)
@Query(value="select * from contract_money where ds >= ?1 and ds <= ?2 and email = ?3 and platform = ?4 and type = 'pay' order by ds desc",nativeQuery=true)
List<ContractMoney> findByDs(String startDate, String endDate, String email, String platform);
@Query(value="select * from contract_money where email = ?1 and platform = ?2 and type = 'pay' order by ds desc",nativeQuery=true)
List<ContractMoney> findByEmail(String email, String platform);
}
......@@ -13,6 +13,9 @@ import java.util.List;
public interface TrackAccount4WebRepository extends JpaRepository<TrackAccount4Web, Long> {
@Query(value = "SELECT * from account4web where email in ?1", nativeQuery = true)
List<Account4Web> findByEmails(List<String> emails);
List<TrackAccount4Web> findByEmails(List<String> emails);
@Query(value = "SELECT * from account4web where email = ?1", nativeQuery = true)
TrackAccount4Web findByEmail(String email);
}
......@@ -33,6 +33,11 @@ public class TkioAccountController {
return ResultModel.OK(tkioAccountService.findAll(loginAccount));
}
@RequestMapping(value = "/findone", method = RequestMethod.GET)
@ResponseBody
public ResultModel findOne(@CurrentAccount User loginAccount, @RequestParam String email) {
return ResultModel.OK(tkioAccountService.findOne(email));
}
//关闭到期提醒
@RequestMapping(value = "/forbiden", method = RequestMethod.PUT)
......
......@@ -11,6 +11,7 @@ import java.util.Map;
public interface TkioAccountService {
List<Account4Web> findAll(User user);
Account4Web findOne(String email);
//到期提醒关闭
Reminder forbiden(User user, Reminder resource);
......
......@@ -137,6 +137,39 @@ public class TkioAccountServiceImpl implements TkioAccountService {
}
return result;
}
@Override
public Account4Web findOne(String email) {
List<Reminder> reminderList = reminderRepository.findAllDistinct("tkio");
Map<Long, Boolean> reMap = new HashMap<>();
if(ValidateUtil.isValid(reminderList)){
for(Reminder re : reminderList){
reMap.put(re.getAccountId(), re.getRemindStatus());
}
}
Account4Web aw = account4WebRepository.findByEmail(email);
List<BackVisit> backVisitList = backVisitRepository.findAllByPlatformAndEmail("tkio", email);
if(ValidateUtil.isValid(backVisitList)){
aw.setBackTime(backVisitList.size());
} else{
aw.setBackTime(0);
}
List<Contract> contractList = contractRepository.findByPlatformAndEmail("tkio", email);
if(ValidateUtil.isValid(contractList)){
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractList.get(contractList.size() - 1 ).getStatus());
aw.setContractTime(contractList.size());
} else{
aw.setContractTime(0);
aw.setContractStatus("empty");
aw.setMoney(0L);
}
if(reMap.containsKey(aw.getAccountId())){
aw.setRemStatus(reMap.get(aw.getAccountId()));
} else{
aw.setRemStatus(true);
}
return aw;
}
@Override
public Reminder forbiden(User user, Reminder resource) {
......
......@@ -32,6 +32,11 @@ public class TrackAccountController {
public ResultModel find(@CurrentAccount User loginAccount) {
return ResultModel.OK(tkioAccountService.findAll(loginAccount));
}
@RequestMapping(value = "/findone", method = RequestMethod.GET)
@ResponseBody
public ResultModel findOne(@CurrentAccount User loginAccount, @RequestParam String email) {
return ResultModel.OK(tkioAccountService.findOne(email));
}
//关闭到期提醒
@RequestMapping(value = "/forbiden", method = RequestMethod.PUT)
......@@ -100,9 +105,26 @@ public class TrackAccountController {
@RequestMapping(value = "/find/pay/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findPay(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate, @PathVariable Long accountId) {
@RequestParam String endDate, @RequestParam String email, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findPay(email,startDate,endDate));
}
//套餐变更查询
@RequestMapping(value = "/find/contract/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findChange(@CurrentAccount User loginAccount, @RequestParam String email, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findContract(email));
}
//合同查询
@RequestMapping(value = "/find/change/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findContract(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate, @RequestParam String email, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findPay(accountId,startDate,endDate));
return ResultModel.OK(tkioAccountService.findContractChange(email,startDate,endDate));
}
}
......@@ -11,6 +11,8 @@ import java.util.Map;
public interface TrackAccountService {
List<TrackAccount4Web> findAll(User user);
TrackAccount4Web findOne(String email);
//到期提醒关闭
Reminder forbiden(User user, Reminder resource);
......@@ -30,5 +32,10 @@ public interface TrackAccountService {
List<BackVisit> findVisit(Long account, String startDate, String endDate);
List<Payment> findPay(Long account, String startDate, String endDate);
List<ContractMoney> findPay(String email, String startDate, String endDate);
List<Contract> findContract(String email);
List<ContractChange> findContractChange(String email, String startDate, String endDate);
}
......@@ -4,11 +4,14 @@ import common.model.*;
import common.repository.*;
import dic.RoleEnum;
import dic.RoleTypeEnum;
import org.apache.commons.collections4.list.TreeList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tkio.model.PackageType;
import tkio.repository.PackageTypeRepository;
import track.model.Account;
import track.model.App;
import track.repository.TrackAccountRepository;
......@@ -49,6 +52,14 @@ public class TrackAccountServiceImpl implements TrackAccountService{
@Autowired
UserRepository userRepository;
@Autowired
ContractMoneyRepository contractMoneyRepository;
@Autowired
ContractRepository contractRepository;
@Autowired
ContractChangeRepository contractChangeRepository;
@Autowired
PackageTypeRepository packageTypeRepository;
@Override
public List<TrackAccount4Web> findAll(User user) {
......@@ -66,7 +77,7 @@ public class TrackAccountServiceImpl implements TrackAccountService{
}
if(ValidateUtil.isValid(account4WebList)){
Map<String, Integer> backTimeMap = getBackTime();
Map<String, Long> payMap = getPayment();
Map<String, List<Contract>> payMap = getPay();
for(TrackAccount4Web aw : account4WebList){
if(backTimeMap.containsKey(aw.getEmail())){
aw.setBackTime(backTimeMap.get(aw.getEmail()));
......@@ -74,8 +85,13 @@ public class TrackAccountServiceImpl implements TrackAccountService{
aw.setBackTime(0);
}
if(payMap.containsKey(aw.getEmail())){
aw.setMoney(payMap.get(aw.getEmail()));
List<Contract> contractList = payMap.get(aw.getEmail());
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractList.get(contractList.size() - 1 ).getStatus());
aw.setContractTime(contractList.size());
} else{
aw.setContractTime(0);
aw.setContractStatus("empty");
aw.setMoney(0L);
}
if(reMap.containsKey(aw.getAccountId())){
......@@ -90,6 +106,40 @@ public class TrackAccountServiceImpl implements TrackAccountService{
}
@Override
public TrackAccount4Web findOne(String email) {
List<Reminder> reminderList = reminderRepository.findAllDistinct("track");
Map<Long, Boolean> reMap = new HashMap<>();
if(ValidateUtil.isValid(reminderList)){
for(Reminder re : reminderList){
reMap.put(re.getAccountId(), re.getRemindStatus());
}
}
TrackAccount4Web aw = trackAccount4WebRepository.findByEmail(email);
List<BackVisit> backVisitList = backVisitRepository.findAllByPlatformAndEmail("track", email);
if(ValidateUtil.isValid(backVisitList)){
aw.setBackTime(backVisitList.size());
} else{
aw.setBackTime(0);
}
List<Contract> contractList = contractRepository.findByPlatformAndEmail("track", email);
if(ValidateUtil.isValid(contractList)){
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractList.get(contractList.size() - 1 ).getStatus());
aw.setContractTime(contractList.size());
} else{
aw.setContractTime(0);
aw.setContractStatus("empty");
aw.setMoney(0L);
}
if(reMap.containsKey(aw.getAccountId())){
aw.setRemStatus(reMap.get(aw.getAccountId()));
} else{
aw.setRemStatus(true);
}
return aw;
}
@Override
public Reminder forbiden(User user, Reminder resource) {
resource.setUser(user.getId());
resource.setModifyTime(new Date());
......@@ -196,19 +246,75 @@ public class TrackAccountServiceImpl implements TrackAccountService{
return result;
}
@Override
public List<Payment> findPay(Long account, String startDate, String endDate) {
List<Payment> result = new ArrayList<>();
public List<ContractMoney> findPay(String email, String startDate, String endDate) {
List<ContractMoney> result = new ArrayList<>();
List<User> userList = userRepository.findAll();
Map<Long, String> userMap = new HashMap<>();
for(User u : userList){
userMap.put(u.getId(), u.getName());
}
List<Payment> list = paymentRepository.findAll(account, startDate, endDate, "track");
if (ValidateUtil.isValid(list)) {
for(Payment re : list){
re.setUserName(userMap.get(re.getUser()));
result.add(re);
List<ContractMoney> list = contractMoneyRepository.findByDs(startDate, endDate, email,"track");
if(ValidateUtil.isValid(list)){
for(ContractMoney cm : list){
Long user = null == cm.getModifyAccount() ? cm.getUser() : cm.getModifyAccount();
cm.setCreateName(userMap.containsKey(user) ? userMap.get(user) : "");
result.add(cm);
}
}
return result;
}
@Override
public List<Contract> findContract(String email) {
List<Contract> result = new ArrayList<>();
List<User> userList = userRepository.findAll();
Map<Long, String> userMap = new HashMap<>();
for(User u : userList){
userMap.put(u.getId(), u.getName());
}
List<PackageType> typeList = packageTypeRepository.findAll();
Map<Long, String> typeMap = new HashMap<>();
if(ValidateUtil.isValid(typeList)){
for(PackageType s: typeList){
typeMap.put(s.getId(), s.getPackageName());
}
}
List<Contract> contractList = contractRepository.findByPlatformAndEmail("track", email);
if(ValidateUtil.isValid(contractList)){
for(Contract cm : contractList){
cm.setSaleName(userMap.containsKey(cm.getSale()) ? userMap.get(cm.getSale()) : "");
cm.setPriceLevelName(typeMap.containsKey(cm.getPriceLevel()) ? typeMap.get(cm.getPriceLevel()) : "");
result.add(cm);
}
}
return result;
}
@Override
public List<ContractChange> findContractChange(String email, String startDate, String endDate) {
List<ContractChange> result = new ArrayList<>();
List<User> userList = userRepository.findAll();
Map<Long, String> userMap = new HashMap<>();
for(User u : userList){
userMap.put(u.getId(), u.getName());
}
List<PackageType> typeList = packageTypeRepository.findAll();
Map<Long, String> typeMap = new HashMap<>();
if(ValidateUtil.isValid(typeList)){
for(PackageType s: typeList){
typeMap.put(s.getId(), s.getPackageName());
}
}
List<ContractChange> contractChangeList = contractChangeRepository.findByPlatformAndEmail("track", email, startDate, endDate);
if(ValidateUtil.isValid(contractChangeList)){
for(ContractChange cm : contractChangeList){
Long user = null == cm.getModifyAccount() ? cm.getUser() : cm.getModifyAccount();
cm.setCreateName(userMap.containsKey(user) ? userMap.get(user) : "");
cm.setLevelName(typeMap.containsKey(cm.getLevel()) ? typeMap.get(cm.getLevel()) : "");
result.add(cm);
}
}
return result;
......@@ -230,15 +336,19 @@ public class TrackAccountServiceImpl implements TrackAccountService{
return map;
}
public Map<String, Long> getPayment(){
Map<String, Long> map = new HashMap<>();
List<Payment> all = paymentRepository.findAllByPlatform("track");
if (ValidateUtil.isValid(all)){
for(Payment pa : all){
public Map<String, List<Contract>> getPay(){
Map<String, List<Contract>> map = new HashMap<>();
List<Contract> contractList = contractRepository.findByPlatform("track");
if (ValidateUtil.isValid(contractList)){
for(Contract pa : contractList){
if(map.containsKey(pa.getEmail())){
map.put(pa.getEmail(), map.get(pa.getEmail()) + pa.getMoney());
List<Contract> list = map.get(pa.getEmail());
list.add(pa);
map.put(pa.getEmail(), list);
} else{
map.put(pa.getEmail(), pa.getMoney());
List<Contract> list = new TreeList<>();
list.add(pa);
map.put(pa.getEmail(), list);
}
}
}
......
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