Commit 5b03442b by songweifeng

ceshi

parent c455e0c3
...@@ -19,9 +19,6 @@ import java.math.BigInteger; ...@@ -19,9 +19,6 @@ import java.math.BigInteger;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.*; import java.util.*;
/**
* Created by song on 2017/10/19.
*/
@Service @Service
public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictService { public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictService {
@Autowired @Autowired
...@@ -42,11 +39,13 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -42,11 +39,13 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
@Autowired @Autowired
private AccountRestrict4WebRepository accountRestrict4WebRepository; private AccountRestrict4WebRepository accountRestrict4WebRepository;
@Autowired
private ConfigParamRepository configParamRepository;
public static final String SUPER_USER_EMAIL_NOTIFY_SUBJECT = "客户包年套餐到期提醒"; private static final String SUPER_USER_EMAIL_NOTIFY_SUBJECT = "客户包年套餐到期提醒";
public static final String SUPER_USER_TRACK_EMAIL_NOTIFY_CONTENT = "%s购买的“%s”中广告效果监测服务%s,请尽快跟进。"; private static final String SUPER_USER_IO_EMAIL_NOTIFY_CONTENT = "%s购买的“%s”中用户行为分析服务%s,请尽快跟进。";
public static final String SUPER_USER_IO_EMAIL_NOTIFY_CONTENT = "%s购买的“%s”中用户行为分析服务%s,请尽快跟进。"; private static final String ALREADY_EXPIRE = "已经到期";
public static final String ALREADY_EXPIRE = "已经到期";
@Override @Override
...@@ -54,8 +53,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -54,8 +53,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
Long rootParent = accountRepository.findRootParentByAccountId(accountId).longValue(); Long rootParent = accountRepository.findRootParentByAccountId(accountId).longValue();
AccountRestrict4Web accountRestrict4Web = new AccountRestrict4Web(); AccountRestrict4Web accountRestrict4Web = new AccountRestrict4Web();
Account one = accountRepository.findOne(accountId);
Long roleCategory = one.getRoleCategory();
List<App> apps = appRepository.listAppByRootAccount(rootParent); List<App> apps = appRepository.listAppByRootAccount(rootParent);
Account rootAccount = accountRepository.findOne(rootParent); Account rootAccount = accountRepository.findOne(rootParent);
...@@ -81,8 +78,21 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -81,8 +78,21 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
String salesManLeaderEmail = salesManLeaderRepository.findLeaderByBussinessMan(rootAccount.getBussinessman()); String salesManLeaderEmail = salesManLeaderRepository.findLeaderByBussinessMan(rootAccount.getBussinessman());
String[] split={""};
if(salesManLeaderEmail!=null ){
split = salesManLeaderEmail.split(",");
}
ArrayList<String> emailList = new ArrayList<>(); ArrayList<String> emailList = new ArrayList<>();
emailList.add(salesManLeaderEmail); Collections.addAll(emailList, split);
ArrayList<String> accountEmailList = new ArrayList<>();
String operate_email = configParamRepository.findParamsByKey("operate_email");
if(operate_email!=null){
String[] split1 = operate_email.split(",");
accountEmailList.addAll(Arrays.asList(split1));
}
//accountEmailList.add(rootAccount.getEmail());
Date lastMonth = getLastMonth(1); Date lastMonth = getLastMonth(1);
String firstDayOfLastMonth = DateUtil.getFirstDayOfMonth(lastMonth); String firstDayOfLastMonth = DateUtil.getFirstDayOfMonth(lastMonth);
...@@ -189,9 +199,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -189,9 +199,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
accountRestrict4Web.setIOPastTimeNotified(true); accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT,
companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期"); companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
String accountContents = "您购买的用户行为分析" + packageType.getPackageName() + "将在"+remainingDays+"天后("+rootAccount.getPastDate()+")到期,为了不影响您的正常使用,请尽快联系商务续订服务。服务到期后我们将会继续支持您的数据上报和接收,但数据展示服务将暂时无法使用。";
try { try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList); Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start(); emailThread.start();
Thread accountEmailThread = new EmailThread("热云数据用户行为分析套餐提醒",accountContents, accountEmailList);
accountEmailThread.start();
} catch (Exception e) { } catch (Exception e) {
isNotifiedObject.setIoTenDaysNotified(false); isNotifiedObject.setIoTenDaysNotified(false);
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
...@@ -203,9 +216,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -203,9 +216,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true); accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期"); String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
String accountContents = "您购买的用户行为分析" + packageType.getPackageName() + "将在"+remainingDays+"天后("+rootAccount.getPastDate()+")到期,为了不影响您的正常使用,请尽快联系商务续订服务。服务到期后我们将会继续支持您的数据上报和接收,但数据展示服务将暂时无法使用。";
try { try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList); Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start(); emailThread.start();
Thread accountEmailThread = new EmailThread("热云数据用户行为分析套餐提醒",accountContents, accountEmailList);
accountEmailThread.start();
} catch (Exception e) { } catch (Exception e) {
isNotifiedObject.setIoOneMonthNotified(false); isNotifiedObject.setIoOneMonthNotified(false);
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
...@@ -231,9 +247,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -231,9 +247,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true); accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有1天到期"); String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有1天到期");
String accountContents = "您购买的用户行为分析" + packageType.getPackageName() + "将在明天到期,为了不影响您的正常使用,请尽快联系商务续订服务。服务到期后我们将会继续支持您的数据上报和接收,但数据展示服务将暂时无法使用。";
try { try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList); Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start(); emailThread.start();
Thread accountEmailThread = new EmailThread("热云数据用户行为分析套餐提醒",accountContents, accountEmailList);
accountEmailThread.start();
} catch (Exception e) { } catch (Exception e) {
isNotifiedObject.setIoOneDaysNotified(false); isNotifiedObject.setIoOneDaysNotified(false);
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
...@@ -268,9 +287,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -268,9 +287,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true); accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。"; String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
String accountContents = "您订阅的用户行为分析" + packageType.getPackageName() + "中本月剩余流量已不足" + ioRemainPercent1 + ",请关注您的套餐流量使用情况。";
try { try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList); Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start(); emailThread.start();
Thread accountEmailThread = new EmailThread("热云数据用户行为分析套餐提醒",accountContents, accountEmailList);
accountEmailThread.start();
} catch (Exception e) { } catch (Exception e) {
isNotifiedObject.setIoThirtyPercentNotified(false); isNotifiedObject.setIoThirtyPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
...@@ -282,9 +304,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -282,9 +304,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true); accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。"; String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
String accountContents = "您订阅的用户行为分析" + packageType.getPackageName() + "中本月剩余流量已不足" + ioRemainPercent1 + ",请关注您的套餐流量使用情况。";
try { try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList); Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start(); emailThread.start();
Thread accountEmailThread = new EmailThread("热云数据用户行为分析套餐提醒",accountContents, accountEmailList);
accountEmailThread.start();
} catch (Exception e) { } catch (Exception e) {
isNotifiedObject.setIoTwentyPercentNotified(false); isNotifiedObject.setIoTwentyPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
...@@ -296,9 +321,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -296,9 +321,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true); accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。"; String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
String accountContents = "您订阅的用户行为分析" + packageType.getPackageName() + "中本月剩余流量已不足" + ioRemainPercent1 + ",请关注您的套餐流量使用情况。";
try { try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList); Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start(); emailThread.start();
Thread accountEmailThread = new EmailThread("热云数据用户行为分析套餐提醒",accountContents, accountEmailList);
accountEmailThread.start();
} catch (Exception e) { } catch (Exception e) {
isNotifiedObject.setIoTenPercentNotified(false); isNotifiedObject.setIoTenPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
...@@ -310,9 +338,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -310,9 +338,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true); accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。"; String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
String accountContents = "您订阅的用户行为分析" + packageType.getPackageName() + "中本月剩余流量已不足" + ioRemainPercent1 + ",请关注您的套餐流量使用情况。";
try { try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList); Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start(); emailThread.start();
Thread accountEmailThread = new EmailThread("热云数据用户行为分析套餐提醒",accountContents, accountEmailList);
accountEmailThread.start();
} catch (Exception e) { } catch (Exception e) {
isNotifiedObject.setIoFivePercentNotified(false); isNotifiedObject.setIoFivePercentNotified(false);
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
...@@ -324,9 +355,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -324,9 +355,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true); accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "中用户行为分析当月流量已用尽,请尽快跟进。"; String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "中用户行为分析当月流量已用尽,请尽快跟进。";
String accountContents = "您订阅的用户行为分析" + packageType.getPackageName() + "中本月事件数已经用完,本月超出部分将占用下周流量限额,最高使用量不超出5%。服务到期后我们将会继续支持您的数据上报和接收,但数据展示服务将暂时无法使用。请您预估下月的流量使用,如果产品统计需求增加,请联系商务升级您的套餐。";
try { try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList); Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start(); emailThread.start();
Thread accountEmailThread = new EmailThread("热云数据用户行为分析套餐提醒",accountContents, accountEmailList);
accountEmailThread.start();
} catch (Exception e) { } catch (Exception e) {
isNotifiedObject.setIoExhaustPercentNotified(false); isNotifiedObject.setIoExhaustPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
......
...@@ -3,11 +3,13 @@ package com.reyun.task; ...@@ -3,11 +3,13 @@ package com.reyun.task;
import com.reyun.model.Account; import com.reyun.model.Account;
import com.reyun.repository.AccountRepository; import com.reyun.repository.AccountRepository;
import com.reyun.service.AccountFlowRestrictService; import com.reyun.service.AccountFlowRestrictService;
import com.reyun.util.DateUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -27,9 +29,16 @@ public class AutoCalculateFlow { ...@@ -27,9 +29,16 @@ public class AutoCalculateFlow {
try{ try{
List<Account> superAccount = accountRepository.findSuperAccount(); List<Account> superAccount = accountRepository.findSuperAccount();
for(Account account:superAccount){ for(Account account:superAccount){
//System.out.println("**********************************************\n\n"); String pastDate1 = account.getPastDate();
accountFlowRestrictService.RestrictFlowByAccountTask(account.getId()); String pastDate5 = DateUtil.getBeforeDays(pastDate1, -5);
//System.out.println("**********************************************\n\n"); Date pastDate = DateUtil.parseDate(pastDate5);
if(DateUtil.compareDate(pastDate, new Date())!=-1){
try{
accountFlowRestrictService.RestrictFlowByAccountTask(account.getId());
}catch (Exception e){
logger.info(e.getMessage());
}
}
} }
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); 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