Commit 30138aaf authored by libin's avatar libin

行为记录

parent 914a4116
...@@ -54,23 +54,10 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe ...@@ -54,23 +54,10 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
behaviorAndDataMap= customerBehaviorNotes.stream().collect(Collectors.groupingBy(CustomerBehaviorNotes::getType, Collectors.toList())); behaviorAndDataMap= customerBehaviorNotes.stream().collect(Collectors.groupingBy(CustomerBehaviorNotes::getType, Collectors.toList()));
} }
long between_day = 0; //获取时间间隔
if (startTime!=null && endTime !=null){ long between_day = getBetween_day(activityId, startTime, endTime);
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(startTime), Instant.ofEpochMilli(endTime));
}else {
ActivityListDTO activityListDTO = activityFeign.findActivityStartTimeAndEndTimeById(activityId);
if (startTime!=null){
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(startTime),Instant.now());
}
if (endTime!=null){
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(activityListDTO.getActivity_startTime()),Instant.ofEpochMilli(endTime));
}
if (startTime == null && endTime == null){
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(activityListDTO.getActivity_startTime()),Instant.now());
}
}
between_day = Math.abs(between_day)==0?1:Math.abs(between_day); between_day = Math.abs(between_day)==0?1:Math.abs(between_day);
EnumSet<BehaviorEnum> behaviorEnums = EnumSet.allOf(BehaviorEnum.class); EnumSet<BehaviorEnum> behaviorEnums = EnumSet.allOf(BehaviorEnum.class);
BehaviorNoteCollectVo behaviorNoteCollectVo; BehaviorNoteCollectVo behaviorNoteCollectVo;
for (BehaviorEnum behaviorEnum : behaviorEnums) { for (BehaviorEnum behaviorEnum : behaviorEnums) {
...@@ -80,43 +67,58 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe ...@@ -80,43 +67,58 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
behaviorNoteCollectVos.add(behaviorNoteCollectVo); behaviorNoteCollectVos.add(behaviorNoteCollectVo);
continue; continue;
} else { } else {
long default_p_total,default_p_avg,default_u_total,default_u_avg;
switch (behaviorEnum) { switch (behaviorEnum) {
case SUCCESS_INVIT: case SUCCESS_INVIT:
int total = popularizeRelations.size(); default_p_total = popularizeRelations.size();
long avg = (total / between_day); default_p_avg= (default_p_total / between_day);
behaviorNoteCollectVo.setP_count(total); default_u_total = default_p_total;
behaviorNoteCollectVo.setP_avg_count(avg); default_u_avg = default_p_avg;
behaviorNoteCollectVo.setU_count(total);
behaviorNoteCollectVo.setU_avg_count(avg);
break; break;
case SUCCESS_MORE_10_INVIT: case SUCCESS_MORE_10_INVIT:
long default_totalMore10 = popularizeRelations.stream().collect(Collectors.groupingBy(ActivityPopularizeRelationDTO::getMajorUserId, Collectors.counting())).values().stream().filter(x -> x >= 10).count(); default_p_total = popularizeRelations.stream().collect(Collectors.groupingBy(ActivityPopularizeRelationDTO::getMajorUserId, Collectors.counting())).values().stream().filter(x -> x >= 10).count();
long default_avgMore10 = default_totalMore10 / between_day; default_p_avg = default_p_total / between_day;
behaviorNoteCollectVo.setP_count(default_totalMore10); default_u_total = default_p_total;
behaviorNoteCollectVo.setP_avg_count(default_avgMore10); default_u_avg = default_p_avg;
behaviorNoteCollectVo.setU_count(default_totalMore10);
behaviorNoteCollectVo.setU_avg_count(default_avgMore10);
break; break;
default: default:
//访问量 //访问量
List<CustomerBehaviorNotes> customerBehaviors = behaviorAndDataMap==null?Collections.EMPTY_LIST:behaviorAndDataMap.get(behaviorEnum.getCode()); List<CustomerBehaviorNotes> customerBehaviors = behaviorAndDataMap==null?Collections.EMPTY_LIST:behaviorAndDataMap.get(behaviorEnum.getCode());
boolean typeIsEmpty = CollectionUtils.isEmpty(customerBehaviors); boolean typeIsEmpty = CollectionUtils.isEmpty(customerBehaviors);
long default_p_total = typeIsEmpty?0:customerBehaviors.size(); default_p_total = typeIsEmpty?0:customerBehaviors.size();
long default_p_avg = default_p_total / between_day; default_p_avg = default_p_total / between_day;
behaviorNoteCollectVo.setP_count(default_p_total);
behaviorNoteCollectVo.setP_avg_count(default_p_avg);
//用户访问量 //用户访问量
Set<CustomerBehaviorNotes> customerBehaviorsSet = new HashSet<>(typeIsEmpty?Collections.EMPTY_SET:customerBehaviorNotes); Set<CustomerBehaviorNotes> customerBehaviorsSet = new HashSet<>(typeIsEmpty?Collections.EMPTY_SET:customerBehaviors);
long default_u_total = customerBehaviorsSet.size(); default_u_total = customerBehaviorsSet.size();
long default_u_avg = default_u_total / between_day; default_u_avg = default_u_total / between_day;
behaviorNoteCollectVo.setU_count(default_u_total);
behaviorNoteCollectVo.setU_avg_count(default_u_avg);
break; break;
} }
behaviorNoteCollectVo.setP_count(default_p_total);
behaviorNoteCollectVo.setP_avg_count(default_p_avg);
behaviorNoteCollectVo.setU_count(default_u_total);
behaviorNoteCollectVo.setU_avg_count(default_u_avg);
behaviorNoteCollectVos.add(behaviorNoteCollectVo); behaviorNoteCollectVos.add(behaviorNoteCollectVo);
} }
} }
return behaviorNoteCollectVos; return behaviorNoteCollectVos;
} }
private long getBetween_day(Integer activityId, Long startTime, Long endTime) {
long between_day = 0;
if (startTime!=null && endTime !=null){
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(startTime), Instant.ofEpochMilli(endTime));
}else {
ActivityListDTO activityListDTO = activityFeign.findActivityStartTimeAndEndTimeById(activityId);
if (startTime!=null){
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(startTime),Instant.now());
}
if (endTime!=null){
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(activityListDTO.getActivity_startTime()),Instant.ofEpochMilli(endTime));
}
if (startTime == null && endTime == null){
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(activityListDTO.getActivity_startTime()),Instant.now());
}
}
return between_day;
}
} }
\ No newline at end of file
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