Browse Source

Merge remote-tracking branch 'origin/feature/points' into feature/points

feature/syp_points
liuchuang 5 years ago
parent
commit
ef1eefd355
  1. 126
      esua-epdc/epdc-commons/epdc-commons-points-tools/pom.xml
  2. 44
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/annotation/RecordUserBehavior.java
  3. 161
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/aop/UserBehaviorAop.java
  4. 71
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/BehaviorResultDto.java
  5. 90
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/PointsLogsAddFormDTO.java
  6. 61
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/PointsLogsFormDTO.java
  7. 122
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/PointsLogsResultDTO.java
  8. 49
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/PointsLogsSumResultDTO.java
  9. 122
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/PointsRuleResultDTO.java
  10. 360
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/UserDTO.java
  11. 32
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/feign/PointsFeignClient.java
  12. 23
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/feign/fallback/PointsFeignClientFallback.java
  13. 44
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/rocketmq/dto/BehaviorDto.java
  14. 41
      esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/rocketmq/producer/PointsProducer.java
  15. 11
      esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/Constant.java
  16. 22
      esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/RedisConstant.java
  17. 10
      esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/RocketMqConstant.java
  18. 215
      esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/enums/BehaviorEnum.java
  19. 1
      esua-epdc/epdc-commons/pom.xml
  20. 2
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java
  21. 3
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java
  22. 8
      esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNewsBrowseFromDTO.java
  23. 26
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppNewsController.java
  24. 360
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/UserDTO.java
  25. 89
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/PointsLogsAddFormDTO.java
  26. 24
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/PointsLogsFormDTO.java
  27. 50
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/PointsLogsSumResultDTO.java
  28. 4
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/PointsRuleResultDTO.java
  29. 11
      esua-epdc/epdc-module/epdc-points/epdc-points-server/pom.xml
  30. 45
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsController.java
  31. 10
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsBehaviorDao.java
  32. 31
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsLogsDao.java
  33. 13
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsRuleDao.java
  34. 28
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/entity/PointsLogsEntity.java
  35. 43
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/feign/UsersFeignClient.java
  36. 26
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/feign/fallback/UsersFeignClientFallback.java
  37. 261
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/mq/PointsModifyConsumer.java
  38. 44
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/mq/dto/BehaviorDto.java
  39. 13
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsBehaviorService.java
  40. 33
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsLogsService.java
  41. 13
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsRuleService.java
  42. 20
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsBehaviorServiceImpl.java
  43. 26
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsLogsServiceImpl.java
  44. 22
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsRuleServiceImpl.java
  45. 12
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/application.yml
  46. 37
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsBehaviorDao.xml
  47. 89
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsLogsDao.xml
  48. 10
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsRuleDao.xml
  49. 5
      esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/UserDTO.java
  50. 6
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/UserEntity.java

126
esua-epdc/epdc-commons/epdc-commons-points-tools/pom.xml

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.esua.epdc</groupId>
<artifactId>epdc-commons</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>epdc-commons-points-tools</artifactId>
<packaging>jar</packaging>
<properties>
<hibernate.validator.version>6.0.12.Final</hibernate.validator.version>
<commons.lang.version>3.7</commons.lang.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version>
<commons.io.version>2.6</commons.io.version>
<hutool.version>4.1.8</hutool.version>
<easypoi.version>3.1.0</easypoi.version>
<joda.time.version>2.9.9</joda.time.version>
<fastjson.version>1.2.59</fastjson.version>
<jsoup.version>1.11.3</jsoup.version>
<lombok.version>1.18.4</lombok.version>
</properties>
<dependencies>
<dependency>
<groupId>com.esua.epdc</groupId>
<artifactId>epdc-commons-tools</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang.version}</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons.fileupload.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>${easypoi.version}</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>${easypoi.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda.time.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>${jsoup.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
</build>
</project>

44
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/annotation/RecordUserBehavior.java

@ -0,0 +1,44 @@
package com.elink.esua.epdc.pointcommons.tools.annotation;
import com.elink.esua.epdc.commons.tools.enums.BehaviorEnum;
import java.lang.annotation.*;
/**
* 积分埋点注解
*
* @author songyunpeng
* @Date 20-04-28
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Inherited
@Documented
public @interface RecordUserBehavior {
/**
* 用户行为
*
* @return
*/
BehaviorEnum behavior();
/**
* 引用标识
*
* @return
*/
String referenceId() default "";
/**
* 用户ID
*
* @return
*/
String userId() default "";
}

161
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/aop/UserBehaviorAop.java

@ -0,0 +1,161 @@
package com.elink.esua.epdc.pointcommons.tools.aop;
import com.alibaba.fastjson.JSONObject;
import com.elink.esua.epdc.commons.tools.constant.Constant;
import com.elink.esua.epdc.commons.tools.constant.RedisConstant;
import com.elink.esua.epdc.commons.tools.constant.RocketMqConstant;
import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.pointcommons.tools.dto.BehaviorResultDto;
import com.elink.esua.epdc.pointcommons.tools.rocketmq.dto.BehaviorDto;
import com.elink.esua.epdc.pointcommons.tools.rocketmq.producer.PointsProducer;
import com.elink.esua.epdc.pointcommons.tools.annotation.RecordUserBehavior;
import com.elink.esua.epdc.pointcommons.tools.feign.PointsFeignClient;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
/**
* 积分埋点切面
*
* @author songyunpeng
* @Date 20-04-28
*/
@Aspect
@Component
public class UserBehaviorAop {
@Autowired
private RedisUtils redisUtils;
@Autowired
private PointsFeignClient pointsFeignClient;
@Autowired
private PointsProducer pointsProducer;
/**
* 使用org.slf4j.Logger,这是Spring实现日志的方法
*/
private final Logger logger = LogManager.getLogger(getClass());
/**
* 定义AOP扫描路径
* 第一个注解只扫描aopTest方法
*/
@Pointcut("@annotation(com.elink.esua.epdc.pointcommons.tools.annotation.RecordUserBehavior)")
public void recordUserBehavior() {
}
/**
* 前置
*/
@Before("recordUserBehavior()")
public void deBefore(JoinPoint joinPoint) {
this.businessLogic(joinPoint, 0);
}
/**
* 后置
* description:
* 1.从redis根据用户动作编码拿取动作信息用来判断是前置还是后置执行
* 2.组装基本信息动作编码用户信息业务关联信息业务ID-- 发送mq消息
* 3.points模块 订阅消息消费消息进行积分操作
*/
@After("recordUserBehavior()")
public void doRecord(JoinPoint joinPoint) {
this.businessLogic(joinPoint, 1);
}
private String covertData(String userIdKey, Object[] args, String[] argNames) {
String referenceId = userIdKey;
if (userIdKey.startsWith("#")) {
String expression = userIdKey.substring(2, userIdKey.length() - 1);
String[] strArr = expression.split("\\.");
if (strArr.length > 2 || strArr.length == 0) {
throw new RenException("格式不正确");
}
if (strArr.length == 1) {
for (int i = 0; i < argNames.length; i++) {
if (argNames[i].equals(strArr[0])) {
return String.valueOf(args[i]);
}
}
} else if (strArr.length == 2) {
for (int i = 0; i < argNames.length; i++) {
if (argNames[i].equals(strArr[0])) {
Object obj = args[i];
try {
Method method = obj.getClass().getDeclaredMethod(strArr[1]);
return String.valueOf(method.invoke(obj));
} catch (Exception e) {
throw new RenException("反射失败");
}
}
}
}
}
return referenceId;
}
/**
* @return
* @Description 封装业务逻辑 way0 前置 1 后置
* @Author songyunpeng
* @Date 2020/4/28
* @Param
**/
private void businessLogic(JoinPoint joinPoint, Integer way) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
RecordUserBehavior recordUserBehavior = method.getAnnotation(RecordUserBehavior.class);
Object[] args = joinPoint.getArgs();
String[] argNames = ((MethodSignature) joinPoint.getSignature()).getParameterNames();
String behaviorCode = recordUserBehavior.behavior().getValue();
//从redis获取动作信息
Object obj = redisUtils.get(RedisConstant.BEHAVIOR_CODE + behaviorCode);
String behaviorRecodingTime = "";
if (obj == null) {
//如果redis是null,则从数据库获取
Result<BehaviorResultDto> result = pointsFeignClient.getBehaviorCodeInfo(behaviorCode);
BehaviorResultDto behaviorResultDto = result.getData();
if (behaviorResultDto == null) {
return;
}
behaviorRecodingTime = behaviorResultDto.getBehaviorRecordingTime();
//将对象存入redis
redisUtils.set(RedisConstant.BEHAVIOR_CODE + behaviorCode, behaviorResultDto);
} else {
BehaviorResultDto behaviorResultDto = ConvertUtils.sourceToTarget(obj, BehaviorResultDto.class);
behaviorRecodingTime = String.valueOf(behaviorResultDto.getBehaviorRecordingTime());
}
//判断前后置
//前置方法调用 如果是前置,但是动作要求后置则直接返回
if (way == 0 && Constant.BEHAVIOR_RECORDING_TIME_AFTER.equals(behaviorRecodingTime)) {
return;
} else if (way == 1 && Constant.BEHAVIOR_RECORDING_TIME_BEFORE.equals(behaviorRecodingTime)) {
return;
}
//组装基本信息
String referenceId = this.covertData(recordUserBehavior.referenceId(), args, argNames);
String userId = this.covertData(recordUserBehavior.userId(), args, argNames);
BehaviorDto behaviorDto = new BehaviorDto();
behaviorDto.setBehavior(behaviorCode);
behaviorDto.setReferenceId(referenceId);
behaviorDto.setUserId(userId);
//发送mq
pointsProducer.sendMessage(RocketMqConstant.MQ_TOPIC_POINTS, RocketMqConstant.MQ_TAG_POINTS, referenceId, JSONObject.toJSONString(behaviorDto));
}
}

71
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/BehaviorResultDto.java

