Commit 67f42a68 by zhangxiaoyan

app tag

parent 39f912c3
...@@ -90,17 +90,15 @@ public class LoginController ...@@ -90,17 +90,15 @@ public class LoginController
if (account != null) { if (account != null) {
if(!account.getRoleCategory().equals(5L)) { if(!account.getRoleCategory().equals(5L)) {
Boolean trackAndIoBothExhaust = accountFlowRestrictService.isTrackAndIoBothExhaust(account.getId()); Boolean trackAndIoBothExhaust = accountFlowRestrictService.isIoExhaust(account.getId());
Long rootParent = accountRepository.findRootParentByAccountId(account.getId()).longValue(); Long rootParent = accountRepository.findRootParentByAccountId(account.getId()).longValue();
Account rootAccount = accountRepository.findOne(rootParent); Account rootAccount = accountRepository.findOne(rootParent);
if (trackAndIoBothExhaust) { if (trackAndIoBothExhaust) {
if (rootAccount.getAllowBehavior()) {
rtnMap.put("msg", "行为分析流量用尽!"); rtnMap.put("msg", "行为分析流量用尽!");
rtnMap.put("code", 211); rtnMap.put("code", 211);
return ResultModel.OK(rtnMap); return ResultModel.OK(rtnMap);
} }
} }
}
if (!account.getIsSuperUser()) { if (!account.getIsSuperUser()) {
//子账号 //子账号
......
...@@ -61,7 +61,6 @@ public class Account { ...@@ -61,7 +61,6 @@ public class Account {
private String regIpAddr; private String regIpAddr;
private String regIpLocation; private String regIpLocation;
private Boolean verifyEmail = false; private Boolean verifyEmail = false;
private Boolean allowBehavior;
private Boolean isFlowRestrict; private Boolean isFlowRestrict;
private String modifyPricelevelTime; private String modifyPricelevelTime;
private Boolean newContract; private Boolean newContract;
...@@ -74,13 +73,6 @@ public class Account { ...@@ -74,13 +73,6 @@ public class Account {
isFlowRestrict = flowRestrict; isFlowRestrict = flowRestrict;
} }
public Boolean getAllowBehavior() {
return allowBehavior;
}
public void setAllowBehavior(Boolean allowBehavior) {
this.allowBehavior = allowBehavior;
}
public Account() { public Account() {
super(); super();
......
...@@ -44,13 +44,9 @@ public class App { ...@@ -44,13 +44,9 @@ public class App {
private Date modifyTime = new Date(); private Date modifyTime = new Date();
private String modifyAccount; private String modifyAccount;
private Boolean delFlag; private Boolean delFlag;
//是否同步DDB
private Boolean syncDdb;
private Long installNum; private Long installNum;
private Long registerNum; private Long registerNum;
//是够是debug模式 true 是测试,false不是测试
private Boolean isDebug;
private Boolean trackAndIoBothExhaust; private Boolean trackAndIoBothExhaust;
private Boolean mainAccountExpire; private Boolean mainAccountExpire;
...@@ -260,22 +256,6 @@ public class App { ...@@ -260,22 +256,6 @@ public class App {
this.delFlag = delFlag; 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 @Transient
public Boolean getTrackAndIoBothExhaust() { public Boolean getTrackAndIoBothExhaust() {
return trackAndIoBothExhaust; return trackAndIoBothExhaust;
...@@ -312,14 +292,6 @@ public class App { ...@@ -312,14 +292,6 @@ public class App {
this.registerNum = registerNum; this.registerNum = registerNum;
} }
public Boolean getDebug() {
return isDebug;
}
public void setDebug(Boolean debug) {
isDebug = debug;
}
public Boolean getDistributeTask() { public Boolean getDistributeTask() {
return distributeTask; return distributeTask;
} }
......
...@@ -15,32 +15,15 @@ public interface AppRepository extends JpaRepository<App, Long> ...@@ -15,32 +15,15 @@ public interface AppRepository extends JpaRepository<App, Long>
@Query(value="select appkey from app where id = ?1",nativeQuery=true) @Query(value="select appkey from app where id = ?1",nativeQuery=true)
String findAppkeyById(Long id); 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) @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); 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) @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); 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) @Query(value = "select * from app where id in ?1", nativeQuery = true)
List<App> findByIds(List<Long> ids); 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) @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); List<App> findAuthAppByRootParent(Long subAccountId, Long rootParent);
...@@ -50,18 +33,8 @@ public interface AppRepository extends JpaRepository<App, Long> ...@@ -50,18 +33,8 @@ public interface AppRepository extends JpaRepository<App, Long>
@Query(value="select platform from app where id = ?1",nativeQuery=true) @Query(value="select platform from app where id = ?1",nativeQuery=true)
String findPlatformByAppId(Long appId); 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) @Query(value="select categoryname from category where categoryid=(select app_genre from app where id=?1);",nativeQuery=true)
String findAppGenreNameByAppID(Long id); 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; package com.reyun.repository;
import com.reyun.model.AppTag; 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 org.springframework.data.repository.CrudRepository;
import java.util.List; import java.util.List;
...@@ -11,10 +14,13 @@ import java.util.List; ...@@ -11,10 +14,13 @@ import java.util.List;
* @author nolan * @author nolan
* @date 26/12/2017 * @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); List<AppTag> findByApp(Long app);
@Query(value = "delete from app_tag where app=?1 ", nativeQuery = true)
@Modifying
Long deleteByApp(Long app); Long deleteByApp(Long app);
} }
...@@ -10,7 +10,6 @@ import java.math.BigInteger; ...@@ -10,7 +10,6 @@ import java.math.BigInteger;
public interface AccountFlowRestrictService { public interface AccountFlowRestrictService {
AccountRestrict4Web findRestrictByAccount(Long accountId); AccountRestrict4Web findRestrictByAccount(Long accountId);
BigInteger getTotalNum(String createTime, String pastDate, String appids, String reportName, String sumType); BigInteger getTotalNum(String createTime, String pastDate, String appids, String reportName, String sumType);
Boolean isTrackAndIoBothExhaust(Long accountId); Boolean isIoExhaust(Long accountId);
Boolean isTrackExhaust(Long accountId);
AccountRestrict4Web RestrictFlowByAccountTask(Long accountId); AccountRestrict4Web RestrictFlowByAccountTask(Long accountId);
} }
...@@ -62,9 +62,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -62,9 +62,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
String companyOrEmail = rootAccount.getCompany() != null ? rootAccount.getCompany() : rootAccount.getEmail(); String companyOrEmail = rootAccount.getCompany() != null ? rootAccount.getCompany() : rootAccount.getEmail();
IsNotified isNotifiedObject = isNotifiedRepository.findIsNotifiedByAccountId(rootParent); IsNotified isNotifiedObject = isNotifiedRepository.findIsNotifiedByAccountId(rootParent);
boolean isTrackProduct = true;
boolean isIOProduct = rootAccount.getAllowBehavior();
StringBuffer appsStr = new StringBuffer(); StringBuffer appsStr = new StringBuffer();
for (App app : apps) { for (App app : apps) {
appsStr = appsStr.append("\'" + app.getAppkey() + "\'" + ","); appsStr = appsStr.append("\'" + app.getAppkey() + "\'" + ",");
...@@ -78,10 +75,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -78,10 +75,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
Boolean flowRestrict = rootAccount.getFlowRestrict(); Boolean flowRestrict = rootAccount.getFlowRestrict();
String pastDate = rootAccount.getPastDate(); 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(); Date currentDate = DateUtil.getCurrentDate();
String currentDateStr = DateUtil.getCurrentDateStr(); String currentDateStr = DateUtil.getCurrentDateStr();
int remainingDays = DateUtil.daysBetween(currentDate, DateUtil.parseDate(pastDate)) + 1; int remainingDays = DateUtil.daysBetween(currentDate, DateUtil.parseDate(pastDate)) + 1;
...@@ -97,23 +90,9 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -97,23 +90,9 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
String firstDayOfThisMonth = DateUtil.getFirstDayOfMonth(new Date()); 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%"); DecimalFormat decimalFormat = new DecimalFormat("0%");
String trackRemainPercent1 = decimalFormat.format(trackRemainPercent);
String IOBeginTime = (isNotifiedObject != null && isNotifiedObject.getThisMonthUpgradeLevel() != null && isNotifiedObject.getThisMonthUpgradeLevel()) ? rootAccount.getModifyPricelevelTime() : firstDayOfThisMonth; String IOBeginTime = (isNotifiedObject != null && isNotifiedObject.getThisMonthUpgradeLevel() != null && isNotifiedObject.getThisMonthUpgradeLevel()) ? rootAccount.getModifyPricelevelTime() : firstDayOfThisMonth;
BigInteger lastMonthEventNum=new BigInteger("0"); BigInteger lastMonthEventNum=new BigInteger("0");
BigInteger thisMonthEventNum=new BigInteger("0"); BigInteger thisMonthEventNum=new BigInteger("0");
BigInteger lastThreeDaysEventNum=new BigInteger("0"); BigInteger lastThreeDaysEventNum=new BigInteger("0");
...@@ -144,17 +123,13 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -144,17 +123,13 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
accountRestrict4Web.setIOLimit(packageType.getIoFlow()); accountRestrict4Web.setIOLimit(packageType.getIoFlow());
accountRestrict4Web.setTrackLimit(packageType.getTrackFlow()); accountRestrict4Web.setTrackLimit(packageType.getTrackFlow());
accountRestrict4Web.setThisMonthIOFlow(thisMonthEventNum); accountRestrict4Web.setThisMonthIOFlow(thisMonthEventNum);
accountRestrict4Web.setTrackTotalFlow(clickNum);
accountRestrict4Web.setAccountId(rootParent); accountRestrict4Web.setAccountId(rootParent);
accountRestrict4Web.setPriceLevel(rootAccount.getPricelevel().intValue()); accountRestrict4Web.setPriceLevel(rootAccount.getPricelevel().intValue());
accountRestrict4Web.setLastMonthIOFlow(lastMonthEventNum); accountRestrict4Web.setLastMonthIOFlow(lastMonthEventNum);
accountRestrict4Web.setIORemainPercent(ioRemainPercent); accountRestrict4Web.setIORemainPercent(ioRemainPercent);
accountRestrict4Web.setTrackRemainPercent(trackRemainPercent);
accountRestrict4Web.setiOremainingDays(IORemainDays); accountRestrict4Web.setiOremainingDays(IORemainDays);
accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setPackLevel(new Long(packageType.getId())); accountRestrict4Web.setPackLevel(new Long(packageType.getId()));
accountRestrict4Web.setFlowRestrict(flowRestrict); accountRestrict4Web.setFlowRestrict(flowRestrict);
accountRestrict4Web.setAllowBehavior(isIOProduct);
accountRestrict4Web.setSuperLevel(packageType.getSuperLevel()); accountRestrict4Web.setSuperLevel(packageType.getSuperLevel());
if (packageType.getSuperLevel()) { if (packageType.getSuperLevel()) {
...@@ -204,85 +179,7 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -204,85 +179,7 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
if (flowRestrict) { 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) {
/** /**
* 是行为分析产品 * 是行为分析产品
*/ */
...@@ -359,104 +256,8 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -359,104 +256,8 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
} }
} }
} }
}
if (!packageType.getSuperLevel() && flowRestrict) { 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);
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();
}
}
}
if (isIOProduct) {
boolean thirtyToTwenty = (thisMonthAvailableTotalFlow.doubleValue() * 0.7 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 0.8 > thisMonthEventNum.doubleValue()); 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 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 tenPercent = (thisMonthAvailableTotalFlow.doubleValue() * 0.9 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 0.95 > thisMonthEventNum.doubleValue());
...@@ -534,7 +335,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -534,7 +335,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
} }
} }
} }
}
isNotifiedObject.setFirstDayOfThisMonth(firstDayOfThisMonth); isNotifiedObject.setFirstDayOfThisMonth(firstDayOfThisMonth);
isNotifiedRepository.save(isNotifiedObject); isNotifiedRepository.save(isNotifiedObject);
...@@ -588,7 +388,7 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -588,7 +388,7 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
} }
@Override @Override
public Boolean isTrackAndIoBothExhaust(Long accountId) { public Boolean isIoExhaust(Long accountId) {
Long rootParent = accountRepository.findRootParentByAccountId(accountId).longValue(); Long rootParent = accountRepository.findRootParentByAccountId(accountId).longValue();
List<App> apps = appRepository.listAppByRootAccount(rootParent); List<App> apps = appRepository.listAppByRootAccount(rootParent);
Boolean isBothExhaust = false; Boolean isBothExhaust = false;
...@@ -606,12 +406,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -606,12 +406,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
PackageType packageType = packageTypeRepository.findPackageTypeByRootParent(rootParent); PackageType packageType = packageTypeRepository.findPackageTypeByRootParent(rootParent);
Boolean flowRestrict = rootAccount.getFlowRestrict(); 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(); String currentDateStr = DateUtil.getCurrentDateStr();
Date lastMonth = getLastMonth(1); Date lastMonth = getLastMonth(1);
...@@ -619,8 +413,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -619,8 +413,6 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
String lastDayOfLastMonth = DateUtil.getLastDayOfMonth(lastMonth); String lastDayOfLastMonth = DateUtil.getLastDayOfMonth(lastMonth);
String firstDayOfThisMonth = DateUtil.getFirstDayOfMonth(new Date()); String firstDayOfThisMonth = DateUtil.getFirstDayOfMonth(new Date());
BigInteger clickNum = getTotalNum(trackBeginTime, pastDate, appids, "account_track_flow_restrict", "click_sum");
IsNotified isNotifiedObject = isNotifiedRepository.findIsNotifiedByAccountId(rootParent); IsNotified isNotifiedObject = isNotifiedRepository.findIsNotifiedByAccountId(rootParent);
String IOBeginTime = (isNotifiedObject != null && isNotifiedObject.getThisMonthUpgradeLevel() != null && isNotifiedObject.getThisMonthUpgradeLevel()) ? rootAccount.getModifyPricelevelTime() : firstDayOfThisMonth; String IOBeginTime = (isNotifiedObject != null && isNotifiedObject.getThisMonthUpgradeLevel() != null && isNotifiedObject.getThisMonthUpgradeLevel()) ? rootAccount.getModifyPricelevelTime() : firstDayOfThisMonth;
BigInteger lastMonthEventNum = getTotalNum(firstDayOfLastMonth, lastDayOfLastMonth, appids, "account_io_flow_restrict", "event_sum"); BigInteger lastMonthEventNum = getTotalNum(firstDayOfLastMonth, lastDayOfLastMonth, appids, "account_io_flow_restrict", "event_sum");
...@@ -636,45 +428,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -636,45 +428,12 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
BigInteger thisMonthRemainingFlow = thisMonthAvailableTotalFlow.subtract(thisMonthEventNum); BigInteger thisMonthRemainingFlow = thisMonthAvailableTotalFlow.subtract(thisMonthEventNum);
if (!packageType.getSuperLevel() && flowRestrict) { if (!packageType.getSuperLevel() && flowRestrict) {
if (rootAccount.getAllowBehavior()) {
isBothExhaust = thisMonthRemainingFlow.doubleValue() < 0; isBothExhaust = thisMonthRemainingFlow.doubleValue() < 0;
} }
} }
}
return isBothExhaust; 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 @Override
public AccountRestrict4Web RestrictFlowByAccountTask(Long accountId) { public AccountRestrict4Web RestrictFlowByAccountTask(Long accountId) {
......
...@@ -83,11 +83,6 @@ public class AppServiceImpl implements AppService { ...@@ -83,11 +83,6 @@ public class AppServiceImpl implements AppService {
app.setDelFlag(true); app.setDelFlag(true);
appRepository.save(app); appRepository.save(app);
/*//删除APP在ddb中的状态
if (Constant.awsneed) {
awsDynamoDBService.deleteAppSdkDebugItem(app.getAppkey());
}*/
return app; return app;
} }
...@@ -144,8 +139,6 @@ public class AppServiceImpl implements AppService { ...@@ -144,8 +139,6 @@ public class AppServiceImpl implements AppService {
resource.setAppkey(ShortUrlGenerator.md5(key)); resource.setAppkey(ShortUrlGenerator.md5(key));
resource.setToken(CipherUtil.generatePassword("reged_"+ShortUrlGenerator.md5(key))); resource.setToken(CipherUtil.generatePassword("reged_"+ShortUrlGenerator.md5(key)));
resource.setRegedbutton(false); resource.setRegedbutton(false);
//新建APP默认debug模式 true 是测试,false不是测试
resource.setIsDebug(false);
// resource.setSyncDdb(false); // resource.setSyncDdb(false);
App app = appRepository.save(resource); App app = appRepository.save(resource);
......
...@@ -545,7 +545,6 @@ public class AuthServiceImpl implements AuthService { ...@@ -545,7 +545,6 @@ public class AuthServiceImpl implements AuthService {
//新建账号 account //新建账号 account
Account saveAccount = this.buildAccount(loginAccount, subAccount, false); Account saveAccount = this.buildAccount(loginAccount, subAccount, false);
saveAccount.setAllowBehavior(loginAccount.getAllowBehavior());
saveAccount = accountRepository.save(saveAccount); saveAccount = accountRepository.save(saveAccount);
//构建权限 auth //构建权限 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