Commit eab501f3 authored by libin's avatar libin

Merge branch 'dev' into base-modify

parents 136b42b6 4e69edea
...@@ -88,7 +88,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel ...@@ -88,7 +88,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
}else { }else {
//判断用户是否有有效的上线 //判断用户是否有有效的上线
log.info("----userId==="+userId+"----bindTime===="+bindTime+"----relation.getBindTime()==="+relation.getBindTime()); log.info("----userId==="+userId+"----bindTime===="+bindTime+"----relation.getBindTime()==="+relation.getBindTime());
if(relation.getParentId()==null||relation.getParentId()==0||(relation.getIsForever()!=1&&relation.getBindTime()<bindTime)){ if(relation.getParentId()==null||relation.getParentId()==0||(relation.getIsForever()!=1&&validTime>0&&relation.getBindTime()<bindTime)){
relation.setParentId(parentId); relation.setParentId(parentId);
relation.setBindType(type); relation.setBindType(type);
relation.setBindTime(time); relation.setBindTime(time);
......
...@@ -16,7 +16,7 @@ public enum BehaviorEnum { ...@@ -16,7 +16,7 @@ public enum BehaviorEnum {
/** /**
* 立即前往(弹窗) * 立即前往(弹窗)
*/ */
DIALOG_WINDOW_TO(1, "立即前往(活动详情页)"), DIALOG_WINDOW_TO(1, "立即前往(弹窗)"),
/** /**
* banner 点击 * banner 点击
...@@ -31,7 +31,7 @@ public enum BehaviorEnum { ...@@ -31,7 +31,7 @@ public enum BehaviorEnum {
/** /**
* 注册 * 注册
*/ */
REGISTRY(4, "注册"), REGISTRY(4, "成功注册"),
/** /**
* 活动页面访问量 * 活动页面访问量
...@@ -46,7 +46,7 @@ public enum BehaviorEnum { ...@@ -46,7 +46,7 @@ public enum BehaviorEnum {
/** /**
* 分享 * 分享
*/ */
SHARE(7, "分享"), SHARE(7, "成功分享"),
/** /**
* App访问 * App访问
...@@ -61,7 +61,12 @@ public enum BehaviorEnum { ...@@ -61,7 +61,12 @@ public enum BehaviorEnum {
/** /**
* 成功邀请人数大于10 * 成功邀请人数大于10
*/ */
SUCCESS_MORE_10_INVIT(10,"成功邀请人数大于10"); SUCCESS_MORE_10_INVIT(10,"成功邀请人数大于10"),
/**
* 立即领取(活动详情页)
*/
IMMEDIATELY_TO_RECEIVE(11,"立即领取(活动详情页)");
BehaviorEnum(int code, String name) { BehaviorEnum(int code, String name) {
this.code = code; this.code = code;
......
package com.xxfc.platform.user.behavior.dto;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 14:16
*/
@Data
public class ActivityBehaviorDTO {
private Integer activityId;
private Integer behaviorTypeId;
}
package com.xxfc.platform.user.behavior.dto;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 17:05
*/
@Data
public class ActivityBehaviorRelationDTO {
/**
* @see com.xxfc.platform.user.behavior.common.BehaviorEnum
* 行为类型
*/
private Integer type;
/**
* 业务id (banner 精彩活动 app弹窗)
*/
private Integer bizId;
/**
* 活动id
*/
private Integer activityId;
}
package com.xxfc.platform.user.behavior.dto;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 14:16
*/
@Data
public class BehaviorTypeDTO {
private String name;
private Integer code;
}
package com.xxfc.platform.user.behavior.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 14:02
*/
@Data
@Table(name = "activity_behavior")
public class ActivityBehavior {
@Id
@GeneratedValue(generator = "JDBC")
private Integer id;
@Column(name = "activity_id")
private Integer activityId;
@Column(name = "behavior_type_id")
private Integer behaviorTypeId;
}
package com.xxfc.platform.user.behavior.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 17:05
*/
@Data
@Table(name = "activity_behavior_relation")
public class ActivityBehaviorRelation {
@Id
@GeneratedValue(generator = "JDBC")
private Integer id;
/**
* @see com.xxfc.platform.user.behavior.common.BehaviorEnum
* 行为类型
*/
private Integer type;
/**
* 业务id (banner 精彩活动 app弹窗)
*/
@Column(name = "biz_id")
private Integer bizId;
/**
* 活动id
*/
@Column(name = "activity_id")
private Integer activityId;
}
package com.xxfc.platform.user.behavior.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 14:02
*/
@Data
@Table(name = "behavior_type")
public class BehaviorType {
@Id
@GeneratedValue(generator = "JDBC")
private Integer id;
@Column(name = "name")
private String name;
@Column(name = "code")
private Integer code;
}
package com.xxfc.platform.user.behavior.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.user.behavior.dto.ActivityBehaviorDTO;
import com.xxfc.platform.user.behavior.entity.ActivityBehavior;
import com.xxfc.platform.user.behavior.mapper.ActivityBehaviorMapper;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 14:10
*/
@Service
public class ActivityBehaviorBiz extends BaseBiz<ActivityBehaviorMapper, ActivityBehavior> {
public List<ActivityBehaviorDTO> findActivityBehaviorsByActivityId(Integer activityId){
return mapper.selectbyActivityId(activityId);
}
}
package com.xxfc.platform.user.behavior.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.user.behavior.dto.ActivityBehaviorRelationDTO;
import com.xxfc.platform.user.behavior.entity.ActivityBehaviorRelation;
import com.xxfc.platform.user.behavior.mapper.ActivityBehaviorRelationMapper;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 17:12
*/
@Service
public class ActivityBehaviorRelationBiz extends BaseBiz<ActivityBehaviorRelationMapper, ActivityBehaviorRelation> {
public List<ActivityBehaviorRelationDTO> findActivityBehaviorRelationsByActivityId(Integer activityId){
return mapper.selectAllByActivityId(activityId);
}
}
package com.xxfc.platform.user.behavior.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.user.behavior.dto.BehaviorTypeDTO;
import com.xxfc.platform.user.behavior.entity.BehaviorType;
import com.xxfc.platform.user.behavior.mapper.BehaviorTypeMapper;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 14:09
*/
@Service
public class BehaviorTypeBiz extends BaseBiz<BehaviorTypeMapper, BehaviorType> {
public List<BehaviorTypeDTO> findBehaviorTypesByIds(List<Integer> typeIds){
return mapper.selectAllByIdList(typeIds);
}
}
...@@ -5,6 +5,9 @@ import com.xxfc.platform.activity.dto.ActivityListDTO; ...@@ -5,6 +5,9 @@ import com.xxfc.platform.activity.dto.ActivityListDTO;
import com.xxfc.platform.activity.dto.ActivityPopularizeRelationDTO; import com.xxfc.platform.activity.dto.ActivityPopularizeRelationDTO;
import com.xxfc.platform.activity.feign.ActivityFeign; import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.user.behavior.common.BehaviorEnum; import com.xxfc.platform.user.behavior.common.BehaviorEnum;
import com.xxfc.platform.user.behavior.dto.ActivityBehaviorDTO;
import com.xxfc.platform.user.behavior.dto.ActivityBehaviorRelationDTO;
import com.xxfc.platform.user.behavior.dto.BehaviorTypeDTO;
import com.xxfc.platform.user.behavior.dto.CustomerBehaviorNoteDTO; import com.xxfc.platform.user.behavior.dto.CustomerBehaviorNoteDTO;
import com.xxfc.platform.user.behavior.entity.CustomerBehaviorNotes; import com.xxfc.platform.user.behavior.entity.CustomerBehaviorNotes;
import com.xxfc.platform.user.behavior.mapper.CustomerBehaviorNotesMapper; import com.xxfc.platform.user.behavior.mapper.CustomerBehaviorNotesMapper;
...@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service; ...@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.time.Instant; import java.time.Instant;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -33,6 +37,12 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe ...@@ -33,6 +37,12 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
private final ActivityFeign activityFeign; private final ActivityFeign activityFeign;
private final BehaviorTypeBiz behaviorTypeBiz;
private final ActivityBehaviorBiz activityBehaviorBiz;
private final ActivityBehaviorRelationBiz activityBehaviorRelationBiz;
public void saveCustomerBehavior(CustomerBehaviorNoteDTO customerBehaviorNoteDTO) { public void saveCustomerBehavior(CustomerBehaviorNoteDTO customerBehaviorNoteDTO) {
CustomerBehaviorNotes customerBehaviorNotes = new CustomerBehaviorNotes(); CustomerBehaviorNotes customerBehaviorNotes = new CustomerBehaviorNotes();
BeanUtils.copyProperties(customerBehaviorNoteDTO, customerBehaviorNotes); BeanUtils.copyProperties(customerBehaviorNoteDTO, customerBehaviorNotes);
...@@ -43,82 +53,186 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe ...@@ -43,82 +53,186 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
public List<BehaviorNoteCollectVo> findBehaviorCollectByActivityId(Integer activityId, Long startTime, Long endTime) { public List<BehaviorNoteCollectVo> findBehaviorCollectByActivityId(Integer activityId, Long startTime, Long endTime) {
List<BehaviorNoteCollectVo> behaviorNoteCollectVos = new ArrayList<>(); List<BehaviorNoteCollectVo> behaviorNoteCollectVos = new ArrayList<>();
List<CustomerBehaviorNotes> customerBehaviorNotes = mapper.selectByActivityIdAndTime(activityId,startTime,endTime);
//获取时间间隔
AtomicLong startAtomic = new AtomicLong(startTime == null ? 0 : startTime);
AtomicLong endAtomic = new AtomicLong(endTime == null ? 0 : endTime);
long between_day = getBetweenDayAndprocessStartTimeAndEndTime(activityId, startAtomic, endAtomic);
between_day = Math.abs(between_day) == 0 ? 1 : Math.abs(between_day);
List<CustomerBehaviorNotes> customerBehaviorNotes = mapper.selectByActivityIdAndTime(activityId, startAtomic.get(), endAtomic.get());
boolean isEmpty = CollectionUtils.isEmpty(customerBehaviorNotes); boolean isEmpty = CollectionUtils.isEmpty(customerBehaviorNotes);
List<ActivityPopularizeRelationDTO> popularizeRelations = new ArrayList<>(); List<ActivityPopularizeRelationDTO> popularizeRelations = new ArrayList<>();
Map<Integer, List<CustomerBehaviorNotes>> behaviorAndDataMap = null; Map<Integer, List<CustomerBehaviorNotes>> behaviorAndDataMap = null;
if (!isEmpty) { if (!isEmpty) {
//邀请成功记录 //邀请成功记录
popularizeRelations= activityFeign.findActivityPopularizeRelationByActivityIdAndTime(activityId, startTime, endTime); popularizeRelations = activityFeign.findActivityPopularizeRelationByActivityIdAndTime(activityId, startAtomic.get(), endAtomic.get());
behaviorAndDataMap= customerBehaviorNotes.stream().collect(Collectors.groupingBy(CustomerBehaviorNotes::getType, Collectors.toList())); behaviorAndDataMap = customerBehaviorNotes.stream().collect(Collectors.groupingBy(CustomerBehaviorNotes::getType, Collectors.toList()));
} }
//根据活动id查询出对应业务id
List<ActivityBehaviorRelationDTO> activityBehaviorRelations = activityBehaviorRelationBiz.findActivityBehaviorRelationsByActivityId(activityId);
List<Integer> bizIds = activityBehaviorRelations.stream().map(ActivityBehaviorRelationDTO::getBizId).collect(Collectors.toList());
//获取时间间隔 //根据业务id查询出行为记录
long between_day = getBetween_day(activityId, startTime, endTime); Map<Integer, List<CustomerBehaviorNotes>> behaviorTypeAndDataOfBizMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(bizIds)) {
List<CustomerBehaviorNotes> customerBehaviorNotesbiz = mapper.selectAllByTypeIdsAndTime(bizIds, startAtomic.get(), endAtomic.get());
//业务数据转换map
if (CollectionUtils.isNotEmpty(customerBehaviorNotesbiz)) {
behaviorTypeAndDataOfBizMap = customerBehaviorNotesbiz.stream().collect(Collectors.groupingBy(CustomerBehaviorNotes::getType, Collectors.toList()));
}
}
//根据活动id查询活动行为
List<ActivityBehaviorDTO> activityBehaviorDTOS = activityBehaviorBiz.findActivityBehaviorsByActivityId(activityId);
if (CollectionUtils.isEmpty(activityBehaviorDTOS)){
return Collections.EMPTY_LIST;
}
List<Integer> behaviorTypeIds = activityBehaviorDTOS.stream().map(ActivityBehaviorDTO::getBehaviorTypeId).collect(Collectors.toList());
//根据活动行为ids查询行为
List<BehaviorTypeDTO> behaviorTypeDTOS = behaviorTypeBiz.findBehaviorTypesByIds(behaviorTypeIds);
List<Integer> behaviorCodes = behaviorTypeDTOS.stream().map(BehaviorTypeDTO::getCode).collect(Collectors.toList());
//过滤出活动行为的枚举类
Set<BehaviorEnum> behaviorEnums = EnumSet.allOf(BehaviorEnum.class).stream().filter(behaviorEnum -> behaviorCodes.contains(behaviorEnum.getCode())).collect(Collectors.toSet());
//数据转换为行为码与行为名称Map
Map<Integer, String> codeAndName = behaviorTypeDTOS.stream().collect(Collectors.toMap(BehaviorTypeDTO::getCode, BehaviorTypeDTO::getName));
between_day = Math.abs(between_day)==0?1:Math.abs(between_day);
EnumSet<BehaviorEnum> behaviorEnums = EnumSet.allOf(BehaviorEnum.class);
BehaviorNoteCollectVo behaviorNoteCollectVo; BehaviorNoteCollectVo behaviorNoteCollectVo;
for (BehaviorEnum behaviorEnum : behaviorEnums) { for (BehaviorEnum behaviorEnum : behaviorEnums) {
behaviorNoteCollectVo = new BehaviorNoteCollectVo(); behaviorNoteCollectVo = new BehaviorNoteCollectVo();
behaviorNoteCollectVo.setBehavior(behaviorEnum.getName()); behaviorNoteCollectVo.setBehavior(codeAndName.get(behaviorEnum.getCode()));
if (isEmpty) { long default_p_total, default_p_avg;
behaviorNoteCollectVos.add(behaviorNoteCollectVo); ActionAcount actionAcount;
continue;
} else {
long default_p_total,default_p_avg,default_u_total,default_u_avg;
switch (behaviorEnum) { switch (behaviorEnum) {
case SUCCESS_INVIT: case SUCCESS_INVIT:
actionAcount = new ActionAcount();
default_p_total = popularizeRelations.size(); default_p_total = popularizeRelations.size();
default_p_avg= (default_p_total / between_day); default_p_avg = (default_p_total / between_day);
default_u_total = default_p_total; actionAcount.setDefault_p_total(default_p_total);
default_u_avg = default_p_avg; actionAcount.setDefault_p_avg(default_p_avg);
actionAcount.setDefault_u_total(default_p_total);
actionAcount.setDefault_u_avg(default_p_avg);
break; break;
case SUCCESS_MORE_10_INVIT: case SUCCESS_MORE_10_INVIT:
actionAcount = new ActionAcount();
default_p_total = 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();
default_p_avg = default_p_total / between_day; default_p_avg = default_p_total / between_day;
default_u_total = default_p_total; actionAcount.setDefault_p_total(default_p_total);
default_u_avg = default_p_avg; actionAcount.setDefault_p_avg(default_p_avg);
actionAcount.setDefault_u_total(default_p_total);
actionAcount.setDefault_u_avg(default_p_avg);
break; break;
default: case APP_VISIT_COUNT:
//访问量 actionAcount = new ActionAcount();
List<CustomerBehaviorNotes> customerBehaviors = behaviorAndDataMap==null?Collections.EMPTY_LIST:behaviorAndDataMap.get(behaviorEnum.getCode()); default_p_total = mapper.selectAppVvisitsByType(BehaviorEnum.APP_VISIT_COUNT.getCode());
boolean typeIsEmpty = CollectionUtils.isEmpty(customerBehaviors);
default_p_total = typeIsEmpty?0:customerBehaviors.size();
default_p_avg = default_p_total / between_day; default_p_avg = default_p_total / between_day;
//用户访问量 actionAcount.setDefault_p_total(default_p_total);
Set<CustomerBehaviorNotes> customerBehaviorsSet = new HashSet<>(typeIsEmpty?Collections.EMPTY_SET:customerBehaviors); actionAcount.setDefault_p_avg(default_p_avg);
default_u_total = customerBehaviorsSet.size(); actionAcount.setDefault_u_total(default_p_total);
default_u_avg = default_u_total / between_day; actionAcount.setDefault_u_avg(default_p_avg);
break;
case BANNER_CLICK:
case WONDERFUL_ACTIVITY_CLICK:
case DIALOG_WINDOW_TO:
case DIALOG_WINDOW:
actionAcount = new ActionAcount(between_day, behaviorTypeAndDataOfBizMap).invoke(behaviorEnum);
break;
default:
actionAcount = new ActionAcount(between_day, behaviorAndDataMap).invoke(behaviorEnum);
break; break;
} }
behaviorNoteCollectVo.setP_count(default_p_total); behaviorNoteCollectVo.setP_count(actionAcount.getDefault_p_total());
behaviorNoteCollectVo.setP_avg_count(default_p_avg); behaviorNoteCollectVo.setP_avg_count(actionAcount.getDefault_p_avg());
behaviorNoteCollectVo.setU_count(default_u_total); behaviorNoteCollectVo.setU_count(actionAcount.getDefault_u_total());
behaviorNoteCollectVo.setU_avg_count(default_u_avg); behaviorNoteCollectVo.setU_avg_count(actionAcount.getDefault_u_avg());
behaviorNoteCollectVos.add(behaviorNoteCollectVo); behaviorNoteCollectVos.add(behaviorNoteCollectVo);
} }
}
return behaviorNoteCollectVos; return behaviorNoteCollectVos;
} }
private long getBetween_day(Integer activityId, Long startTime, Long endTime) { private long getBetweenDayAndprocessStartTimeAndEndTime(Integer activityId, AtomicLong startTime, AtomicLong endTime) {
long between_day = 0; if (startTime.get() == 0 || endTime.get() == 0) {
if (startTime!=null && endTime !=null){
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(startTime), Instant.ofEpochMilli(endTime));
}else {
ActivityListDTO activityListDTO = activityFeign.findActivityStartTimeAndEndTimeById(activityId); ActivityListDTO activityListDTO = activityFeign.findActivityStartTimeAndEndTimeById(activityId);
if (startTime!=null){ Instant now = Instant.now();
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(startTime),Instant.now()); if (startTime.get() != 0) {
endTime.set(now.toEpochMilli());
}
if (endTime.get() != 0) {
startTime.set(activityListDTO.getActivity_startTime());
}
if (startTime.get() == 0 && endTime.get() == 0) {
startTime.set(activityListDTO.getActivity_startTime());
endTime.set(now.toEpochMilli());
} }
if (endTime!=null){
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(activityListDTO.getActivity_startTime()),Instant.ofEpochMilli(endTime));
} }
if (startTime == null && endTime == null){ return ChronoUnit.DAYS.between(Instant.ofEpochMilli(startTime.get()), Instant.ofEpochMilli(endTime.get()));
between_day = ChronoUnit.DAYS.between(Instant.ofEpochMilli(activityListDTO.getActivity_startTime()),Instant.now());
} }
private class ActionAcount {
private long between_day;
private Map<Integer, List<CustomerBehaviorNotes>> behaviorMap;
private long default_p_total;
private long default_p_avg;
private long default_u_total;
private long default_u_avg;
public ActionAcount(long between_day, Map<Integer, List<CustomerBehaviorNotes>> behaviorMap) {
this.between_day = between_day;
this.behaviorMap = behaviorMap;
}
public ActionAcount() {
}
public ActionAcount invoke(BehaviorEnum behaviorEnum) {
List<CustomerBehaviorNotes> behaviorTypeData = behaviorMap.get(behaviorEnum.getCode());
boolean isEmpty = CollectionUtils.isEmpty(behaviorTypeData);
default_p_total = isEmpty ? 0 : behaviorTypeData.size();
default_p_avg = default_p_total / between_day;
Set<CustomerBehaviorNotes> behaviorTypeDataSet = new HashSet<>(isEmpty ? Collections.EMPTY_SET : behaviorTypeData);
default_u_total = behaviorTypeDataSet.size();
default_u_avg = default_u_total / between_day;
return this;
}
public long getDefault_p_total() {
return default_p_total;
}
public long getDefault_p_avg() {
return default_p_avg;
}
public long getDefault_u_total() {
return default_u_total;
}
public long getDefault_u_avg() {
return default_u_avg;
}
public void setBetween_day(long between_day) {
this.between_day = between_day;
}
public void setBehaviorMap(Map<Integer, List<CustomerBehaviorNotes>> behaviorMap) {
this.behaviorMap = behaviorMap;
}
public void setDefault_p_total(long default_p_total) {
this.default_p_total = default_p_total;
}
public void setDefault_p_avg(long default_p_avg) {
this.default_p_avg = default_p_avg;
}
public void setDefault_u_total(long default_u_total) {
this.default_u_total = default_u_total;
}
public void setDefault_u_avg(long default_u_avg) {
this.default_u_avg = default_u_avg;
} }
return between_day;
} }
} }
\ No newline at end of file
package com.xxfc.platform.user.behavior.mapper;
import com.xxfc.platform.user.behavior.dto.ActivityBehaviorDTO;
import com.xxfc.platform.user.behavior.entity.ActivityBehavior;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 14:10
*/
public interface ActivityBehaviorMapper extends Mapper<ActivityBehavior> {
@Select("select `activity_id`,`behavior_type_id` from `activity_behavior` where `activity_id`=#{activityId}")
@Results(value = {
@Result(column = "activity_id",property = "activityId"),
@Result(column = "behavior_type_id",property = "behaviorTypeId")
})
List<ActivityBehaviorDTO> selectbyActivityId(@Param("activityId") Integer activityId);
}
package com.xxfc.platform.user.behavior.mapper;
import com.xxfc.platform.user.behavior.dto.ActivityBehaviorRelationDTO;
import com.xxfc.platform.user.behavior.entity.ActivityBehaviorRelation;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 17:11
*/
public interface ActivityBehaviorRelationMapper extends Mapper<ActivityBehaviorRelation> {
@Select("select `type`,`biz_id`,`activity_id` from `activity_behavior_relation` where `activity_id`=#{activityId}")
@Results(value = {
@Result(property = "type",column = "type"),
@Result(property = "bizId",column = "biz_id"),
@Result(property = "activityId",column = "activity_id")
})
List<ActivityBehaviorRelationDTO> selectAllByActivityId(@Param("activityId") Integer activityId);
}
package com.xxfc.platform.user.behavior.mapper;
import com.xxfc.platform.user.behavior.dto.BehaviorTypeDTO;
import com.xxfc.platform.user.behavior.entity.BehaviorType;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.additional.idlist.IdListMapper;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 14:13
*/
public interface BehaviorTypeMapper extends Mapper<BehaviorType>, IdListMapper<BehaviorType,Integer> {
@Select("<script>select `name`,`code` from behavior_type where `id` in <foreach collection='typeIds' open='(' item='typeId' separator=',' close=')'> #{typeId}</foreach></script>")
@Results(value = {
@Result(column = "name",property = "name"),
@Result(column ="code",property = "code")
})
List<BehaviorTypeDTO> selectAllByIdList(@Param("typeIds") List<Integer> typeIds);
}
...@@ -16,4 +16,8 @@ import java.util.List; ...@@ -16,4 +16,8 @@ import java.util.List;
public interface CustomerBehaviorNotesMapper extends Mapper<CustomerBehaviorNotes> { public interface CustomerBehaviorNotesMapper extends Mapper<CustomerBehaviorNotes> {
List<CustomerBehaviorNotes> selectByActivityIdAndTime(@Param("activityId") Integer activityId,@Param("startTime") Long startTime,@Param("endTime") Long endTime); List<CustomerBehaviorNotes> selectByActivityIdAndTime(@Param("activityId") Integer activityId,@Param("startTime") Long startTime,@Param("endTime") Long endTime);
long selectAppVvisitsByType(@Param("code") int code);
List<CustomerBehaviorNotes> selectAllByTypeIdsAndTime(@Param("bizIds") List<Integer> bizIds,@Param("startTime") Long startTime,@Param("endTime") Long endTime);
} }
...@@ -21,13 +21,13 @@ import java.util.Objects; ...@@ -21,13 +21,13 @@ import java.util.Objects;
* @data 2019/8/12 14:14 * @data 2019/8/12 14:14
*/ */
@RestController @RestController
@RequestMapping("customerBehaviorNotes") @RequestMapping("/customerBehaviorNotes")
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) @RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CustomerBehaviorNotesController { public class CustomerBehaviorNotesController {
private final CustomerBehaviorNotesBiz customerBehaviorNotesBiz; private final CustomerBehaviorNotesBiz customerBehaviorNotesBiz;
@PostMapping("app/unauth/save") @PostMapping("/app/unauth/save")
public ObjectRestResponse<Void> saveCustomerBehavior(@RequestBody CustomerBehaviorNoteDTO customerBehaviorNoteDTO, AppUserDTO appUserDTO) { public ObjectRestResponse<Void> saveCustomerBehavior(@RequestBody CustomerBehaviorNoteDTO customerBehaviorNoteDTO, AppUserDTO appUserDTO) {
if (Objects.nonNull(appUserDTO.getUserid())) { if (Objects.nonNull(appUserDTO.getUserid())) {
customerBehaviorNoteDTO.setCustomerId(String.valueOf(appUserDTO.getUserid())); customerBehaviorNoteDTO.setCustomerId(String.valueOf(appUserDTO.getUserid()));
......
...@@ -26,4 +26,25 @@ ...@@ -26,4 +26,25 @@
and <![CDATA[ `crt_time` <= #{endTime}]]> and <![CDATA[ `crt_time` <= #{endTime}]]>
</if> </if>
</select> </select>
<select id="selectAppVvisitsByType" resultType="long">
select count(id) from `customer_behavior_notes` where `type`=#{code}
</select>
<select id="selectAllByTypeIdsAndTime" resultMap="customerBehaviorNotesMap">
select * from `customer_behavior_notes` where `type_id` in
<foreach collection="bizIds" item="bizId" open="(" close=")" separator=",">
#{bizId}
</foreach>
<if test="startTime != null != null and endTime !=null">
and `crt_time` between #{startTime} and #{endTime}
</if>
<if test="startTime != null and endTime == null">
and <![CDATA[`crt_time` >= #{startTime}]]>
</if>
<if test="endTime != null and startTime == null">
and <![CDATA[ `crt_time` <= #{endTime}]]>
</if>
and `type` in(0,1,2,3)
</select>
</mapper> </mapper>
\ 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