@ -0,0 +1,71 @@
package com.elink.esua.epdc.pointcommons.tools.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @author songyunpeng
* @Description
* @create 2020-04-28
*/
@Data
public class BehaviorResultDto implements Serializable {
private static final long serialVersionUID = 5458618984429715932L;
/**
* ID
*/
private String id;
/**
* 动作编码
*/
private String behaviorCode;
/**
* 动作描述
*/
private String behaviorDesc;
/**
* 动作记录时机 0-方法执行前1-方法执行后
*/
private String behaviorRecordingTime;
/**
* 备注
*/
private String remark;
/**
* 乐观锁
*/
private Integer revision;
/**
* 删除标识 0-1-
*/
private String delFlag;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

90
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/PointsLogsAddFormDTO.java

@ -0,0 +1,90 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.pointcommons.tools.dto;
import lombok.Data;
import java.util.Date;
/**
* 积分记录表 添加
*
* @author songyunpeng
* @since v1.0.0 2020-04-29
*/
@Data
public class PointsLogsAddFormDTO {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private String userId;
/**
* 用户昵称
*/
private String nickname;
/**
* 关联表ID
*/
private String referenceId;
/**
* 积分规则编码
*/
private String ruleCode;
/**
* 积分行为编码
*/
private String behaviorCode;
/**
* 积分操作类型 0-减积分1-加积分
*/
private String operationType;
/**
* 操作积分值
*/
private Integer points;
/**
* 操作描述
*/
private String operationDesc;
/**
* 操作时间
*/
private Date operationTime;
/**
* 操作方式 user-用户操作admin-管理员操作sys-系统操作
*/
private String operationMode;
/**
* 剩余积分值
*/
private Integer lavePoints;
}

61
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/PointsLogsFormDTO.java

@ -0,0 +1,61 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.pointcommons.tools.dto;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 积分记录查询 参数
*
* @author elink elink@elink-cn.com
* @since v1.0.0 2020-04-29
*/
@Data
public class PointsLogsFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private String userId;
/**
* 关联表ID
*/
private String referenceId;
/**
* 积分行为编码
*/
private String behaviorCode;
/**
* 上限日期标识
*/
private String operationFlag;
/**
* 上限值
*/
private Integer upperLimitVal;
}

122
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/PointsLogsResultDTO.java

@ -0,0 +1,122 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.pointcommons.tools.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 积分记录表 积分记录表
*
* @author elink elink@elink-cn.com
* @since v1.0.0 2020-04-29
*/
@Data
public class PointsLogsResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private String id;
/**
* 用户ID
*/
private String userId;
/**
* 关联表ID
*/
private String referenceId;
/**
* 积分规则编码
*/
private String ruleCode;
/**
* 积分行为编码
*/
private String behaviorCode;
/**
* 积分操作类型 0-减积分1-加积分
*/
private String operationType;
/**
* 操作积分值
*/
private Integer points;
/**
* 操作描述
*/
private String operationDesc;
/**
* 操作时间
*/
private Date operationTime;
/**
* 操作方式 user-用户操作admin-管理员操作sys-系统操作
*/
private String operationMode;
/**
* 剩余积分值
*/
private Integer lavePoints;
/**
* 乐观锁
*/
private Integer revision;
/**
* 删除标识 0-1-
*/
private String delFlag;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

49
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/PointsLogsSumResultDTO.java

@ -0,0 +1,49 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.pointcommons.tools.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 一定时限内的积分总和返回
*
* @author elink elink@elink-cn.com
* @since v1.0.0 2020-04-29
*/
@Data
public class PointsLogsSumResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 总和
*/
private Integer total;
/**
* 操作时间
*/
private Date operationTime;
}

122
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/PointsRuleResultDTO.java

@ -0,0 +1,122 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.pointcommons.tools.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 积分规则管理表 积分规则管理表
*
* @author zhangyong
* @since v1.0.0 2020-04-28
*/
@Data
public class PointsRuleResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private String id;
/**
* 积分规则编码
*/
private String ruleCode;
/**
* 动作编码
*/
private String behaviorCode;
/**
* 积分规则描述
*/
private String ruleDesc;
/**
* 规则操作类型 0-减积分1-加积分
*/
private String operationType;
/**
* 积分规则值
*/
private Integer points;
/**
* 上线统计指标 0-分钟1-小时2-3-4-
*/
private String limitType;
/**
* 积分上限值
*/
private Integer upperLimitVal;
/**
* 启用标识 0-1-
*/
private String enableFlag;
/**
* 附加值
*/
private String addedVal;
/**
* 备注
*/
private String remark;
/**
* 乐观锁
*/
private Integer revision;
/**
* 删除标识 0-1-
*/
private String delFlag;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

360
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/dto/UserDTO.java

@ -0,0 +1,360 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.pointcommons.tools.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 用户信息表
*
* @author qu qu@gmail.com
* @since v1.0.0 2019-09-02
*/
@Data
public class UserDTO implements Serializable {
private static final long serialVersionUID = 915598602233599300L;
/**
* 主键
*/
private String id;
/**
* 昵称
*/
private String nickname;
/**
* 手机号
*/
private String mobile;
/**
* 密码
*/
private String password;
/**
* 认证时间
*/
private Date registerTime;
/**
* 头像
*/
private String faceImg;
/**
* 性别(女性-0男性-1)
* {@link com.elink.esua.epdc.commons.tools.enums.UserSexEnum}
*/
private String sex;
/**
* 生日
*/
private Date birthday;
/**
* 邮箱
*/
private String email;
/**
* 电话
*/
private String telephone;
/**
* 邮编
*/
private String zipCode;
/**
* 职业
*/
private String profession;
/**
* 爱好
*/
private String hobbies;
/**
* 个性签名
*/
private String userSign;
/**
* 邀请码
*/
private String invitationCode;
/**
* 最近登录时间
*/
private Date lastLoginTime;
/**
* 最近登录IP
*/
private String lastLoginIp;
/**
* 最近登录位置经度
*/
private String lastLongitude;
/**
* 最近登录位置维度
*/
private String lastLatitude;
/**
* 真实姓名
*/
private String realName;
/**
* 身份证号
*/
private String identityNo;
/**
* 所在道路如山东路168号
*/
private String road;
/**
* 小区名称
*/
private String villageName;
/**
* 住处楼栋-单元-房间
*/
private String dwellingPlace;
/**
* 居民住址
*/
private String address;
/**
* 微信OPENID
*/
private String wxOpenId;
/**
* 微信unionId
*/
private String wxUnionId;
/**
* 是否是党员(0-1-)
*/
private String partyFlag;
/**
* 注册方式wx微信注册
*/
private String registerWay;
/**
* 用户来源(wp:公众号)
*/
private String registerSource;
/**
* 手机号所属省份
*/
private String mobileProvince;
/**
* 手机号所属城市
*/
private String mobileCity;
/**
* 手机号所属运营商
*/
private String mobileCarrier;
/**
* 用户积分
*/
private Integer points;
/**
* 用户累计
*/
private Integer points_totle;
/**
* 邀请人ID
*/
private String inviteUserId;
/**
* 状态参考枚举类{@link com.elink.esua.epdc.enums.AppUserStatesEnum}
*/
private String state;
/**
* 区县
*/
private String district;
/**
* 区县ID
*/
private Long districtId;
/**
* 街道
*/
private String street;
/**
* 街道ID
*/
private Long streetId;
/**
* 社区
*/
private String community;
/**
* 社区ID
*/
private Long communityId;
/**
* 网格
*/
private String grid;
/**
* 网格ID
*/
private Long gridId;
/**
* 删除标记
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 注册时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
/**
*
*/
private String lastName;
/**
*
*/
private String firstName;
/**
* 干部下沉 0不
*/
private String cadreFlag;
/**
* 党员标签
*/
private String tagIds;
/**
* 审核备注
*/
private String remark;
/**
* 是否是网格长
*/
private String leaderFlag;
/**
* 认证历史-累计提交认证次数
*/
private Integer totalSubmitNum;
/**
* 认证历史-通过次数
*/
private Integer totalPassSubmitNum;
/**
* 认证历史-不通过次数
*/
private Integer totalFailNum;
/**
* 居住网格id
*/
private Long deptId;
/**
* 父所有部门
*/
private String parentDeptIds;
/**
* 父所有部门
*/
private String parentDeptNames;
/**
* 所有部门ID
*/
private String allDeptIds;
/**
* 所有部门名称
*/
private String allDeptNames;
}

32
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/feign/PointsFeignClient.java

@ -0,0 +1,32 @@
package com.elink.esua.epdc.pointcommons.tools.feign;
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.pointcommons.tools.dto.*;
import com.elink.esua.epdc.pointcommons.tools.feign.fallback.PointsFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author songyunpeng
* @date 2020/04/28
*/
@FeignClient(name = ServiceConstant.EPDC_POINTS_SERVER, fallback = PointsFeignClientFallback.class, url = "http://127.0.0.1:9070")
public interface PointsFeignClient {
/**
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.lang.String>
* @Description 获取动作编码信息
* @Author songyunpeng
* @Date 2020/4/28
* @Param [behaviorCode]
**/
@PostMapping(value = "points/points/getBehaviorCodeInfo/{behaviorCode}", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<BehaviorResultDto> getBehaviorCodeInfo(@PathVariable String behaviorCode);
}

23
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/feign/fallback/PointsFeignClientFallback.java

@ -0,0 +1,23 @@
package com.elink.esua.epdc.pointcommons.tools.feign.fallback;
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.pointcommons.tools.dto.*;
import com.elink.esua.epdc.pointcommons.tools.feign.PointsFeignClient;
import org.springframework.stereotype.Component;
/**
* @author songyunpeng
* @date 2020/4/28 9:30
*/
@Component
public class PointsFeignClientFallback implements PointsFeignClient {
@Override
public Result<BehaviorResultDto> getBehaviorCodeInfo(String behaviorCode) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_POINTS_SERVER, "getBehaviorCodeInfo", behaviorCode);
}
}

44
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/rocketmq/dto/BehaviorDto.java

@ -0,0 +1,44 @@
package com.elink.esua.epdc.pointcommons.tools.rocketmq.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 用户行为DTO
*
* @author songyunpeng
* @Date 20-04-28
*/
@Data
public class BehaviorDto implements Serializable {
private static final long serialVersionUID = 5458618984429715932L;
/**
* 用户行为
*/
private String behavior;
/**
* 业务ID
*/
private String referenceId;
/**
* 其他业务ID
*/
private String otherReferenceId;
/**
* 用户ID
*/
private String userId;
/**
* 其他标识
*/
private String ortherFlag;
}

41
esua-epdc/epdc-commons/epdc-commons-points-tools/src/main/java/com/elink/esua/epdc/pointcommons/tools/rocketmq/producer/PointsProducer.java

