Commit 67f42a68 by zhangxiaoyan

app tag

parent 39f912c3
......@@ -90,15 +90,13 @@ public class LoginController
if (account != null) {
if(!account.getRoleCategory().equals(5L)) {
Boolean trackAndIoBothExhaust = accountFlowRestrictService.isTrackAndIoBothExhaust(account.getId());
Boolean trackAndIoBothExhaust = accountFlowRestrictService.isIoExhaust(account.getId());
Long rootParent = accountRepository.findRootParentByAccountId(account.getId()).longValue();
Account rootAccount = accountRepository.findOne(rootParent);
if (trackAndIoBothExhaust) {
if (rootAccount.getAllowBehavior()) {
rtnMap.put("msg", "行为分析流量用尽!");
rtnMap.put("code", 211);
return ResultModel.OK(rtnMap);
}
rtnMap.put("msg", "行为分析流量用尽!");
rtnMap.put("code", 211);
return ResultModel.OK(rtnMap);
}
}
......
......@@ -61,7 +61,6 @@ public class Account {
private String regIpAddr;
private String regIpLocation;
private Boolean verifyEmail = false;
private Boolean allowBehavior;
private Boolean isFlowRestrict;
private String modifyPricelevelTime;
private Boolean newContract;
......@@ -74,13 +73,6 @@ public class Account {
isFlowRestrict = flowRestrict;
}
public Boolean getAllowBehavior() {
return allowBehavior;
}
public void setAllowBehavior(Boolean allowBehavior) {
this.allowBehavior = allowBehavior;
}
public Account() {
super();
......
......@@ -44,13 +44,9 @@ public class App {
private Date modifyTime = new Date();
private String modifyAccount;
private Boolean delFlag;
//是否同步DDB
private Boolean syncDdb;
private Long installNum;
private Long registerNum;
//是够是debug模式 true 是测试,false不是测试
private Boolean isDebug;
private Boolean trackAndIoBothExhaust;
private Boolean mainAccountExpire;
......@@ -260,22 +256,6 @@ public class App {
this.delFlag = delFlag;
}
public Boolean getIsDebug() {
return this.isDebug;
}
public void setIsDebug(Boolean isDebug) {
this.isDebug = isDebug;
}
public Boolean getSyncDdb() {
return syncDdb;
}
public void setSyncDdb(Boolean syncDdb) {
this.syncDdb = syncDdb;
}
@Transient
public Boolean getTrackAndIoBothExhaust() {
return trackAndIoBothExhaust;
......@@ -312,14 +292,6 @@ public class App {
this.registerNum = registerNum;
}
public Boolean getDebug() {
return isDebug;
}
public void setDebug(Boolean debug) {
isDebug = debug;
}
public Boolean getDistributeTask() {
return distributeTask;
}
......
......@@ -15,32 +15,15 @@ public interface AppRepository extends JpaRepository<App, Long>
@Query(value="select appkey from app where id = ?1",nativeQuery=true)
String findAppkeyById(Long id);
List<App> findByAccount(Long account);
@Query(value = "select * from app where account =?1 and bundleid = ?2 and del_flag is not true", nativeQuery = true)
App findByBundleidInNotDel(Long account, String bundleid);
@Query(value = "select * from app where account =?1 and name = ?2 and del_flag is not true", nativeQuery = true)
App findByNameNotDel(Long account, String name);
@Query(value = "select * from app where sync_ddb is false and del_flag is not true", nativeQuery = true)
List<App> findNotSyncAppDebug();
@Query(value = "select * from app where token = ?1 limit 1", nativeQuery = true)
App findOneByAppToken(String token);
@Query(value = "select * from app where id in ?1", nativeQuery = true)
List<App> findByIds(List<Long> ids);
@Query(value = "SELECT DISTINCT t2.* FROM campaign t0 JOIN channel t1 ON t0.channel = t1.id JOIN app t2 ON t0.app = t2.id WHERE t0.del_flag is not true and (t1.type!='ry_coop' or t1.type is NULL) and t1.category = 'ADVERTISING' and t2.id in ?1 and t2.platform = ?2 and t2.del_flag is not TRUE" , nativeQuery = true)
List<App> findAppsFromOnelink(List<Long> appids, String platform);
@Query(value = "SELECT DISTINCT t2.* FROM campaign t0 JOIN channel t1 ON t0.channel = t1.id JOIN app t2 ON t0.app = t2.id WHERE t0.del_flag is not true and (t1.type!='ry_coop' or t1.type is NULL) and t1.category = 'ADVERTISING' and t2.id = ?1" , nativeQuery = true)
App findAppFromOnelink(Long appid);
@Query(value = "select * from app where appkey in ?1", nativeQuery = true)
List<App> findByAppkeys(List<String> appkeys);
@Query(value = "select * from app a join auth b on a.id = b.app where b.account = ?1 and b.create_account in (select id from account where root_parent = ?2) ", nativeQuery = true)
List<App> findAuthAppByRootParent(Long subAccountId, Long rootParent);
......@@ -50,18 +33,8 @@ public interface AppRepository extends JpaRepository<App, Long>
@Query(value="select platform from app where id = ?1",nativeQuery=true)
String findPlatformByAppId(Long appId);
@Query(value="select categoryname from category where categoryid=(select game_genre from app where id=?1);",nativeQuery=true)
String findGameCategoryByAppID(Long appId);
@Query(value="select categoryname from category where categoryid=(select app_genre from app where id=?1);",nativeQuery=true)
String findAppGenreNameByAppID(Long id);
@Query(value = "select DISTINCT a.* from app a right join data_auth d on a.id = d.app where d.account = ?1 and d.app in ?2 and d.channel = ?3 and (d.all_campaign is true or d.channel_permit is true)", nativeQuery = true)
List<App> listTotalAuthorizedApp(Long accountId, List<Long> appIdList, Long channelId);
@Query(value = "select create_account from app where appkey=?1", nativeQuery = true)
String findCreateAccountByAppkey(String appKey);
@Query(value = "select DISTINCT a.* from app a right join data_auth d on a.id = d.app where d.account = ?1 and d.channel = ?2 and (d.all_campaign is true or d.channel_permit is true)", nativeQuery = true)
List<App> listApps(Long accountId, Long channelId);
}
package com.reyun.repository;
import com.reyun.model.AppTag;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
......@@ -11,10 +14,13 @@ import java.util.List;
* @author nolan
* @date 26/12/2017
*/
public interface AppTagRepository extends CrudRepository<AppTag, Long>
public interface AppTagRepository extends JpaRepository<AppTag, Long>
{
@Query(value = "select * from app_tag where app=?1", nativeQuery = true)
List<AppTag> findByApp(Long app);
@Query(value = "delete from app_tag where app=?1 ", nativeQuery = true)
@Modifying
Long deleteByApp(Long app);
}
......@@ -10,7 +10,6 @@ import java.math.BigInteger;
public interface AccountFlowRestrictService {
AccountRestrict4Web findRestrictByAccount(Long accountId);
BigInteger getTotalNum(String createTime, String pastDate, String appids, String reportName, String sumType);
Boolean isTrackAndIoBothExhaust(Long accountId);
Boolean isTrackExhaust(Long accountId);
Boolean isIoExhaust(Long accountId);
AccountRestrict4Web RestrictFlowByAccountTask(Long accountId);
}
......@@ -62,9 +62,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
String companyOrEmail = rootAccount.getCompany() != null ? rootAccount.getCompany() : rootAccount.getEmail();
IsNotified isNotifiedObject = isNotifiedRepository.findIsNotifiedByAccountId(rootParent);
boolean isTrackProduct = true;
boolean isIOProduct = rootAccount.getAllowBehavior();
StringBuffer appsStr = new StringBuffer();
for (App app : apps) {
appsStr = appsStr.append("\'" + app.getAppkey() + "\'" + ",");
......@@ -78,10 +75,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
Boolean flowRestrict = rootAccount.getFlowRestrict();
String pastDate = rootAccount.getPastDate();
String trackBeginTime;
Date rootCreateTime = rootAccount.getPubDate();
String createTime = DateUtil.format(rootCreateTime, "yyyy-MM-dd");
trackBeginTime = (rootAccount.getNewContract() != null && rootAccount.getNewContract()) ? rootAccount.getModifyPricelevelTime() : createTime;
Date currentDate = DateUtil.getCurrentDate();
String currentDateStr = DateUtil.getCurrentDateStr();
int remainingDays = DateUtil.daysBetween(currentDate, DateUtil.parseDate(pastDate)) + 1;
......@@ -97,23 +90,9 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
String firstDayOfThisMonth = DateUtil.getFirstDayOfMonth(new Date());
BigInteger clickNum =new BigInteger("0");
BigInteger lastThreeDaysClickNum1=new BigInteger("0");
if(apps.size()>0) {
clickNum = getTotalNum(trackBeginTime, pastDate, appids, "account_track_flow_restrict", "click_sum");
lastThreeDaysClickNum1 = getTotalNum(trackBeginTime, currentDateStr, appids, "account_track_three_days_flow_restrict", "click_sum");
}
BigInteger lastThreeDaysClickNum = lastThreeDaysClickNum1.compareTo(new BigInteger("0")) != 0 ? lastThreeDaysClickNum1 : new BigInteger("1");
int trackRemainDays = (int) Math.floor((packageType.getTrackFlow().doubleValue() - clickNum.doubleValue()) / ((lastThreeDaysClickNum.doubleValue() / 3)));
double trackRemainPercent = 1.0 - clickNum.doubleValue() / packageType.getTrackFlow().doubleValue();
DecimalFormat decimalFormat = new DecimalFormat("0%");
String trackRemainPercent1 = decimalFormat.format(trackRemainPercent);
String IOBeginTime = (isNotifiedObject != null && isNotifiedObject.getThisMonthUpgradeLevel() != null && isNotifiedObject.getThisMonthUpgradeLevel()) ? rootAccount.getModifyPricelevelTime() : firstDayOfThisMonth;
BigInteger lastMonthEventNum=new BigInteger("0");
BigInteger thisMonthEventNum=new BigInteger("0");
BigInteger lastThreeDaysEventNum=new BigInteger("0");
......@@ -144,17 +123,13 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
accountRestrict4Web.setIOLimit(packageType.getIoFlow());
accountRestrict4Web.setTrackLimit(packageType.getTrackFlow());
accountRestrict4Web.setThisMonthIOFlow(thisMonthEventNum);
accountRestrict4Web.setTrackTotalFlow(clickNum);
accountRestrict4Web.setAccountId(rootParent);
accountRestrict4Web.setPriceLevel(rootAccount.getPricelevel().intValue());
accountRestrict4Web.setLastMonthIOFlow(lastMonthEventNum);
accountRestrict4Web.setIORemainPercent(ioRemainPercent);
accountRestrict4Web.setTrackRemainPercent(trackRemainPercent);
accountRestrict4Web.setiOremainingDays(IORemainDays);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setPackLevel(new Long(packageType.getId()));
accountRestrict4Web.setFlowRestrict(flowRestrict);
accountRestrict4Web.setAllowBehavior(isIOProduct);
accountRestrict4Web.setSuperLevel(packageType.getSuperLevel());
if (packageType.getSuperLevel()) {
......@@ -204,334 +179,159 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
if (flowRestrict) {
if (isTrackProduct) {
/**
* 是广告检测产品
*/
if (remainingDays > 1 && remainingDays <= 10 && (isNotifiedObject.getTrackTenDaysNotified() == null || !isNotifiedObject.getTrackTenDaysNotified())) {
isNotifiedObject.setTrackTenDaysNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackPastTimeNotified(true);
String contents = String.format(SUPER_USER_TRACK_EMAIL_NOTIFY_CONTENT,
companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setTrackTenDaysNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays > 10 && remainingDays <= 30 && (isNotifiedObject.getTrackOneMonthNotified() == null || !isNotifiedObject.getTrackOneMonthNotified())) {
isNotifiedObject.setTrackOneMonthNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackPastTimeNotified(true);
String contents = String.format(SUPER_USER_TRACK_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setTrackOneMonthNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays <= 0 && (isNotifiedObject.getTrackExpireNotified() == null || !isNotifiedObject.getTrackExpireNotified())) {
isNotifiedObject.setTrackExpireNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackPastTimeNotified(true);
String contents = String.format(SUPER_USER_TRACK_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), ALREADY_EXPIRE);
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setTrackExpireNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays == 1 && (isNotifiedObject.getTrackOneDaysNotified() == null || !isNotifiedObject.getTrackOneDaysNotified())) {
isNotifiedObject.setTrackOneDaysNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackPastTimeNotified(true);
String contents = String.format(SUPER_USER_TRACK_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有1天到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setTrackOneDaysNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays > 30 && remainingDays <= 60 && (isNotifiedObject.getTrackTwoMonthNotified() == null || !isNotifiedObject.getTrackTwoMonthNotified())) {
isNotifiedObject.setTrackTwoMonthNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackPastTimeNotified(true);
String contents = String.format(SUPER_USER_TRACK_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setTrackTwoMonthNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackPastTimeNotified(false);
e.printStackTrace();
}
}
}
if (isIOProduct) {
/**
* 是行为分析产品
*/
if (remainingDays > 1 && remainingDays <= 10 && (isNotifiedObject.getIoTenDaysNotified() == null || !isNotifiedObject.getIoTenDaysNotified())) {
isNotifiedObject.setIoTenDaysNotified(true);
/**
* 是行为分析产品
*/
if (remainingDays > 1 && remainingDays <= 10 && (isNotifiedObject.getIoTenDaysNotified() == null || !isNotifiedObject.getIoTenDaysNotified())) {
isNotifiedObject.setIoTenDaysNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT,
companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoTenDaysNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT,
companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoTenDaysNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays > 10 && remainingDays <= 30 && (isNotifiedObject.getIoOneMonthNotified() == null || !isNotifiedObject.getIoOneMonthNotified())) {
isNotifiedObject.setIoOneMonthNotified(true);
accountRestrict4Web.setIOPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays > 10 && remainingDays <= 30 && (isNotifiedObject.getIoOneMonthNotified() == null || !isNotifiedObject.getIoOneMonthNotified())) {
isNotifiedObject.setIoOneMonthNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoOneMonthNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoOneMonthNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays <= 0 && (isNotifiedObject.getIoExpireNotified() == null || !isNotifiedObject.getIoExpireNotified())) {
isNotifiedObject.setIoExpireNotified(true);
accountRestrict4Web.setIOPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays <= 0 && (isNotifiedObject.getIoExpireNotified() == null || !isNotifiedObject.getIoExpireNotified())) {
isNotifiedObject.setIoExpireNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), ALREADY_EXPIRE);
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoExpireNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), ALREADY_EXPIRE);
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoExpireNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays == 1 && (isNotifiedObject.getIoOneDaysNotified() == null || !isNotifiedObject.getIoOneDaysNotified())) {
isNotifiedObject.setIoOneDaysNotified(true);
accountRestrict4Web.setIOPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays == 1 && (isNotifiedObject.getIoOneDaysNotified() == null || !isNotifiedObject.getIoOneDaysNotified())) {
isNotifiedObject.setIoOneDaysNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有1天到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoOneDaysNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有1天到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoOneDaysNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays > 30 && remainingDays <= 60 && (isNotifiedObject.getIoTwoMonthNotified() == null || !isNotifiedObject.getIoTwoMonthNotified())) {
isNotifiedObject.setIoTwoMonthNotified(true);
accountRestrict4Web.setIOPastTimeNotified(false);
e.printStackTrace();
}
} else if (remainingDays > 30 && remainingDays <= 60 && (isNotifiedObject.getIoTwoMonthNotified() == null || !isNotifiedObject.getIoTwoMonthNotified())) {
isNotifiedObject.setIoTwoMonthNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoTwoMonthNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(true);
String contents = String.format(SUPER_USER_IO_EMAIL_NOTIFY_CONTENT, companyOrEmail, packageType.getPackageName(), "还有" + remainingDays + "天即将到期");
try {
Thread emailThread = new EmailThread(SUPER_USER_EMAIL_NOTIFY_SUBJECT, contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoTwoMonthNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOPastTimeNotified(false);
e.printStackTrace();
}
accountRestrict4Web.setIOPastTimeNotified(false);
e.printStackTrace();
}
}
}
if (!packageType.getSuperLevel() && flowRestrict) {
/**
* 不是超级用户,是包流量的用户
*/
if (isTrackProduct) {
boolean thirtyToTwenty = (packageType.getTrackFlow().doubleValue() * 0.7 <= clickNum.doubleValue()) && (packageType.getTrackFlow().doubleValue() * 0.8 > clickNum.doubleValue());
boolean twentyToTen = (packageType.getTrackFlow().doubleValue() * 0.8 <= clickNum.doubleValue()) && (packageType.getTrackFlow().doubleValue() * 0.9 > clickNum.doubleValue());
boolean tenPercent = (packageType.getTrackFlow().doubleValue() * 0.9 <= clickNum.doubleValue()) && (packageType.getTrackFlow().doubleValue() * 0.95 > clickNum.doubleValue());
boolean fivePercent = (packageType.getTrackFlow().doubleValue() * 0.95 <= clickNum.doubleValue()) && (packageType.getTrackFlow().doubleValue() * 1 > clickNum.doubleValue());
boolean exPercent = packageType.getTrackFlow().doubleValue() <= clickNum.doubleValue();
if (thirtyToTwenty && (isNotifiedObject.getTrackThirtyPercentNotified() == null || !isNotifiedObject.getTrackThirtyPercentNotified())) {
isNotifiedObject.setTrackThirtyPercentNotified(true);
boolean thirtyToTwenty = (thisMonthAvailableTotalFlow.doubleValue() * 0.7 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 0.8 > thisMonthEventNum.doubleValue());
boolean twentyToTen = (thisMonthAvailableTotalFlow.doubleValue() * 0.8 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 0.9 > thisMonthEventNum.doubleValue());
boolean tenPercent = (thisMonthAvailableTotalFlow.doubleValue() * 0.9 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 0.95 > thisMonthEventNum.doubleValue());
boolean fivePercent = (thisMonthAvailableTotalFlow.doubleValue() * 0.95 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 1 > thisMonthEventNum.doubleValue());
boolean exPercent = thisMonthAvailableTotalFlow.doubleValue() * 1 <= thisMonthEventNum.doubleValue();
if (thirtyToTwenty && (isNotifiedObject.getIoThirtyPercentNotified() == null || !isNotifiedObject.getIoThirtyPercentNotified())) {
isNotifiedObject.setIoThirtyPercentNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoThirtyPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setTrackFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "中广告效果监控剩余流量不足" + trackRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("广告效果监控产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setTrackThirtyPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setTrackFlowNotified(false);
e.printStackTrace();
}
} else if (twentyToTen && (isNotifiedObject.getTrackTwentyPercentNotified() == null || !isNotifiedObject.getTrackTwentyPercentNotified())) {
isNotifiedObject.setTrackTwentyPercentNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setTrackFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "中广告效果监控剩余流量不足" + trackRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("广告效果监控产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setTrackTwentyPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setTrackFlowNotified(false);
e.printStackTrace();
}
} else if (tenPercent && (isNotifiedObject.getTrackTenPercentNotified() == null || !isNotifiedObject.getTrackTenPercentNotified())) {
isNotifiedObject.setTrackTenPercentNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setTrackFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "中广告效果监控剩余流量不足" + trackRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("广告效果监控产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setTrackTenPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setTrackFlowNotified(false);
e.printStackTrace();
}
} else if (fivePercent && (isNotifiedObject.getTrackFivePercentNotified() == null || !isNotifiedObject.getTrackFivePercentNotified())) {
isNotifiedObject.setTrackFivePercentNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setTrackFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "中广告效果监控剩余流量不足" + trackRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("广告效果监控产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setTrackFivePercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setTrackFlowNotified(false);
e.printStackTrace();
}
} else if (exPercent && (isNotifiedObject.getTrackExhaustPercentNotified() == null || !isNotifiedObject.getTrackExhaustPercentNotified())) {
isNotifiedObject.setTrackExhaustPercentNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setTrackFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "中广告效果监控流量已用尽,请尽快跟进。";
try {
Thread emailThread = new EmailThread("广告效果监控产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setTrackExhaustPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setTrackFlowNotified(false);
e.printStackTrace();
}
accountRestrict4Web.setIOFlowNotified(false);
e.printStackTrace();
}
}
if (isIOProduct) {
boolean thirtyToTwenty = (thisMonthAvailableTotalFlow.doubleValue() * 0.7 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 0.8 > thisMonthEventNum.doubleValue());
boolean twentyToTen = (thisMonthAvailableTotalFlow.doubleValue() * 0.8 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 0.9 > thisMonthEventNum.doubleValue());
boolean tenPercent = (thisMonthAvailableTotalFlow.doubleValue() * 0.9 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 0.95 > thisMonthEventNum.doubleValue());
boolean fivePercent = (thisMonthAvailableTotalFlow.doubleValue() * 0.95 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 1 > thisMonthEventNum.doubleValue());
boolean exPercent = thisMonthAvailableTotalFlow.doubleValue() * 1 <= thisMonthEventNum.doubleValue();
if (thirtyToTwenty && (isNotifiedObject.getIoThirtyPercentNotified() == null || !isNotifiedObject.getIoThirtyPercentNotified())) {
isNotifiedObject.setIoThirtyPercentNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoThirtyPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(false);
e.printStackTrace();
}
} else if (twentyToTen && (isNotifiedObject.getIoTwentyPercentNotified() == null || !isNotifiedObject.getIoTwentyPercentNotified())) {
isNotifiedObject.setIoTwentyPercentNotified(true);
} else if (twentyToTen && (isNotifiedObject.getIoTwentyPercentNotified() == null || !isNotifiedObject.getIoTwentyPercentNotified())) {
isNotifiedObject.setIoTwentyPercentNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoTwentyPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoTwentyPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(false);
e.printStackTrace();
}
} else if (tenPercent && (isNotifiedObject.getIoTenPercentNotified() == null || !isNotifiedObject.getIoTenPercentNotified())) {
isNotifiedObject.setIoTenPercentNotified(true);
accountRestrict4Web.setIOFlowNotified(false);
e.printStackTrace();
}
} else if (tenPercent && (isNotifiedObject.getIoTenPercentNotified() == null || !isNotifiedObject.getIoTenPercentNotified())) {
isNotifiedObject.setIoTenPercentNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoTenPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoTenPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(false);
e.printStackTrace();
}
} else if (fivePercent && (isNotifiedObject.getIoFivePercentNotified() == null || !isNotifiedObject.getIoFivePercentNotified())) {
isNotifiedObject.setIoFivePercentNotified(true);
accountRestrict4Web.setIOFlowNotified(false);
e.printStackTrace();
}
} else if (fivePercent && (isNotifiedObject.getIoFivePercentNotified() == null || !isNotifiedObject.getIoFivePercentNotified())) {
isNotifiedObject.setIoFivePercentNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoFivePercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "用户行为分析当月剩余流量不足" + ioRemainPercent1 + ",请尽快跟进。";
try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoFivePercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(false);
e.printStackTrace();
}
} else if (exPercent && (isNotifiedObject.getIoExhaustPercentNotified() == null || !isNotifiedObject.getIoExhaustPercentNotified())) {
isNotifiedObject.setIoExhaustPercentNotified(true);
accountRestrict4Web.setIOFlowNotified(false);
e.printStackTrace();
}
} else if (exPercent && (isNotifiedObject.getIoExhaustPercentNotified() == null || !isNotifiedObject.getIoExhaustPercentNotified())) {
isNotifiedObject.setIoExhaustPercentNotified(true);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "中用户行为分析当月流量已用尽,请尽快跟进。";
try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoExhaustPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(true);
String contents = companyOrEmail + "购买的" + packageType.getPackageName() + "中用户行为分析当月流量已用尽,请尽快跟进。";
try {
Thread emailThread = new EmailThread("用户行为分析产品流量提醒", contents, emailList);
emailThread.start();
} catch (Exception e) {
isNotifiedObject.setIoExhaustPercentNotified(false);
isNotifiedRepository.save(isNotifiedObject);
accountRestrict4Web.setIOFlowNotified(false);
e.printStackTrace();
}
accountRestrict4Web.setIOFlowNotified(false);
e.printStackTrace();
}
}
}
......@@ -588,7 +388,7 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
}
@Override
public Boolean isTrackAndIoBothExhaust(Long accountId) {
public Boolean isIoExhaust(Long accountId) {
Long rootParent = accountRepository.findRootParentByAccountId(accountId).longValue();
List<App> apps = appRepository.listAppByRootAccount(rootParent);
Boolean isBothExhaust = false;
......@@ -606,12 +406,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
PackageType packageType = packageTypeRepository.findPackageTypeByRootParent(rootParent);
Boolean flowRestrict = rootAccount.getFlowRestrict();
String pastDate = rootAccount.getPastDate();
String trackBeginTime;
Date rootCreateTime = rootAccount.getCreateTime();
String createTime = DateUtil.format(rootCreateTime, "yyyy-MM-dd");
trackBeginTime = (rootAccount.getNewContract() != null && rootAccount.getNewContract()) ? rootAccount.getModifyPricelevelTime() : createTime;
String currentDateStr = DateUtil.getCurrentDateStr();
Date lastMonth = getLastMonth(1);
......@@ -619,8 +413,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
String lastDayOfLastMonth = DateUtil.getLastDayOfMonth(lastMonth);
String firstDayOfThisMonth = DateUtil.getFirstDayOfMonth(new Date());
BigInteger clickNum = getTotalNum(trackBeginTime, pastDate, appids, "account_track_flow_restrict", "click_sum");
IsNotified isNotifiedObject = isNotifiedRepository.findIsNotifiedByAccountId(rootParent);
String IOBeginTime = (isNotifiedObject != null && isNotifiedObject.getThisMonthUpgradeLevel() != null && isNotifiedObject.getThisMonthUpgradeLevel()) ? rootAccount.getModifyPricelevelTime() : firstDayOfThisMonth;
BigInteger lastMonthEventNum = getTotalNum(firstDayOfLastMonth, lastDayOfLastMonth, appids, "account_io_flow_restrict", "event_sum");
......@@ -636,45 +428,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
BigInteger thisMonthRemainingFlow = thisMonthAvailableTotalFlow.subtract(thisMonthEventNum);
if (!packageType.getSuperLevel() && flowRestrict) {
if (rootAccount.getAllowBehavior()) {
isBothExhaust = thisMonthRemainingFlow.doubleValue() < 0;
}
isBothExhaust = thisMonthRemainingFlow.doubleValue() < 0;
}
}
return isBothExhaust;
}
@Override
public Boolean isTrackExhaust(Long accountId) {
Long rootParent = accountRepository.findRootParentByAccountId(accountId).longValue();
List<App> apps = appRepository.listAppByRootAccount(rootParent);
Boolean isBothExhaust = false;
if (apps.size() != 0) {
Account rootAccount = accountRepository.findOne(rootParent);
StringBuffer appsStr = new StringBuffer();
for (App app : apps) {
appsStr = appsStr.append("\'" + app.getAppkey() + "\'" + ",");
}
String appids = appsStr.substring(0, appsStr.length() - 1);
/**
* 1.根据母帐号获取用户等级
*/
PackageType packageType = packageTypeRepository.findPackageTypeByRootParent(rootParent);
Boolean flowRestrict = rootAccount.getFlowRestrict();
String pastDate = rootAccount.getPastDate();
String trackBeginTime;
Date rootCreateTime = rootAccount.getCreateTime();
String createTime = DateUtil.format(rootCreateTime, "yyyy-MM-dd");
trackBeginTime = (rootAccount.getNewContract() != null && rootAccount.getNewContract()) ? rootAccount.getModifyPricelevelTime() : createTime;
BigInteger clickNum = getTotalNum(trackBeginTime, pastDate, appids, "account_track_flow_restrict", "click_sum");
if (!packageType.getSuperLevel() && flowRestrict) {
isBothExhaust = (packageType.getTrackFlow().doubleValue() - clickNum.doubleValue() < 0);
}
}
return isBothExhaust;
}
@Override
public AccountRestrict4Web RestrictFlowByAccountTask(Long accountId) {
......
......@@ -83,11 +83,6 @@ public class AppServiceImpl implements AppService {
app.setDelFlag(true);
appRepository.save(app);
/*//删除APP在ddb中的状态
if (Constant.awsneed) {
awsDynamoDBService.deleteAppSdkDebugItem(app.getAppkey());
}*/
return app;
}
......@@ -144,8 +139,6 @@ public class AppServiceImpl implements AppService {
resource.setAppkey(ShortUrlGenerator.md5(key));
resource.setToken(CipherUtil.generatePassword("reged_"+ShortUrlGenerator.md5(key)));
resource.setRegedbutton(false);
//新建APP默认debug模式 true 是测试,false不是测试
resource.setIsDebug(false);
// resource.setSyncDdb(false);
App app = appRepository.save(resource);
......
......@@ -545,7 +545,6 @@ public class AuthServiceImpl implements AuthService {
//新建账号 account
Account saveAccount = this.buildAccount(loginAccount, subAccount, false);
saveAccount.setAllowBehavior(loginAccount.getAllowBehavior());
saveAccount = accountRepository.save(saveAccount);
//构建权限 auth
......
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