Commit be830d66 by manxiaoqiang

Merge remote-tracking branch 'remotes/origin/feature_20180116_new'

* remotes/origin/feature_20180116_new: (41 commits) app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 app排序 ...
parents 424a97b7 af967d85
This source diff could not be displayed because it is too large. You can view the blob instead.
package common.controller;
import common.model.Menu;
import common.model.User;
import common.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import security.annotation.CurrentAccount;
import util.ResultModel;
import java.util.List;
/**
* Created by mxq on 17/12/21.
* 优先测试账号查询
*/
@Controller
@RequestMapping("saleauth")
public class SaleAuthController {
@Autowired
private MenuService menuService;
@RequestMapping(value = "find", method = RequestMethod.GET)
@ResponseBody
public ResultModel findAll(@CurrentAccount User loginAccount) {
List<Menu> menus = menuService.listAll();
return ResultModel.OK(menus);
}
}
......@@ -53,7 +53,7 @@ public class UserController {
public ResultModel create(@CurrentAccount User loginAccount, @RequestBody User resource, HttpServletRequest request) {
if(userService.validEmail(resource.getEmail())){
userService.create(loginAccount, resource);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), resource.getEmail(), "创建系统账号", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), resource.getEmail(), "创建系统账号", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(true);
}else{
......@@ -64,7 +64,7 @@ public class UserController {
@RequestMapping(value = "/update", method = RequestMethod.PUT)
@ResponseBody
public ResultModel update(@CurrentAccount User loginAccount, @RequestBody User resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), resource.getEmail(), "修改系统账号", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), resource.getEmail(), "修改系统账号", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(userService.update(loginAccount, resource));
}
......@@ -97,7 +97,7 @@ public class UserController {
@ResponseBody
public ResultModel delete(@CurrentAccount User loginAccount, @PathVariable Long id, HttpServletRequest request) {
User user = userService.delete(loginAccount, id);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "删除系统账号", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "删除系统账号", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(user);
}
......@@ -106,7 +106,7 @@ public class UserController {
@ResponseBody
public ResultModel enable(@CurrentAccount User loginAccount, @PathVariable Long id, HttpServletRequest request) {
User user = userService.enable(loginAccount, id);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "启用系统账号", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "启用系统账号", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(user);
}
......@@ -115,7 +115,7 @@ public class UserController {
@ResponseBody
public ResultModel forbiden(@CurrentAccount User loginAccount, @PathVariable Long id, HttpServletRequest request) {
User user = userService.forbiden(loginAccount, id);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "停用系统账号", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "停用系统账号", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(user);
}
......@@ -126,7 +126,7 @@ public class UserController {
User login = userRepository.login(name);
if(null == login){
User user = userService.updateName(loginAccount, name);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "修改系统账号名字", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "修改系统账号名字", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(true);
}else{
......@@ -141,7 +141,7 @@ public class UserController {
User login = userRepository.login(loginAccount.getEmail(), CipherUtil.generatePassword(oldpwd));
if(null != login){
User user = userService.updatePwd(loginAccount, pwd);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "修改系统账号密码", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "修改系统账号密码", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(true);
}else{
......@@ -153,7 +153,7 @@ public class UserController {
@RequestMapping(value = "/update/pwd", method = RequestMethod.PUT)
@ResponseBody
public ResultModel updatePwd(@RequestParam String email, @RequestParam String pwd, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(email, email, OperateObjectTypeEnum.INNERUSER.getKey(), email, "修改系统账号密码", request);
UserLogThread userlog = new UserLogThread(email, email, OperateObjectTypeEnum.INNERUSER.getKey(), email, "修改系统账号密码", request,null);
userlog.start();
return ResultModel.OK(userService.updatePwd(email, pwd));
}
......@@ -172,4 +172,13 @@ public class UserController {
public ResultModel validCode(@RequestParam String email, @RequestParam String code, @RequestParam String pwd) {
return ResultModel.OK(userService.validCode(email, code, pwd));
}
@RequestMapping(value = "/find/{role}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findByRole(@PathVariable Long role) {
return ResultModel.OK(userService.findbyRole(role));
}
}
package common.controller;
import common.model.User;
import common.model.UserLog;
import common.service.UserLogService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import security.annotation.CurrentAccount;
import util.ResultModel;
import java.util.List;
......@@ -24,7 +26,7 @@ public class UserLogController
///api/userlog/list?startDate=2017-12-26&endDate=2017-12-27
@RequestMapping(value = "list", method = RequestMethod.GET)
@ResponseBody
public ResultModel findByDS(@RequestParam String startDate, @RequestParam String endDate) {
return ResultModel.OK(userLogService.findUserLog(startDate, endDate));
public ResultModel findByDS(@CurrentAccount User user, @RequestParam String startDate, @RequestParam String endDate) {
return ResultModel.OK(userLogService.findUserLog(user,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;
}
}
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Date;
/**
* Created by mxq on 2018/1/16.
*/
@Entity
public class Contract {
private Long id;
private String product;
private String myBodyName;
private String myBodyCode;
private String customerBody;
private String email;
private String contractCode;
private String contractType;
private String startDate;
private String endDate;
private Long priceLevel;
private Long money;
private Double rebate;
private Long sale;
private String platform;
private String status;
private String saleName;
private String priceLevelName;
private Long payMoney;
private Long invoice;
private String createName;
private Long modifyAccount;
private Long createAccount;
private Date modifyTime;
private Date createTime;
private String ds;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getProduct() {
return product;
}
public void setProduct(String product) {
this.product = product;
}
public String getMyBodyName() {
return myBodyName;
}
public void setMyBodyName(String myBodyName) {
this.myBodyName = myBodyName;
}
public String getMyBodyCode() {
return myBodyCode;
}
public void setMyBodyCode(String myBodyCode) {
this.myBodyCode = myBodyCode;
}
public String getCustomerBody() {
return customerBody;
}
public void setCustomerBody(String customerBody) {
this.customerBody = customerBody;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getContractCode() {
return contractCode;
}
public void setContractCode(String contractCode) {
this.contractCode = contractCode;
}
public String getContractType() {
return contractType;
}
public void setContractType(String contractType) {
this.contractType = contractType;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String stratDate) {
this.startDate = stratDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public Long getPriceLevel() {
return priceLevel;
}
public void setPriceLevel(Long priceLevel) {
this.priceLevel = priceLevel;
}
public Long getMoney() {
return money;
}
public void setMoney(Long money) {
this.money = money;
}
public Double getRebate() {
return rebate;
}
public void setRebate(Double rebate) {
this.rebate = rebate;
}
public Long getSale() {
return sale;
}
public void setSale(Long sale) {
this.sale = sale;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public Long getModifyAccount() {
return modifyAccount;
}
public void setModifyAccount(Long modifyAccount) {
this.modifyAccount = modifyAccount;
}
public Long getCreateAccount() {
return createAccount;
}
public void setCreateAccount(Long createAccount) {
this.createAccount = createAccount;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDs() {
return ds;
}
public void setDs(String ds) {
this.ds = ds;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Long getPayMoney() {
return payMoney;
}
public void setPayMoney(Long payMoney) {
this.payMoney = payMoney;
}
public Long getInvoice() {
return invoice;
}
public void setInvoice(Long invoice) {
this.invoice = invoice;
}
@Transient
public String getSaleName() {
return saleName;
}
public void setSaleName(String saleName) {
this.saleName = saleName;
}
@Transient
public String getPriceLevelName() {
return priceLevelName;
}
public void setPriceLevelName(String priceLevelName) {
this.priceLevelName = priceLevelName;
}
public String getCreateName() {
return createName;
}
public void setCreateName(String createName) {
this.createName = createName;
}
@Override
public String toString() {
return "Contract{" +
"id=" + id +
", product='" + product + '\'' +
", myBodyName='" + myBodyName + '\'' +
", myBodyCode='" + myBodyCode + '\'' +
", customerBody='" + customerBody + '\'' +
", email='" + email + '\'' +
", contractCode='" + contractCode + '\'' +
", contractType='" + contractType + '\'' +
", startDate='" + startDate + '\'' +
", endDate='" + endDate + '\'' +
", priceLevel=" + priceLevel +
", money=" + money +
", rebate=" + rebate +
", sale=" + sale +
", platform='" + platform + '\'' +
", status='" + status + '\'' +
", modifyAccount=" + modifyAccount +
", createAccount=" + createAccount +
", modifyTime=" + modifyTime +
", createTime=" + createTime +
", ds='" + ds + '\'' +
'}';
}
}
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* Created by mxq on 2018/1/17.
*/
@Entity
public class ContractBody {
private Long id;
private String name;
private String code;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
/**
* Created by mxq on 2018/1/18.
*/
@Entity
public class ContractChange {
private Long id;
private String contractCode;
private String email;
private String company;
private String ds;
private String type;
private String content;
private Long level;
private Long money;
private Long user;
private String createName;
private String platform;
private String levelName;
private Long modifyAccount;
private Long createAccount;
private Date modifyTime;
private Date createTime;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDs() {
return ds;
}
public void setDs(String ds) {
this.ds = ds;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Long getUser() {
return user;
}
public void setUser(Long user) {
this.user = user;
}
public String getContractCode() {
return contractCode;
}
public void setContractCode(String contractCode) {
this.contractCode = contractCode;
}
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 Long getModifyAccount() {
return modifyAccount;
}
public void setModifyAccount(Long modifyAccount) {
this.modifyAccount = modifyAccount;
}
public Long getCreateAccount() {
return createAccount;
}
public void setCreateAccount(Long createAccount) {
this.createAccount = createAccount;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Long getLevel() {
return level;
}
public void setLevel(Long level) {
this.level = level;
}
public Long getMoney() {
return money;
}
public void setMoney(Long money) {
this.money = money;
}
public String getCreateName() {
return createName;
}
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;
}
}
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;
/**
* Created by mxq on 2018/1/18.
*/
@Entity
public class ContractMoney {
private Long id;
private String contractCode;
private String email;
private String company;
private String ds;
private String type;
private Long money;
private Long user;
private String createName;
private String platform;
private Long modifyAccount;
private Long createAccount;
private Date modifyTime;
private Date createTime;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getContractCode() {
return contractCode;
}
public void setContractCode(String contractCode) {
this.contractCode = contractCode;
}
public String getDs() {
return ds;
}
public void setDs(String ds) {
this.ds = ds;
}
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 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 Long getModifyAccount() {
return modifyAccount;
}
public void setModifyAccount(Long modifyAccount) {
this.modifyAccount = modifyAccount;
}
public Long getCreateAccount() {
return createAccount;
}
public void setCreateAccount(Long createAccount) {
this.createAccount = createAccount;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreateName() {
return createName;
}
public void setCreateName(String createName) {
this.createName = createName;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
}
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.criteria.CriteriaBuilder;
/**
* Created by mxq on 2018/1/17.
*/
@Entity
public class PriceLevelMoney {
private Long id;
private Integer pricelevel;
private String product;
private Long money;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getPricelevel() {
return pricelevel;
}
public void setPricelevel(Integer pricelevel) {
this.pricelevel = pricelevel;
}
public String getProduct() {
return product;
}
public void setProduct(String product) {
this.product = product;
}
public Long getMoney() {
return money;
}
public void setMoney(Long money) {
this.money = money;
}
}
......@@ -17,6 +17,9 @@ public class Reminder {
private Boolean remindStatus;
private String closeDesc;
private Long user;
private Long level1;
private Long level2;
private Long level3;
private String userName;
private Date modifyTime;
private String ds;
......@@ -103,6 +106,30 @@ public class Reminder {
this.closeDesc = closeDesc;
}
public Long getLevel1() {
return level1;
}
public void setLevel1(Long level1) {
this.level1 = level1;
}
public Long getLevel2() {
return level2;
}
public void setLevel2(Long level2) {
this.level2 = level2;
}
public Long getLevel3() {
return level3;
}
public void setLevel3(Long level3) {
this.level3 = level3;
}
@Override
public String toString() {
return "Reminder{" +
......
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;
@Entity
public class ReminderLevel {
private Long id;
private Long parent;
private Long level;
private String name;
private String type;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getParent() {
return parent;
}
public void setParent(Long parent) {
this.parent = parent;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getLevel() {
return level;
}
public void setLevel(Long level) {
this.level = level;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* Created by mxq on 2018/1/16.
*/
@Entity
public class SaleAuth {
private Long id;
private String name;
private Integer roleLevel;
private Long parent;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getRoleLevel() {
return roleLevel;
}
public void setRoleLevel(Integer roleLevel) {
this.roleLevel = roleLevel;
}
public Long getParent() {
return parent;
}
public void setParent(Long parent) {
this.parent = parent;
}
public SaleAuth() {
}
public SaleAuth(Long id, String name, Integer roleLevel, Long parent) {
this.id = id;
this.name = name;
this.roleLevel = roleLevel;
this.parent = parent;
}
@Override
public String toString() {
return "SaleAuth{" +
"id=" + id +
", name='" + name + '\'' +
", roleLevel=" + roleLevel +
", parent=" + parent +
'}';
}
}
......@@ -27,6 +27,8 @@ public class TrackAccount4Web {
private Boolean ioStatus;
private Boolean trackStatus;
private Boolean remStatus;
private String contractStatus;
private Integer contractTime;
@Id
@GeneratedValue
......@@ -182,6 +184,22 @@ public class TrackAccount4Web {
this.remStatus = remStatus;
}
public String getContractStatus() {
return contractStatus;
}
public void setContractStatus(String contractStatus) {
this.contractStatus = contractStatus;
}
public Integer getContractTime() {
return contractTime;
}
public void setContractTime(Integer contractTime) {
this.contractTime = contractTime;
}
@Override
public String toString() {
return "Account4Web{" +
......
......@@ -20,6 +20,7 @@ public class User {
private String roleTypeName;
private String auth;
private Boolean status;
private Long parent;
private Long modifyAccount;
private Long createAccount;
......@@ -152,6 +153,14 @@ public class User {
this.roleName = roleName;
}
public Long getParent() {
return parent;
}
public void setParent(Long parent) {
this.parent = parent;
}
@Override
public String toString() {
return "User{" +
......@@ -160,8 +169,12 @@ public class User {
", password='" + password + '\'' +
", name='" + name + '\'' +
", role=" + role +
", roleName='" + roleName + '\'' +
", roleType=" + roleType +
", roleTypeName='" + roleTypeName + '\'' +
", auth='" + auth + '\'' +
", status=" + status +
", parent=" + parent +
", modifyAccount=" + modifyAccount +
", createAccount=" + createAccount +
", modifyTime=" + modifyTime +
......
......@@ -21,6 +21,9 @@ public class UserLog
private String operateObject;
private String operateType;
private String location;
private String OldObject;
private String newObject;
private Long role;
@Id
@GeneratedValue
......@@ -114,18 +117,44 @@ public class UserLog
this.location = location;
}
public String getOldObject() {
return OldObject;
}
public void setOldObject(String oldObject) {
OldObject = oldObject;
}
public String getNewObject() {
return newObject;
}
public void setNewObject(String newObject) {
this.newObject = newObject;
}
public Long getRole() {
return role;
}
public void setRole(Long role) {
this.role = role;
}
@Override
public String toString()
{
public String toString() {
return "UserLog{" +
"id=" + id +
", operateTime=" + operateTime +
", operateTime='" + operateTime + '\'' +
", operaAccount='" + operaAccount + '\'' +
", accountName='" + accountName + '\'' +
", ip='" + ip + '\'' +
", operateObjectType='" + operateObjectType + '\'' +
", operateObject='" + operateObject + '\'' +
", operateType='" + operateType + '\'' +
", location='" + location + '\'' +
", OldObject='" + OldObject + '\'' +
", newObject='" + newObject + '\'' +
'}';
}
}
......@@ -21,4 +21,7 @@ public interface Account4WebRepository extends JpaRepository<Account4Web, Long>
@Query(value = "SELECT * from account4web where status = '已过期' or status = '流量用尽'", nativeQuery = true)
List<Account4Web> findPast();
@Query(value = "SELECT * from account4web where email = ?1", nativeQuery = true)
Account4Web findByEmail(String email);
}
......@@ -2,6 +2,7 @@ package common.repository;
import common.model.Auth;
import common.model.Menu;
import common.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
......@@ -12,4 +13,7 @@ import java.util.List;
public interface AuthRepository extends JpaRepository<Auth, Long> {
Auth findByUser(Long user);
@Query(value="SELECT * from `auth` where user in ?1",nativeQuery=true)
List<Auth> findAllByUsers(List<Long> ids);
}
......@@ -19,4 +19,7 @@ public interface BackVisitRepository extends JpaRepository<BackVisit, Long> {
@Query(value = "select * from back_visit where platform = ?1", nativeQuery = true)
List<BackVisit> findAllByPlatform(String platform);
@Query(value = "select * from back_visit where platform = ?1 and email = ?2", nativeQuery = true)
List<BackVisit> findAllByPlatformAndEmail(String platform, String email);
}
package common.repository;
import common.model.Contract;
import common.model.ContractBody;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface ContractBodyRepository extends JpaRepository<ContractBody, Long> {
}
package common.repository;
import common.model.Contract;
import common.model.ContractChange;
import common.model.ContractMoney;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigInteger;
import java.util.List;
@Transactional
public interface ContractChangeRepository extends JpaRepository<ContractChange, Long> {
@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);
}
package common.repository;
import common.model.Contract;
import common.model.ContractChange;
import common.model.ContractMoney;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Transactional
public interface ContractMoneyRepository extends JpaRepository<ContractMoney, Long> {
@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 and platform = ?3 order by ds desc",nativeQuery=true)
List<ContractMoney> findByDsAll(String startDate, String endDate, String platform);
@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);
@Query(value="select * from contract_money where email = ?1 and platform = ?2 and type = 'pay' order by ds desc",nativeQuery=true)
List<ContractMoney> findByEmail(String email, String platform);
}
package common.repository;
import common.model.Contract;
import common.model.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigInteger;
import java.util.List;
@Transactional
public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value="select count(*) from contract where ds = ?1",nativeQuery=true)
BigInteger countNumByDs(String ds);
@Query(value="select count(*) from contract where email = ?1 and platform = ?2",nativeQuery=true)
BigInteger countNumByEmail(String email, String platfrom);
@Query(value="select * from contract where ds >= ?1 and ds <= ?2 and platform = ?3 order by ds desc",nativeQuery=true)
List<Contract> findByDs(String startDate, String endDate, String platfrom);
@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);
@Query(value="SELECT * from contract where start_date = ?1 and status <> 'cancel'",nativeQuery=true)
List<Contract> findByStartDate(String startDate);
@Query(value="SELECT * from contract where end_date <= ?1 and (status <> 'end' or status <> 'cancel')",nativeQuery=true)
List<Contract> findByEndDate(String endDate);
}
package common.repository;
import common.model.Contract;
import common.model.PriceLevelMoney;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface PriceLevelMoneyRepository extends JpaRepository<PriceLevelMoney, Long> {
@Query(value="select * from price_level_money where product = ?1 and pricelevel = ?2",nativeQuery=true)
PriceLevelMoney getOne(String product, Integer level);
}
package common.repository;
import common.model.ReminderLevel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface ReminderLevelRepository extends JpaRepository<ReminderLevel, Long> {
}
package common.repository;
import common.model.Auth;
import common.model.SaleAuth;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface SaleAuthRepository extends JpaRepository<SaleAuth, Long> {
}
......@@ -13,6 +13,9 @@ import java.util.List;
public interface TrackAccount4WebRepository extends JpaRepository<TrackAccount4Web, Long> {
@Query(value = "SELECT * from account4web where email in ?1", nativeQuery = true)
List<Account4Web> findByEmails(List<String> emails);
List<TrackAccount4Web> findByEmails(List<String> emails);
@Query(value = "SELECT * from account4web where email = ?1", nativeQuery = true)
TrackAccount4Web findByEmail(String email);
}
......@@ -11,6 +11,6 @@ import java.util.List;
*/
public interface UserLogRepository extends JpaRepository<UserLog, Long>
{
@Query(value = "select * from user_log where substr(operate_time, 1, 10)>=?1 and substr(operate_time, 1, 10)<=?2", nativeQuery = true)
List<UserLog> findByOperateTime(String startDate, String endDate);
@Query(value = "select * from user_log where substr(operate_time, 1, 10)>=?1 and substr(operate_time, 1, 10)<=?2 and opera_account in ?3", nativeQuery = true)
List<UserLog> findByOperateTime(String startDate, String endDate, List<String> emails);
}
......@@ -23,4 +23,30 @@ public interface UserRepository extends JpaRepository<User, Long> {
@Query(value="select * from user where email = ?1 and del_flag is not true",nativeQuery=true)
User login(String email);
@Query(value="select * from user where del_flag is not true and (role = 2 or role = 3)",nativeQuery=true)
List<User> findSales();
@Query(value="SELECT * from `user` where del_flag is not true and role = ?1 ORDER BY role_type",nativeQuery=true)
List<User> findAllByRole(Long role);
@Query(value="SELECT * from `user` where role = ?1 ORDER BY role_type",nativeQuery=true)
List<User> findAllUserByRole(Long role);
@Query(value="SELECT * from `user` where del_flag is not true and parent = ?1",nativeQuery=true)
List<User> findAllByParent(Long id);
@Query(value="SELECT * from `user` where parent = ?1",nativeQuery=true)
List<User> findByParent(Long id);
@Query(value="SELECT * from `user` where del_flag is not true and id in ?1",nativeQuery=true)
List<User> findAllByIds(List<Long> ids);
@Query(value="SELECT * from `user` where id in ?1",nativeQuery=true)
List<User> findByIds(List<Long> ids);
@Query(value="SELECT * from `user` where del_flag is not true and parent in ?1",nativeQuery=true)
List<User> findAllByParents(List<Long> ids);
@Query(value="SELECT * from `user` where parent in ?1",nativeQuery=true)
List<User> findByParents(List<Long> ids);
}
package common.service;
import common.model.*;
import tkio.model.PackageType;
import java.util.List;
import java.util.Map;
/**
* Created by mxq on 2018/1/16.
*/
public interface ContractService {
Map<String, Object> checkAccount(String email, String platfrom);
List<ContractBody> findBody();
String getContractCode(String code);
List<PackageType> findSetmeal();
Double getRebat(String product, Integer level, Long money);
List<User> getSales();
Contract create(User loginUser, Contract resource);
Contract update(User loginUser, Contract resource);
List<Contract> findAll(String startDate, String endDate, String platfrom);
Contract findOne(String code);
ContractMoney pay(User loginUser, ContractMoney resource);
Contract change(User loginUser, ContractChange resource);
List<ContractMoney> findPay(String startDate, String endDate, String code);
List<ContractChange> findChange(String startDate, String endDate, String code);
Contract updatePay(User loginUser, ContractMoney resource);
List<ContractMoney> findPayAll(String startDate, String endDate, String platform);
}
package common.service;
/**
* Created by mxq on 2018/1/16.
*/
public interface SaleAuthService {
}
package common.service;
import common.model.User;
import common.model.UserLog;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -11,5 +12,5 @@ import java.util.List;
*/
public interface UserLogService
{
List<UserLog> findUserLog(String startDate, String endDate);
List<UserLog> findUserLog(User user, String startDate, String endDate);
}
......@@ -33,4 +33,10 @@ public interface UserService {
Boolean sendCode(String email);
Boolean validCode(String email, String code, String pwd);
List<User> findbyRole(Long role);
List<User> findSonsAlive(Long user);
List<User> findAllSons(Long user);
}
package common.service.impl;
import common.model.User;
import common.model.UserLog;
import common.repository.UserLogRepository;
import common.service.UserLogService;
import common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import util.StringUtil;
import util.ValidateUtil;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
......@@ -25,11 +28,22 @@ public class UserLogServiceImpl implements UserLogService
{
@Autowired UserLogRepository userLogRepository;
@Autowired
UserService userService;
@Override
public List<UserLog> findUserLog(String startDate, String endDate)
public List<UserLog> findUserLog(User user,String startDate, String endDate)
{
return userLogRepository.findByOperateTime(startDate, endDate);
List<User> allSons = userService.findAllSons(user.getId());
List<String> emailList = new ArrayList<>();
emailList.add(user.getEmail());
if(ValidateUtil.isValid(allSons)){
for(User u : allSons){
emailList.add(u.getEmail());
}
}
return userLogRepository.findByOperateTime(startDate, endDate, emailList);
}
}
......@@ -9,6 +9,8 @@ import common.repository.UserRepository;
import common.service.UserService;
import dic.RoleEnum;
import dic.RoleTypeEnum;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import office.service.BussinussManService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -101,7 +103,45 @@ public class UserServiceImpl implements UserService {
auth.setModifyAccount(login.getId());
auth.setAuth(resource.getAuth());
auth.setUser(save.getId());
authRepository.save(auth);
Auth authSave = authRepository.save(auth);
if(save.getRoleType().equals(RoleTypeEnum.COMMON.getKey())){
JSONArray rootArr = JSONArray.fromObject(authSave.getAuth());
List<String> authList = new ArrayList<>();
if(ValidateUtil.isValid(rootArr)){
for (int i = 0; i < rootArr.size(); i++) {
JSONObject obj = rootArr.getJSONObject(i);
authList.add(obj.getString("id"));
}
}
List<User> userList = findSonsAlive(save.getId());
if(ValidateUtil.isValid(userList)){
List<Long> ids = new ArrayList<>();
for(User u : userList){
ids.add(u.getId());
}
List<Auth> list = authRepository.findAllByUsers(ids);
if(ValidateUtil.isValid(list)){
List<Auth> authListSave = new ArrayList<>();
for(Auth a : list){
String authStr = a.getAuth();
JSONArray arrSave = new JSONArray();
JSONArray arr = JSONArray.fromObject(authStr);
if(ValidateUtil.isValid(arr)){
for (int i = 0; i < arr.size(); i++) {
JSONObject obj = arr.getJSONObject(i);
if(authList.contains(obj.getString("id"))){
arrSave.add(obj);
}
}
}
a.setAuth(arrSave.toString());
authListSave.add(a);
}
authRepository.save(authSave);
}
}
}
return save;
}
......@@ -120,6 +160,8 @@ public class UserServiceImpl implements UserService {
userList = userRepository.findList();
} else if(RoleTypeEnum.MANAGER.getKey().equals(login.getRoleType())){
userList = userRepository.findOneDepartment(login.getRole());
}else{
userList = findSonsAlive(login.getId());
}
if(ValidateUtil.isValid(userList)){
for(User u : userList){
......@@ -226,4 +268,85 @@ public class UserServiceImpl implements UserService {
}
return false;
}
@Override
public List<User> findbyRole(Long role) {
List<Auth> authList = authRepository.findAll();
Map<Long, String> map = new HashMap<>();
if(ValidateUtil.isValid(authList)){
for(Auth a : authList){
map.put(a.getUser(), a.getAuth());
}
}
List<User> result = new ArrayList<>();
List<User> userList = userRepository.findAllByRole(role);
if(ValidateUtil.isValid(userList)){
for(User u : userList){
if(map.containsKey(u.getId())){
u.setAuth(map.get(u.getId()));
}
result.add(u);
}
}
return result;
}
@Override
public List<User> findSonsAlive(Long user) {
List<User> result = new ArrayList<>();
User one = userRepository.findOne(user);
if(one.getRole().equals(RoleEnum.MANAGER.getKey())){
List<User> list = userRepository.findList();
if(ValidateUtil.isValid(list)){
result.addAll(list);
}
} else if(one.getRoleType().equals(RoleTypeEnum.MANAGER.getKey())){
List<User> list = userRepository.findAllByRole(one.getRole());
if(ValidateUtil.isValid(list)){
result.addAll(list);
}
} else{
List<User> list = userRepository.findAllByParent(user);
while(ValidateUtil.isValid(list)){
result.addAll(list);
List<Long> ids = new ArrayList<>();
for(User u : list){
ids.add(u.getId());
}
list = userRepository.findAllByParents(ids);
}
}
return result;
}
@Override
public List<User> findAllSons(Long user) {
List<User> result = new ArrayList<>();
User one = userRepository.findOne(user);
if(one.getRole().equals(RoleEnum.MANAGER.getKey())){
List<User> list = userRepository.findAll();
if(ValidateUtil.isValid(list)){
result.addAll(list);
}
} else if(one.getRoleType().equals(RoleTypeEnum.MANAGER.getKey())){
List<User> list = userRepository.findAllUserByRole(one.getRole());
if(ValidateUtil.isValid(list)){
result.addAll(list);
}
} else{
List<User> list = userRepository.findByParent(user);
while(ValidateUtil.isValid(list)){
result.addAll(list);
List<Long> ids = new ArrayList<>();
for(User u : list){
ids.add(u.getId());
}
list = userRepository.findByParents(ids);
}
}
return result;
}
}
package common.task;
import common.context.AppUtils;
import common.model.Contract;
import common.model.User;
import common.model.UserLog;
import common.repository.UserLogRepository;
import common.repository.UserRepository;
import dic.RoleTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import tkio.model.PackageType;
import tkio.repository.PackageTypeRepository;
import util.DateUtil;
import util.IPAddrUtil;
import util.MailUtils;
import util.ValidateUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* Created by zxy on 2017/12/15.
*/
public class ContractSendEmailThread
extends Thread
{
protected Logger logger = LoggerFactory.getLogger(ContractSendEmailThread.class);
private PackageTypeRepository packageTypeRepository = AppUtils.getApplicationContext().getBean(PackageTypeRepository.class);
private UserRepository userRepository = AppUtils.getApplicationContext().getBean(UserRepository.class);
private Contract contract;
public ContractSendEmailThread(Contract contract) {
this.contract = contract;
}
@Override
public void run()
{
Map<Long, String> packageMap = getPackageMap();
StringBuffer sb = new StringBuffer();
sb.append("账号 :" + this.contract.getEmail() + " 签约了," + " 套餐 :" +
packageMap.get(this.contract.getPriceLevel()) + ",开始时间 " + this.contract.getStartDate()
+ ",结束时间 " + this.contract.getEndDate());
User user = userRepository.findOne(this.contract.getSale());
List<String> list = new ArrayList<>();
list.add(user.getEmail());
if(!user.getRoleType().equals(RoleTypeEnum.MANAGER.getKey())){
List<User> userList = userRepository.findOneDepartment(user.getRole());
for(User u : userList){
if (u.getRoleType().equals(RoleTypeEnum.MANAGER.getKey())){
list.add(u.getEmail());
}
}
}
try {
MailUtils.sendSimpleEmail("新建合同", sb.toString(),list);
} catch (Exception e) {
e.printStackTrace();
}
}
public Map<Long, String> getPackageMap(){
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());
}
}
return typeMap;
}
}
package common.task;
import com.google.common.base.Splitter;
import common.model.AppCategory;
import common.model.AppInfo;
import common.model.Contract;
import common.repository.AppCategoryRepository;
import common.repository.AppInfoRepository;
import common.repository.CityRepository;
import common.repository.ContractRepository;
import dmp.model.OtPkgDevStats;
import dmp.repository.OtPkgDevStatsRepository;
import dmp.repository.TagCrawlerAppsWandoujiaRepository;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.anarres.lzo.LzoAlgorithm;
import org.anarres.lzo.LzoDecompressor;
import org.anarres.lzo.LzoInputStream;
import org.anarres.lzo.LzoLibrary;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import util.*;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by zxy on 2017/12/26.
*/
public class ContractTask
{
private static Logger logger = LoggerFactory.getLogger(ContractTask.class);
@Autowired
ContractRepository contractRepository;
public void task(){
List<Contract> contractList = contractRepository.findByStartDate(DateUtil.getBeforeDays(0));
if(ValidateUtil.isValid(contractList)){
List<Contract> list = new ArrayList<>();
for(Contract c : contractList){
c.setStatus("executing");
list.add(c);
}
contractRepository.save(list);
}
List<Contract> contractList2 = contractRepository.findByEndDate(DateUtil.getBeforeDays(0));
if(ValidateUtil.isValid(contractList2)){
List<Contract> list = new ArrayList<>();
for(Contract c : contractList2){
c.setStatus("end");
list.add(c);
}
contractRepository.save(list);
}
}
}
......@@ -158,13 +158,15 @@ public class ReportCallable
if (!StringUtil.isEmpty(sortString)) {
sortString = getSortMap().get(sortString);
resultOrderSql = String.format(orderSql, sortString, isASC!=null && isASC==0?"DESC":"ASC");
} else{//
resultOrderSql = String.format(orderSql, "num", "DESC");
}
String resultLimitSql = String.format(limitSql, pageNum*pageSize, pageSize);
result = String.format(sql + " %s %s", app_sb.length()>0?" where ":"",
app_sb.length()>0?app_sb.substring(5):"",
data_sb.length()>0?" where ":"",
data_sb.length()>0?data_sb.substring(5):"",
StringUtil.isEmpty(sortString)?"":resultOrderSql,
resultOrderSql,
resultLimitSql);
}
......
......@@ -242,7 +242,7 @@ public class SyncAppDataTask
opds.setDs(array[2].toString());
resultList.add(opds);
if (resultList.size() >= 2000) {
System.out.println(resultList);
//System.out.println(resultList);
otPkgDevStatsRepository.save(resultList);
resultList = new ArrayList<>();
}
......@@ -250,7 +250,7 @@ public class SyncAppDataTask
AppInfo appInfo = generateAppInfo(array, ry_pkgNameList, map, newCategorys, citys);
appResultList.add(appInfo);
if (appResultList.size() >= 2000) {
System.out.println(appResultList);
//System.out.println(appResultList);
appInfoRepository.save(appResultList);
appResultList = new ArrayList<>();
}
......@@ -263,7 +263,7 @@ public class SyncAppDataTask
appInfoRepository.save(appResultList);
}
System.out.println(newCategorys);
//System.out.println(newCategorys);
if (newCategorys.size() > 0) {
appCategoryRepository.save(newCategorys);
}
......
package security.interceptor;
import com.fasterxml.jackson.databind.ObjectMapper;
import common.model.User;
import common.repository.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import security.RedisLoginStatusManager;
import security.TokenManager;
import util.Constant;
import util.ResultModel;
import util.ResultStatus;
import util.StringUtil;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.util.Enumeration;
public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
......@@ -48,7 +55,8 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
}
//从header中得到token
String token = request.getHeader(httpHeaderName);
token = StringUtil.isEmpty(token) ? getCookieToken(request.getCookies(), "TOKEN") : token;
//token = StringUtil.isEmpty(token) ? getCookieToken(request.getCookies(), "TOKEN") : token;
if(null != token){
token = token.substring(httpHeaderPrefix.length());
//验证token
String key = manager.getKeyFromToken(token);
......@@ -56,7 +64,6 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
boolean loginStatus = redisLoginStatusManager.getLoginStatusByKey(token);
if (!StringUtil.isEmpty(key)) {
String id = getCookieToken(request.getCookies(), "TOKEN");
User one = userRepository.findOne(Long.parseLong(key));
User sessionAct = (User) request.getSession().getAttribute(Constant.CURRENT_ACCOUNT);
......@@ -65,6 +72,19 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
}
return true;
}
}
try {
//如果验证token失败,并且方法注明了Authorization,返回401错误
response.setStatus(HttpStatus.UNAUTHORIZED.value());
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(response.getOutputStream()));
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
String json = new ObjectMapper().writeValueAsString(ResultModel.ERROR(ResultStatus.USERNAME_LOGIN_EXPIRE));
writer.write(json);
writer.close();
} catch (Exception e){
e.printStackTrace();
}
return false;
}
......
package tkio.controller;
import common.model.BackVisit;
import common.model.Payment;
import common.model.Reminder;
import common.model.User;
import common.model.*;
import common.service.UserService;
import dic.OperateObjectTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -12,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
import security.annotation.CurrentAccount;
import tkio.service.TkioAccountService;
import util.ResultModel;
import util.ResultStatus;
import util.UserLogThread;
import javax.servlet.http.HttpServletRequest;
......@@ -33,12 +31,26 @@ public class TkioAccountController {
return ResultModel.OK(tkioAccountService.findAll(loginAccount));
}
@RequestMapping(value = "/findone", method = RequestMethod.GET)
@ResponseBody
public ResultModel findOne(@CurrentAccount User loginAccount, @RequestParam String email) {
Account4Web account4Web = tkioAccountService.findOne(email);
if(null == account4Web){
return ResultModel.ERROR(ResultStatus.USER_EMPTY);
}
return ResultModel.OK(account4Web);
}
@RequestMapping(value = "/find/reminderlevel", method = RequestMethod.GET)
@ResponseBody
public ResultModel findReminderlevel() {
return ResultModel.OK(tkioAccountService.findReminderlevel());
}
//关闭到期提醒
@RequestMapping(value = "/forbiden", method = RequestMethod.PUT)
@ResponseBody
public ResultModel forbiden(@CurrentAccount User loginAccount, @RequestBody Reminder resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "关闭到期提醒", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "关闭异常状态跟进", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.forbiden(loginAccount, resource));
}
......@@ -47,7 +59,7 @@ public class TkioAccountController {
@RequestMapping(value = "/enable", method = RequestMethod.PUT)
@ResponseBody
public ResultModel enable(@CurrentAccount User loginAccount, @RequestBody Reminder resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "开启到期提醒", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "开启异常状态跟进", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.enable(loginAccount, resource));
}
......@@ -56,7 +68,7 @@ public class TkioAccountController {
@RequestMapping(value = "/pay", method = RequestMethod.PUT)
@ResponseBody
public ResultModel pay(@CurrentAccount User loginAccount, @RequestBody Payment resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "缴费", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "缴费", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.pay(loginAccount, resource));
}
......@@ -65,7 +77,7 @@ public class TkioAccountController {
@RequestMapping(value = "/visit", method = RequestMethod.PUT)
@ResponseBody
public ResultModel visit(@CurrentAccount User loginAccount, @RequestBody BackVisit resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "回访", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "回访", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK( tkioAccountService.visit(loginAccount, resource));
}
......@@ -109,9 +121,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(accountId,startDate,endDate));
return ResultModel.OK(tkioAccountService.findPay(email,startDate,endDate));
}
//套餐变更查询
@RequestMapping(value = "/find/contract/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findChange(@CurrentAccount User loginAccount, @RequestParam String email, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findContract(email));
}
//合同查询
@RequestMapping(value = "/find/change/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findContract(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate, @RequestParam String email, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findContractChange(email,startDate,endDate));
}
}
......@@ -22,7 +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)
@Query(value = "SELECT * from account where is_super_user is true and bussinessman in ?1", nativeQuery = true)
List<Account> findBussnissMan(List<Integer> bussinussIds);
@Query(value = "select * from account where root_parent = ?1", nativeQuery = true)
......@@ -30,4 +30,7 @@ public interface AccountRepository extends JpaRepository<Account, Long> {
@Query(value = "select count(*) from account where root_parent = ?1 and create_time > ?2 and create_time < ?3", nativeQuery = true)
BigInteger countByRootParent(Long accountId, String startDate, String endDate);
@Query(value = "select * from account where email = ?1", nativeQuery = true)
Account findByEmail(String email);
}
......@@ -17,4 +17,7 @@ public interface SalesManLeaderRepository extends JpaRepository<SalesManLeader,
@Query(value = "select * from sales_man_leader where email = ?1", nativeQuery = true)
SalesManLeader findOneByEmail(String email);
@Query(value = "select * from sales_man_leader where email in ?1", nativeQuery = true)
List<SalesManLeader> findAllByEmails(List<String> emails);
}
package tkio.service;
import common.model.Contract;
import tkio.model.Account;
/**
* Created by mxq on 2018/1/23.
*/
public interface AccountService {
Account update(Contract contract);
Account forbiden(Contract contract);
}
......@@ -11,6 +11,9 @@ import java.util.Map;
public interface TkioAccountService {
List<Account4Web> findAll(User user);
Account4Web findOne(String email);
List<ReminderLevel> findReminderlevel();
//到期提醒关闭
Reminder forbiden(User user, Reminder resource);
......@@ -33,6 +36,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);
}
package tkio.service.impl;
import common.model.Contract;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import security.annotation.Authorization;
import tkio.model.Account;
import tkio.repository.AccountRepository;
import tkio.service.AccountService;
import util.DateUtil;
import util.ValidateUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* Created by mxq on 2018/1/23.
*/
@Service
public class AccountServiceImpl implements AccountService {
@Autowired
AccountRepository accountRepository;
@Override
public Account update(Contract contract) {
Account account = accountRepository.findByEmail(contract.getEmail());
String today = DateUtil.getBeforeDays(0);
Date pubDate = DateUtil.getDate(contract.getStartDate());
account.setPastDate(contract.getEndDate());
account.setNewContract(true);
account.setPubDate(pubDate);
account.setModifyPricelevelTime(contract.getStartDate());
account.setModifyTime(new Date());
account.setModifyAccount(0l);
account.setPricelevel(contract.getPriceLevel());
if(!(contract.getEndDate().compareTo(today) < 0)){
account.setStatus(1);
}
if(contract.getProduct().contains("io")){
account.setAllowBehavior(true);
}else{
account.setAllowBehavior(false);
}
Account save = accountRepository.save(account);
//修改子账号
List<Account> accountList = accountRepository.findByRootParent(account.getId());
if (ValidateUtil.isValid(accountList)){
List<Account> list = new ArrayList<>();
for(Account ac : accountList){
ac.setPastDate(contract.getEndDate());
ac.setPubDate(pubDate);
ac.setModifyPricelevelTime(contract.getStartDate());
ac.setPricelevel(contract.getPriceLevel());
ac.setAllowBehavior(save.getAllowBehavior());
list.add(ac);
}
accountRepository.save(list);
}
return save;
}
@Override
public Account forbiden(Contract contract) {
Account account = accountRepository.findByEmail(contract.getEmail());
account.setStatus(0);
return accountRepository.save(account);
}
}
package track.controller;
import common.model.BackVisit;
import common.model.Payment;
import common.model.Reminder;
import common.model.User;
import common.model.*;
import dic.OperateObjectTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -12,6 +9,7 @@ import security.annotation.CurrentAccount;
import tkio.service.TkioAccountService;
import track.service.TrackAccountService;
import util.ResultModel;
import util.ResultStatus;
import util.UserLogThread;
import javax.servlet.http.HttpServletRequest;
......@@ -32,12 +30,21 @@ public class TrackAccountController {
public ResultModel find(@CurrentAccount User loginAccount) {
return ResultModel.OK(tkioAccountService.findAll(loginAccount));
}
@RequestMapping(value = "/findone", method = RequestMethod.GET)
@ResponseBody
public ResultModel findOne(@CurrentAccount User loginAccount, @RequestParam String email) {
TrackAccount4Web account4Web = tkioAccountService.findOne(email);
if(null == account4Web){
return ResultModel.ERROR(ResultStatus.USER_EMPTY);
}
return ResultModel.OK(account4Web);
}
//关闭到期提醒
@RequestMapping(value = "/forbiden", method = RequestMethod.PUT)
@ResponseBody
public ResultModel forbiden(@CurrentAccount User loginAccount, @RequestBody Reminder resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "关闭到期提醒", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "关闭到期提醒", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.forbiden(loginAccount, resource));
}
......@@ -46,7 +53,7 @@ public class TrackAccountController {
@RequestMapping(value = "/enable", method = RequestMethod.PUT)
@ResponseBody
public ResultModel enable(@CurrentAccount User loginAccount, @RequestBody Reminder resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "开启到期提醒", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "开启到期提醒", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.enable(loginAccount, resource));
}
......@@ -55,7 +62,7 @@ public class TrackAccountController {
@RequestMapping(value = "/pay", method = RequestMethod.PUT)
@ResponseBody
public ResultModel pay(@CurrentAccount User loginAccount, @RequestBody Payment resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "缴费", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "缴费", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.pay(loginAccount, resource));
}
......@@ -64,7 +71,7 @@ public class TrackAccountController {
@RequestMapping(value = "/visit", method = RequestMethod.PUT)
@ResponseBody
public ResultModel visit(@CurrentAccount User loginAccount, @RequestBody BackVisit resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "回访", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "回访", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK( tkioAccountService.visit(loginAccount, resource));
}
......@@ -100,9 +107,26 @@ public class TrackAccountController {
@RequestMapping(value = "/find/pay/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findPay(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate, @PathVariable Long accountId) {
@RequestParam String endDate, @RequestParam String email, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findPay(email,startDate,endDate));
}
//套餐变更查询
@RequestMapping(value = "/find/contract/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findChange(@CurrentAccount User loginAccount, @RequestParam String email, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findContract(email));
}
//合同查询
@RequestMapping(value = "/find/change/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel findContract(@CurrentAccount User loginAccount, @RequestParam String startDate,
@RequestParam String endDate, @RequestParam String email, @PathVariable Long accountId) {
return ResultModel.OK(tkioAccountService.findPay(accountId,startDate,endDate));
return ResultModel.OK(tkioAccountService.findContractChange(email,startDate,endDate));
}
}
package track.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* Created by mxq on 2018/1/29.
*/
@Entity
public class MeasuresTrackNew {
private Long id;
private String ds;
private Double clickNum;
private String appid;
private Integer eventNum;
private Integer blackInstallNum;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDs() {
return ds;
}
public void setDs(String ds) {
this.ds = ds;
}
public Double getClickNum() {
return clickNum;
}
public void setClickNum(Double clickNum) {
this.clickNum = clickNum;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public Integer getEventNum() {
return eventNum;
}
public void setEventNum(Integer eventNum) {
this.eventNum = eventNum;
}
public Integer getBlackInstallNum() {
return blackInstallNum;
}
public void setBlackInstallNum(Integer blackInstallNum) {
this.blackInstallNum = blackInstallNum;
}
}
package track.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import track.model.App;
import track.model.MeasuresTrackNew;
import java.math.BigInteger;
import java.util.List;
public interface MeasureRepository extends JpaRepository<MeasuresTrackNew, Long> {
@Query(value = "select sum(click_num) from measures_track_new where appid in ?1 and ds <= ?2 and ds >= ?3", nativeQuery = true)
Double findByApp(List<String> appid, String endDate, String startDate);
}
package track.service;
import tkio.model.AccountRestrict4Web;
import track.model.Account;
import java.math.BigInteger;
/**
* Created by song on 2017/10/19.
*/
public interface TrackAccountFlowRestrictService {
BigInteger findRestrictByAccount(Account accountId);
}
......@@ -11,6 +11,8 @@ import java.util.Map;
public interface TrackAccountService {
List<TrackAccount4Web> findAll(User user);
TrackAccount4Web findOne(String email);
//到期提醒关闭
Reminder forbiden(User user, Reminder resource);
......@@ -30,5 +32,10 @@ public interface TrackAccountService {
List<BackVisit> findVisit(Long account, String startDate, String endDate);
List<Payment> findPay(Long account, String startDate, String endDate);
List<ContractMoney> findPay(String email, String startDate, String endDate);
List<Contract> findContract(String email);
List<ContractChange> findContractChange(String email, String startDate, String endDate);
}
package track.service.impl;
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 org.springframework.util.StringUtils;
import tkio.model.AccountRestrict4Web;
import track.model.Account;
import track.model.App;
import track.repository.MeasureRepository;
import track.repository.TrackAppRepository;
import track.service.TrackAccountFlowRestrictService;
import util.Constant;
import util.DateUtil;
import util.HttpClientUtil;
import util.ValidateUtil;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by song on 2017/10/19.
*/
@Service
public class TrackAccountFlowRestrictServiceImpl implements TrackAccountFlowRestrictService {
@Autowired
TrackAppRepository trackAppRepository;
@Autowired
MeasureRepository measureRepository;
@Override
public BigInteger findRestrictByAccount(Account account) {
BigInteger re = new BigInteger("0");
List<App> apps = trackAppRepository.findByAccount(account.getId());
StringBuffer appsStr = new StringBuffer();
if(ValidateUtil.isValid(apps)){
List<String> appids = new ArrayList<>();
for (App app : apps) {
appids.add(app.getAppkey());
}
String startDate = DateUtil.format(account.getPubDate());
String endDate = DateUtil.getBeforeDays(0);
Double click = measureRepository.findByApp(appids, endDate, startDate);
return null == click ? re : new BigInteger(click.intValue() + "");
}
return re;
}
}
......@@ -4,11 +4,14 @@ import common.model.*;
import common.repository.*;
import dic.RoleEnum;
import dic.RoleTypeEnum;
import org.apache.commons.collections4.list.TreeList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tkio.model.PackageType;
import tkio.repository.PackageTypeRepository;
import track.model.Account;
import track.model.App;
import track.repository.TrackAccountRepository;
......@@ -49,6 +52,14 @@ public class TrackAccountServiceImpl implements TrackAccountService{
@Autowired
UserRepository userRepository;
@Autowired
ContractMoneyRepository contractMoneyRepository;
@Autowired
ContractRepository contractRepository;
@Autowired
ContractChangeRepository contractChangeRepository;
@Autowired
PackageTypeRepository packageTypeRepository;
@Override
public List<TrackAccount4Web> findAll(User user) {
......@@ -66,7 +77,7 @@ public class TrackAccountServiceImpl implements TrackAccountService{
}
if(ValidateUtil.isValid(account4WebList)){
Map<String, Integer> backTimeMap = getBackTime();
Map<String, Long> payMap = getPayment();
Map<String, List<Contract>> payMap = getPay();
for(TrackAccount4Web aw : account4WebList){
if(backTimeMap.containsKey(aw.getEmail())){
aw.setBackTime(backTimeMap.get(aw.getEmail()));
......@@ -74,8 +85,13 @@ public class TrackAccountServiceImpl implements TrackAccountService{
aw.setBackTime(0);
}
if(payMap.containsKey(aw.getEmail())){
aw.setMoney(payMap.get(aw.getEmail()));
List<Contract> contractList = payMap.get(aw.getEmail());
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractList.get(contractList.size() - 1 ).getStatus());
aw.setContractTime(contractList.size());
} else{
aw.setContractTime(0);
aw.setContractStatus("empty");
aw.setMoney(0L);
}
if(reMap.containsKey(aw.getAccountId())){
......@@ -90,6 +106,43 @@ public class TrackAccountServiceImpl implements TrackAccountService{
}
@Override
public TrackAccount4Web findOne(String email) {
List<Reminder> reminderList = reminderRepository.findAllDistinct("track");
Map<Long, Boolean> reMap = new HashMap<>();
if(ValidateUtil.isValid(reminderList)){
for(Reminder re : reminderList){
reMap.put(re.getAccountId(), re.getRemindStatus());
}
}
TrackAccount4Web aw = trackAccount4WebRepository.findByEmail(email);
if(null == aw){
return null;
}
List<BackVisit> backVisitList = backVisitRepository.findAllByPlatformAndEmail("track", email);
if(ValidateUtil.isValid(backVisitList)){
aw.setBackTime(backVisitList.size());
} else{
aw.setBackTime(0);
}
List<Contract> contractList = contractRepository.findByPlatformAndEmail("track", email);
if(ValidateUtil.isValid(contractList)){
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractList.get(contractList.size() - 1 ).getStatus());
aw.setContractTime(contractList.size());
} else{
aw.setContractTime(0);
aw.setContractStatus("empty");
aw.setMoney(0L);
}
if(reMap.containsKey(aw.getAccountId())){
aw.setRemStatus(reMap.get(aw.getAccountId()));
} else{
aw.setRemStatus(true);
}
return aw;
}
@Override
public Reminder forbiden(User user, Reminder resource) {
resource.setUser(user.getId());
resource.setModifyTime(new Date());
......@@ -196,19 +249,75 @@ public class TrackAccountServiceImpl implements TrackAccountService{
return result;
}
@Override
public List<Payment> findPay(Long account, String startDate, String endDate) {
List<Payment> result = new ArrayList<>();
public List<ContractMoney> findPay(String email, String startDate, String endDate) {
List<ContractMoney> result = new ArrayList<>();
List<User> userList = userRepository.findAll();
Map<Long, String> userMap = new HashMap<>();
for(User u : userList){
userMap.put(u.getId(), u.getName());
}
List<Payment> list = paymentRepository.findAll(account, startDate, endDate, "track");
if (ValidateUtil.isValid(list)) {
for(Payment re : list){
re.setUserName(userMap.get(re.getUser()));
result.add(re);
List<ContractMoney> list = contractMoneyRepository.findByDs(startDate, endDate, email,"track");
if(ValidateUtil.isValid(list)){
for(ContractMoney cm : list){
Long user = null == cm.getModifyAccount() ? cm.getUser() : cm.getModifyAccount();
cm.setCreateName(userMap.containsKey(user) ? userMap.get(user) : "");
result.add(cm);
}
}
return result;
}
@Override
public List<Contract> findContract(String email) {
List<Contract> result = new ArrayList<>();
List<User> userList = userRepository.findAll();
Map<Long, String> userMap = new HashMap<>();
for(User u : userList){
userMap.put(u.getId(), u.getName());
}
List<PackageType> typeList = packageTypeRepository.findAll();
Map<Long, String> typeMap = new HashMap<>();
if(ValidateUtil.isValid(typeList)){
for(PackageType s: typeList){
typeMap.put(s.getId(), s.getPackageName());
}
}
List<Contract> contractList = contractRepository.findByPlatformAndEmail("track", email);
if(ValidateUtil.isValid(contractList)){
for(Contract cm : contractList){
cm.setSaleName(userMap.containsKey(cm.getSale()) ? userMap.get(cm.getSale()) : "");
cm.setPriceLevelName(typeMap.containsKey(cm.getPriceLevel()) ? typeMap.get(cm.getPriceLevel()) : "");
result.add(cm);
}
}
return result;
}
@Override
public List<ContractChange> findContractChange(String email, String startDate, String endDate) {
List<ContractChange> result = new ArrayList<>();
List<User> userList = userRepository.findAll();
Map<Long, String> userMap = new HashMap<>();
for(User u : userList){
userMap.put(u.getId(), u.getName());
}
List<PackageType> typeList = packageTypeRepository.findAll();
Map<Long, String> typeMap = new HashMap<>();
if(ValidateUtil.isValid(typeList)){
for(PackageType s: typeList){
typeMap.put(s.getId(), s.getPackageName());
}
}
List<ContractChange> contractChangeList = contractChangeRepository.findByPlatformAndEmail("track", email, startDate, endDate);
if(ValidateUtil.isValid(contractChangeList)){
for(ContractChange cm : contractChangeList){
Long user = null == cm.getModifyAccount() ? cm.getUser() : cm.getModifyAccount();
cm.setCreateName(userMap.containsKey(user) ? userMap.get(user) : "");
cm.setLevelName(typeMap.containsKey(cm.getLevel()) ? typeMap.get(cm.getLevel()) : "");
result.add(cm);
}
}
return result;
......@@ -230,15 +339,19 @@ public class TrackAccountServiceImpl implements TrackAccountService{
return map;
}
public Map<String, Long> getPayment(){
Map<String, Long> map = new HashMap<>();
List<Payment> all = paymentRepository.findAllByPlatform("track");
if (ValidateUtil.isValid(all)){
for(Payment pa : all){
public Map<String, List<Contract>> getPay(){
Map<String, List<Contract>> map = new HashMap<>();
List<Contract> contractList = contractRepository.findByPlatform("track");
if (ValidateUtil.isValid(contractList)){
for(Contract pa : contractList){
if(map.containsKey(pa.getEmail())){
map.put(pa.getEmail(), map.get(pa.getEmail()) + pa.getMoney());
List<Contract> list = map.get(pa.getEmail());
list.add(pa);
map.put(pa.getEmail(), list);
} else{
map.put(pa.getEmail(), pa.getMoney());
List<Contract> list = new TreeList<>();
list.add(pa);
map.put(pa.getEmail(), list);
}
}
}
......
......@@ -8,6 +8,7 @@ import org.jsoup.helper.DataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import track.model.Account;
import track.repository.TrackAccountRepository;
import track.service.TrackAccountFlowRestrictService;
import util.DateUtil;
import util.ValidateUtil;
......@@ -23,6 +24,8 @@ public class AccountTask {
TrackAccountRepository trackAccountRepository;
@Autowired
TrackAccount4WebRepository trackAccount4WebRepository;
@Autowired
TrackAccountFlowRestrictService trackAccountFlowRestrictService;
public void task(){
trackAccount4WebRepository.deleteAll();
......@@ -41,6 +44,7 @@ public class AccountTask {
}else{
account4Web.setStatus("已激活");
}
account4Web.setTrack(trackAccountFlowRestrictService.findRestrictByAccount(ac));
account4Web.setPastDate(ac.getPastDate());
account4Web.setUser(ac.getName());
account4Web.setTell(ac.getPhone());
......
......@@ -33,6 +33,15 @@ public class DateUtil {
public static final int C_ONE_HOUR = 60 * C_ONE_MINUTE;
public static final long C_ONE_DAY = 24L * C_ONE_HOUR;
public static Date getDate(String dataStr){
SimpleDateFormat sdf = new SimpleDateFormat(C_DATE_PATTON_DEFAULT);
try {
return sdf.parse(dataStr);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* Return the current date
*
......@@ -763,6 +772,15 @@ public class DateUtil {
return beforeDays;
}
public static String getDays2(int days) {
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(new Date());
startCalendar.add(Calendar.DAY_OF_YEAR, -days);
String beforeDays = format(startCalendar.getTime(),
C_DATA_PATTON_YYYYMMDD);
return beforeDays;
}
public static String getBeforeDays(String date, int days) {
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(parseDate(date));
......
package util;
import common.context.AppUtils;
import common.model.UserLog;
import common.repository.UserLogRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
/**
* Created by zxy on 2017/12/15.
*/
public class NewUserLogThread
extends Thread
{
protected Logger logger = LoggerFactory.getLogger(NewUserLogThread.class);
private UserLogRepository userLogRepository = AppUtils.getApplicationContext().getBean(UserLogRepository.class);
//操作用户
private String operaAccount;
//操作用户名
private String accountName;
//操作对象的类型:OperateObjectTypeEnum
private String operateObjectType;
//客户管理和系统账号管理是操作对象的账号,以后再加别的模块再定
private String operateObject;
//操作类型:“创建账号”“编辑账号”“录入缴费信息”“录入回访信息”“处理过期提醒”等等,如果都定下来有哪些,可以做一个字典
private String operateType;
//操作前的对象数据
private String oldObject;
//操作后的对象数据
private String newObject;
//为了获取ip及解析地点
private HttpServletRequest request;
/**
* 传入内容为对象
* UserLogThread userlog = new UserLogThread("zxy@reyun.com", "zxy", OperateObjectTypeEnum.CUSTOMER.getKey(), "app", "查看app", request);
* userlog.start();
*/
public NewUserLogThread(String operaAccount, String accountName, String operateObjectType, String operateObject, String operateType, String oldObject, String newObject, HttpServletRequest request) {
this.operaAccount = operaAccount;
this.accountName = accountName;
this.operateObjectType = operateObjectType;
this.operateObject = operateObject;
this.operateType = operateType;
this.oldObject = oldObject;
this.newObject = newObject;
this.request = request;
}
@Override
public void run()
{
try
{
UserLog audit = new UserLog();
audit.setOperaAccount(this.operaAccount);
audit.setAccountName(this.accountName);
audit.setOperateObjectType(this.operateObjectType);
audit.setOperateObject(this.operateObject);
audit.setOperateTime(DateUtil.format(new Date(), DateUtil.C_TIME_PATTON_DEFAULT));
audit.setOperateType(this.operateType);
audit.setOldObject(this.oldObject);
audit.setNewObject(this.newObject);
if (this.request != null) {
String ipAddr = IPAddrUtil.getIpAddrNew(request);
audit.setIp(ipAddr);
if(ValidateUtil.isValid(ipAddr)){
String locationFromIpAddr = IPAddrUtil.getLocationFromIpAddr(ipAddr);
audit.setLocation(locationFromIpAddr);
}
}
userLogRepository.save(audit);
} catch (Exception e) {
e.printStackTrace();
}
}
}
......@@ -10,7 +10,7 @@ public enum ResultStatus {
NUMBER_LIMIT(-300, "超过限定值,无法添加"),
NETWORK_ERROR(404, "网络异常"),
PARAM_INVALID(-1000, "参数错误"),
USERNAME_OR_PASSWORD_ERROR(-1001, "用户名或密码错误"),
USER_EMPTY(-1001, "用户不存在"),
USERNAME_LOGIN_EXPIRE(-1002, "用户登陆失效"),
SUB_ACCOUNT_DISABLE(-1003, "子帐号已禁用"),
ORIGINAL_ACCOUNT_DISABLE(-1004, "主体帐号已禁用"),
......
......@@ -32,12 +32,14 @@ public class UserLogThread
//为了获取ip及解析地点
private HttpServletRequest request;
private Long role;
/**
* 传入内容为对象
* UserLogThread userlog = new UserLogThread("zxy@reyun.com", "zxy", OperateObjectTypeEnum.CUSTOMER.getKey(), "app", "查看app", request);
* userlog.start();
*/
public UserLogThread(String operaAccount, String accountName, String operateObjectType, String operateObject, String operateType, HttpServletRequest request)
public UserLogThread(String operaAccount, String accountName, String operateObjectType, String operateObject, String operateType, HttpServletRequest request, Long role)
{
this.operaAccount = operaAccount;
this.accountName = accountName;
......@@ -45,6 +47,7 @@ public class UserLogThread
this.operateObject = operateObject;
this.operateType = operateType;
this.request = request;
this.role = role;
}
......@@ -60,6 +63,7 @@ public class UserLogThread
audit.setOperateObject(this.operateObject);
audit.setOperateTime(DateUtil.format(new Date(), DateUtil.C_TIME_PATTON_DEFAULT));
audit.setOperateType(this.operateType);
audit.setRole(this.role);
if (this.request != null) {
String ipAddr = IPAddrUtil.getIpAddrNew(request);
......
......@@ -25,9 +25,12 @@
<task:scheduled ref="emailTask" method="task" cron="0 20 0 * * ?"/>
</task:scheduled-tasks>
<bean id="trackAccountTask" class="track.task.AccountTask"></bean>
<bean id="contractTask" class="common.task.ContractTask"></bean>
<task:scheduled-tasks>
<task:scheduled ref="contractTask" method="task" cron="0 28 17 * * ?"/>
</task:scheduled-tasks>
<bean id="trackAccountTask" class="track.task.AccountTask"></bean>
<task:scheduled-tasks>
<!--//定时同步短链数据(每5分钟执行一次)-->
<task:scheduled ref="trackAccountTask" method="task" cron="0 32 0 * * ?"/>
......
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