@ -0,0 +1,41 @@
package com.elink.esua.epdc.pointcommons.tools.rocketmq.producer;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 积分埋点-发送MQ消息
*
* @Authorsongyunpeng
* @Date2020/4/28 16:14
*/
@Slf4j
@Component
public class PointsProducer {
@Autowired
private RocketMQTemplate rocketMQTemplate;
/**
* 发送消息
*
* @return void
* @params [topic, tag, keys, body]
* @author liuchuang
* @since 2020/3/6 21:09
*/
public void sendMessage(String topic, String tag, String keys, String body) {
Message message = new Message(topic, tag, keys, body.getBytes());
try {
SendResult sendResult = rocketMQTemplate.getProducer().send(message);
log.info("积分埋点发送消息结果:{sendStatus:{}, topic:{}, msgId:{}}", sendResult.getSendStatus(), topic, sendResult.getMsgId());
} catch (Exception e) {
log.error("积分埋点发送消息异常:{topic:{}, tag:{}, keys:{}, body:{}}", topic, tag, keys, body);
e.printStackTrace();
}
}
}

11
esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/Constant.java

@ -108,4 +108,15 @@ public interface Constant {
* 移动端接口标识
*/
String EPDC_APP = "epdc-app/";
/**
* 动作记录时机
*/
String BEHAVIOR_RECORDING_TIME_BEFORE = "0";
/**
* 动作记录时机
*/
String BEHAVIOR_RECORDING_TIME_AFTER = "1";
}

22
esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/RedisConstant.java

@ -0,0 +1,22 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package com.elink.esua.epdc.commons.tools.constant;
/**
* redis前缀常量
*
* @author songyunpeng
* @date 20-04-28
*/
public interface RedisConstant {
/**
* 行为编码前缀
*/
String BEHAVIOR_CODE = "epdc:config:behavior:";
}

10
esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/RocketMqConstant.java

@ -28,4 +28,14 @@ public interface RocketMqConstant {
* 分类信息修改-消息tag
*/
String MQ_TAG_CATEGORY = "jinshui-categoryTag";
/**
* 积分埋点-消息topic
*/
String MQ_TOPIC_POINTS = "jinshui-pointsTopic";
/**
* 积分埋点-消息tag
*/
String MQ_TAG_POINTS = "jinshui-pointsTag";
}

215
esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/enums/BehaviorEnum.java

