Commit aec63e4d by manxiaoqiang

大后台客户列表

parent c00d79af
......@@ -35,7 +35,7 @@ public class LoginController {
cookie.setPath("/");
cookie.setMaxAge(60 * 60 * 24 * 7);
response.addCookie(cookie);
return ResultModel.OK(true);
return ResultModel.OK(user);
}
return ResultModel.OK(false);
}
......
......@@ -19,7 +19,7 @@ public class Account4Web {
private Integer backTime;
private String user;
private String tell;
private Integer money;
private Long money;
private Boolean ioStatus;
private Boolean trackStatus;
......@@ -121,11 +121,11 @@ public class Account4Web {
this.tell = tell;
}
public Integer getMoney() {
public Long getMoney() {
return money;
}
public void setMoney(Integer money) {
public void setMoney(Long money) {
this.money = money;
}
......
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;
/**
* Created by mxq on 2017/12/26.
*/
@Entity
public class BackVisit {
private Long id;
private Long accountId;
private String email;
private String platform;
private Long visitTime;
private Long user;
private Date visitDate;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public Long getVisitTime() {
return visitTime;
}
public void setVisitTime(Long visitTime) {
this.visitTime = visitTime;
}
public Long getUser() {
return user;
}
public void setUser(Long user) {
this.user = user;
}
public Date getVisitDate() {
return visitDate;
}
public void setVisitDate(Date visitDate) {
this.visitDate = visitDate;
}
@Override
public String toString() {
return "BackVisit{" +
"id=" + id +
", accountId=" + accountId +
", email='" + email + '\'' +
", platform='" + platform + '\'' +
", visitTime=" + visitTime +
", user=" + user +
", visitDate=" + visitDate +
'}';
}
}
package common.model;
/**
* Created by mxq on 2017/12/26.
*/
public class KeyValue {
private String email;
private Integer timenum;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getTimenum() {
return timenum;
}
public void setTimenum(Integer timenum) {
this.timenum = timenum;
}
public KeyValue(String email, Integer timenum) {
this.email = email;
this.timenum = timenum;
}
public KeyValue() {
}
@Override
public String toString() {
return "KeyValue{" +
"email='" + email + '\'' +
", timenum=" + timenum +
'}';
}
}
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;
/**
* Created by mxq on 2017/12/26.
*/
@Entity
public class Payment {
private Long id;
private Long accountId;
private String email;
private String platform;
private String type;
private Long money;
private Long user;
private Date payDate;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getMoney() {
return money;
}
public void setMoney(Long money) {
this.money = money;
}
public Long getUser() {
return user;
}
public void setUser(Long user) {
this.user = user;
}
public Date getPayDate() {
return payDate;
}
public void setPayDate(Date payDate) {
this.payDate = payDate;
}
}
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;
/**
* Created by mxq on 2017/12/26.
*/
@Entity
public class Reminder {
private Long id;
private Long accountId;
private String email;
private String platform;
private Boolean remindStatus;
private Long user;
private Date modifyTime;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public Boolean getRemindStatus() {
return remindStatus;
}
public void setRemindStatus(Boolean remindStatus) {
this.remindStatus = remindStatus;
}
public Long getUser() {
return user;
}
public void setUser(Long user) {
this.user = user;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
}
......@@ -3,9 +3,16 @@ package common.repository;
import common.model.Account4Web;
import common.model.Auth;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import tkio.model.Account;
import java.util.List;
@Transactional
public interface Account4WebRepository extends JpaRepository<Account4Web, Long> {
@Query(value = "SELECT * from account4web where email in ?1", nativeQuery = true)
List<Account4Web> findByEmails(List<String> emails);
}
package common.repository;
import common.model.Auth;
import common.model.BackVisit;
import common.model.KeyValue;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import tkio.model.Account;
import java.util.List;
@Transactional
public interface BackVisitRepository extends JpaRepository<BackVisit, Long> {
@Query(value = "SELECT * from back_visit", nativeQuery = true)
List<BackVisit> findAllCount();
}
package common.repository;
import common.model.Auth;
import common.model.Payment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface PaymentRepository extends JpaRepository<Payment, Long> {
}
package common.repository;
import common.model.Auth;
import common.model.Reminder;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface ReminderRepository extends JpaRepository<Reminder, Long> {
}
package tkio.controller;
import common.model.User;
import common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import security.annotation.CurrentAccount;
import tkio.service.TkioAccountService;
import util.ResultModel;
/**
* Created by mxq on 2017/12/21.
*/
@Controller
@RequestMapping("marketing/accountmng/tkio")
public class TkioAccountController {
@RequestMapping(value = "/find", method = RequestMethod.GET)
@ResponseBody
public ResultModel find(@CurrentAccount User loginAccount) {
return ResultModel.OK();
}
@RequestMapping(value = "/delete", method = RequestMethod.GET)
@ResponseBody
public ResultModel delete(@CurrentAccount User loginAccount, @RequestBody User resource) {
return ResultModel.OK();
}
@RequestMapping(value = "/update/{id}", method = RequestMethod.PUT)
@ResponseBody
public ResultModel updateName(@CurrentAccount User loginAccount, @RequestParam String name, @PathVariable Long id) {
return ResultModel.OK();
}
@RequestMapping(value = "/update/{id}/pwd", method = RequestMethod.PUT)
@ResponseBody
public ResultModel updatePwd(@CurrentAccount User loginAccount, @RequestParam String pwd, @PathVariable Long id) {
return ResultModel.OK();
}
@RequestMapping(value = "/update/pwd", method = RequestMethod.PUT)
@ResponseBody
public ResultModel updatePwd(@RequestParam String email, @RequestParam String pwd) {
return ResultModel.OK();
}
@RequestMapping(value = "forget/", method = RequestMethod.GET)
@ResponseBody
public ResultModel sengCode(@RequestParam String email) {
return ResultModel.OK();
}
@RequestMapping(value = "valid/code", method = RequestMethod.GET)
@ResponseBody
public ResultModel validCode(@RequestParam String email, @RequestParam String code) {
return ResultModel.OK();
}
}
......@@ -22,4 +22,7 @@ public interface AccountRepository extends JpaRepository<Account, Long> {
@Query(value = "SELECT * from account where is_super_user is true and `status` = 1 and past_date < ?1", nativeQuery = true)
List<Account> findRootParentsPast(String today);
@Query(value = "SELECT * from account where is_super_user is true and bussinessman = ?1", nativeQuery = true)
List<Account> findBussnissMan(List<Integer> bussinussIds);
}
......@@ -5,8 +5,16 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import tkio.model.SalesManLeader;
import java.util.List;
@Transactional
public interface SalesManLeaderRepository extends JpaRepository<SalesManLeader, Long> {
@Query(value = "select email from sales_man_leader where id=(select leader from sales_man_leader where id=?1)", nativeQuery = true)
String findLeaderByBussinessMan(Long bussinessMan);
@Query(value = "select * from sales_man_leader where leader = (select id from sales_man_leader where email = ?1)", nativeQuery = true)
List<SalesManLeader> findByEmail(String email);
@Query(value = "select * from sales_man_leader where email = ?1", nativeQuery = true)
SalesManLeader findOneByEmail(String email);
}
package tkio.service;
import common.model.Account4Web;
import common.model.User;
import java.util.List;
/**
* Created by mxq on 2017/12/26.
*/
public interface TkioAccountService {
List<Account4Web> findAll(User user);
}
package tkio.service.impl;
import com.amazonaws.services.dynamodbv2.xspec.B;
import common.model.*;
import common.repository.Account4WebRepository;
import common.repository.BackVisitRepository;
import common.repository.PaymentRepository;
import common.repository.UserRepository;
import dic.RoleEnum;
import dic.RoleTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tkio.model.Account;
import tkio.model.SalesManLeader;
import tkio.repository.AccountRepository;
import tkio.repository.SalesManLeaderRepository;
import tkio.service.TkioAccountService;
import util.ValidateUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by mxq on 2017/12/26.
*/
public class TkioAccountServiceImpl implements TkioAccountService {
@Autowired
Account4WebRepository account4WebRepository;
@Autowired
SalesManLeaderRepository salesManLeaderRepository;
@Autowired
AccountRepository accountRepository;
@Autowired
BackVisitRepository backVisitRepository;
@Autowired
PaymentRepository paymentRepository;
@Override
public List<Account4Web> findAll(User user) {
List<Account4Web> result = new ArrayList<>();
List<Account4Web> account4WebList = null;
if(user.getRole().equals(RoleEnum.MANAGER.getKey())){
account4WebList = account4WebRepository.findAll();
} else{
List<Integer> idList = new ArrayList<>();
if(user.getRoleType().equals(RoleTypeEnum.MANAGER.getKey())){
List<SalesManLeader> salesManLeaderList = salesManLeaderRepository.findByEmail(user.getEmail());
if (ValidateUtil.isValid(salesManLeaderList)){
for(SalesManLeader sml : salesManLeaderList){
idList.add(sml.getId());
}
}
}else{
SalesManLeader salesManLeader = salesManLeaderRepository.findOneByEmail(user.getEmail());
idList.add(salesManLeader.getId());
}
if(ValidateUtil.isValid(idList)){
List<Account> accountList = accountRepository.findBussnissMan(idList);
List<String> emails = new ArrayList<>();
if(ValidateUtil.isValid(accountList)){
for(Account ac : accountList){
emails.add(ac.getEmail());
}
account4WebList = account4WebRepository.findByEmails(emails);
}
}
}
if(ValidateUtil.isValid(account4WebList)){
Map<String, Integer> backTimeMap = getBackTime();
Map<String, Long> payMap = getPayment();
for(Account4Web aw : account4WebList){
if(backTimeMap.containsKey(aw.getEmail())){
aw.setBackTime(backTimeMap.get(aw.getEmail()));
} else{
aw.setBackTime(0);
}
if(payMap.containsKey(aw.getEmail())){
aw.setMoney(payMap.get(aw.getEmail()));
} else{
aw.setMoney(0L);
}
result.add(aw);
}
}
return result;
}
public Map<String, Integer> getBackTime(){
Map<String, Integer> map = new HashMap<>();
List<BackVisit> all = backVisitRepository.findAll();
if (ValidateUtil.isValid(all)){
for(BackVisit bv : all){
if(map.containsKey(bv.getEmail())){
map.put(bv.getEmail(), map.get(bv.getEmail()) + 1);
} else{
map.put(bv.getEmail(), 1);
}
}
}
return map;
}
public Map<String, Long> getPayment(){
Map<String, Long> map = new HashMap<>();
List<Payment> all = paymentRepository.findAll();
if (ValidateUtil.isValid(all)){
for(Payment pa : all){
if(map.containsKey(pa.getEmail())){
map.put(pa.getEmail(), map.get(pa.getEmail()) + pa.getMoney());
} else{
map.put(pa.getEmail(), pa.getMoney());
}
}
}
return map;
}
}
......@@ -6,8 +6,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import tkio.model.Account;
import tkio.model.AccountRestrict4Web;
import tkio.model.PackageType;
import tkio.model.SalesManLeader;
import tkio.repository.AccountRepository;
import tkio.repository.PackageTypeRepository;
import tkio.repository.SalesManLeaderRepository;
import tkio.service.AccountFlowRestrictService;
import util.DateUtil;
import util.ValidateUtil;
......@@ -34,7 +36,12 @@ public class AccountTask {
@Autowired
private PackageTypeRepository packageTypeRepository;
@Autowired
SalesManLeaderRepository salesManLeaderRepository;
public void task(){
//清空前一天数据
account4WebRepository.deleteAll();
List<Account4Web> list = new ArrayList<>();
//未过期的查询是否流量到期
List<Account> accountValidList = accountRepository.findRootParentsUnPast(DateUtil.getBeforeDays(1));
......@@ -57,7 +64,8 @@ public class AccountTask {
}
account4Web.setIoStatus(restrict4Web.getAllowBehavior());
account4Web.setTrackStatus(restrict4Web.getTrackFlowNotified());
account4Web.setUser(ac.getBussinessman().toString());
account4Web.setUser(ac.getName());
account4Web.setTell(ac.getPhone());
list.add(account4Web);
}
}
......
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