Commit 291a8ccf authored by libin's avatar libin

行为日志记录

parent 4ecde1ea
......@@ -54,23 +54,10 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
behaviorAndDataMap= customerBehaviorNotes.stream().collect(Collectors.groupingBy(CustomerBehaviorNotes::getType, Collectors.toList()));
}
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());
}
}
//获取时间间隔
long between_day = getBetween_day(activityId, startTime, endTime);
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);
BehaviorNoteCollectVo behaviorNoteCollectVo;
for (BehaviorEnum behaviorEnum : behaviorEnums) {
......@@ -80,43 +67,58 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
behaviorNoteCollectVos.add(behaviorNoteCollectVo);
continue;
} else {
long default_p_total,default_p_avg,default_u_total,default_u_avg;
switch (behaviorEnum) {
case SUCCESS_INVIT:
int total = popularizeRelations.size();
long avg = (total / between_day);
behaviorNoteCollectVo.setP_count(total);
behaviorNoteCollectVo.setP_avg_count(avg);
behaviorNoteCollectVo.setU_count(total);
behaviorNoteCollectVo.setU_avg_count(avg);
default_p_total = popularizeRelations.size();
default_p_avg= (default_p_total / between_day);
default_u_total = default_p_total;
default_u_avg = default_p_avg;
break;
case SUCCESS_MORE_10_INVIT:
long default_totalMore10 = popularizeRelations.stream().collect(Collectors.groupingBy(ActivityPopularizeRelationDTO::getMajorUserId, Collectors.counting())).values().stream().filter(x -> x >= 10).count();
long default_avgMore10 = default_totalMore10 / between_day;
behaviorNoteCollectVo.setP_count(default_totalMore10);
behaviorNoteCollectVo.setP_avg_count(default_avgMore10);
behaviorNoteCollectVo.setU_count(default_totalMore10);
behaviorNoteCollectVo.setU_avg_count(default_avgMore10);
default_p_total = popularizeRelations.stream().collect(Collectors.groupingBy(ActivityPopularizeRelationDTO::getMajorUserId, Collectors.counting())).values().stream().filter(x -> x >= 10).count();
default_p_avg = default_p_total / between_day;
default_u_total = default_p_total;
default_u_avg = default_p_avg;
break;
default:
//访问量
List<CustomerBehaviorNotes> customerBehaviors = behaviorAndDataMap==null?Collections.EMPTY_LIST:behaviorAndDataMap.get(behaviorEnum.getCode());
boolean typeIsEmpty = CollectionUtils.isEmpty(customerBehaviors);
long default_p_total = typeIsEmpty?0:customerBehaviors.size();
long default_p_avg = default_p_total / between_day;
behaviorNoteCollectVo.setP_count(default_p_total);
behaviorNoteCollectVo.setP_avg_count(default_p_avg);
default_p_total = typeIsEmpty?0:customerBehaviors.size();
default_p_avg = default_p_total / between_day;
//用户访问量
Set<CustomerBehaviorNotes> customerBehaviorsSet = new HashSet<>(typeIsEmpty?Collections.EMPTY_SET:customerBehaviorNotes);
long default_u_total = customerBehaviorsSet.size();
long default_u_avg = default_u_total / between_day;
behaviorNoteCollectVo.setU_count(default_u_total);
behaviorNoteCollectVo.setU_avg_count(default_u_avg);
Set<CustomerBehaviorNotes> customerBehaviorsSet = new HashSet<>(typeIsEmpty?Collections.EMPTY_SET:customerBehaviors);
default_u_total = customerBehaviorsSet.size();
default_u_avg = default_u_total / between_day;
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);
}
}
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
......@@ -21,13 +21,13 @@ import java.util.Objects;
* @data 2019/8/12 14:14
*/
@RestController
@RequestMapping("customerBehaviorNotes")
@RequestMapping("/customerBehaviorNotes")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CustomerBehaviorNotesController {
private final CustomerBehaviorNotesBiz customerBehaviorNotesBiz;
@PostMapping("app/unauth/save")
@PostMapping("/app/unauth/save")
public ObjectRestResponse<Void> saveCustomerBehavior(@RequestBody CustomerBehaviorNoteDTO customerBehaviorNoteDTO, AppUserDTO appUserDTO) {
if (Objects.nonNull(appUserDTO.getUserid())) {
customerBehaviorNoteDTO.setCustomerId(String.valueOf(appUserDTO.getUserid()));
......
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