@ -0,0 +1,215 @@
package com.elink.esua.epdc.commons.tools.enums;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 积分埋点枚举
*
* @author songyunpeng
* @Date 20-04-28
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum BehaviorEnum {
/**
* 完善居民信息
*/
PERFECT_RESIDENT_INFO("perfect_resident_info"),
/**
* 完善党员信息
*/
PERFECT_PARTY_INFO("perfect_party_info"),
/**
* 完善企业信息
*/
PERFECT_ENTERPRISE_INFO("perfect_enterprise_info"),
/**
* 新闻浏览
*/
NEWS_BROWSE("news_browse"),
/**
* 新闻点赞
*/
NEWS_SUPPORT("news_support"),
/**
* 新闻点踩
*/
NEWS_OPPOSITION("news_opposition"),
/**
* 新闻分享
*/
NEWS_SHARE("news_share"),
/**
* 发布议题
*/
ISSUE_PUBLISH("issue_publish"),
/**
* 发布的议题审核通过
*/
ISSUE_AUDIT_PASS("issue_audit_pass"),
/**
* 发布的议题审核不通过
*/
ISSUE_AUDIT_FAILED("issue_audit_failed"),
/**
* 议题点赞
*/
ISSUE_SUPPORT("issue_support"),
/**
* 议题点踩
*/
ISSUE_OPPOSITION("issue_opposition"),
/**
* 议题评论
*/
ISSUE_COMMENT("issue_comment"),
/**
* 议题评论的回复
*/
ISSUE_COMMENT_REPLY("issue_comment_reply"),
/**
* 议题评论的点赞
*/
ISSUE_COMMENT_SUPPORT("issue_comment_support"),
/**
* 议题评论的点踩
*/
ISSUE_COMMENT_OPPOSITION("issue_comment_opposition"),
/**
* 议题浏览
*/
ISSUE_BROWSE("issue_browse"),
/**
* 议题分享
*/
ISSUE_SHARE("issue_share"),
/**
* 议题转成项目
*/
ISSUE_TO_PROJECT("issue_to_project"),
/**
* 项目的点赞
*/
PROJECT_SUPPORT("project_support"),
/**
* 项目的点踩
*/
PROJECT_OPPOSITION("project_opposition"),
/**
* 项目评论
*/
PROJECT_COMMENT("project_comment"),
/**
* 项目评论的回复
*/
PROJECT_COMMENT_REPLY("project_comment_reply"),
/**
* 项目浏览
*/
PROJECT_BROWSE("project_browse"),
/**
* 项目分享
*/
PROJECT_SHARE("project_share"),
/**
* 项目满意度评价
*/
PROJECT_EVALUATION("project_evaluation"),
/**
* 创建社群
*/
GROUP_CREATE_APPLICATION("group_create_application"),
/**
* 申请加入社群
*/
GROUP_JOIN_APPLICATION("group_join_application"),
/**
* 同意加入社群
*/
GROUP_JOIN_SUCCESS("group_join_success"),
/**
* 不同意加入社群
*/
GROUP_JOIN_FAIL("group_join_fail"),
/**
* 同意创建社群
*/
GROUP_CREATE_SUCCESS("group_create_success"),
/**
* 不同意创建社群
*/
GROUP_APPLICATION_FAIL("group_application_fail"),
/**
* 修改社群信息
*/
GROUP_MODIFY_INFO("group_modify_info"),
/**
* 解散群
*/
GROUP_DISSOLUTION("group_dissolution"),
/**
* 邀请好友
*/
GROUP_INVITATION("group_invitation"),
/**
* 发布话题
*/
GROUP_TOPIC_PUBLISH("group_topic_publish"),
/**
* 话题转为议题
*/
GROUP_TOPIC_TO_EVENTS("group_topic_to_events"),
/**
* 话题点赞
*/
GROUP_TOPIC_SUPPORT("group_topic_support"),
/**
* 话题点踩
*/
GROUP_TOPIC_OPPOSITION("group_topic_opposition"),
/**
* 话题评论
*/
GROUP_COMMENT("group_comment"),
/**
* 话题评论的回复
*/
GROUP_COMMENT_REPLY("group_comment_reply"),
/**
* 话题浏览
*/
GROUP_BROWSE("group_browse"),
/**
* 用户进入社群
*/
GROUP_OPEN("group_open");
private String value;
BehaviorEnum(final String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
}

1
esua-epdc/epdc-commons/pom.xml

@ -14,6 +14,7 @@
<modules>
<module>epdc-commons-tools</module>
<module>epdc-commons-points-tools</module>
<module>epdc-commons-mybatis</module>
<module>epdc-commons-dynamic-datasource</module>
<module>epdc-commons-api-version-control</module>

2
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java

@ -90,7 +90,7 @@ public interface NewsService {
* @Exception
*
*/
Result modifyNewsBrowse(EpdcNewsBrowseFromDTO newsBrowseFromDTO);
Result modifyNewsBrowse(TokenDto userDetail, EpdcNewsBrowseFromDTO newsBrowseFromDTO);
/**
* 用户消息已读

3
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java

@ -73,7 +73,8 @@ public class NewsServiceImpl implements NewsService {
@Override
public Result modifyNewsBrowse(EpdcNewsBrowseFromDTO newsBrowseFromDTO) {
public Result modifyNewsBrowse(TokenDto userDetail, EpdcNewsBrowseFromDTO newsBrowseFromDTO) {
newsBrowseFromDTO.setUserId(userDetail.getUserId());
return newsFeignClient.modifyNewsBrowse(newsBrowseFromDTO);
}

8
esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNewsBrowseFromDTO.java

@ -6,9 +6,9 @@ import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author: qushutong
* @Date: 2019/9/7 14:10
* @Description: 新闻浏览
* @author: qushutong
* @Date: 2019/9/7 14:10
* @Description: 新闻浏览
*/
@Data
public class EpdcNewsBrowseFromDTO implements Serializable {
@ -20,4 +20,6 @@ public class EpdcNewsBrowseFromDTO implements Serializable {
@NotNull(message = "新闻id不能为空")
private String newsId;
private String userId;
}

26
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppNewsController.java

@ -18,6 +18,7 @@
package com.elink.esua.epdc.controller;
import com.elink.esua.epdc.commons.tools.constant.Constant;
import com.elink.esua.epdc.commons.tools.enums.BehaviorEnum;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.dto.BannerDTO;
@ -25,6 +26,7 @@ import com.elink.esua.epdc.dto.epdc.form.*;
import com.elink.esua.epdc.dto.epdc.result.EpdcBannerListResultDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcNewsDetailResultDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcNewsListResultDTO;
import com.elink.esua.epdc.pointcommons.tools.annotation.RecordUserBehavior;
import com.elink.esua.epdc.service.BannerService;
import com.elink.esua.epdc.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
@ -81,7 +83,23 @@ public class EpdcAppNewsController {
}
/***
* @Description 点赞或踩
* @Description 点赞
* @Author qushutong
* @Date 2019/9/7 14:15
* @Param []
* @Return com.elink.esua.epdc.commons.tools.utils.Result
* @Exception
*
*/
@PostMapping("statementSupport")
@RecordUserBehavior(behavior = BehaviorEnum.NEWS_SUPPORT, referenceId = "#{newsStatementFromDTO.getNewsId}", userId = "#{newsStatementFromDTO.getUserId}")
public Result upDateStatementSupport(@RequestBody EpdcNewsStatementFromDTO newsStatementFromDTO) {
ValidatorUtils.validateEntity(newsStatementFromDTO);
return newsService.modifyStatement(newsStatementFromDTO);
}
/***
* @Description 点踩
* @Author qushutong
* @Date 2019/9/7 14:15
* @Param []
@ -90,6 +108,7 @@ public class EpdcAppNewsController {
*
*/
@PostMapping("statement")
@RecordUserBehavior(behavior = BehaviorEnum.NEWS_OPPOSITION, referenceId = "#{newsStatementFromDTO.getNewsId}", userId = "#{newsStatementFromDTO.getUserId}")
public Result upDateStatement(@RequestBody EpdcNewsStatementFromDTO newsStatementFromDTO) {
ValidatorUtils.validateEntity(newsStatementFromDTO);
return newsService.modifyStatement(newsStatementFromDTO);
@ -105,6 +124,7 @@ public class EpdcAppNewsController {
*
*/
@PostMapping("browse")
@RecordUserBehavior(behavior = BehaviorEnum.NEWS_BROWSE, referenceId = "#{newsBrowseFromDTO.getNewsId}", userId = "#{newsBrowseFromDTO.getUserId}")
public Result modifyNewsBrowse(@RequestBody EpdcNewsBrowseFromDTO newsBrowseFromDTO) {
ValidatorUtils.validateEntity(newsBrowseFromDTO);
return newsService.modifyNewsBrowse(newsBrowseFromDTO);
@ -114,12 +134,12 @@ public class EpdcAppNewsController {
/***
* banner列表
* @param
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.BannerDTO>>
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.BannerDTO>>
* @author qushutong
* @date 2019/9/10 20:58
*/
@GetMapping("list")
public Result<List<EpdcBannerListResultDTO>> listBanner(@RequestBody EpdcBannerListFromDTO fromDTO ){
public Result<List<EpdcBannerListResultDTO>> listBanner(@RequestBody EpdcBannerListFromDTO fromDTO) {
return new Result().ok(bannerService.listBanner(fromDTO));
}
}

360
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/UserDTO.java

@ -0,0 +1,360 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 用户信息表
*
* @author qu qu@gmail.com
* @since v1.0.0 2019-09-02
*/
@Data
public class UserDTO implements Serializable {
private static final long serialVersionUID = 915598602233599300L;
/**
* 主键
*/
private String id;
/**
* 昵称
*/
private String nickname;
/**
* 手机号
*/
private String mobile;
/**
* 密码
*/
private String password;
/**
* 认证时间
*/
private Date registerTime;
/**
* 头像
*/
private String faceImg;
/**
* 性别(女性-0男性-1)
* {@link com.elink.esua.epdc.commons.tools.enums.UserSexEnum}
*/
private String sex;
/**
* 生日
*/
private Date birthday;
/**
* 邮箱
*/
private String email;
/**
* 电话
*/
private String telephone;
/**
* 邮编
*/
private String zipCode;
/**
* 职业
*/
private String profession;
/**
* 爱好
*/
private String hobbies;
/**
* 个性签名
*/
private String userSign;
/**
* 邀请码
*/
private String invitationCode;
/**
* 最近登录时间
*/
private Date lastLoginTime;
/**
* 最近登录IP
*/
private String lastLoginIp;
/**
* 最近登录位置经度
*/
private String lastLongitude;
/**
* 最近登录位置维度
*/
private String lastLatitude;
/**
* 真实姓名
*/
private String realName;
/**
* 身份证号
*/
private String identityNo;
/**
* 所在道路如山东路168号
*/
private String road;
/**
* 小区名称
*/
private String villageName;
/**
* 住处楼栋-单元-房间
*/
private String dwellingPlace;
/**
* 居民住址
*/
private String address;
/**
* 微信OPENID
*/
private String wxOpenId;
/**
* 微信unionId
*/
private String wxUnionId;
/**
* 是否是党员(0-1-)
*/
private String partyFlag;
/**
* 注册方式wx微信注册
*/
private String registerWay;
/**
* 用户来源(wp:公众号)
*/
private String registerSource;
/**
* 手机号所属省份
*/
private String mobileProvince;
/**
* 手机号所属城市
*/
private String mobileCity;
/**
* 手机号所属运营商
*/
private String mobileCarrier;
/**
* 用户积分
*/
private Integer points;
/**
* 用户累计
*/
private Integer points_totle;
/**
* 邀请人ID
*/
private String inviteUserId;
/**
* 状态参考枚举类{@link com.elink.esua.epdc.enums.AppUserStatesEnum}
*/
private String state;
/**
* 区县
*/
private String district;
/**
* 区县ID
*/
private Long districtId;
/**
* 街道
*/
private String street;
/**
* 街道ID
*/
private Long streetId;
/**
* 社区
*/
private String community;
/**
* 社区ID
*/
private Long communityId;
/**
* 网格
*/
private String grid;
/**
* 网格ID
*/
private Long gridId;
/**
* 删除标记
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 注册时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
/**
*
*/
private String lastName;
/**
*
*/
private String firstName;
/**
* 干部下沉 0不
*/
private String cadreFlag;
/**
* 党员标签
*/
private String tagIds;
/**
* 审核备注
*/
private String remark;
/**
* 是否是网格长
*/
private String leaderFlag;
/**
* 认证历史-累计提交认证次数
*/
private Integer totalSubmitNum;
/**
* 认证历史-通过次数
*/
private Integer totalPassSubmitNum;
/**
* 认证历史-不通过次数
*/
private Integer totalFailNum;
/**
* 居住网格id
*/
private Long deptId;
/**
* 父所有部门
*/
private String parentDeptIds;
/**
* 父所有部门
*/
private String parentDeptNames;
/**
* 所有部门ID
*/
private String allDeptIds;
/**
* 所有部门名称
*/
private String allDeptNames;
}

89
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/PointsLogsAddFormDTO.java

@ -0,0 +1,89 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto.form;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 积分记录表 添加
*
* @author songyunpeng
* @since v1.0.0 2020-04-29
*/
@Data
public class PointsLogsAddFormDTO {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private String userId;
/**
* 用户昵称
*/
private String nickname;
/**
* 关联表ID
*/
private String referenceId;
/**
* 积分规则编码
*/
private String ruleCode;
/**
* 积分行为编码
*/
private String behaviorCode;
/**
* 积分操作类型 0-减积分1-加积分
*/
private String operationType;
/**
* 操作积分值
*/
private Integer points;
/**
* 操作描述
*/
private String operationDesc;
/**
* 操作时间
*/
private Date operationTime;
/**
* 操作方式 user-用户操作admin-管理员操作sys-系统操作
*/
private String operationMode;
/**
* 剩余积分值
*/
private Integer lavePoints;
}

24
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/PointsLogsFormDTO.java

@ -39,20 +39,36 @@ public class PointsLogsFormDTO implements Serializable {
/**
* 用户ID
*/
@NotNull
private String userId;
private String userId;
/**
* 用户昵称
*/
private String nickName;
/**
* 关联表ID
*/
@NotNull
private String referenceId;
/**
* 积分行为编码
*/
@NotNull
private String behaviorCode;
/**
* 积分规则编码
*/
private String ruleCode;
/**
* 上限日期标识
*/
private String operationFlag;
/**
* 上限值
*/
private Integer upperLimitVal;
}

50
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/PointsLogsSumResultDTO.java

@ -0,0 +1,50 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 一定时限内的积分总和返回
*
* @author elink elink@elink-cn.com
* @since v1.0.0 2020-04-29
*/
@Data
public class PointsLogsSumResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 总和
*/
private Integer total;
/**
* 操作时间
*/
private Date operationTime;
}

4
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/PointsRuleResultDTO.java

@ -119,4 +119,8 @@ public class PointsRuleResultDTO implements Serializable {
*/
private Date updatedTime;
/**
* 动作上限次数0-不限 1-一次 ....
*/
private String limitNum;
}

11
esua-epdc/epdc-module/epdc-points/epdc-points-server/pom.xml

@ -63,6 +63,11 @@
<artifactId>orika-spring-boot-starter</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>
<build>
@ -146,6 +151,8 @@
<!--RocketMQ-->
<rocketmq.name.server>47.104.85.99:9876;114.215.125.123:9876</rocketmq.name.server>
<rocketmq.consumer.group>jinshui-organizationGroup</rocketmq.consumer.group>
<rocketmq.producer.group>jinshui-pointsGroup</rocketmq.producer.group>
<rocketmq.consumer.points.group>jinshui-pointsGroup</rocketmq.consumer.points.group>
</properties>
</profile>
@ -174,6 +181,8 @@
<!--RocketMQ-->
<rocketmq.name.server>47.104.85.99:9876;114.215.125.123:9876</rocketmq.name.server>
<rocketmq.consumer.group>jinshui-organizationGroup</rocketmq.consumer.group>
<rocketmq.producer.group>jinshui-pointsGroup</rocketmq.producer.group>
<rocketmq.consumer.points.group>jinshui-pointsGroup</rocketmq.consumer.points.group>
</properties>
</profile>
@ -204,6 +213,8 @@
<!--RocketMQ-->
<rocketmq.name.server>172.16.0.7:9876;172.16.0.8:9876</rocketmq.name.server>
<rocketmq.consumer.group>jinshui-organizationGroup</rocketmq.consumer.group>
<rocketmq.producer.group>jinshui-pointsGroup</rocketmq.producer.group>
<rocketmq.consumer.points.group>jinshui-pointsGroup</rocketmq.consumer.points.group>
</properties>
</profile>
</profiles>

45
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsController.java

@ -0,0 +1,45 @@
package com.elink.esua.epdc.controller;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.dto.PointsLogsDTO;
import com.elink.esua.epdc.dto.form.PointsLogsAddFormDTO;
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO;
import com.elink.esua.epdc.dto.result.BehaviorResultDto;
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO;
import com.elink.esua.epdc.dto.result.PointsLogsSumResultDTO;
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO;
import com.elink.esua.epdc.entity.PointsLogsEntity;
import com.elink.esua.epdc.service.PointsBehaviorService;
import com.elink.esua.epdc.service.PointsLogsService;
import com.elink.esua.epdc.service.PointsRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author songyunpeng
* @Description 提供外部接口Controller
* @create 2020-04-28
*/
@RestController
@RequestMapping("points")
public class PointsController {
@Autowired
private PointsBehaviorService pointsBehaviorService;
/**
* @return com.elink.esua.epdc.dto.result.BehaviorResultDto
* @Description 根据动作编码获取动作信息
* @Author songyunpeng
* @Date 2020/4/28
* @Param [behaviorCode]
**/
@PostMapping("getBehaviorCodeInfo/{behaviorCode}")
public Result<BehaviorResultDto> getBehaviorCodeInfo(@PathVariable String behaviorCode) {
return pointsBehaviorService.getBehaviorCodeInfoByBehaviorCode(behaviorCode);
}
}

10
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsBehaviorDao.java

@ -19,6 +19,7 @@ package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.PointsBehaviorDTO;
import com.elink.esua.epdc.dto.result.BehaviorResultDto;
import com.elink.esua.epdc.entity.PointsBehaviorEntity;
import org.apache.ibatis.annotations.Mapper;
@ -48,6 +49,15 @@ public interface PointsBehaviorDao extends BaseDao<PointsBehaviorEntity> {
*/
List<PointsBehaviorDTO> selectListPointsBehavior(Map<String, Object> params);
/**
* @return com.elink.esua.epdc.dto.result.BehaviorResultDto
* @Description 根据动作编码获取动作信息
* @Author songyunpeng
* @Date 2020/4/28
* @Param []
**/
BehaviorResultDto getBehaviorCodeInfoByBehaviorCode(String behaviorCode);
/**
* 获取全部的动作编码
*

31
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsLogsDao.java

@ -18,6 +18,9 @@
package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO;
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO;
import com.elink.esua.epdc.dto.result.PointsLogsSumResultDTO;
import com.elink.esua.epdc.dto.form.EpdcAppPointsRankingFormDTO;
import com.elink.esua.epdc.dto.form.EpdcAppPointsRecordFormDTO;
import com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO;
@ -35,6 +38,32 @@ import java.util.List;
*/
@Mapper
public interface PointsLogsDao extends BaseDao<PointsLogsEntity> {
/**
* @return com.elink.esua.epdc.dto.result.PointsLogsResultDTO
* @Description 根据用户业务ID行为编码获取日志记录
* @Author songyunpeng
* @Date 2020/4/29
* @Param [pointsLogsFormDTO]
**/
List<PointsLogsResultDTO> selecOneLogsByBehaviorCodeAndUserIdAndReferenceId(PointsLogsFormDTO pointsLogsFormDTO);
/**
* @return java.lang.Integer
* @Description 根据行为编码和用户ID获取积分 该动作积分总和
* @Author songyunpeng
* @Date 2020/4/29
* @Param [pointsLogsFormDTO]
**/
PointsLogsSumResultDTO getPointsSumByBehaviorCodeAndUserId(PointsLogsFormDTO pointsLogsFormDTO);
/**
* @return com.elink.esua.epdc.dto.result.PointsLogsResultDTO
* @Description 获取指定人指定动作的最新一条工作日志
* @Author songyunpeng
* @Date 2020/4/29
* @Param [pointsLogsFormDTO]
**/
PointsLogsResultDTO getLastPointLogs(PointsLogsFormDTO pointsLogsFormDTO);
/**
* 当前登录用户 积分记录接口
@ -56,7 +85,7 @@ public interface PointsLogsDao extends BaseDao<PointsLogsEntity> {
* param pageIndex 必选 页码
* param pageSize 必选 页容量
* param rankingType 必选 排名方式0-1-
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO>>
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO>>
* @Author: zy
* @Date: 2020-04-30
*/

13
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsRuleDao.java

@ -20,6 +20,8 @@ package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.PointsRuleDTO;
import com.elink.esua.epdc.dto.result.BehaviorResultDto;
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO;
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO;
import com.elink.esua.epdc.entity.PointsRuleEntity;
import org.apache.ibatis.annotations.Mapper;
@ -34,14 +36,15 @@ import java.util.Map;
*/
@Mapper
public interface PointsRuleDao extends BaseDao<PointsRuleEntity> {
/**
* @Description 根据动作编码获取动作信息
* @return com.elink.esua.epdc.dto.result.PointsRuleResultDTO
* @Description 根据动作编码获取积分规则
* @Author songyunpeng
* @Date 2020/4/28
* @Param []
* @return com.elink.esua.epdc.dto.result.BehaviorResultDto
* @Date 2020/4/29
* @Param [behaviorCode]
**/
BehaviorResultDto getBehaviorCodeInfoByBehaviorCode(String behaviorCode);
PointsRuleEntity selecOnePointsRuleByBehaviorCode(String behaviorCode);
/**
* 积分规则配置 列表查询

28
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/entity/PointsLogsEntity.java

@ -32,60 +32,64 @@ import java.util.Date;
* @since v1.0.0 2020-04-29
*/
@Data
@EqualsAndHashCode(callSuper=false)
@EqualsAndHashCode(callSuper = false)
@TableName("epdc_points_logs")
public class PointsLogsEntity extends BaseEpdcEntity {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private String userId;
private String userId;
/**
* 用户昵称
*/
private String nickname;
/**
* 关联表ID
*/
private String referenceId;
private String referenceId;
/**
* 积分规则编码
*/
private String ruleCode;
private String ruleCode;
/**
* 积分行为编码
*/
private String behaviorCode;
private String behaviorCode;
/**
* 积分操作类型 0-减积分1-加积分
*/
private String operationType;
private String operationType;
/**
* 操作积分值
*/
private Integer points;
private Integer points;
/**
* 操作描述
*/
private String operationDesc;
private String operationDesc;
/**
* 操作时间
*/
private Date operationTime;
private Date operationTime;
/**
* 操作方式 user-用户操作admin-管理员操作sys-系统操作
*/
private String operationMode;
private String operationMode;
/**
* 剩余积分值
*/
private Integer lavePoints;
private Integer lavePoints;
}

43
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/feign/UsersFeignClient.java

@ -0,0 +1,43 @@
package com.elink.esua.epdc.feign;
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.UserDTO;
import com.elink.esua.epdc.feign.fallback.UsersFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author songyunpeng
* @date 2020/04/28
*/
@FeignClient(name = ServiceConstant.EPDC_USER_SERVER, fallback = UsersFeignClientFallback.class, url = "http://127.0.0.1:9068")
public interface UsersFeignClient {
/**
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.pointcommons.tools.dto.BehaviorResultDto>
* @Description 获取用户信息
* @Author songyunpeng
* @Date 2020/4/29
* @Param [id]
**/
@GetMapping(value = "app-user/user/{id}", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<UserDTO> getUserById(@PathVariable String id);
/**
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.pointcommons.tools.dto.BehaviorResultDto>
* @Description 更新用户信息
* @Author songyunpeng
* @Date 2020/4/29
* @Param [dto]
**/
@PutMapping(value = "app-user/user", consumes = MediaType.APPLICATION_JSON_VALUE)
Result updateUser(@RequestBody UserDTO dto);
}

26
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/feign/fallback/UsersFeignClientFallback.java

@ -0,0 +1,26 @@
package com.elink.esua.epdc.feign.fallback;
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.UserDTO;
import com.elink.esua.epdc.feign.UsersFeignClient;
import org.springframework.stereotype.Component;
/**
* @author songyunpeng
* @date 2020/4/28 9:30
*/
@Component
public class UsersFeignClientFallback implements UsersFeignClient {
@Override
public Result<UserDTO> getUserById(String id) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "get", id);
}
@Override
public Result updateUser(UserDTO dto) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "update", dto);
}
}

261
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/mq/PointsModifyConsumer.java

@ -0,0 +1,261 @@
package com.elink.esua.epdc.mq;
import com.alibaba.fastjson.JSONObject;
import com.elink.esua.epdc.commons.tools.constant.RocketMqConstant;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.DateUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.UserDTO;
import com.elink.esua.epdc.dto.form.PointsLogsAddFormDTO;
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO;
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO;
import com.elink.esua.epdc.dto.result.PointsLogsSumResultDTO;
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO;
import com.elink.esua.epdc.entity.PointsLogsEntity;
import com.elink.esua.epdc.feign.UsersFeignClient;
import com.elink.esua.epdc.mq.dto.BehaviorDto;
import com.elink.esua.epdc.service.PointsBehaviorService;
import com.elink.esua.epdc.service.PointsLogsService;
import com.elink.esua.epdc.service.PointsRuleService;
import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
* 积分埋点-监听MQ消息
*
* @Authorsongyunpeng
* @Date2020/4/28 13:44
*/
@Slf4j
@Component
@RocketMQMessageListener(topic = RocketMqConstant.MQ_TOPIC_POINTS, consumerGroup = "${rocketmq.consumer.points-group}", messageModel = MessageModel.BROADCASTING)
public class PointsModifyConsumer implements RocketMQListener<MessageExt> {
@Autowired
private PointsBehaviorService pointsBehaviorService;
@Autowired
private PointsLogsService pointsLogsService;
@Autowired
private PointsRuleService pointsRuleService;
@Autowired
private UsersFeignClient usersFeignClient;
/**
* 操作类型 加分
*/
private static final String OPERATION_TYPE_ADD = "1";
/**
* 操作类型 减分
*/
private static final String OPERATION_TYPE_SUB = "0";
/**
* 动作限制次数 无限次
*/
private static final String OPERATION_LIMIT_NUM = "0";
/**
* 成功
*/
private static final String SUCCESS_CODE = "success";
/**
* 处理逻辑1根据业务ID和动作编码去日志里查看是够已经有这个记录如果有根据规则判断是否进行积分加减
* 2进行用户的积分的加和减然后更新redis里用户的积分的值更新数据库里用户积分的值
* 3将用户操作记录存入日志表
**/
@Override
public void onMessage(MessageExt messageExt) {
log.info("EPDC-NEWS-SERVER消费消息START:{topic:{}, msgId:{}}", RocketMqConstant.MQ_TOPIC_ORGANIZATION, messageExt.getMsgId());
try {
String charset = "UTF-8";
String body = new String(messageExt.getBody(), charset);
BehaviorDto dto = JSONObject.parseObject(body, BehaviorDto.class);
this.handlePoints(dto);
log.info("EPDC-NEWS-SERVER消费消息END:{topic:{}, msgId:{}, body:{}}", RocketMqConstant.MQ_TOPIC_ORGANIZATION, messageExt.getMsgId(), body);
} catch (Exception e) {
log.info("EPDC-NEWS-SERVER消费消息失败:msgId:{}", messageExt.getMsgId());
e.printStackTrace();
}
}
/**
* 处理新闻浏览积分 同一新闻算一次
* <p>
* 根据动作编码获取积分规则信息
* 根据动作编码和用户ID获取此动作在一定时限内的总分然后根据上线统计指标判断是否到达上限值未到达加分或减分达到则不进行操作
*/
private void handlePoints(BehaviorDto dto) {
//计算是否超过该动作的积分上限 -- 开始
//1.根据行为编码获取积分规则
PointsLogsFormDTO pointsLogsFormDTO = new PointsLogsFormDTO();
pointsLogsFormDTO.setBehaviorCode(dto.getBehavior());
pointsLogsFormDTO.setUserId(dto.getUserId());
pointsLogsFormDTO.setReferenceId(dto.getReferenceId());
PointsRuleResultDTO pointsRuleResultDTO = pointsRuleService.getPointsRuleByBehaviorCode(dto.getBehavior());
if (pointsRuleResultDTO == null) {
return;
}
pointsLogsFormDTO.setRuleCode(pointsRuleResultDTO.getRuleCode());
//1.1如果规则里动作次数上限不为0则需要判断该动作是否超过次数上限
if (!OPERATION_LIMIT_NUM.equals(pointsRuleResultDTO.getLimitNum())) {
//此处通过规则编码获取日志信息(用于针对 表态(指多个工作)只记录一次分数)
List<PointsLogsResultDTO> pointsLogsResultDTs = pointsLogsService.getLogsByBehaviorCodeAndUserIdAndReferenceId(pointsLogsFormDTO);
//如果大于或者等于上限 代表不能再进行操作
if (pointsLogsResultDTs != null && pointsLogsResultDTs.size() >= Integer.parseInt(pointsRuleResultDTO.getLimitNum())) {
return;
}
}
//2.赋值积分规则的上限期限(小时,年。。。。)
pointsLogsFormDTO.setOperationFlag(pointsRuleResultDTO.getLimitType());
pointsLogsFormDTO.setUpperLimitVal(pointsRuleResultDTO.getUpperLimitVal() - pointsRuleResultDTO.getPoints());
//3.根据积分上限期限,行为编码获取该用户最近的一次行为记录和时间
PointsLogsSumResultDTO pointsLogsSumResultDTO = pointsLogsService.getPointsSumByBehaviorCodeAndUserId(pointsLogsFormDTO);
//4.先判断积分总值是否超出上限 若超过上限且返回的时间+1min大与当前时间则返回(此时代表已经到达界限且在该时限内不能再加分)
//此处返回的时间为离当前时间最近的一条剩余积分最多的时间
if (pointsLogsSumResultDTO != null) {
if (Math.abs(pointsLogsSumResultDTO.getTotal()) >= Math.abs(pointsRuleResultDTO.getUpperLimitVal())) {
switch (pointsRuleResultDTO.getLimitType()) {
case "0":
if (DateUtils.addDateMinutes(pointsLogsSumResultDTO.getOperationTime(), 1).after(new Date())) {
return;
}
break;
case "1":
if (DateUtils.addDateHours(pointsLogsSumResultDTO.getOperationTime(), 1).after(new Date())) {
return;
}
break;
case "2":
if (DateUtils.addDateDays(pointsLogsSumResultDTO.getOperationTime(), 1).after(new Date())) {
return;
}
break;
case "3":
if (DateUtils.addDateMonths(pointsLogsSumResultDTO.getOperationTime(), 1).after(new Date())) {
return;
}
break;
case "4":
if (DateUtils.addDateYears(pointsLogsSumResultDTO.getOperationTime(), 1).after(new Date())) {
return;
}
break;
default:
break;
}
}
}
//计算是否超过该动作的积分上限 -- 结束
//更新用户的积分 -- 开始
//1.获取用户信息
Result<UserDTO> userById = usersFeignClient.getUserById(dto.getUserId());
if (!SUCCESS_CODE.equals(userById.getMsg())) {
return;
}
UserDTO userDTO = userById.getData();
if (userDTO == null) {
return;
}
//2.更新用户积分分数
if (OPERATION_TYPE_ADD.equals(pointsRuleResultDTO.getOperationType())) {
userDTO.setPoints(userDTO.getPoints() + pointsRuleResultDTO.getPoints());
userDTO.setPoints_totle(userDTO.getPoints_totle() == null ? 0 : userDTO.getPoints_totle() + pointsRuleResultDTO.getPoints());
} else if (OPERATION_TYPE_SUB.equals(pointsRuleResultDTO.getOperationType())) {
userDTO.setPoints(userDTO.getPoints() - pointsRuleResultDTO.getPoints());
}
//3.更新数据库用户积分
usersFeignClient.updateUser(userDTO);
//4.更新redis用户积分情况
//更新用户的积分 -- 结束
//添加操作日志 -- 开始
addRuleLog(pointsRuleResultDTO, dto, pointsLogsSumResultDTO, pointsLogsFormDTO, userDTO);
//添加操作日志 -- 结束
}
/**
* 时间计算逻辑#
* 返回的总数为 离当前时间最早的一个剩余分数为界限值之后一分钟内的分数的总和 -- 作用是与界限值做判断
* 返回的时间为 离当前时间最早的一个剩余分数为界限值的操作时间 -- 作用是判断是否超过时间界限
* <p>
* 总结为若是超过积分总数界限且返回的时间+1min大于当前时间代表在时间界限内用户还在操作此时不给加分
* 若是超过积分总数界限且返回的时间+1min小于当前时间代表不在时间界限内用户在操作取界限值为剩余分
* 若是没有超过积分总数界限且返回的时间+1min小于当前时间代表不在时间界限内用户在操作取界限值为剩余分
* 若是没有超过积分总数界限且返回的时间+1min大于当前时间代表在时间界限内用户在操作剩余积分正常加减
*/
private void addRuleLog(PointsRuleResultDTO pointsRuleResultDTO, BehaviorDto dto, PointsLogsSumResultDTO pointsLogsSumResultDTO, PointsLogsFormDTO pointsLogsFormDTO, UserDTO userDTO) {
PointsLogsAddFormDTO pointsLogsAddFormDTO = new PointsLogsAddFormDTO();
pointsLogsAddFormDTO.setUserId(dto.getUserId());
pointsLogsAddFormDTO.setNickname(userDTO.getNickname());
pointsLogsAddFormDTO.setReferenceId(dto.getReferenceId());
pointsLogsAddFormDTO.setRuleCode(pointsRuleResultDTO.getRuleCode());
pointsLogsAddFormDTO.setBehaviorCode(pointsRuleResultDTO.getBehaviorCode());
pointsLogsAddFormDTO.setOperationType(pointsRuleResultDTO.getOperationType());
pointsLogsAddFormDTO.setPoints(pointsRuleResultDTO.getPoints());
pointsLogsAddFormDTO.setOperationDesc(pointsRuleResultDTO.getRuleDesc());
pointsLogsAddFormDTO.setOperationTime(new Date());
pointsLogsAddFormDTO.setOperationMode("user");
//若是返回时间+1min/hour/day/month/year 大于当前时间则正常加减 其他取界限值
if (pointsLogsSumResultDTO != null) {
switch (pointsRuleResultDTO.getLimitType()) {
case "0":
if (DateUtils.addDateMinutes(pointsLogsSumResultDTO.getOperationTime(), 1).after(new Date())) {
PointsLogsResultDTO pointsLogsResultDTO = pointsLogsService.getLastPointLogs(pointsLogsFormDTO);
pointsLogsAddFormDTO.setLavePoints(pointsLogsResultDTO.getLavePoints() - pointsRuleResultDTO.getPoints());
} else {
pointsLogsAddFormDTO.setLavePoints(pointsRuleResultDTO.getUpperLimitVal() - pointsRuleResultDTO.getPoints());
}
break;
case "1":
if (DateUtils.addDateHours(pointsLogsSumResultDTO.getOperationTime(), 1).after(new Date())) {
PointsLogsResultDTO pointsLogsResultDTO = pointsLogsService.getLastPointLogs(pointsLogsFormDTO);
pointsLogsAddFormDTO.setLavePoints(pointsLogsResultDTO.getLavePoints() - pointsRuleResultDTO.getPoints());
} else {
pointsLogsAddFormDTO.setLavePoints(pointsRuleResultDTO.getUpperLimitVal() - pointsRuleResultDTO.getPoints());
}
break;
case "2":
if (DateUtils.addDateDays(pointsLogsSumResultDTO.getOperationTime(), 1).after(new Date())) {
PointsLogsResultDTO pointsLogsResultDTO = pointsLogsService.getLastPointLogs(pointsLogsFormDTO);
pointsLogsAddFormDTO.setLavePoints(pointsLogsResultDTO.getLavePoints() - pointsRuleResultDTO.getPoints());
} else {
pointsLogsAddFormDTO.setLavePoints(pointsRuleResultDTO.getUpperLimitVal() - pointsRuleResultDTO.getPoints());
}
break;
case "3":
if (DateUtils.addDateMonths(pointsLogsSumResultDTO.getOperationTime(), 1).after(new Date())) {
PointsLogsResultDTO pointsLogsResultDTO = pointsLogsService.getLastPointLogs(pointsLogsFormDTO);
pointsLogsAddFormDTO.setLavePoints(pointsLogsResultDTO.getLavePoints() - pointsRuleResultDTO.getPoints());
} else {
pointsLogsAddFormDTO.setLavePoints(pointsRuleResultDTO.getUpperLimitVal() - pointsRuleResultDTO.getPoints());
}
break;
case "4":
if (DateUtils.addDateYears(pointsLogsSumResultDTO.getOperationTime(), 1).after(new Date())) {
PointsLogsResultDTO pointsLogsResultDTO = pointsLogsService.getLastPointLogs(pointsLogsFormDTO);
pointsLogsAddFormDTO.setLavePoints(pointsLogsResultDTO.getLavePoints() - pointsRuleResultDTO.getPoints());
} else {
pointsLogsAddFormDTO.setLavePoints(pointsRuleResultDTO.getUpperLimitVal() - pointsRuleResultDTO.getPoints());
}
break;
default:
}
} else {
pointsLogsAddFormDTO.setLavePoints(pointsRuleResultDTO.getUpperLimitVal() - pointsRuleResultDTO.getPoints());
}
PointsLogsEntity pointsLogsEntity = ConvertUtils.sourceToTarget(pointsLogsAddFormDTO, PointsLogsEntity.class);
pointsLogsService.insert(pointsLogsEntity);
}
}

44
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/mq/dto/BehaviorDto.java

@ -0,0 +1,44 @@
package com.elink.esua.epdc.mq.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 用户行为DTO
*
* @author songyunpeng
* @Date 20-04-28
*/
@Data
public class BehaviorDto implements Serializable {
private static final long serialVersionUID = 5458618984429715932L;
/**
* 用户行为
*/
private String behavior;
/**
* 业务ID
*/
private String referenceId;
/**
* 其他业务ID
*/
private String otherReferenceId;
/**
* 用户ID
*/
private String userId;
/**
* 其他标识
*/
private String ortherFlag;
}

13
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsBehaviorService.java

@ -21,6 +21,7 @@ import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.PointsBehaviorDTO;
import com.elink.esua.epdc.dto.result.BehaviorResultDto;
import com.elink.esua.epdc.entity.PointsBehaviorEntity;
import java.util.List;
@ -94,11 +95,21 @@ public interface PointsBehaviorService extends BaseService<PointsBehaviorEntity>
*/
void delete(String[] ids);
/**
* @return com.elink.esua.epdc.dto.result.BehaviorResultDto
* @Description 根据动作编码获取动作信息
* @Author songyunpeng
* @Date 2020/4/28
* @Param [behaviorCode]
**/
Result<BehaviorResultDto> getBehaviorCodeInfoByBehaviorCode(String behaviorCode);
/**
* 获取全部的动作编码
*
* @Param: []
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.PointsBehaviorDTO>>
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.PointsBehaviorDTO>>
* @Author: zy
* @Date: 2020-04-29
*/

33
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsLogsService.java

@ -19,7 +19,11 @@ package com.elink.esua.epdc.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.PointsLogsDTO;
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO;
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO;
import com.elink.esua.epdc.dto.result.PointsLogsSumResultDTO;
import com.elink.esua.epdc.dto.form.EpdcAppPointsRankingFormDTO;
import com.elink.esua.epdc.dto.form.EpdcAppPointsRecordFormDTO;
import com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO;
@ -117,9 +121,36 @@ public interface PointsLogsService extends BaseService<PointsLogsEntity> {
* param pageIndex 必选 页码
* param pageSize 必选 页容量
* param rankingType 必选 排名方式0-1-
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO>>
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO>>
* @Author: zy
* @Date: 2020-04-30
*/
List<EpdcAppPointsRankingResultDTO> listPointsRanking(EpdcAppPointsRankingFormDTO formDto);
/**
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.result.PointsLogsResultDTO>
* @Description 根据用户业务ID行为编码获取日志记录嘻嘻
* @Author songyunpeng
* @Date 2020/4/29
* @Param [pointsLogsFormDTO]
**/
List<PointsLogsResultDTO> getLogsByBehaviorCodeAndUserIdAndReferenceId(PointsLogsFormDTO pointsLogsFormDTO);
/**
* @return java.lang.Integer
* @Description 根据行为编码和用户ID获取积分 该动作积分总和
* @Author songyunpeng
* @Date 2020/4/29
* @Param [pointsLogsFormDTO]
**/
PointsLogsSumResultDTO getPointsSumByBehaviorCodeAndUserId(PointsLogsFormDTO pointsLogsFormDTO);
/**
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.result.PointsLogsResultDTO>
* @Description 获取指定人指定动作的最新一条工作日志
* @Author songyunpeng
* @Date 2020/4/29
* @Param [pointsLogsFormDTO]
**/
PointsLogsResultDTO getLastPointLogs(PointsLogsFormDTO pointsLogsFormDTO);
}

13
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsRuleService.java

@ -21,6 +21,10 @@ import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.PointsRuleDTO;
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO;
import com.elink.esua.epdc.dto.result.BehaviorResultDto;
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO;
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO;
import com.elink.esua.epdc.entity.PointsRuleEntity;
import java.util.List;
@ -93,4 +97,13 @@ public interface PointsRuleService extends BaseService<PointsRuleEntity> {
* @date 2020-04-28
*/
void delete(String[] ids);
/**
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.result.PointsRuleResultDTO>
* @Description 根据动作编码获取积分规则
* @Author songyunpeng
* @Date 2020/4/29
* @Param [behaviorCode]
**/
PointsRuleResultDTO getPointsRuleByBehaviorCode(String behaviorCode);
}

20
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsBehaviorServiceImpl.java

@ -29,6 +29,7 @@ import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dao.PointsBehaviorDao;
import com.elink.esua.epdc.dto.PointsBehaviorDTO;
import com.elink.esua.epdc.dto.result.BehaviorResultDto;
import com.elink.esua.epdc.entity.PointsBehaviorEntity;
import com.elink.esua.epdc.redis.PointsBehaviorRedis;
import com.elink.esua.epdc.service.PointsBehaviorService;
@ -70,8 +71,8 @@ public class PointsBehaviorServiceImpl extends BaseServiceImpl<PointsBehaviorDao
return ConvertUtils.sourceToTarget(entityList, PointsBehaviorDTO.class);
}
private QueryWrapper<PointsBehaviorEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<PointsBehaviorEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<PointsBehaviorEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -95,7 +96,7 @@ public class PointsBehaviorServiceImpl extends BaseServiceImpl<PointsBehaviorDao
PointsBehaviorEntity entity = ConvertUtils.sourceToTarget(dto, PointsBehaviorEntity.class);
insert(entity);
// 存入redis
redisUtils.set(RedisKeys.getAllRuleCodeKey(entity.getBehaviorCode()) , entity, RedisUtils.NOT_EXPIRE);
redisUtils.set(RedisKeys.getAllRuleCodeKey(entity.getBehaviorCode()), entity, RedisUtils.NOT_EXPIRE);
return new Result();
}
@ -131,7 +132,7 @@ public class PointsBehaviorServiceImpl extends BaseServiceImpl<PointsBehaviorDao
// 删除redis中的存储信息
redisUtils.delete(RedisKeys.getAllRuleCodeKey(queryEntity.getBehaviorCode()));
// 新增redis信息
redisUtils.set(RedisKeys.getAllRuleCodeKey(entity.getBehaviorCode()) , entity, RedisUtils.NOT_EXPIRE);
redisUtils.set(RedisKeys.getAllRuleCodeKey(entity.getBehaviorCode()), entity, RedisUtils.NOT_EXPIRE);
return new Result();
}
@ -145,6 +146,17 @@ public class PointsBehaviorServiceImpl extends BaseServiceImpl<PointsBehaviorDao
redisUtils.delete(RedisKeys.getAllRuleCodeKey(entity.getBehaviorCode()));
}
@Override
public Result<BehaviorResultDto> getBehaviorCodeInfoByBehaviorCode(String behaviorCode) {
if (StringUtils.isBlank(behaviorCode)) {
return new Result<BehaviorResultDto>().error("行为编码为空");
}
BehaviorResultDto behaviorResultDto = baseDao.getBehaviorCodeInfoByBehaviorCode(behaviorCode);
Result<BehaviorResultDto> resultDtoResult = new Result<>();
resultDtoResult.setData(behaviorResultDto);
return resultDtoResult;
}
@Override
public List<PointsBehaviorDTO> listBehaviorDesc() {
return baseDao.selectListBehaviorDesc();

26
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsLogsServiceImpl.java

@ -24,8 +24,12 @@ import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dao.PointsLogsDao;
import com.elink.esua.epdc.dto.PointsLogsDTO;
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO;
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO;
import com.elink.esua.epdc.dto.result.PointsLogsSumResultDTO;
import com.elink.esua.epdc.dto.form.EpdcAppPointsRankingFormDTO;
import com.elink.esua.epdc.dto.form.EpdcAppPointsRecordFormDTO;
import com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO;
@ -70,8 +74,8 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points
return ConvertUtils.sourceToTarget(entityList, PointsLogsDTO.class);
}
private QueryWrapper<PointsLogsEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<PointsLogsEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<PointsLogsEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -106,6 +110,24 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public List<PointsLogsResultDTO> getLogsByBehaviorCodeAndUserIdAndReferenceId(PointsLogsFormDTO pointsLogsFormDTO) {
List<PointsLogsResultDTO> pointsLogsResultDTO = baseDao.selecOneLogsByBehaviorCodeAndUserIdAndReferenceId(pointsLogsFormDTO);
return pointsLogsResultDTO;
}
@Override
public PointsLogsSumResultDTO getPointsSumByBehaviorCodeAndUserId(PointsLogsFormDTO pointsLogsFormDTO) {
PointsLogsSumResultDTO pointsLogsSumResultDTO = baseDao.getPointsSumByBehaviorCodeAndUserId(pointsLogsFormDTO);
return pointsLogsSumResultDTO;
}
@Override
public PointsLogsResultDTO getLastPointLogs(PointsLogsFormDTO pointsLogsFormDTO) {
PointsLogsResultDTO pointsLogsResultDTO = baseDao.getLastPointLogs(pointsLogsFormDTO);
return pointsLogsResultDTO;
}
@Override
public List<EpdcAppPointsRecordResultDTO> listPointsRecord(EpdcAppPointsRecordFormDTO formDto) {
int pageIndex = (formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize();

22
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsRuleServiceImpl.java

@ -20,15 +20,21 @@ package com.elink.esua.epdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.exception.ErrorCode;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.redis.RedisKeys;
import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dao.PointsRuleDao;
import com.elink.esua.epdc.dto.PointsRuleDTO;
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO;
import com.elink.esua.epdc.dto.result.BehaviorResultDto;
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO;
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO;
import com.elink.esua.epdc.entity.PointsRuleEntity;
import com.elink.esua.epdc.redis.PointsRuleRedis;
import com.elink.esua.epdc.service.PointsRuleService;
@ -70,8 +76,8 @@ public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, Points
return ConvertUtils.sourceToTarget(entityList, PointsRuleDTO.class);
}
private QueryWrapper<PointsRuleEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<PointsRuleEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -95,7 +101,7 @@ public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, Points
PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class);
insert(entity);
// 存入redis
redisUtils.set(RedisKeys.getAllPointsRuleCodeKey(entity.getRuleCode()) , entity, RedisUtils.NOT_EXPIRE);
redisUtils.set(RedisKeys.getAllPointsRuleCodeKey(entity.getRuleCode()), entity, RedisUtils.NOT_EXPIRE);
return new Result();
}
@ -131,7 +137,7 @@ public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, Points
// 删除redis中的存储信息
redisUtils.delete(RedisKeys.getAllPointsRuleCodeKey(queryEntity.getRuleCode()));
// 新增redis信息
redisUtils.set(RedisKeys.getAllPointsRuleCodeKey(entity.getRuleCode()) , entity, RedisUtils.NOT_EXPIRE);
redisUtils.set(RedisKeys.getAllPointsRuleCodeKey(entity.getRuleCode()), entity, RedisUtils.NOT_EXPIRE);
return new Result();
}
@ -145,4 +151,12 @@ public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, Points
redisUtils.delete(RedisKeys.getAllPointsRuleCodeKey(entity.getRuleCode()));
}
@Override
public PointsRuleResultDTO getPointsRuleByBehaviorCode(String behaviorCode) {
PointsRuleEntity pointsRuleEntity = baseDao.selecOnePointsRuleByBehaviorCode(behaviorCode);
PointsRuleResultDTO pointsRuleResultDTO = ConvertUtils.sourceToTarget(pointsRuleEntity, PointsRuleResultDTO.class);
return pointsRuleResultDTO;
}
}

