Commit aef33454 authored by hezhen's avatar hezhen

Merge branch 'dev' of http://113.105.137.151:22280/youjj/cloud-platform into dev

parents d7312e81 4cbc45f1
......@@ -29,6 +29,14 @@ public class ResultCode {
// 只能取消预定两个月内的车辆
public static int ONLY_UNBOOK_TWO_MONTH = Integer.valueOf(SystemProperty.getResultConfig("ONLY_UNBOOK_TWO_MONTH"));
// 添加车辆太多
public static int ADD_VEHICLE_MORE = Integer.valueOf(SystemProperty.getResultConfig("ADD_VEHICLE_MORE"));
// 停靠公司不能为空
public static int RET_COMPANY_CAN_NOT_BE_NULL = Integer.valueOf(SystemProperty.getResultConfig("RET_COMPANY_CAN_NOT_BE_NULL"));
// 车牌不能为空
public static int NUMBER_PLAT_CAN_NOT_BE_NULL = Integer.valueOf(SystemProperty.getResultConfig("NUMBER_PLAT_CAN_NOT_BE_NULL"));
// 选择日期不可取消预定
public static int VEHICLE_CAN_NOT_UNBOOK = Integer.valueOf(SystemProperty.getResultConfig("VEHICLE_CAN_NOT_UNBOOK"));
......
......@@ -238,4 +238,13 @@ BOOKED_DATE_IS_EMPTY = 4015
4015 = 预定日期为空
TODAY_CAN_NOT_BOOK = 4016
4016 = 当天不可预定
\ No newline at end of file
4016 = 当天不可预定
ADD_VEHICLE_MORE = 4017
4017 = 添加车辆过多,请分批添加
RET_COMPANY_CAN_NOT_BE_NULL = 4018
4018 = 停靠公司不能为空
NUMBER_PLAT_CAN_NOT_BE_NULL = 4019
4019 = 车牌不能为空
\ No newline at end of file
......@@ -16,6 +16,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.rest.CommonBaseController;
import com.github.wxiaoqi.security.common.util.Query;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -78,13 +79,13 @@ public class UserController extends CommonBaseController {
if (StringUtils.isNotBlank(username)) {
List<User> list = userBiz.getCountByUsername(username);
if (list.size() > 0) {
throw new RuntimeException("用户名不能重复");
}
return ObjectRestResponse.createFailedResult(ResCode.USER_IS_EXIST.getCode(), ResCode.USER_IS_EXIST.getDesc());
}
}
userBiz.insertSelective(vo);
//添加权限关系
groupBiz.modifyUserGroups(vo.getId(), vo.getMembers());
return new ObjectRestResponse();
return ObjectRestResponse.succ();
}
private void handleDataLimit(@RequestBody UserVO dto) {
......@@ -166,12 +167,12 @@ public class UserController extends CommonBaseController {
if (StringUtils.isNotBlank(username)) {
List<User> list = userBiz.getCountByUsername(username);
if (list.size() > 1) {
throw new RuntimeException("用户名不能重复");
return ObjectRestResponse.createFailedResult(ResCode.USER_IS_EXIST.getCode(), ResCode.USER_IS_EXIST.getDesc());
}
if (list.size() == 1) {
User user = list.get(0);
if (!user.getId().equals(vo.getId())) {
throw new RuntimeException("用户名不能重复");
return ObjectRestResponse.createFailedResult(ResCode.USER_IS_EXIST.getCode(), ResCode.USER_IS_EXIST.getDesc());
}
}
}
......
package com.xxfc.platform.activity.dto;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/13 9:59
*/
@Data
public class ActivityListDTO {
private Long activity_startTime;
private Long activity_endTime;
}
package com.xxfc.platform.activity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/12 19:01
*/
@Data
public class ActivityPopularizeRelationDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主用户
*/
@ApiModelProperty(value = "主用户")
private Integer majorUserId;
/**
* 次要用户
*/
@ApiModelProperty(value = "次要用户")
private Integer minorUserId;
}
......@@ -2,6 +2,8 @@ package com.xxfc.platform.activity.feign;
import com.github.wxiaoqi.security.admin.dto.UserInfoDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.activity.dto.ActivityListDTO;
import com.xxfc.platform.activity.dto.ActivityPopularizeRelationDTO;
import com.xxfc.platform.activity.entity.IntegralUserTotal;
import com.xxfc.platform.activity.vo.UserCouponVo;
import io.swagger.annotations.ApiModelProperty;
......@@ -46,18 +48,27 @@ public interface ActivityFeign {
@ApiOperation("优惠卷取消使用")
@RequestMapping(value = "/user/cancelUse", method = RequestMethod.POST)
public ObjectRestResponse cancelUse(@RequestParam(value = "TickerNo",defaultValue ="" ) String TickerNo);
public ObjectRestResponse cancelUse(@RequestParam(value = "TickerNo", defaultValue = "") String TickerNo);
@ApiOperation("新人有礼参加活动")
@RequestMapping(value = "/join/user", method = RequestMethod.POST)
public ObjectRestResponse join(@RequestParam(value = "userId",defaultValue ="0" ) Integer userId);
public ObjectRestResponse join(@RequestParam(value = "userId", defaultValue = "0") Integer userId);
@ApiModelProperty("获取用户积分")
@GetMapping(value = "/user/info")
public UserInfoDTO getUserInfo(@RequestParam("userId") Integer userId);
@ApiOperation("清除数据")
@GetMapping("/activity_data/clear")
ObjectRestResponse<Void> clearDate(@RequestParam(value = "userIds") List<Integer> userIds);
@ApiOperation("清除数据")
@GetMapping("/activity_data/clear")
ObjectRestResponse<Void> clearDate(@RequestParam(value = "userIds") List<Integer> userIds);
@ApiOperation("查询活动邀请数据")
@GetMapping("/activityPopularizeRelation/activity_popularize")
List<ActivityPopularizeRelationDTO> findActivityPopularizeRelationByActivityIdAndTime(@RequestParam(value = "activityId") Integer activityId,
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime);
@ApiOperation("查询活动的时间")
@GetMapping("/activityList/time/{activityId}")
ActivityListDTO findActivityStartTimeAndEndTimeById(@PathVariable(value = "activityId") Integer activityId);
}
package com.xxfc.platform.activity.biz;
import com.xxfc.platform.activity.dto.ActivityListDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.xxfc.platform.activity.entity.ActivityList;
......@@ -10,6 +12,7 @@ import tk.mybatis.mapper.weekend.WeekendSqls;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Objects;
/**
* 活动(活动列表)
......@@ -30,4 +33,14 @@ public class ActivityListBiz extends BaseBiz<ActivityListMapper,ActivityList> {
List<ActivityList> activityLists = selectByExample(exa);
return activityLists;
}
public ActivityListDTO findActivityStartTimeAndEndTimeById(Integer activityId) {
ActivityListDTO activityListDTO = new ActivityListDTO();
ActivityList activityList = mapper.selectByPrimaryKey(activityId);
if (Objects.nonNull(activityList)){
activityListDTO.setActivity_startTime(activityList.getStartTime());
activityListDTO.setActivity_endTime(activityList.getEndTime());
}
return activityListDTO;
}
}
\ No newline at end of file
package com.xxfc.platform.activity.biz;
import com.xxfc.platform.activity.dto.ActivityPopularizeRelationDTO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import com.xxfc.platform.activity.entity.ActivityPopularizeRelation;
import com.xxfc.platform.activity.mapper.ActivityPopularizeRelationMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.util.ArrayList;
import java.util.List;
/**
* 活动的参与者关系表
*
......@@ -15,4 +20,13 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
*/
@Service
public class ActivityPopularizeRelationBiz extends BaseBiz<ActivityPopularizeRelationMapper,ActivityPopularizeRelation> {
public List<ActivityPopularizeRelationDTO> findActivityPopularizeRelationsByActivityIdAndTime(Integer activityId, Long startTime, Long endTime) {
List<ActivityPopularizeRelationDTO> activityPopularizeRelationDTOS = new ArrayList<>();
List<ActivityPopularizeRelationDTO> relations = mapper.findActivityPopularizeRelationsByActivityIdAndTime(activityId, startTime, endTime);
if (CollectionUtils.isNotEmpty(relations)){
activityPopularizeRelationDTOS.addAll(relations);
}
return activityPopularizeRelationDTOS;
}
}
\ No newline at end of file
package com.xxfc.platform.activity.mapper;
import com.xxfc.platform.activity.dto.ActivityPopularizeRelationDTO;
import com.xxfc.platform.activity.entity.ActivityPopularizeRelation;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 活动的参与者关系表
*
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-17 19:51:17
*/
public interface ActivityPopularizeRelationMapper extends Mapper<ActivityPopularizeRelation> {
List<ActivityPopularizeRelationDTO> findActivityPopularizeRelationsByActivityIdAndTime(@Param("activityId") Integer activityId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
}
......@@ -4,12 +4,14 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.activity.biz.ActivityListBiz;
import com.xxfc.platform.activity.biz.HomeActivitiesBiz;
import com.xxfc.platform.activity.dto.ActivityListDTO;
import com.xxfc.platform.activity.entity.ActivityList;
import com.xxfc.platform.activity.entity.ActivityManagement;
import com.xxfc.platform.activity.entity.HomeActivities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -34,4 +36,9 @@ public class ActivityListController extends BaseController<ActivityListBiz,Activ
// List<ActivityList> list= baseBiz.activities();
return ObjectRestResponse.succ(activities);
}
@GetMapping("/time/{activityId}")
public ActivityListDTO findActivityStartTimeAndEndTimeById(@PathVariable(value = "activityId") Integer activityId){
return baseBiz.findActivityStartTimeAndEndTimeById(activityId);
}
}
\ No newline at end of file
......@@ -2,13 +2,26 @@ package com.xxfc.platform.activity.rest;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.activity.biz.ActivityPopularizeRelationBiz;
import com.xxfc.platform.activity.dto.ActivityPopularizeRelationDTO;
import com.xxfc.platform.activity.entity.ActivityPopularizeRelation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("activityPopularizeRelation")
public class ActivityPopularizeRelationController extends BaseController<ActivityPopularizeRelationBiz,ActivityPopularizeRelation> {
@GetMapping("/activity_popularize")
public List<ActivityPopularizeRelationDTO> findActivityPopularizeRelationByActivityIdAndTime(@RequestParam(value = "activityId") Integer activityId,
@RequestParam(value = "startTime",required = false) Long startTime,
@RequestParam(value = "endTime",required = false) Long endTime){
return baseBiz.findActivityPopularizeRelationsByActivityIdAndTime(activityId,startTime,endTime);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxfc.platform.activity.mapper.ActivityPopularizeRelationMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.activity.entity.ActivityPopularizeRelation" id="activityPopularizeRelationMap">
<result property="id" column="id"/>
<result property="crtTime" column="crt_time"/>
<result property="updTime" column="upd_time"/>
<result property="popularizeId" column="popularize_id"/>
<result property="majorUserId" column="major_user_id"/>
<result property="minorUserId" column="minor_user_id"/>
</resultMap>
<select id="findActivityPopularizeRelationsByActivityIdAndTime" resultMap="activityPopularizeRelationMap">
select * from `activity_popularize_relation` where `popularize_id`=#{activityId}
<if test="startTime != 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>
</select>
</mapper>
\ No newline at end of file
......@@ -97,11 +97,11 @@ public class BackStageOrderController extends CommonBaseController implements Us
if (userIds != null && userIds.size() > 0) {
ObjectRestResponse<List<AppUserVo>> objectRestResponse = userFeign.getByUserIds(userIds);
log.info("获取用户信息:objectRestResponse = {}", objectRestResponse.getData());
Map<String, AppUserVo> appUserVoMap = objectRestResponse.getData() == null ? new HashMap<String, AppUserVo>()
: objectRestResponse.getData().parallelStream().collect(Collectors.toMap(v -> v.getUserid().toString().trim(), v -> v));
Map<Integer, AppUserVo> appUserVoMap = objectRestResponse.getData() == null ? new HashMap<Integer, AppUserVo>()
: objectRestResponse.getData().parallelStream().collect(Collectors.toMap(v -> v.getUserid(), v ->v));
for (OrderListVo orderPageVO : list) {
AppUserVo appUserVo = appUserVoMap.get(orderPageVO.getUserId().toString());
AppUserVo appUserVo = appUserVoMap.get(orderPageVO.getUserId());
if (null != appUserVo) {
orderPageVO.setTelephone(appUserVo.getUsername());
orderPageVO.setUsername(appUserVo.getNickname());
......
......@@ -16,7 +16,7 @@ public enum BehaviorEnum {
/**
* 立即前往(弹窗)
*/
DIALOG_WINDOW_TO(1, "立即前往"),
DIALOG_WINDOW_TO(1, "立即前往(活动详情页)"),
/**
* banner 点击
......@@ -33,20 +33,35 @@ public enum BehaviorEnum {
*/
REGISTRY(4, "注册"),
/**
* 活动页面访问量
*/
ACTIVITY_VISITS(5,"活动页面访问"),
/**
* 领取任务
*/
CLAIM_TASK(5, "领取任务"),
CLAIM_TASK(6, "领取任务"),
/**
* 分享
*/
SHARE(6, "分享"),
SHARE(7, "分享"),
/**
* App访问
*/
APP_VISIT_COUNT(8,"App访问量"),
/**
* 成功邀请人数
*/
SUCCESS_INVIT(9,"成功邀请人数"),
/**
* 邀请
* 成功邀请人数大于10
*/
INVITATION(7, "邀请");
SUCCESS_MORE_10_INVIT(10,"成功邀请人数大于10");
BehaviorEnum(int code, String name) {
this.code = code;
......
......@@ -8,6 +8,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;
/**
......@@ -61,4 +62,17 @@ public class CustomerBehaviorNotes implements Serializable {
@Column(name = "request_id")
@ApiModelProperty(value = "请求id")
private String requestId;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CustomerBehaviorNotes that = (CustomerBehaviorNotes) o;
return Objects.equals(customerId, that.customerId);
}
@Override
public int hashCode() {
return Objects.hash(customerId);
}
}
package com.xxfc.platform.user.behavior.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/12 18:32
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class BehaviorNoteCollectVo implements Serializable {
/**
* @see com.xxfc.platform.user.behavior.common.BehaviorEnum + 成功邀请人数 ,邀请人数>=10 ,App 访问量
* 行为
*/
private String behavior;
/**
* 日访问数
*/
private long p_count;
/**
* 日平均访问数
*/
private long p_avg_count;
/**
* 用户每日访问总数
*/
private long u_count;
/**
* 用户每日平均访问总数
*/
private long u_avg_count;
}
......@@ -25,5 +25,11 @@
<artifactId>xx-user-behavior-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-activity-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.xxfc.platform.user.behavior;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import tk.mybatis.spring.annotation.MapperScan;
/**
......@@ -12,6 +13,7 @@ import tk.mybatis.spring.annotation.MapperScan;
* @data 2019/8/12 10:04
*/
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "com.xxfc.platform.*.feign")
@MapperScan(basePackages = "com.xxfc.platform.user.behavior.mapper")
@SpringBootApplication
public class UserBeHaviorApplication {
......
package com.xxfc.platform.user.behavior.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.activity.dto.ActivityListDTO;
import com.xxfc.platform.activity.dto.ActivityPopularizeRelationDTO;
import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.user.behavior.common.BehaviorEnum;
import com.xxfc.platform.user.behavior.dto.CustomerBehaviorNoteDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.xxfc.platform.user.behavior.entity.CustomerBehaviorNotes;
import com.xxfc.platform.user.behavior.mapper.CustomerBehaviorNotesMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.user.behavior.vo.BehaviorNoteCollectVo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
/**
* 用户行为记录表
......@@ -18,12 +28,95 @@ import java.time.Instant;
* @date 2019-08-12 14:03:55
*/
@Service
public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMapper,CustomerBehaviorNotes> {
@RequiredArgsConstructor(onConstructor = @__({@Autowired}))
public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMapper, CustomerBehaviorNotes> {
private final ActivityFeign activityFeign;
public void saveCustomerBehavior(CustomerBehaviorNoteDTO customerBehaviorNoteDTO) {
CustomerBehaviorNotes customerBehaviorNotes = new CustomerBehaviorNotes();
BeanUtils.copyProperties(customerBehaviorNoteDTO,customerBehaviorNotes);
BeanUtils.copyProperties(customerBehaviorNoteDTO, customerBehaviorNotes);
customerBehaviorNotes.setCrtTime(Instant.now().toEpochMilli());
mapper.insertSelective(customerBehaviorNotes);
}
public List<BehaviorNoteCollectVo> findBehaviorCollectByActivityId(Integer activityId, Long startTime, Long endTime) {
List<BehaviorNoteCollectVo> behaviorNoteCollectVos = new ArrayList<>();
List<CustomerBehaviorNotes> customerBehaviorNotes = mapper.selectByActivityIdAndTime(activityId,startTime,endTime);
boolean isEmpty = CollectionUtils.isEmpty(customerBehaviorNotes);
List<ActivityPopularizeRelationDTO> popularizeRelations = new ArrayList<>();
Map<Integer, List<CustomerBehaviorNotes>> behaviorAndDataMap = null;
if (!isEmpty) {
//邀请成功记录
popularizeRelations= activityFeign.findActivityPopularizeRelationByActivityIdAndTime(activityId, startTime, endTime);
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());
}
}
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) {
behaviorNoteCollectVo = new BehaviorNoteCollectVo();
behaviorNoteCollectVo.setBehavior(behaviorEnum.getName());
if (isEmpty) {
behaviorNoteCollectVos.add(behaviorNoteCollectVo);
continue;
} else {
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);
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);
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);
//用户访问量
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);
break;
}
behaviorNoteCollectVos.add(behaviorNoteCollectVo);
}
}
return behaviorNoteCollectVos;
}
}
\ No newline at end of file
package com.xxfc.platform.user.behavior.mapper;
import com.xxfc.platform.user.behavior.entity.CustomerBehaviorNotes;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 用户行为记录表
*
......@@ -11,5 +14,6 @@ import tk.mybatis.mapper.common.Mapper;
* @date 2019-08-12 14:03:55
*/
public interface CustomerBehaviorNotesMapper extends Mapper<CustomerBehaviorNotes> {
List<CustomerBehaviorNotes> selectByActivityIdAndTime(@Param("activityId") Integer activityId,@Param("startTime") Long startTime,@Param("endTime") Long endTime);
}
package com.xxfc.platform.user.behavior.rest.admin;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.user.behavior.biz.CustomerBehaviorNotesBiz;
import com.xxfc.platform.user.behavior.vo.BehaviorNoteCollectVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description 用户行为日志*后台统计
* @description 用户行为日志*后台统计
* @data 2019/8/12 15:16
*/
@RestController
......@@ -19,4 +22,11 @@ public class CustomerBehaviorNotesAdminController {
private final CustomerBehaviorNotesBiz customerBehaviorNotesBiz;
@GetMapping("/collect/{activityId}")
public ObjectRestResponse<List<BehaviorNoteCollectVo>> findCollectByActivityId(@PathVariable(value = "activityId") Integer activityId,
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime) {
List<BehaviorNoteCollectVo> behaviorNoteCollectVos = customerBehaviorNotesBiz.findBehaviorCollectByActivityId(activityId, startTime, endTime);
return ObjectRestResponse.succ(behaviorNoteCollectVos);
}
}
......@@ -3,7 +3,7 @@
<mapper namespace="com.xxfc.platform.user.behavior.mapper.CustomerBehaviorNotesMapper">
<!-- 可根据自己的需求,是否要使用 -->
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.user.behavior.entity.CustomerBehaviorNotes" id="customerBehaviorNotesMap">
<result property="id" column="id"/>
<result property="customerId" column="customer_id"/>
......@@ -11,5 +11,19 @@
<result property="type" column="type"/>
<result property="typeId" column="type_id"/>
<result property="crtTime" column="crt_time"/>
<result property="requestId" column="request_id"/>
</resultMap>
<select id="selectByActivityIdAndTime" resultMap="customerBehaviorNotesMap">
select * from `customer_behavior_notes` where `type_id`=#{activityId}
<if test="startTime != 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>
</select>
</mapper>
\ No newline at end of file
......@@ -53,6 +53,7 @@ public enum ResCode {
ORDER_DETAIL_IS_NOT_EXIST(10001, "订单详情不可查询"),
YOU_AUTH_FAIL(-2,"无权限查看此信息"),
ORDER_IS_NOT_PAY(10002, "订单未支付"),
USER_IS_EXIST(10003, "用户名已存在");
;
/**
* 返回码
......
......@@ -2,9 +2,9 @@ package com.xxfc.platform.vehicle.biz;
import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.constant.ConstantType;
import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.entity.Constant;
......@@ -159,7 +159,7 @@ public class ConstantBiz extends BaseBiz<ConstantMapper,Constant> {
return Boolean.FALSE;
}
if(constants.size()>MAX_BATCH_SIZE_CONSTANT_UPDATE){
throw new IllegalArgumentException(" exceed max batch size");
throw new BaseException(" exceed max batch size");
}
return Boolean.TRUE;
......@@ -198,7 +198,7 @@ public class ConstantBiz extends BaseBiz<ConstantMapper,Constant> {
return 0;
}
if(codes.size()>MAX_BATCH_SIZE_CONSTANT_UPDATE){
throw new IllegalArgumentException(" exceed max batch size");
throw new BaseException(" exceed max batch size");
}
List<String> delCodes = Lists.newArrayList();
for(Integer code:codes){
......@@ -242,12 +242,12 @@ public class ConstantBiz extends BaseBiz<ConstantMapper,Constant> {
*/
public Boolean checkIfExists(Integer type,Integer code){
if(!ConstantType.exists(type)){
throw new CustomIllegalParamException(" no such type of constant");
throw new BaseException(" no such type of constant");
}
List<ConstantVo> constantVoList = getAllConstantByType(type);
if(CollectionUtils.isEmpty(constantVoList)){
throw new CustomIllegalParamException(" no such code of constant in relative type");
throw new BaseException(" no such code of constant in relative type");
}
for(ConstantVo constantVo:constantVoList){
......@@ -255,7 +255,7 @@ public class ConstantBiz extends BaseBiz<ConstantMapper,Constant> {
return Boolean.TRUE;
}
}
throw new CustomIllegalParamException(" no such code of constant in relative type");
throw new BaseException(" no such code of constant in relative type");
}
}
......@@ -3,8 +3,8 @@ package com.xxfc.platform.vehicle.biz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.constant.RegionType;
import com.xxfc.platform.vehicle.entity.SysRegion;
......@@ -42,7 +42,7 @@ public class SysRegionBiz extends BaseBiz<SysRegionMapper, SysRegion> {
public List<SysRegion> getRegionsByCodes(List<Long> ids){
List<String> redisCacheKeys = Lists.newArrayList();
if(CollectionUtils.isEmpty(ids)){
throw new CustomIllegalParamException("empty id list");
throw new BaseException("empty id list");
}
for(Long id:ids){
redisCacheKeys.add(RedisKey.SYS_REGION_CACHE_PREFIX+id);
......
......@@ -208,7 +208,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public RestResponse add(List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception{
if(addOrUpdateVehicleVoList.size()>MAX_BATCH_SIZE_VEHICLE){
throw new CustomIllegalParamException("添加的车辆数量过多!");
throw new BaseException(ResultCode.ADD_VEHICLE_MORE);
}
for(AddOrUpdateVehicleVo addOrUpdateVehicleVo:addOrUpdateVehicleVoList) {
......@@ -217,7 +217,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
BeanUtilsBean.getInstance().copyProperties(vehicle, addOrUpdateVehicleVo);
if (addOrUpdateVehicleVo.getParkBranchCompanyId()==null) {
throw new CustomIllegalParamException("停靠公司不能为空");
throw new BaseException(ResultCode.RET_COMPANY_CAN_NOT_BE_NULL);
}
vehicle.setId(UUID.randomUUID().toString());
......@@ -251,7 +251,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
// }
if(addOrUpdateVehicleVo.getNumberPlate() == null){
throw new CustomIllegalParamException("车牌不能为空");
throw new BaseException(ResultCode.NUMBER_PLAT_CAN_NOT_BE_NULL);
}
List<Vehicle> vehicles = mapper.lockByCode(addOrUpdateVehicleVo);
return vehicles;
......@@ -265,14 +265,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
@Transactional
public RestResponse update(List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception{
if(addOrUpdateVehicleVoList.size()>MAX_BATCH_SIZE_VEHICLE){
throw new CustomIllegalParamException("exceed max batch size");
throw new BaseException(ResultCode.ADD_VEHICLE_MORE);
}
for(AddOrUpdateVehicleVo addOrUpdateVehicleVo:addOrUpdateVehicleVoList){
Vehicle vehicle = new Vehicle();
BeanUtilsBean.getInstance().copyProperties(vehicle, addOrUpdateVehicleVo);
if (addOrUpdateVehicleVo.getParkBranchCompanyId()==null) {
throw new CustomIllegalParamException("Stop at branch office cannot be empty");
throw new BaseException(ResultCode.RET_COMPANY_CAN_NOT_BE_NULL);
}
//悲观锁,检查是否已存在车牌或编码
......@@ -305,7 +305,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
*/
public RestResponse discard(List<String> idList){
if(idList.size()>MAX_BATCH_SIZE_VEHICLE){
throw new CustomIllegalParamException("exceed max batch size");
throw new BaseException(ResultCode.ADD_VEHICLE_MORE);
}
Map<String,Object> params = Maps.newHashMap();
params.put("idList",idList);
......@@ -341,7 +341,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" you can only within 2 month");
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey());
......@@ -427,7 +427,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
//检查车辆是否可以预定
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -470,7 +470,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//修改相关车辆预定记录
Boolean hasSuc = bookedVehicle(bookVehicleVo);
if(!hasSuc){
throw new BaseException("车辆预定失败");
throw new BaseException(ResultCode.BOOKED_FAILED_CODE);
}
//添加随车物品
......@@ -511,7 +511,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey());
......@@ -607,7 +607,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
VehicleBookRecord vehicleBookRecord = vehicleBookRecordBiz.selectById(bookRecordId);
//申请记录验证
if(vehicleBookRecord == null){
throw new CustomIllegalParamException(" invalid book record");
return RestResponse.codeAndMessage(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
}
if(!VehicleBookRecordStatus.APPLY.getCode().equals(vehicleBookRecord.getStatus())){
return RestResponse.code(ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getCode());
......@@ -663,7 +663,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
VehicleBookRecord vehicleBookRecord = vehicleBookRecordBiz.selectById(bookRecordId);
//申请记录验证
if(vehicleBookRecord == null){
throw new CustomIllegalParamException(" invalid book record");
return RestResponse.codeAndMessage(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
}
//已通过审核的可以取消预定
if(!VehicleBookRecordStatus.APPROVE.getCode().equals(vehicleBookRecord.getStatus())){
......@@ -679,7 +679,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//取消预定
Boolean hasSuc = unbookVehicle(bookVehicleVo);
if(!hasSuc){
throw new IllegalArgumentException(" invalid book record ");
return RestResponse.codeAndMessage(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
}
//修改预定状态,写入取消人
Map<String,Object> updateParam = Maps.newHashMap();
......@@ -751,7 +751,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
Boolean rs = Boolean.TRUE;
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -789,7 +789,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
params.put("yearMonth",yearMonth);
//加入更新条件
if(CollectionUtils.isEmpty(bookedDates)){
throw new CustomIllegalParamException(" there are no day to book");
throw new BaseException(ResultCode.BOOKED_DATE_IS_EMPTY);
}
Map<String,List<String>> yearMonthAndDate = new HashMap<>();
yearMonthAndDate.put(vehicleBookInfo.getYearMonth(),bookedDates);
......@@ -1043,10 +1043,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map<String,List<String>> yearMonthAndDateNotBooked = new HashMap<>();//未预定年月 - 未预定日期列表
classifyByYearMonth(notBookedDates,yearMonthAndDateNotBooked,allYearMonth);
if(allYearMonth.size()>0 && params.get("subordinateBranch") == null){
throw new CustomIllegalParamException(" <subordinateBranch> must included in params while using <bookedInfo> param. ");
throw new BaseException(" <subordinateBranch> must included in params while using <bookedInfo> param. ");
}
if(allYearMonth.size()>MAX_MONTH_COUNT_BOOKED_INFO_QUERY){
throw new CustomIllegalParamException(" only 3 month can be included <bookedInfo> param.");
throw new BaseException(" only 3 month can be included <bookedInfo> param.");
}
//加入预定信息查询条件
fillBookedDateSearchParam(params,yearMonthAndDate,yearMonthAndDateNotBooked);
......
......@@ -3,10 +3,10 @@ package com.xxfc.platform.vehicle.biz;
import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.VehicleBookHourInfo;
import com.xxfc.platform.vehicle.mapper.VehicleBookHourInfoMapper;
......@@ -39,15 +39,15 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
startDate = simpleDateFormat.parse(bookStartDate);
endDate = simpleDateFormat.parse(bookEndDate);
}catch (Exception e) {
e.printStackTrace();
}
//判定时间是否合法
if (bookStartDate.compareTo(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER)) < 0) {
throw new CustomIllegalParamException(ResultCode.getMsg(ResultCode.ONLY_BOOK_FROM_TODAY));
throw new BaseException(ResultCode.ONLY_BOOK_FROM_TODAY);
}
if (bookStartDate.compareTo(bookEndDate) > 0) {
throw new CustomIllegalParamException("预定开始日期不能大于结束日期!");
throw new BaseException(ResultCode.ONLY_BOOK_FROM_TODAY);
}
Map<String, Integer> predictableHours = Maps.newHashMap();
//预定开始小时
......
......@@ -12,7 +12,6 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.BookType;
import com.xxfc.platform.vehicle.constant.RedisKey;
......@@ -273,7 +272,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
if(params.get("selectedMonth") != null) {
String selectedMonth = (String)params.get("selectedMonth");
if(StringUtils.isBlank(selectedMonth)){
throw new CustomIllegalParamException(" no month selected ");
throw new BaseException("no month selected ");
}
DateTime selectedMonthDate = DateTime.parse(selectedMonth,YEARMONTH_DATE_TIME_FORMATTER);
if(selectedMonthDate.compareTo(DateTime.now().plusMonths(-1).withDayOfMonth(1).withMillisOfDay(0)) < 0){
......
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