Commit 8719d6d4 by manxiaoqiang

大后台tiko客户管理

parent 5a47a71c
......@@ -8,20 +8,24 @@ import java.util.Date;
@Entity
public class Account4Web {
private Long id;
private Long accountId;
private String email;
private String company;
private Date createDate;
private String status;
private String packageType;
private String pastDate;
private String track;
private String io;
private BigInteger track;
private BigInteger io;
private BigInteger trackLimit;
private BigInteger ioLimit;
private Integer backTime;
private String user;
private String tell;
private Long money;
private Boolean ioStatus;
private Boolean trackStatus;
private Boolean remStatus;
@Id
@GeneratedValue
......@@ -33,6 +37,14 @@ public class Account4Web {
this.id = id;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public String getEmail() {
return email;
}
......@@ -81,22 +93,38 @@ public class Account4Web {
this.pastDate = pastDate;
}
public String getTrack() {
public BigInteger getTrack() {
return track;
}
public void setTrack(String track) {
public void setTrack(BigInteger track) {
this.track = track;
}
public String getIo() {
public BigInteger getIo() {
return io;
}
public void setIo(String io) {
public void setIo(BigInteger io) {
this.io = io;
}
public BigInteger getTrackLimit() {
return trackLimit;
}
public void setTrackLimit(BigInteger trackLimit) {
this.trackLimit = trackLimit;
}
public BigInteger getIoLimit() {
return ioLimit;
}
public void setIoLimit(BigInteger ioLimit) {
this.ioLimit = ioLimit;
}
public Integer getBackTime() {
return backTime;
}
......@@ -144,4 +172,35 @@ public class Account4Web {
public void setTrackStatus(Boolean trackStatus) {
this.trackStatus = trackStatus;
}
public Boolean getRemStatus() {
return remStatus;
}
public void setRemStatus(Boolean remStatus) {
this.remStatus = remStatus;
}
@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 +
'}';
}
}
......@@ -15,6 +15,7 @@ public class Reminder {
private String email;
private String platform;
private Boolean remindStatus;
private String closeDesc;
private Long user;
private String userName;
private Date modifyTime;
......@@ -93,4 +94,28 @@ public class Reminder {
public void setUserName(String userName) {
this.userName = userName;
}
public String getCloseDesc() {
return closeDesc;
}
public void setCloseDesc(String closeDesc) {
this.closeDesc = closeDesc;
}
@Override
public String toString() {
return "Reminder{" +
"id=" + id +
", accountId=" + accountId +
", email='" + email + '\'' +
", platform='" + platform + '\'' +
", remindStatus=" + remindStatus +
", closeDesc='" + closeDesc + '\'' +
", user=" + user +
", userName='" + userName + '\'' +
", modifyTime=" + modifyTime +
", ds='" + ds + '\'' +
'}';
}
}
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.math.BigInteger;
import java.util.Date;
@Entity
public class TrackAccount4Web {
private Long id;
private Long accountId;
private String email;
private String company;
private Date createDate;
private String status;
private String packageType;
private String pastDate;
private BigInteger track;
private BigInteger io;
private BigInteger trackLimit;
private BigInteger ioLimit;
private Integer backTime;
private String user;
private String tell;
private Long money;
private Boolean ioStatus;
private Boolean trackStatus;
private Boolean remStatus;
@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 getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getPackageType() {
return packageType;
}
public void setPackageType(String packageType) {
this.packageType = packageType;
}
public String getPastDate() {
return pastDate;
}
public void setPastDate(String pastDate) {
this.pastDate = pastDate;
}
public BigInteger getTrack() {
return track;
}
public void setTrack(BigInteger track) {
this.track = track;
}
public BigInteger getIo() {
return io;
}
public void setIo(BigInteger io) {
this.io = io;
}
public BigInteger getTrackLimit() {
return trackLimit;
}
public void setTrackLimit(BigInteger trackLimit) {
this.trackLimit = trackLimit;
}
public BigInteger getIoLimit() {
return ioLimit;
}
public void setIoLimit(BigInteger ioLimit) {
this.ioLimit = ioLimit;
}
public Integer getBackTime() {
return backTime;
}
public void setBackTime(Integer backTime) {
this.backTime = backTime;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getTell() {
return tell;
}
public void setTell(String tell) {
this.tell = tell;
}
public Long getMoney() {
return money;
}
public void setMoney(Long money) {
this.money = money;
}
public Boolean getIoStatus() {
return ioStatus;
}
public void setIoStatus(Boolean ioStatus) {
this.ioStatus = ioStatus;
}
public Boolean getTrackStatus() {
return trackStatus;
}
public void setTrackStatus(Boolean trackStatus) {
this.trackStatus = trackStatus;
}
public Boolean getRemStatus() {
return remStatus;
}
public void setRemStatus(Boolean remStatus) {
this.remStatus = remStatus;
}
@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 +
'}';
}
}
package common.repository;
import common.model.Auth;
import common.model.BackVisit;
import common.model.KeyValue;
import common.model.Reminder;
import common.model.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
......@@ -17,6 +14,9 @@ public interface BackVisitRepository extends JpaRepository<BackVisit, Long> {
@Query(value = "SELECT * from back_visit", nativeQuery = true)
List<BackVisit> findAllCount();
@Query(value = "select * from back_visit where account_id = ?1 and ds > ?2 and ds < ?3 and platform = ?4", nativeQuery = true)
@Query(value = "select * from back_visit where account_id = ?1 and ds >= ?2 and ds <= ?3 and platform = ?4", nativeQuery = true)
List<BackVisit> findAll(Long accountId, String startDate, String endDate, String platform);
@Query(value = "select * from back_visit where platform = ?1", nativeQuery = true)
List<BackVisit> findAllByPlatform(String platform);
}
......@@ -12,6 +12,9 @@ import java.util.List;
@Transactional
public interface PaymentRepository extends JpaRepository<Payment, Long> {
@Query(value = "select * from payment where account_id = ?1 and ds > ?2 and ds < ?3 and platform = ?4", nativeQuery = true)
@Query(value = "select * from payment where account_id = ?1 and ds >= ?2 and ds <= ?3 and platform = ?4", nativeQuery = true)
List<Payment> findAll(Long accountId, String startDate, String endDate, String platform);
@Query(value = "select * from payment where platform = ?1", nativeQuery = true)
List<Payment> findAllByPlatform(String platform);
}
......@@ -12,6 +12,9 @@ import java.util.List;
@Transactional
public interface ReminderRepository extends JpaRepository<Reminder, Long> {
@Query(value = "select * from reminder where account_id = ?1 and ds > ?2 and ds < ?3 and platform = ?4", nativeQuery = true)
@Query(value = "select * from reminder where account_id = ?1 and ds >= ?2 and ds <= ?3 and platform = ?4", nativeQuery = true)
List<Reminder> findAll(Long accountId, String startDate, String endDate, String platform);
@Query(value = "SELECT * from reminder where id in (select max(id) from reminder where platform = ?1 group by account_id )", nativeQuery = true)
List<Reminder> findAllDistinct(String platform);
}
package common.repository;
import common.model.Account4Web;
import common.model.TrackAccount4Web;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import javax.sound.midi.Track;
import java.util.List;
@Transactional
public interface TrackAccount4WebRepository extends JpaRepository<TrackAccount4Web, Long> {
@Query(value = "SELECT * from account4web where email in ?1", nativeQuery = true)
List<Account4Web> findByEmails(List<String> emails);
}
......@@ -16,7 +16,7 @@ import util.ResultModel;
* Created by mxq on 2017/12/21.
*/
@Controller
@RequestMapping("marketing/accountmng/tkio")
@RequestMapping("tkio/marketing/accountmng")
public class TkioAccountController {
@Autowired
......
......@@ -13,7 +13,7 @@ public interface AppRepository extends JpaRepository<App, Long> {
@Query(value = "select * from app where account in (select id from account where parent = ?1 or id = ?1) and del_flag is not true", nativeQuery = true)
List<App> listAppByRootAccount(Long account);
@Query(value = "select count(*) from app where account in ?1 and create_time > ?2 and create_time < ?3", nativeQuery = true)
@Query(value = "select count(*) from app where account in ?1 and create_time >= ?2 and create_time <= ?3", nativeQuery = true)
BigInteger countByAccount(List<Long> accountId, String startDate, String endDate);
@Query(value = "select appkey from app where account in ?1", nativeQuery = true)
......
......@@ -88,6 +88,13 @@ public class TkioAccountServiceImpl implements TkioAccountService {
}
}
}
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());
}
}
if(ValidateUtil.isValid(account4WebList)){
Map<String, Integer> backTimeMap = getBackTime();
Map<String, Long> payMap = getPayment();
......@@ -102,6 +109,11 @@ public class TkioAccountServiceImpl implements TkioAccountService {
} else{
aw.setMoney(0L);
}
if(reMap.containsKey(aw.getAccountId())){
aw.setRemStatus(reMap.get(aw.getAccountId()));
} else{
aw.setRemStatus(true);
}
result.add(aw);
}
}
......@@ -132,6 +144,7 @@ public class TkioAccountServiceImpl implements TkioAccountService {
public Payment pay(User user, Payment resource) {
resource.setUser(user.getId());
resource.setPayDate(new Date());
resource.setPlatform("tkio");
resource.setDs(DateUtil.getBeforeDays(0));
return paymentRepository.save(resource);
}
......@@ -140,6 +153,7 @@ public class TkioAccountServiceImpl implements TkioAccountService {
public BackVisit visit(User user, BackVisit resource) {
resource.setUser(user.getId());
resource.setVisitDate(new Date());
resource.setPlatform("tkio");
resource.setDs(DateUtil.getBeforeDays(0));
return backVisitRepository.save(resource);
}
......@@ -274,7 +288,7 @@ public class TkioAccountServiceImpl implements TkioAccountService {
public Map<String, Integer> getBackTime(){
Map<String, Integer> map = new HashMap<>();
List<BackVisit> all = backVisitRepository.findAll();
List<BackVisit> all = backVisitRepository.findAllByPlatform("tkio");
if (ValidateUtil.isValid(all)){
for(BackVisit bv : all){
if(map.containsKey(bv.getEmail())){
......@@ -289,7 +303,7 @@ public class TkioAccountServiceImpl implements TkioAccountService {
public Map<String, Long> getPayment(){
Map<String, Long> map = new HashMap<>();
List<Payment> all = paymentRepository.findAll();
List<Payment> all = paymentRepository.findAllByPlatform("tkio");
if (ValidateUtil.isValid(all)){
for(Payment pa : all){
if(map.containsKey(pa.getEmail())){
......
......@@ -49,21 +49,24 @@ public class AccountTask {
for(Account ac : accountValidList){
AccountRestrict4Web restrict4Web = accountFlowRestrictService.findRestrictByAccount(ac.getId());
Account4Web account4Web = new Account4Web();
account4Web.setAccountId(ac.getId());
account4Web.setEmail(ac.getEmail());
account4Web.setCompany(ac.getCompany());
account4Web.setCreateDate(ac.getCreateTime());
account4Web.setCreateDate(ac.getPubDate());
account4Web.setStatus(null == restrict4Web.getIOFlowNotified() ? "已激活" : (restrict4Web.getIOFlowNotified() ? "已激活" : "流量用尽"));
account4Web.setPackageType(restrict4Web.getPackageName());
account4Web.setPastDate(ac.getPastDate());
if (ac.getPricelevel().equals(7L) || ac.getPricelevel().equals(8L) || ac.getPricelevel().equals(5L)){
account4Web.setIo(restrict4Web.getThisMonthIOFlow().toString());
account4Web.setTrack(restrict4Web.getTrackTotalFlow().toString());
if (ac.getPricelevel().equals(7L) || ac.getPricelevel().equals(8L) || ac.getPricelevel().equals(5L) || ac.getPricelevel().equals(6L)){
account4Web.setIo(restrict4Web.getThisMonthIOFlow());
account4Web.setTrack(restrict4Web.getTrackTotalFlow());
}else{
account4Web.setIo(restrict4Web.getThisMonthIOFlow() + "/" + restrict4Web.getIOLimit());
account4Web.setTrack(restrict4Web.getTrackTotalFlow() + "/" + restrict4Web.getTrackLimit());
}
account4Web.setIo(restrict4Web.getThisMonthIOFlow());
account4Web.setTrack(restrict4Web.getTrackTotalFlow());
account4Web.setIoLimit(restrict4Web.getIOLimit());
account4Web.setTrackLimit(restrict4Web.getTrackLimit());
account4Web.setIoStatus(restrict4Web.getAllowBehavior());
account4Web.setTrackStatus(restrict4Web.getTrackFlowNotified());
}
account4Web.setUser(ac.getName());
account4Web.setTell(ac.getPhone());
list.add(account4Web);
......@@ -79,14 +82,13 @@ public class AccountTask {
if(ValidateUtil.isValid(pastAccountList)){
for(Account ac : pastAccountList){
Account4Web account4Web = new Account4Web();
account4Web.setAccountId(ac.getId());
account4Web.setEmail(ac.getEmail());
account4Web.setCompany(ac.getCompany());
account4Web.setCreateDate(ac.getCreateTime());
account4Web.setCreateDate(ac.getPubDate());
account4Web.setStatus("已过期");
account4Web.setPackageType(map.get(ac.getPricelevel()));
account4Web.setPastDate(ac.getPastDate());
account4Web.setIo("----");
account4Web.setTrack("----");
account4Web.setIoStatus(false);
account4Web.setTrackStatus(false);
account4Web.setUser(ac.getName());
......
package track.controller;
import common.model.BackVisit;
import common.model.Payment;
import common.model.Reminder;
import common.model.User;
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("track/marketing/accountmng")
public class TrackAccountController {
@Autowired
TkioAccountService tkioAccountService;
//客户列表
@RequestMapping(value = "/findAll", method = RequestMethod.GET)
@ResponseBody
public ResultModel find(@CurrentAccount User loginAccount) {
return ResultModel.OK(tkioAccountService.findAll(loginAccount));
}
//关闭到期提醒
@RequestMapping(value = "/forbiden", method = RequestMethod.PUT)
@ResponseBody
public ResultModel forbiden(@CurrentAccount User loginAccount, @RequestBody Reminder resource) {
return ResultModel.OK(tkioAccountService.forbiden(loginAccount, resource));
}
//开启到期提醒
@RequestMapping(value = "/enable", method = RequestMethod.PUT)
@ResponseBody
public ResultModel enable(@CurrentAccount User loginAccount, @RequestBody Reminder resource) {
return ResultModel.OK(tkioAccountService.enable(loginAccount, resource));
}
//缴费
@RequestMapping(value = "/pay", method = RequestMethod.PUT)
@ResponseBody
public ResultModel pay(@CurrentAccount User loginAccount, @RequestBody Payment resource) {
return ResultModel.OK(tkioAccountService.pay(loginAccount, resource));
}
//回访
@RequestMapping(value = "/visit", method = RequestMethod.PUT)
@ResponseBody
public ResultModel visit(@CurrentAccount User loginAccount, @RequestBody BackVisit resource) {
return ResultModel.OK( tkioAccountService.visit(loginAccount, resource));
}
//功能使用查询
@RequestMapping(value = "/find/function/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel updateName(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findFunTimes(accountId,startDate,endDate));
}
//功能使用查询
@RequestMapping(value = "/find/pv/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel pv(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findPv(accountId,startDate,endDate));
}
//到期提醒查询
@RequestMapping(value = "/find/reminder/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findRed(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findRed(accountId,startDate,endDate));
}
//回访查询
@RequestMapping(value = "/find/visit/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findVisit(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findVisit(accountId,startDate,endDate));
}
//缴费查询
@RequestMapping(value = "/find/pay/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findPay(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findPay(accountId,startDate,endDate));
}
}
package track.model;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Entity
public class Account {
private Long id;
private String email;
private String password;
private String company;
private String name;
private String phone;
private String qq;
private boolean isSuperUser;
private boolean isActive=true;
private Long parent = (long) 0;
private Date pubDate = new Date();
private String isSpecialAccount;
private int status;
private Integer type; //帐户类型: SA(1)
private Long roleid;
private List<String> authPermissions;
private List<Map<String, String>> ChannelPermissions;
private List<Map<String, String>> campaignPermissions;
private String pastDate;
private String remark;
@Transient
public List<String> getAuthPermissions() {
return authPermissions;
}
public void setAuthPermissions(List<String> authPermissions) {
this.authPermissions = authPermissions;
}
@Transient
public List<Map<String, String>> getCampaignPermissions() {
return campaignPermissions;
}
public void setCampaignPermissions(List<Map<String, String>> campaignPermissions) {
this.campaignPermissions = campaignPermissions;
}
@Transient
public List<Map<String, String>> getChannelPermissions() {
return ChannelPermissions;
}
public void setChannelPermissions(
List<Map<String, String>> channelPermissions) {
ChannelPermissions = channelPermissions;
}
public Account() {
super();
}
public Account(String email, String password, String company, String name,
String phone, String qq, boolean isSuperUser, boolean isActive) {
super();
this.email = email;
this.password = password;
this.company = company;
this.name = name;
this.phone = phone;
this.qq = qq;
this.isSuperUser = isSuperUser;
this.isActive = isActive;
}
public String getCompany() {
return company;
}
public String getEmail() {
return email;
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public boolean getIsSuperUser() {
return isSuperUser;
}
public String getName() {
return name;
}
public String getPassword() {
return password;
}
public String getPhone() {
return phone;
}
public Date getPubDate() {
return pubDate;
}
public String getQq() {
return qq;
}
public boolean isActive() {
return isActive;
}
public void setActive(boolean isActive) {
this.isActive = isActive;
}
public void setCompany(String company) {
this.company = company;
}
public void setEmail(String email) {
this.email = email;
}
public void setId(Long id) {
this.id = id;
}
public void setIsSuperUser(boolean isSuperUser) {
this.isSuperUser = isSuperUser;
}
public void setName(String name) {
this.name = name;
}
public void setPassword(String password) {
this.password = password;
}
public void setPhone(String phone) {
this.phone = phone;
}
public void setPubDate(Date pubDate) {
this.pubDate = pubDate;
}
public void setQq(String qq) {
this.qq = qq;
}
public void setSuperUser(boolean isSuperUser) {
this.isSuperUser = isSuperUser;
}
public Long getParent() {
return parent;
}
public void setParent(Long parent) {
this.parent = parent;
}
public String getIsSpecialAccount() {
return isSpecialAccount;
}
public void setIsSpecialAccount(String isSpecialAccount) {
this.isSpecialAccount = isSpecialAccount;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Long getRoleid() {
return roleid;
}
public void setRoleid(Long roleid) {
this.roleid = roleid;
}
public String getPastDate() {
return pastDate;
}
public void setPastDate(String pastDate) {
this.pastDate = pastDate;
}
@Column(length=28)
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
@Override
public String toString() {
return "Account{" +
"authPermissions=" + authPermissions +
", campaignPermissions=" + campaignPermissions +
", ChannelPermissions=" + ChannelPermissions +
", company='" + company + '\'' +
", email='" + email + '\'' +
", id=" + id +
", isActive=" + isActive +
", isSpecialAccount='" + isSpecialAccount + '\'' +
", isSuperUser=" + isSuperUser +
", name='" + name + '\'' +
", parent=" + parent +
", password='" + password + '\'' +
", pastDate='" + pastDate + '\'' +
", phone='" + phone + '\'' +
", pubDate=" + pubDate +
", qq='" + qq + '\'' +
", remark='" + remark + '\'' +
", roleid=" + roleid +
", status=" + status +
", type=" + type +
'}';
}
}
package track.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Entity
public class App {
private Long id;
@NotNull
private String name;
private String platform;
private String appGenre;
private String gameGenre;
private String appkey;
private String url;
private Long account;
private boolean sync;
private boolean isActive;
private Long origiApp;
private String bundleid;
private String token;
private String installtoken;
private boolean regedbutton;
private Date pubDate = new Date();
public App() {
super();
}
public App(String name, String platform, String appGenre, String gameGenre) {
this.name = name;
this.platform = platform;
this.appGenre = appGenre;
this.gameGenre = gameGenre;
}
public App(String name, String platform, String appGenre, String gameGenre,
Long account) {
this.name = name;
this.platform = platform;
this.appGenre = appGenre;
this.gameGenre = gameGenre;
this.account = account;
}
public boolean isActive() {
return isActive;
}
public void setActive(boolean isActive) {
this.isActive = isActive;
}
public Long getAccount() {
return account;
}
public String getAppGenre() {
return appGenre;
}
public String getAppkey() {
return appkey;
}
public String getGameGenre() {
return gameGenre;
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public String getName() {
return name;
}
public String getPlatform() {
return platform;
}
public Date getPubDate() {
return pubDate;
}
public String getUrl() {
return url;
}
public boolean isSync() {
return sync;
}
public void setAccount(Long account) {
this.account = account;
}
public void setAppGenre(String appGenre) {
this.appGenre = appGenre;
}
public void setAppkey(String appkey) {
this.appkey = appkey;
}
public void setGameGenre(String gameGenre) {
this.gameGenre = gameGenre;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public void setPubDate(Date pubDate) {
this.pubDate = pubDate;
}
public void setSync(boolean sync) {
this.sync = sync;
}
public void setUrl(String url) {
this.url = url;
}
public Long getOrigiApp() {
return origiApp;
}
public void setOrigiApp(Long origiApp) {
this.origiApp = origiApp;
}
public String getBundleid() {
return bundleid;
}
public void setBundleid(String bundleid) {
this.bundleid = bundleid;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public boolean isRegedbutton() {
return regedbutton;
}
public void setRegedbutton(boolean regedbutton) {
this.regedbutton = regedbutton;
}
public String getInstalltoken() {
return installtoken;
}
public void setInstalltoken(String installtoken) {
this.installtoken = installtoken;
}
@Override
public String toString() {
return "App{" +
"id=" + id +
", name='" + name + '\'' +
", platform='" + platform + '\'' +
", appGenre='" + appGenre + '\'' +
", gameGenre='" + gameGenre + '\'' +
", appkey='" + appkey + '\'' +
", url='" + url + '\'' +
", account=" + account +
", sync=" + sync +
", isActive=" + isActive +
", origiApp=" + origiApp +
", bundleid='" + bundleid + '\'' +
", token='" + token + '\'' +
", installtoken='" + installtoken + '\'' +
", regedbutton=" + regedbutton +
", pubDate=" + pubDate +
'}';
}
}
package track.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;
@Entity
public class Campaign {
private Long id;
private Long app;
private String os;
private String type;
private Long channel;
private String channelid;
private String name;
private String campaignGroup;
private String callback;
private String url;
private String surl;
private Date pubDate = new Date();
private Integer addParam;
private String campaignpackid;
private String specialKeys;
//创建账号,或子账号或母账号
private Long account;
private String advertiserid;
private String bundleid;
private boolean awssuccess = false;
public Campaign() {
super();
}
public String getChannelid() {
return channelid;
}
public void setChannelid(String channelid) {
this.channelid = channelid;
}
public Long getApp() {
return app;
}
public String getCallback() {
return callback;
}
/* public Long getCampaignGroup() {
return campaignGroup;
}*/
public Long getChannel() {
return channel;
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public String getName() {
return name;
}
public Date getPubDate() {
return pubDate;
}
public String getSurl() {
return surl;
}
public String getType() {
return type;
}
public String getUrl() {
return url;
}
public void setApp(Long app) {
this.app = app;
}
public void setCallback(String callback) {
this.callback = callback;
}
/* public void setCampaignGroup(Long campaignGroup) {
this.campaignGroup = campaignGroup;
}*/
public void setChannel(Long channel) {
this.channel = channel;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setPubDate(Date pubDate) {
this.pubDate = pubDate;
}
public void setSurl(String surl) {
this.surl = surl;
}
public void setType(String type) {
this.type = type;
}
public void setUrl(String url) {
this.url = url;
}
public String getSpecialKeys() {
return specialKeys;
}
public void setSpecialKeys(String specialKeys) {
this.specialKeys = specialKeys;
}
public Integer getAddParam() {
return addParam;
}
public void setAddParam(Integer addParam) {
this.addParam = addParam;
}
public Long getAccount() {
return account;
}
public void setAccount(Long account) {
this.account = account;
}
public String getOs() {
return os;
}
public void setOs(String os) {
this.os = os;
}
public boolean isAwssuccess() {
return awssuccess;
}
public void setAwssuccess(boolean awssuccess) {
this.awssuccess = awssuccess;
}
public String getCampaignpackid() {
return campaignpackid;
}
public void setCampaignpackid(String campaignpackid) {
this.campaignpackid = campaignpackid;
}
public String getAdvertiserid() {
return advertiserid;
}
public void setAdvertiserid(String advertiserid) {
this.advertiserid = advertiserid;
}
public String getBundleid() {
return bundleid;
}
public void setBundleid(String bundleid) {
this.bundleid = bundleid;
}
public String getCampaignGroup() {
return campaignGroup;
}
public void setCampaignGroup(String campaignGroup) {
this.campaignGroup = campaignGroup;
}
@Override
public String toString() {
return "Campaign{" +
"id=" + id +
", app=" + app +
", os='" + os + '\'' +
", type='" + type + '\'' +
", channel=" + channel +
", channelid='" + channelid + '\'' +
", name='" + name + '\'' +
", campaignGroup=" + campaignGroup +
", callback='" + callback + '\'' +
", url='" + url + '\'' +
", surl='" + surl + '\'' +
", pubDate=" + pubDate +
", addParam=" + addParam +
", campaignpackid='" + campaignpackid + '\'' +
", specialKeys='" + specialKeys + '\'' +
", account=" + account +
", advertiserid='" + advertiserid + '\'' +
", bundleid='" + bundleid + '\'' +
", awssuccess=" + awssuccess +
'}';
}
}
package track.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;
@Entity
public class Channel {
private Long id;
private String name;
private Long account;
private String category;
private String url;
private Date pubDate=new Date();
private String type;
private String uniqueName;
private String firstchar;
private boolean ishttps=false;
private String os;
private String trackurl = "http://uri6.com/$surl";
private String androidparam;
private String iosparam;
private boolean istrackurlspecial=false;
private Integer orderindex;
private boolean isintegrate = false;
//0 正常渠道 1 被合并渠道,不再显示
private Boolean hidden = false;
public Channel() {
super();
}
public Channel(String name, String category, String url) {
super();
this.name = name;
this.category = category;
this.url = url;
}
public Long getAccount() {
return account;
}
public String getCategory() {
return category;
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public String getName() {
return name;
}
public Date getPubDate() {
return pubDate;
}
public String getUrl() {
return url;
}
public void setAccount(Long account) {
this.account = account;
}
public void setCategory(String category) {
this.category = category;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setPubDate(Date pubDate) {
this.pubDate = pubDate;
}
public void setUrl(String url) {
this.url = url;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUniqueName() {
return uniqueName;
}
public void setUniqueName(String uniqueName) {
this.uniqueName = uniqueName;
}
public String getFirstchar() {
return firstchar;
}
public void setFirstchar(String firstchar) {
this.firstchar = firstchar;
}
public boolean isIshttps() {
return ishttps;
}
public void setIshttps(boolean ishttps) {
this.ishttps = ishttps;
}
public String getOs() {
return os;
}
public void setOs(String os) {
this.os = os;
}
public String getTrackurl() {
return trackurl;
}
public void setTrackurl(String trackurl) {
this.trackurl = trackurl;
}
public String getAndroidparam() {
return androidparam;
}
public void setAndroidparam(String androidparam) {
this.androidparam = androidparam;
}
public String getIosparam() {
return iosparam;
}
public void setIosparam(String iosparam) {
this.iosparam = iosparam;
}
public boolean isIstrackurlspecial() {
return istrackurlspecial;
}
public void setIstrackurlspecial(boolean istrackurlspecial) {
this.istrackurlspecial = istrackurlspecial;
}
public boolean isIsintegrate() {
return isintegrate;
}
public Integer getOrderindex()
{
return orderindex;
}
public void setOrderindex(Integer orderindex)
{
this.orderindex = orderindex;
}
public void setIsintegrate(boolean isintegrate) {
this.isintegrate = isintegrate;
}
public Boolean getHidden() {
return hidden;
}
public void setHidden(Boolean hidden) {
this.hidden = hidden;
}
}
package track.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import track.model.Account;
import java.math.BigInteger;
import java.util.List;
@Transactional
public interface TrackAccountRepository extends JpaRepository<Account, Long> {
@Query(value = "select * from account c where is_super_user=true and past_date is not null", nativeQuery = true)
List<Account> findAllParent();
@Query(value = "select * from account c where parent = ?1", nativeQuery = true)
List<Account> findByParent(Long account);
@Query(value = "select count(*) from account where parent = ?1 and pub_date > ?2 and pub_date < ?3", nativeQuery = true)
BigInteger countByRootParent(Long accountId, String startDate, String endDate);
}
package track.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import track.model.Account;
import track.model.App;
import java.math.BigInteger;
import java.util.List;
public interface TrackAppRepository extends JpaRepository<App, Long> {
List<App> findByAccount(Long account);
@Query(value = "select count(*) from app where account in ?1 and pub_date >= ?2 and pub_date <= ?3", nativeQuery = true)
BigInteger countByAccount(List<Long> accountId, String startDate, String endDate);
@Query(value = "select * from app where account in ?1 ", nativeQuery = true)
List<App> findByAccount(List<Long> accountId);
}
package track.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import track.model.Campaign;
import java.math.BigInteger;
import java.util.List;
import java.util.Set;
public interface TrackCampaignRepository
extends JpaRepository<Campaign, Long>
{
@Query(value = "select count(*) from campaign where app in ?1 and pub_date >= ?2 and pub_date <= ?3", nativeQuery = true)
BigInteger countByAccount(List<Long> appids, String startDate, String endDate);
}
package track.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import track.model.Channel;
import java.math.BigInteger;
import java.util.List;
import java.util.Set;
public interface TrackChannelRepository extends JpaRepository<Channel, Long> {
List<Channel> findByAccount(Long account);
@Query(value = "select count(*) from channel where account in ?1 and pub_date > ?2 and pub_date < ?3", nativeQuery = true)
BigInteger countByAccount(List<Long> accountId, String startDate, String endDate);
}
package track.service;
import common.model.*;
import java.util.List;
import java.util.Map;
/**
* Created by mxq on 2017/12/27.
*/
public interface TrackAccountService {
List<TrackAccount4Web> findAll(User user);
//到期提醒关闭
Reminder forbiden(User user, Reminder resource);
//到期提醒开启
Reminder enable(User user, Reminder resource);
//缴费
Payment pay(User user, Payment resource);
//回访
BackVisit visit(User user, BackVisit resource);
//查询功能使用情况
Map<String, Integer> findFunTimes(Long account, String startDate, String endDate);
List<Reminder> findRed(Long account, String startDate, String endDate);
List<BackVisit> findVisit(Long account, String startDate, String endDate);
List<Payment> findPay(Long account, String startDate, String endDate);
}
package track.service.impl;
import common.model.*;
import common.repository.*;
import dic.RoleEnum;
import dic.RoleTypeEnum;
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 track.model.Account;
import track.model.App;
import track.repository.TrackAccountRepository;
import track.repository.TrackAppRepository;
import track.repository.TrackCampaignRepository;
import track.repository.TrackChannelRepository;
import track.service.TrackAccountService;
import util.Constant;
import util.DateUtil;
import util.HttpClientUtil;
import util.ValidateUtil;
import java.math.BigInteger;
import java.util.*;
/**
* Created by mxq on 2017/12/27.
*/
@Service
public class TrackAccountServiceImpl implements TrackAccountService{
@Autowired
TrackAccount4WebRepository trackAccount4WebRepository;
@Autowired
TrackAccountRepository accountRepository;
@Autowired
BackVisitRepository backVisitRepository;
@Autowired
PaymentRepository paymentRepository;
@Autowired
ReminderRepository reminderRepository;
@Autowired
TrackCampaignRepository campaignRepository;
@Autowired
TrackChannelRepository channelRepository;
@Autowired
TrackAppRepository appRepository;
@Autowired
UserRepository userRepository;
@Override
public List<TrackAccount4Web> findAll(User user) {
List<TrackAccount4Web> result = new ArrayList<>();
List<TrackAccount4Web> account4WebList = null;
if(user.getRole().equals(RoleEnum.MANAGER.getKey())){
account4WebList = trackAccount4WebRepository.findAll();
}
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());
}
}
if(ValidateUtil.isValid(account4WebList)){
Map<String, Integer> backTimeMap = getBackTime();
Map<String, Long> payMap = getPayment();
for(TrackAccount4Web 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);
}
if(reMap.containsKey(aw.getAccountId())){
aw.setRemStatus(reMap.get(aw.getAccountId()));
} else{
aw.setRemStatus(true);
}
result.add(aw);
}
}
return result;
}
@Override
public Reminder forbiden(User user, Reminder resource) {
resource.setUser(user.getId());
resource.setModifyTime(new Date());
resource.setPlatform("track");
resource.setRemindStatus(false);
resource.setDs(DateUtil.getBeforeDays(0));
return reminderRepository.save(resource);
}
@Override
public Reminder enable(User user, Reminder resource) {
resource.setUser(user.getId());
resource.setModifyTime(new Date());
resource.setPlatform("track");
resource.setRemindStatus(true);
resource.setDs(DateUtil.getBeforeDays(0));
return reminderRepository.save(resource);
}
@Override
public Payment pay(User user, Payment resource) {
resource.setUser(user.getId());
resource.setPayDate(new Date());
resource.setPlatform("track");
resource.setDs(DateUtil.getBeforeDays(0));
return paymentRepository.save(resource);
}
@Override
public BackVisit visit(User user, BackVisit resource) {
resource.setUser(user.getId());
resource.setVisitDate(new Date());
resource.setPlatform("track");
resource.setDs(DateUtil.getBeforeDays(0));
return backVisitRepository.save(resource);
}
@Override
public Map<String, Integer> findFunTimes(Long account, String startDate, String endDate) {
Map<String, Integer> result = new HashMap<>();
List<Account> accountList = accountRepository.findByParent(account);
List<Long> idList = new ArrayList<>();
for(Account ac : accountList){
idList.add(ac.getId());
}
List<App> appList = appRepository.findByAccount(idList);
List<Long> appidList = new ArrayList<>();
if(ValidateUtil.isValid(appList)){
for(App app : appList){
appidList.add(app.getId());
}
}
BigInteger numAccount = accountRepository.countByRootParent(account, startDate, endDate);
BigInteger numApp = appRepository.countByAccount(idList, startDate, endDate);
BigInteger numCampaign = campaignRepository.countByAccount(idList, startDate, endDate);
BigInteger numChannel = channelRepository.countByAccount(idList, startDate, endDate);
result.put("numAccount", numAccount.intValue());
result.put("numApp", numApp.intValue());
result.put("numCampaign", numCampaign.intValue());
result.put("numChannel", numChannel.intValue());
result.put("event_sum", null);
result.put("click_sum", null);
return result;
}
@Override
public List<Reminder> findRed(Long account, String startDate, String endDate) {
List<Reminder> 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<Reminder> list = reminderRepository.findAll(account, startDate, endDate, "track");
if (ValidateUtil.isValid(list)) {
for(Reminder re : list){
re.setUserName(userMap.get(re.getUser()));
result.add(re);
}
}
return result;
}
@Override
public List<BackVisit> findVisit(Long account, String startDate, String endDate) {
List<BackVisit> 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<BackVisit> list = backVisitRepository.findAll(account, startDate, endDate, "track");
if (ValidateUtil.isValid(list)) {
for(BackVisit re : list){
re.setUserName(userMap.get(re.getUser()));
result.add(re);
}
}
return result;
}
@Override
public List<Payment> findPay(Long account, String startDate, String endDate) {
List<Payment> 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);
}
}
return result;
}
public Map<String, Integer> getBackTime(){
Map<String, Integer> map = new HashMap<>();
List<BackVisit> all = backVisitRepository.findAllByPlatform("track");
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.findAllByPlatform("track");
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;
}
}
package track.task;
import common.model.Account4Web;
import common.model.TrackAccount4Web;
import common.repository.TrackAccount4WebRepository;
import org.jsoup.helper.DataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import track.model.Account;
import track.repository.TrackAccountRepository;
import util.DateUtil;
import util.ValidateUtil;
import java.util.ArrayList;
import java.util.List;
/**
* Created by mxq on 2017/12/25.
*/
public class AccountTask {
@Autowired
TrackAccountRepository trackAccountRepository;
@Autowired
TrackAccount4WebRepository trackAccount4WebRepository;
public void task(){
trackAccount4WebRepository.deleteAll();
List<TrackAccount4Web> list = new ArrayList<>();
List<Account> accountList = trackAccountRepository.findAllParent();
String today = DateUtil.getBeforeDays(0);
if(ValidateUtil.isValid(accountList)){
for(Account ac : accountList){
TrackAccount4Web account4Web = new TrackAccount4Web();
account4Web.setAccountId(ac.getId());
account4Web.setEmail(ac.getEmail());
account4Web.setCompany(ac.getCompany());
account4Web.setCreateDate(ac.getPubDate());
if(today.compareTo(ac.getPastDate()) > 0){
account4Web.setStatus("已过期");
}else{
account4Web.setStatus("已激活");
}
account4Web.setPastDate(ac.getPastDate());
account4Web.setUser(ac.getName());
account4Web.setTell(ac.getPhone());
list.add(account4Web);
}
}
if(ValidateUtil.isValid(list)){
trackAccount4WebRepository.save(list);
}
}
}
......@@ -14,6 +14,14 @@
<task:scheduled-tasks>
<!--//定时同步短链数据(每5分钟执行一次)-->
<task:scheduled ref="tkioAccountTask" method="task" cron="0 26 10 * * ?"/>
<task:scheduled ref="tkioAccountTask" method="task" cron="0 21 15 * * ?"/>
</task:scheduled-tasks>
<bean id="trackAccountTask" class="track.task.AccountTask"></bean>
<task:scheduled-tasks>
<!--//定时同步短链数据(每5分钟执行一次)-->
<task:scheduled ref="trackAccountTask" method="task" cron="0 32 16 * * ?"/>
</task:scheduled-tasks>
</beans>
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