12
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/application.yml

@ -84,4 +84,14 @@ mybatis-plus:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
rocketmq:
name-server: @rocketmq.name.server@
producer:
group: @rocketmq.producer.group@
consumer:
group: @rocketmq.consumer.group@
points-group: @rocketmq.consumer.points.group@

37
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsBehaviorDao.xml

@ -19,25 +19,34 @@
<select id="selectListPointsBehavior" resultType="com.elink.esua.epdc.dto.PointsBehaviorDTO">
SELECT
(@i:=@i+1) as orderNumber,
b.ID id,
b.BEHAVIOR_CODE behaviorCode,
b.BEHAVIOR_DESC behaviorDesc,
b.BEHAVIOR_RECORDING_TIME behaviorRecordingTime,
b.REMARK remark
(@i:=@i+1) as orderNumber,
b.ID id,
b.BEHAVIOR_CODE behaviorCode,
b.BEHAVIOR_DESC behaviorDesc,
b.BEHAVIOR_RECORDING_TIME behaviorRecordingTime,
b.REMARK remark
FROM
`epdc_points_behavior` b, (select @i:=0) as it
`epdc_points_behavior` b, (select @i:=0) as it
WHERE b.DEL_FLAG = 0
<if test="behaviorCode != null and behaviorCode != ''">
AND b.BEHAVIOR_CODE LIKE concat('%',#{behaviorCode},'%')
</if>
<if test="behaviorDesc != null and behaviorDesc != ''">
AND b.BEHAVIOR_DESC LIKE concat('%',#{behaviorDesc},'%')
</if>
<if test="behaviorCode != null and behaviorCode != ''">
AND b.BEHAVIOR_CODE LIKE concat('%',#{behaviorCode},'%')
</if>
<if test="behaviorDesc != null and behaviorDesc != ''">
AND b.BEHAVIOR_DESC LIKE concat('%',#{behaviorDesc},'%')
</if>
ORDER BY
b.CREATED_TIME
b.CREATED_TIME
</select>
<select id="getBehaviorCodeInfoByBehaviorCode" resultType="com.elink.esua.epdc.dto.result.BehaviorResultDto">
select ID,BEHAVIOR_CODE,BEHAVIOR_DESC,BEHAVIOR_RECORDING_TIME,REMARK,REVISION,DEL_FLAG,CREATED_BY
,CREATED_TIME,UPDATED_BY,UPDATED_TIME
from epdc_points_behavior where BEHAVIOR_CODE = #{behaviorCode} and DEL_FLAG ='0' limit 1;
</select>
<select id="selectListBehaviorDesc" resultType="com.elink.esua.epdc.dto.PointsBehaviorDTO">
SELECT
b.BEHAVIOR_CODE behaviorCode,

89
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsLogsDao.xml

@ -39,27 +39,82 @@
l.OPERATION_TIME DESC
LIMIT #{pageIndex}, #{pageSize}
</select>
<select id="selecOneLogsByBehaviorCodeAndUserIdAndReferenceId"
resultType="com.elink.esua.epdc.dto.result.PointsLogsResultDTO">
select ID,USER_ID,REFERENCE_ID,RULE_CODE,BEHAVIOR_CODE,POINTS,OPERATION_DESC,OPERATION_TIME,OPERATION_MODE
,LAVE_POINTS,REVISION,DEL_FLAG,CREATED_BY,CREATED_TIME,UPDATED_BY,UPDATED_TIME
from epdc_points_logs where DEL_FLAG ='0' and USER_ID = #{userId} and REFERENCE_ID = #{referenceId}
and RULE_CODE = #{ruleCode}
</select>
<select id="getPointsSumByBehaviorCodeAndUserId" resultType="com.elink.esua.epdc.dto.result.PointsLogsSumResultDTO">
select sum(z) - sum(f) as total,OPERATION_TIME from(
select
case when OPERATION_TYPE =0 then sum(POINTS) else 0 end as f,
case when OPERATION_TYPE =1 then sum(POINTS) else 0 end as z,
BEHAVIOR_CODE,
(select OPERATION_TIME from epdc_points_logs where LAVE_POINTS = #{upperLimitVal} order by OPERATION_TIME desc
limit 1) as OPERATION_TIME
from epdc_points_logs where USER_ID = #{userId} and BEHAVIOR_CODE = #{behaviorCode}
<if test="operationFlag == 0">
and OPERATION_TIME between (select OPERATION_TIME from epdc_points_logs where LAVE_POINTS = #{upperLimitVal}
order by OPERATION_TIME desc limit 1) and
(select date_add(OPERATION_TIME,interval +1 minute )from epdc_points_logs where LAVE_POINTS =
#{upperLimitVal} order by OPERATION_TIME desc limit 1)
</if>
<if test="operationFlag == 1">
and OPERATION_TIME between (select OPERATION_TIME from epdc_points_logs where LAVE_POINTS = #{upperLimitVal}
order by OPERATION_TIME desc limit 1) and
(select date_add(OPERATION_TIME,interval +1 hour )from epdc_points_logs where LAVE_POINTS = #{upperLimitVal}
order by OPERATION_TIME desc limit 1)
</if>
<if test="operationFlag == 2">
and OPERATION_TIME between (select OPERATION_TIME from epdc_points_logs where LAVE_POINTS = #{upperLimitVal}
order by OPERATION_TIME desc limit 1) and
(select date_add(OPERATION_TIME,interval +1 day )from epdc_points_logs where LAVE_POINTS = #{upperLimitVal}
order by OPERATION_TIME desc limit 1)
</if>
<if test="operationFlag == 3">
and OPERATION_TIME between (select OPERATION_TIME from epdc_points_logs where LAVE_POINTS = #{upperLimitVal}
order by OPERATION_TIME desc limit 1) and
(select date_add(OPERATION_TIME,interval +1 month )from epdc_points_logs where LAVE_POINTS =
#{upperLimitVal} order by OPERATION_TIME desc limit 1)
</if>
<if test="operationFlag == 4">
and OPERATION_TIME between (select OPERATION_TIME from epdc_points_logs where LAVE_POINTS = #{upperLimitVal}
order by OPERATION_TIME desc limit 1) and
(select date_add(OPERATION_TIME,interval +1 year )from epdc_points_logs where LAVE_POINTS = #{upperLimitVal}
order by OPERATION_TIME desc limit 1)
</if>
group by OPERATION_TYPE)a group by a.BEHAVIOR_CODE;
</select>
<select id="getLastPointLogs" resultType="com.elink.esua.epdc.dto.result.PointsLogsResultDTO">
select ID,USER_ID,REFERENCE_ID,RULE_CODE,BEHAVIOR_CODE,POINTS,OPERATION_DESC,OPERATION_TIME,OPERATION_MODE
,LAVE_POINTS,REVISION,DEL_FLAG,CREATED_BY,CREATED_TIME,UPDATED_BY,UPDATED_TIME
from epdc_points_logs where DEL_FLAG ='0' and USER_ID = #{userId}
and BEHAVIOR_CODE = #{behaviorCode} order by OPERATION_TIME desc limit 1
</select>
<select id="selectListPointsRanking" resultType="com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO">
SELECT
tab.USER_ID userId,
tab.NICKNAME nickName,
(tab.totalPointsAdd - tab.totalPointsDeducted) points
tab.USER_ID userId,
tab.NICKNAME nickName,
(tab.totalPointsAdd - tab.totalPointsDeducted) points
FROM(
SELECT
USER_ID,
NICKNAME,
SUM(case when OPERATION_TYPE = 0 then IFNULL(points,0) else 0 end) totalPointsDeducted,
SUM(case when OPERATION_TYPE = 1 then IFNULL(points,0) else 0 end) totalPointsAdd
FROM epdc_points_logs
WHERE DEL_FLAG = 0
<if test="rankingType != null and rankingType == 0">
AND YEARWEEK(date_format(OPERATION_TIME,'%Y-%m-%d')) = YEARWEEK(now())
</if>
<if test="rankingType != null and rankingType == 1">
AND DATE_FORMAT( OPERATION_TIME, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' )
</if>
GROUP BY USER_ID
SELECT
USER_ID,
NICKNAME,
SUM(case when OPERATION_TYPE = 0 then IFNULL(points,0) else 0 end) totalPointsDeducted,
SUM(case when OPERATION_TYPE = 1 then IFNULL(points,0) else 0 end) totalPointsAdd
FROM epdc_points_logs
WHERE DEL_FLAG = 0
<if test="rankingType != null and rankingType == 0">
AND YEARWEEK(date_format(OPERATION_TIME,'%Y-%m-%d')) = YEARWEEK(now())
</if>
<if test="rankingType != null and rankingType == 1">
AND DATE_FORMAT( OPERATION_TIME, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' )
</if>
GROUP BY USER_ID
) tab ORDER BY (tab.totalPointsAdd - tab.totalPointsDeducted) DESC
LIMIT #{pageIndex}, #{pageSize}
</select>

10
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsRuleDao.xml

@ -24,12 +24,10 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="getBehaviorCodeInfoByBehaviorCode" resultType="com.elink.esua.epdc.dto.result.BehaviorResultDto">
select ID,BEHAVIOR_CODE,BEHAVIOR_DESC,BEHAVIOR_RECORDING_TIME,REMARK,REVISION,DEL_FLAG,CREATED_BY
,CREATED_TIME,UPDATED_BY,UPDATED_TIME
from epdc_points_behavior where BEHAVIOR_CODE = #{behaviorCode} and DEL_FLAG ='1' limit 1;
<select id="selecOnePointsRuleByBehaviorCode" resultMap="pointsRuleMap">
select ID,RULE_CODE,BEHAVIOR_CODE,RULE_DESC,OPERATION_TYPE,POINTS,LIMIT_TYPE,UPPER_LIMIT_VAL
,ENABLE_FLAG,ADDED_VAL,REMARK,REVISION,DEL_FLAG,CREATED_BY,CREATED_TIME,UPDATED_BY,UPDATED_TIME,LIMIT_NUM
from epdc_points_rule where BEHAVIOR_CODE = #{behaviorCode} limit 1
</select>
<select id="selectListPointsRule" resultType="com.elink.esua.epdc.dto.PointsRuleDTO">

5
esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/UserDTO.java

@ -206,6 +206,11 @@ public class UserDTO implements Serializable {
*/
private Integer points;
/**
* 用户累计积分
*/
private Integer points_totle;
/**
* 邀请人ID
*/

6
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/UserEntity.java

@ -203,6 +203,12 @@ public class UserEntity extends BaseEpdcEntity {
*/
private Integer points;
/**
* 用户累计积分
*/
private Integer points_totle;
/**
* 邀请人ID
*/

Loading…
Cancel
Save