This commit is contained in:
尹吉欢
2017-11-07 11:13:02 +08:00
parent 5efff996b2
commit 5b03dd0893
4 changed files with 29 additions and 18 deletions
@@ -3,12 +3,14 @@ package com.fangjia.job.fsh.document;
import java.util.Date; import java.util.Date;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field; import org.springframework.data.mongodb.core.mapping.Field;
/** /**
* 理财和贷款潜客统计 * 理财和贷款潜客统计
* @author yinjihuan * @author yinjihuan
*/ */
@Document(collection="customer_stat")
public class CustomerStat { public class CustomerStat {
@Id @Id
@@ -34,7 +34,7 @@ public class AdVisitLogServiceImpl extends EntityService<AdVisitLog> implements
sql.append("?,"); sql.append("?,");
params.add(poi); params.add(poi);
} }
sql.delete(0, sql.length() - 1); sql.delete(sql.length() - 1, sql.length());
sql.append(")"); sql.append(")");
if (StringUtils.isNotBlank(start) && StringUtils.isNotBlank(end)) { if (StringUtils.isNotBlank(start) && StringUtils.isNotBlank(end)) {
sql.append(" and visit_time between ? and ?"); sql.append(" and visit_time between ? and ?");
@@ -1,5 +1,6 @@
package com.fangjia.job.fsh.service; package com.fangjia.job.fsh.service;
import java.math.BigDecimal;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -172,7 +173,7 @@ public class CustomerStatServiceImpl implements CustomerStatService {
} }
// 从5星开始分析,满足条件则继续下个用户的分析,不满足则继续4星的分析,以此类推 // 从5星开始分析,满足条件则继续下个用户的分析,不满足则继续4星的分析,以此类推
for (int i = 5; i <= 1; i--) { for (int i = 5; i >= 1; i--) {
LoanCustomersConfig config = getLoanCustomersConfig(i, loanCustomersConfigList); LoanCustomersConfig config = getLoanCustomersConfig(i, loanCustomersConfigList);
if (config == null) { if (config == null) {
continue; continue;
@@ -180,57 +181,64 @@ public class CustomerStatServiceImpl implements CustomerStatService {
// 配置了最近分析时间才需要根据时间去查询PV // 配置了最近分析时间才需要根据时间去查询PV
String start = ""; String start = "";
String end = ""; String end = "";
if (loanFilterConfig.getAnalyTime() > 0) { if (config.getAnalyTime() > 0) {
Map<String, String> timeMap = DateUtilCustom.getLatelyDate(loanFilterConfig.getAnalyTime()); Map<String, String> timeMap = DateUtilCustom.getLatelyDate(config.getAnalyTime());
start = timeMap.get("start"); start = timeMap.get("start");
end = timeMap.get("end"); end = timeMap.get("end");
} }
// 判断贷款评估PV // 判断贷款评估PV
if (config.getLoanEvalPv() > 0) { if (config.getLoanEvalPv() > 0) {
if (visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/myLoan/loanStep", "/myLoan/result"), start, end) <= config.getLoanEvalPv()) { long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/myLoan/loanStep", "/myLoan/result"), start, end);
if (count <= config.getLoanEvalPv()) {
continue; continue;
} }
} }
// 判断申请评估PV // 判断贷款申请PV
if (config.getLoanApplyPv() > 0) { if (config.getLoanApplyPv() > 0) {
if (visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/myLoan/info", "/myLoan/applyResult"), start, end) <= config.getLoanApplyPv()) { long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/myLoan/info", "/myLoan/applyResult"), start, end);
if (count <= config.getLoanApplyPv()) {
continue; continue;
} }
} }
// 判断我要贷款首页PV // 判断我要贷款首页PV
if (config.getLoanIndexPagePv() > 0) { if (config.getLoanIndexPagePv() > 0) {
if (visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/myLoan/index"), start, end) <= config.getLoanIndexPagePv()) { long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/myLoan/index"), start, end);
if (count <= config.getLoanIndexPagePv()) {
continue; continue;
} }
} }
// 判断我要置换首页PV // 判断我要置换首页PV
if (config.getSubIndexPagePv() > 0) { if (config.getSubIndexPagePv() > 0) {
if (visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/changeHouse/index"), start, end) <= config.getSubIndexPagePv()) { long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/changeHouse/index"), start, end);
if (count <= config.getSubIndexPagePv()) {
continue; continue;
} }
} }
// 判断出租管理PV // 判断出租管理PV
if (config.getRentManagerPv() > 0) { if (config.getRentManagerPv() > 0) {
if (visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/rent/index"), start, end) <= config.getRentManagerPv()) { long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/rent/index"), start, end);
if (count <= config.getRentManagerPv()) {
continue; continue;
} }
} }
// 判断出售分析PV // 判断出售分析PV
if (config.getSaleAnalyPv() > 0) { if (config.getSaleAnalyPv() > 0) {
if (visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/saleAnalysis/analysisDetail"), start, end) <= config.getSaleAnalyPv()) { long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/saleAnalysis/analysisDetail"), start, end);
if (count <= config.getSaleAnalyPv()) {
continue; continue;
} }
} }
// 判断贷款评估次数 // 判断贷款评估次数
if (config.getLoanEvalCount() > 0) { if (config.getLoanEvalCount() > 0) {
if (loanApplyService.queryCountByType(eid, uid, 2, start, end) <= config.getLoanEvalCount()) { long count = loanApplyService.queryCountByType(eid, uid, 2, start, end);
if (count <= config.getLoanEvalCount()) {
continue; continue;
} }
} }
@@ -255,7 +263,7 @@ public class CustomerStatServiceImpl implements CustomerStatService {
} }
// 从5星开始分析,满足条件则继续下个用户的分析,不满足则继续4星的分析,以此类推 // 从5星开始分析,满足条件则继续下个用户的分析,不满足则继续4星的分析,以此类推
for (int i = 5; i <= 1; i--) { for (int i = 5; i >= 1; i--) {
FinancialCustomersConfig config = getFinancialCustomersConfig(i, financialCustomersList); FinancialCustomersConfig config = getFinancialCustomersConfig(i, financialCustomersList);
if (config == null) { if (config == null) {
continue; continue;
@@ -338,7 +346,8 @@ public class CustomerStatServiceImpl implements CustomerStatService {
// 企业下的用户数量 // 企业下的用户数量
long enterpriseUserCount = enterpriseProductUserService.queryUserCount(eid); long enterpriseUserCount = enterpriseProductUserService.queryUserCount(eid);
long level = houseInfoService.queryHouseTotalPriceLevel(eid, uid); long level = houseInfoService.queryHouseTotalPriceLevel(eid, uid);
return level / enterpriseUserCount * 100.0; double rate = new BigDecimal((double)enterpriseUserCount/level).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
return rate;
} }
/** /**
@@ -362,7 +371,7 @@ public class CustomerStatServiceImpl implements CustomerStatService {
long adClickCount = adVisitLogService.queryPvCount(eid, uid, Arrays.asList(0, 1, 2, 3), start, end); long adClickCount = adVisitLogService.queryPvCount(eid, uid, Arrays.asList(0, 1, 2, 3), start, end);
List<String> uriList = Arrays.asList("/fsh/result", "/saleAnalysis/analysisDetail", "/rent/index"); List<String> uriList = Arrays.asList("/fsh/result", "/saleAnalysis/analysisDetail", "/rent/index");
long pvCount = visitLogService.queryPvCountByUser(eid, uid, uriList, start, end); long pvCount = visitLogService.queryPvCountByUser(eid, uid, uriList, start, end);
double rate = adClickCount / pvCount * 100.0; double rate = new BigDecimal((double)adClickCount/pvCount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
return rate; return rate;
} }
@@ -378,7 +387,7 @@ public class CustomerStatServiceImpl implements CustomerStatService {
long adClickCount = adVisitLogService.queryPvCount(eid, uid, Arrays.asList(4), start, end); long adClickCount = adVisitLogService.queryPvCount(eid, uid, Arrays.asList(4), start, end);
List<String> uriList = Arrays.asList("/changeHouse/details"); List<String> uriList = Arrays.asList("/changeHouse/details");
long pvCount = visitLogService.queryPvCountByUser(eid, uid, uriList, start, end); long pvCount = visitLogService.queryPvCountByUser(eid, uid, uriList, start, end);
double rate = adClickCount / pvCount * 100.0; double rate = new BigDecimal((double)adClickCount/pvCount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
return rate; return rate;
} }
@@ -63,7 +63,7 @@ public class VisitLogServiceImpl extends EntityService<VisitLog> implements Visi
sql.append("?,"); sql.append("?,");
params.add(uri); params.add(uri);
} }
sql.delete(0, sql.length() - 1); sql.delete(sql.length() - 1, sql.length());
sql.append(")"); sql.append(")");
if (StringUtils.isNotBlank(start) && StringUtils.isNotBlank(end)) { if (StringUtils.isNotBlank(start) && StringUtils.isNotBlank(end)) {
sql.append(" and visit_time between ? and ?"); sql.append(" and visit_time between ? and ?");