Commit 880a5618 by manxiaoqiang

合同

parent 6dcdfbdc
......@@ -3,12 +3,16 @@ package common.controller;
import common.model.*;
import common.service.ContractService;
import common.service.MenuService;
import dic.OperateObjectTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import security.annotation.CurrentAccount;
import util.NewUserLogThread;
import util.ResultModel;
import util.UserLogThread;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
......@@ -76,8 +80,11 @@ public class ContractController {
@RequestMapping(value = "create", method = RequestMethod.POST)
@ResponseBody
public ResultModel create(@CurrentAccount User loginAccount, @RequestBody Contract contract) {
return ResultModel.OK(service.create(loginAccount, contract));
public ResultModel create(@CurrentAccount User loginAccount, @RequestBody Contract contract, HttpServletRequest request) {
Contract contract1 = service.create(loginAccount, contract);
NewUserLogThread userlog = new NewUserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), contract.getContractCode(), "新建合同","",contract1.toString(), request);
userlog.start();
return ResultModel.OK(contract1);
}
@RequestMapping(value = "update", method = RequestMethod.PUT)
......
......@@ -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;
}
}
......@@ -21,6 +21,8 @@ public class UserLog
private String operateObject;
private String operateType;
private String location;
private String OldObject;
private String newObject;
@Id
@GeneratedValue
......@@ -114,18 +116,36 @@ 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;
}
@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 + '\'' +
'}';
}
}
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> {
}
......@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tkio.model.PackageType;
import tkio.repository.PackageTypeRepository;
import tkio.service.AccountService;
import util.DateUtil;
import util.ValidateUtil;
......@@ -37,6 +38,8 @@ public class ContractServiceImpl implements ContractService{
ContractChangeRepository contractChangeRepository;
@Autowired
ContractMoneyRepository contractMoneyRepository;
@Autowired
AccountService accountService;
@Override
public Map<String, Object> checkAccount(String email) {
......@@ -106,6 +109,11 @@ public class ContractServiceImpl implements ContractService{
resource.setCreateAccount(loginUser.getId());
resource.setCreateTime(new Date());
//同步修改trackingio的数据
if(resource.getPlatform().equals("tkio")){
accountService.update(resource);
}
return contractRepository.save(resource);
}
......@@ -163,6 +171,10 @@ public class ContractServiceImpl implements ContractService{
cc.setPlatform(contract.getPlatform());
contractChangeRepository.save(cc);
//同步修改trackingio的数据
if(resource.getPlatform().equals("tkio")){
accountService.update(contract);
}
return contractRepository.save(contract);
}
......@@ -251,7 +263,16 @@ public class ContractServiceImpl implements ContractService{
BigDecimal bg = new BigDecimal(rebat);
double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
contract.setRebate(f1);
//同步修改trackingio的数据
if(resource.getPlatform().equals("tkio")){
accountService.update(contract);
}
}else{
//同步修改trackingio的数据
if(resource.getPlatform().equals("tkio")){
accountService.forbiden(contract);
}
contract.setStatus("cancel");
}
resource.setPlatform(contract.getPlatform());
......
......@@ -158,6 +158,8 @@ 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 ":"",
......
......@@ -38,6 +38,11 @@ public class TkioAccountController {
public ResultModel findOne(@CurrentAccount User loginAccount, @RequestParam String email) {
return ResultModel.OK(tkioAccountService.findOne(email));
}
@RequestMapping(value = "/find/reminderlevel", method = RequestMethod.GET)
@ResponseBody
public ResultModel findReminderlevel() {
return ResultModel.OK(tkioAccountService.findReminderlevel());
}
//关闭到期提醒
@RequestMapping(value = "/forbiden", method = RequestMethod.PUT)
......
......@@ -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);
}
......@@ -12,6 +12,8 @@ public interface TkioAccountService {
List<Account4Web> findAll(User user);
Account4Web findOne(String email);
List<ReminderLevel> findReminderlevel();
//到期提醒关闭
Reminder forbiden(User user, Reminder resource);
......
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.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);
}
}
......@@ -3,6 +3,7 @@ package tkio.service.impl;
import com.amazonaws.services.dynamodbv2.xspec.B;
import common.model.*;
import common.repository.*;
import common.service.UserService;
import dic.RoleEnum;
import dic.RoleTypeEnum;
import org.apache.commons.collections.map.AbstractMapDecorator;
......@@ -67,6 +68,11 @@ public class TkioAccountServiceImpl implements TkioAccountService {
ContractChangeRepository contractChangeRepository;
@Autowired
PackageTypeRepository packageTypeRepository;
@Autowired
UserService userService;
@Autowired
ReminderLevelRepository reminderLevelRepository;
@Override
public List<Account4Web> findAll(User user) {
List<Account4Web> result = new ArrayList<>();
......@@ -83,8 +89,21 @@ public class TkioAccountServiceImpl implements TkioAccountService {
}
}
}else{
SalesManLeader salesManLeader = salesManLeaderRepository.findOneByEmail(user.getEmail());
idList.add(salesManLeader.getId());
List<String> emailList = new ArrayList<>();
emailList.add(user.getEmail());
List<User> userList = userService.findAllSons(user.getId());
if(ValidateUtil.isValid(userList)){
for(User u : userList){
emailList.add(u.getEmail());
}
}
List<SalesManLeader> manLeaderList = salesManLeaderRepository.findAllByEmails(emailList);
if(ValidateUtil.isValid(manLeaderList)){
for(SalesManLeader a : manLeaderList){
idList.add(a.getId());
}
}
}
if(ValidateUtil.isValid(idList)){
List<Account> accountList = accountRepository.findBussnissMan(idList);
......@@ -172,6 +191,11 @@ public class TkioAccountServiceImpl implements TkioAccountService {
}
@Override
public List<ReminderLevel> findReminderlevel() {
return reminderLevelRepository.findAll();
}
@Override
public Reminder forbiden(User user, Reminder resource) {
resource.setUser(user.getId());
resource.setModifyTime(new Date());
......
......@@ -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
*
......
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();
}
}
}
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