Commit 5fc737e7 by manxiaoqiang

合同

parent 9e50ac7b
......@@ -110,4 +110,11 @@ public class ContractController {
public ResultModel updatePay(@CurrentAccount User loginAccount, @RequestBody ContractMoney 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 {
private Boolean trackStatus;
private Boolean remStatus;
private Long bussinessMan;
private String contractStatus;
private Integer contractTime;
@Id
@GeneratedValue
public Long getId() {
......@@ -198,26 +201,19 @@ public class Account4Web {
this.createDs = createDs;
}
@Override
public String toString() {
return "Account4Web{" +
"id=" + id +
", email='" + email + '\'' +
", company='" + company + '\'' +
", createDate=" + createDate +
", status='" + status + '\'' +
", packageType='" + packageType + '\'' +
", pastDate='" + pastDate + '\'' +
", track=" + track +
", io=" + io +
", trackLimit=" + trackLimit +
", ioLimit=" + ioLimit +
", backTime=" + backTime +
", user='" + user + '\'' +
", tell='" + tell + '\'' +
", money=" + money +
", ioStatus=" + ioStatus +
", trackStatus=" + trackStatus +
'}';
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;
}
}
......@@ -21,6 +21,8 @@ public class ContractChange {
private Long money;
private Long user;
private String createName;
private String platform;
private String levelName;
private Long modifyAccount;
private Long createAccount;
......@@ -148,4 +150,20 @@ public class ContractChange {
public void setCreateName(String 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 {
private Long money;
private Long user;
private String createName;
private String platform;
private Long modifyAccount;
private Long createAccount;
......@@ -130,4 +131,12 @@ public class ContractMoney {
public void setCreateName(String 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,
@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);
@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
@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);
@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> {
@Query(value="select * from contract where contract_code = ?1",nativeQuery=true)
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 {
List<ContractChange> findChange(String startDate, String endDate, String code);
Contract updatePay(User loginUser, ContractMoney resource);
List<ContractMoney> findPay(String startDate, String endDate);
}
......@@ -160,6 +160,7 @@ public class ContractServiceImpl implements ContractService{
double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
contract.setRebate(f1);
}
cc.setPlatform(contract.getPlatform());
contractChangeRepository.save(cc);
return contractRepository.save(contract);
......@@ -204,6 +205,7 @@ public class ContractServiceImpl implements ContractService{
}
contractRepository.save(contract);
resource.setPlatform(contract.getPlatform());
resource.setCreateAccount(loginUser.getId());
resource.setCreateTime(new Date());
resource.setUser(loginUser.getId());
......@@ -226,6 +228,7 @@ public class ContractServiceImpl implements ContractService{
}else{
contract.setStatus("cancel");
}
resource.setPlatform(contract.getPlatform());
resource.setCreateAccount(loginUser.getId());
resource.setCreateTime(new Date());
resource.setDs(DateUtil.getBeforeDays(0));
......@@ -315,4 +318,25 @@ public class ContractServiceImpl implements ContractService{
save.setCreateName(saleMap.containsKey(save.getSale()) ? saleMap.get(save.getSale()) : "");
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 {
@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.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 {
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.*;
import dic.RoleEnum;
import dic.RoleTypeEnum;
import org.apache.commons.collections.map.AbstractMapDecorator;
import org.apache.commons.collections4.list.TreeList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import tkio.model.Account;
import tkio.model.PackageType;
import tkio.model.SalesManLeader;
import tkio.repository.*;
import tkio.service.AccountFlowRestrictService;
......@@ -57,7 +59,14 @@ public class TkioAccountServiceImpl implements TkioAccountService {
AccountFlowRestrictService accountFlowRestrictService;
@Autowired
UserRepository userRepository;
@Autowired
ContractMoneyRepository contractMoneyRepository;
@Autowired
ContractRepository contractRepository;
@Autowired
ContractChangeRepository contractChangeRepository;
@Autowired
PackageTypeRepository packageTypeRepository;
@Override
public List<Account4Web> findAll(User user) {
List<Account4Web> result = new ArrayList<>();
......@@ -88,6 +97,8 @@ public class TkioAccountServiceImpl implements TkioAccountService {
}
}
}
List<Reminder> reminderList = reminderRepository.findAllDistinct("tkio");
Map<Long, Boolean> reMap = new HashMap<>();
if(ValidateUtil.isValid(reminderList)){
......@@ -95,9 +106,11 @@ public class TkioAccountServiceImpl implements TkioAccountService {
reMap.put(re.getAccountId(), re.getRemindStatus());
}
}
if(ValidateUtil.isValid(account4WebList)){
Map<String, Integer> backTimeMap = getBackTime();
Map<String, Long> payMap = getPayment();
Map<String, List<Contract>> payMap = getPay();
for(Account4Web aw : account4WebList){
if(backTimeMap.containsKey(aw.getEmail())){
aw.setBackTime(backTimeMap.get(aw.getEmail()));
......@@ -105,8 +118,13 @@ public class TkioAccountServiceImpl implements TkioAccountService {
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())){
......@@ -277,18 +295,73 @@ public class TkioAccountServiceImpl implements TkioAccountService {
}
@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, "tkio");
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,"tkio");
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("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;
......@@ -310,18 +383,25 @@ public class TkioAccountServiceImpl implements TkioAccountService {
return map;
}
public Map<String, Long> getPayment(){
Map<String, Long> map = new HashMap<>();
List<Payment> all = paymentRepository.findAllByPlatform("tkio");
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("tkio");
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);
}
}
}
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