Commit 5fc737e7 by manxiaoqiang

合同

parent 9e50ac7b
...@@ -110,4 +110,11 @@ public class ContractController { ...@@ -110,4 +110,11 @@ public class ContractController {
public ResultModel updatePay(@CurrentAccount User loginAccount, @RequestBody ContractMoney contract) { public ResultModel updatePay(@CurrentAccount User loginAccount, @RequestBody ContractMoney contract) {
return ResultModel.OK(service.updatePay(loginAccount, contract)); return ResultModel.OK(service.updatePay(loginAccount, contract));
} }
@RequestMapping(value = "find/payall", method = RequestMethod.GET)
@ResponseBody
public ResultModel findPayAll(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate) {
return ResultModel.OK(service.findPay(startDate, endDate));
}
} }
...@@ -28,6 +28,9 @@ public class Account4Web { ...@@ -28,6 +28,9 @@ public class Account4Web {
private Boolean trackStatus; private Boolean trackStatus;
private Boolean remStatus; private Boolean remStatus;
private Long bussinessMan; private Long bussinessMan;
private String contractStatus;
private Integer contractTime;
@Id @Id
@GeneratedValue @GeneratedValue
public Long getId() { public Long getId() {
...@@ -198,26 +201,19 @@ public class Account4Web { ...@@ -198,26 +201,19 @@ public class Account4Web {
this.createDs = createDs; this.createDs = createDs;
} }
@Override public String getContractStatus() {
public String toString() { return contractStatus;
return "Account4Web{" + }
"id=" + id +
", email='" + email + '\'' + public void setContractStatus(String contractStatus) {
", company='" + company + '\'' + this.contractStatus = contractStatus;
", createDate=" + createDate + }
", status='" + status + '\'' +
", packageType='" + packageType + '\'' + public Integer getContractTime() {
", pastDate='" + pastDate + '\'' + return contractTime;
", track=" + track + }
", io=" + io +
", trackLimit=" + trackLimit + public void setContractTime(Integer contractTime) {
", ioLimit=" + ioLimit + this.contractTime = contractTime;
", backTime=" + backTime +
", user='" + user + '\'' +
", tell='" + tell + '\'' +
", money=" + money +
", ioStatus=" + ioStatus +
", trackStatus=" + trackStatus +
'}';
} }
} }
...@@ -21,6 +21,8 @@ public class ContractChange { ...@@ -21,6 +21,8 @@ public class ContractChange {
private Long money; private Long money;
private Long user; private Long user;
private String createName; private String createName;
private String platform;
private String levelName;
private Long modifyAccount; private Long modifyAccount;
private Long createAccount; private Long createAccount;
...@@ -148,4 +150,20 @@ public class ContractChange { ...@@ -148,4 +150,20 @@ public class ContractChange {
public void setCreateName(String createName) { public void setCreateName(String createName) {
this.createName = createName; this.createName = createName;
} }
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public String getLevelName() {
return levelName;
}
public void setLevelName(String levelName) {
this.levelName = levelName;
}
} }
...@@ -19,6 +19,7 @@ public class ContractMoney { ...@@ -19,6 +19,7 @@ public class ContractMoney {
private Long money; private Long money;
private Long user; private Long user;
private String createName; private String createName;
private String platform;
private Long modifyAccount; private Long modifyAccount;
private Long createAccount; private Long createAccount;
...@@ -130,4 +131,12 @@ public class ContractMoney { ...@@ -130,4 +131,12 @@ public class ContractMoney {
public void setCreateName(String createName) { public void setCreateName(String createName) {
this.createName = createName; this.createName = createName;
} }
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
} }
...@@ -16,4 +16,7 @@ public interface ContractChangeRepository extends JpaRepository<ContractChange, ...@@ -16,4 +16,7 @@ public interface ContractChangeRepository extends JpaRepository<ContractChange,
@Query(value="select * from contract_change where ds >= ?1 and ds <= ?2 and contract_code = ?3 order by ds desc",nativeQuery=true) @Query(value="select * from contract_change where ds >= ?1 and ds <= ?2 and contract_code = ?3 order by ds desc",nativeQuery=true)
List<ContractChange> findByDs(String startDate, String endDate, String code); List<ContractChange> findByDs(String startDate, String endDate, String code);
@Query(value="SELECT * from contract_change where platform = ?1 and email = ?2 and ds >= ?3 and ds <= ?4 order by ds desc",nativeQuery=true)
List<ContractChange> findByPlatformAndEmail(String platform, String email, String startDate, String endDate);
} }
...@@ -14,4 +14,10 @@ public interface ContractMoneyRepository extends JpaRepository<ContractMoney, Lo ...@@ -14,4 +14,10 @@ public interface ContractMoneyRepository extends JpaRepository<ContractMoney, Lo
@Query(value="select * from contract_money where ds >= ?1 and ds <= ?2 and contract_code = ?3 order by ds desc",nativeQuery=true) @Query(value="select * from contract_money where ds >= ?1 and ds <= ?2 and contract_code = ?3 order by ds desc",nativeQuery=true)
List<ContractMoney> findByDs(String startDate, String endDate, String code); List<ContractMoney> findByDs(String startDate, String endDate, String code);
@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)
List<ContractMoney> findByDs(String startDate, String endDate, String email, String platform);
} }
...@@ -23,4 +23,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> { ...@@ -23,4 +23,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value="select * from contract where contract_code = ?1",nativeQuery=true) @Query(value="select * from contract where contract_code = ?1",nativeQuery=true)
Contract findByCode(String contract_code); Contract findByCode(String contract_code);
@Query(value="SELECT * from contract where platform = ?1",nativeQuery=true)
List<Contract> findByPlatform(String platform);
@Query(value="SELECT * from contract where platform = ?1 and email = ?2",nativeQuery=true)
List<Contract> findByPlatformAndEmail(String platform, String email);
} }
...@@ -38,4 +38,6 @@ public interface ContractService { ...@@ -38,4 +38,6 @@ public interface ContractService {
List<ContractChange> findChange(String startDate, String endDate, String code); List<ContractChange> findChange(String startDate, String endDate, String code);
Contract updatePay(User loginUser, ContractMoney resource); Contract updatePay(User loginUser, ContractMoney resource);
List<ContractMoney> findPay(String startDate, String endDate);
} }
...@@ -160,6 +160,7 @@ public class ContractServiceImpl implements ContractService{ ...@@ -160,6 +160,7 @@ public class ContractServiceImpl implements ContractService{
double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
contract.setRebate(f1); contract.setRebate(f1);
} }
cc.setPlatform(contract.getPlatform());
contractChangeRepository.save(cc); contractChangeRepository.save(cc);
return contractRepository.save(contract); return contractRepository.save(contract);
...@@ -204,6 +205,7 @@ public class ContractServiceImpl implements ContractService{ ...@@ -204,6 +205,7 @@ public class ContractServiceImpl implements ContractService{
} }
contractRepository.save(contract); contractRepository.save(contract);
resource.setPlatform(contract.getPlatform());
resource.setCreateAccount(loginUser.getId()); resource.setCreateAccount(loginUser.getId());
resource.setCreateTime(new Date()); resource.setCreateTime(new Date());
resource.setUser(loginUser.getId()); resource.setUser(loginUser.getId());
...@@ -226,6 +228,7 @@ public class ContractServiceImpl implements ContractService{ ...@@ -226,6 +228,7 @@ public class ContractServiceImpl implements ContractService{
}else{ }else{
contract.setStatus("cancel"); contract.setStatus("cancel");
} }
resource.setPlatform(contract.getPlatform());
resource.setCreateAccount(loginUser.getId()); resource.setCreateAccount(loginUser.getId());
resource.setCreateTime(new Date()); resource.setCreateTime(new Date());
resource.setDs(DateUtil.getBeforeDays(0)); resource.setDs(DateUtil.getBeforeDays(0));
...@@ -315,4 +318,25 @@ public class ContractServiceImpl implements ContractService{ ...@@ -315,4 +318,25 @@ public class ContractServiceImpl implements ContractService{
save.setCreateName(saleMap.containsKey(save.getSale()) ? saleMap.get(save.getSale()) : ""); save.setCreateName(saleMap.containsKey(save.getSale()) ? saleMap.get(save.getSale()) : "");
return save; return save;
} }
@Override
public List<ContractMoney> findPay(String startDate, String endDate) {
List<User> sales = userRepository.findAll();
Map<Long, String> saleMap = new HashMap<>();
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);
if(ValidateUtil.isValid(list)){
for(ContractMoney cm : list){
cm.setCreateName(saleMap.containsKey(cm.getUser()) ? saleMap.get(cm.getUser()) : "");
result.add(cm);
}
}
return result;
}
} }
...@@ -109,9 +109,25 @@ public class TkioAccountController { ...@@ -109,9 +109,25 @@ public class TkioAccountController {
@RequestMapping(value = "/find/pay/{accountId}", method = RequestMethod.GET) @RequestMapping(value = "/find/pay/{accountId}", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public ResultModel findPay(@CurrentAccount User loginAccount, @RequestParam String startDate, 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.findPay(accountId,startDate,endDate)); 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.findContractChange(email,startDate,endDate));
}
} }
...@@ -33,6 +33,9 @@ public interface TkioAccountService { ...@@ -33,6 +33,9 @@ public interface TkioAccountService {
List<BackVisit> findVisit(Long account, String startDate, String endDate); 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);
} }
...@@ -6,6 +6,7 @@ import common.repository.*; ...@@ -6,6 +6,7 @@ import common.repository.*;
import dic.RoleEnum; import dic.RoleEnum;
import dic.RoleTypeEnum; import dic.RoleTypeEnum;
import org.apache.commons.collections.map.AbstractMapDecorator; import org.apache.commons.collections.map.AbstractMapDecorator;
import org.apache.commons.collections4.list.TreeList;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import tkio.model.Account; import tkio.model.Account;
import tkio.model.PackageType;
import tkio.model.SalesManLeader; import tkio.model.SalesManLeader;
import tkio.repository.*; import tkio.repository.*;
import tkio.service.AccountFlowRestrictService; import tkio.service.AccountFlowRestrictService;
...@@ -57,7 +59,14 @@ public class TkioAccountServiceImpl implements TkioAccountService { ...@@ -57,7 +59,14 @@ public class TkioAccountServiceImpl implements TkioAccountService {
AccountFlowRestrictService accountFlowRestrictService; AccountFlowRestrictService accountFlowRestrictService;
@Autowired @Autowired
UserRepository userRepository; UserRepository userRepository;
@Autowired
ContractMoneyRepository contractMoneyRepository;
@Autowired
ContractRepository contractRepository;
@Autowired
ContractChangeRepository contractChangeRepository;
@Autowired
PackageTypeRepository packageTypeRepository;
@Override @Override
public List<Account4Web> findAll(User user) { public List<Account4Web> findAll(User user) {
List<Account4Web> result = new ArrayList<>(); List<Account4Web> result = new ArrayList<>();
...@@ -88,6 +97,8 @@ public class TkioAccountServiceImpl implements TkioAccountService { ...@@ -88,6 +97,8 @@ public class TkioAccountServiceImpl implements TkioAccountService {
} }
} }
} }
List<Reminder> reminderList = reminderRepository.findAllDistinct("tkio"); List<Reminder> reminderList = reminderRepository.findAllDistinct("tkio");
Map<Long, Boolean> reMap = new HashMap<>(); Map<Long, Boolean> reMap = new HashMap<>();
if(ValidateUtil.isValid(reminderList)){ if(ValidateUtil.isValid(reminderList)){
...@@ -95,9 +106,11 @@ public class TkioAccountServiceImpl implements TkioAccountService { ...@@ -95,9 +106,11 @@ public class TkioAccountServiceImpl implements TkioAccountService {
reMap.put(re.getAccountId(), re.getRemindStatus()); reMap.put(re.getAccountId(), re.getRemindStatus());
} }
} }
if(ValidateUtil.isValid(account4WebList)){ if(ValidateUtil.isValid(account4WebList)){
Map<String, Integer> backTimeMap = getBackTime(); Map<String, Integer> backTimeMap = getBackTime();
Map<String, Long> payMap = getPayment(); Map<String, List<Contract>> payMap = getPay();
for(Account4Web aw : account4WebList){ for(Account4Web aw : account4WebList){
if(backTimeMap.containsKey(aw.getEmail())){ if(backTimeMap.containsKey(aw.getEmail())){
aw.setBackTime(backTimeMap.get(aw.getEmail())); aw.setBackTime(backTimeMap.get(aw.getEmail()));
...@@ -105,8 +118,13 @@ public class TkioAccountServiceImpl implements TkioAccountService { ...@@ -105,8 +118,13 @@ public class TkioAccountServiceImpl implements TkioAccountService {
aw.setBackTime(0); aw.setBackTime(0);
} }
if(payMap.containsKey(aw.getEmail())){ 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{ } else{
aw.setContractTime(0);
aw.setContractStatus("empty");
aw.setMoney(0L); aw.setMoney(0L);
} }
if(reMap.containsKey(aw.getAccountId())){ if(reMap.containsKey(aw.getAccountId())){
...@@ -277,18 +295,73 @@ public class TkioAccountServiceImpl implements TkioAccountService { ...@@ -277,18 +295,73 @@ public class TkioAccountServiceImpl implements TkioAccountService {
} }
@Override @Override
public List<Payment> findPay(Long account, String startDate, String endDate) { public List<ContractMoney> findPay(String email, String startDate, String endDate) {
List<Payment> result = new ArrayList<>(); List<ContractMoney> result = new ArrayList<>();
List<User> userList = userRepository.findAll(); List<User> userList = userRepository.findAll();
Map<Long, String> userMap = new HashMap<>(); Map<Long, String> userMap = new HashMap<>();
for(User u : userList){ for(User u : userList){
userMap.put(u.getId(), u.getName()); userMap.put(u.getId(), u.getName());
} }
List<Payment> list = paymentRepository.findAll(account, startDate, endDate, "tkio"); List<ContractMoney> list = contractMoneyRepository.findByDs(startDate, endDate, email,"tkio");
if (ValidateUtil.isValid(list)) { if(ValidateUtil.isValid(list)){
for(Payment re : list){ for(ContractMoney cm : list){
re.setUserName(userMap.get(re.getUser())); Long user = null == cm.getModifyAccount() ? cm.getUser() : cm.getModifyAccount();
result.add(re); 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("tkio", 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("tkio", 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; return result;
...@@ -310,18 +383,25 @@ public class TkioAccountServiceImpl implements TkioAccountService { ...@@ -310,18 +383,25 @@ public class TkioAccountServiceImpl implements TkioAccountService {
return map; return map;
} }
public Map<String, Long> getPayment(){
Map<String, Long> map = new HashMap<>();
List<Payment> all = paymentRepository.findAllByPlatform("tkio"); public Map<String, List<Contract>> getPay(){
if (ValidateUtil.isValid(all)){ Map<String, List<Contract>> map = new HashMap<>();
for(Payment pa : all){ List<Contract> contractList = contractRepository.findByPlatform("tkio");
if (ValidateUtil.isValid(contractList)){
for(Contract pa : contractList){
if(map.containsKey(pa.getEmail())){ 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{ } else{
map.put(pa.getEmail(), pa.getMoney()); List<Contract> list = new TreeList<>();
list.add(pa);
map.put(pa.getEmail(), list);
} }
} }
} }
return map; return map;
} }
} }
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