Browse Source

爱心互助-居民端接口3

dev_shibei_match
zhangyongzhangyong 5 years ago
parent
commit
423a9fef1d
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 9
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActInfoDTO.java
  3. 81
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ActUserClockLogFormDTO.java
  4. 61
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActRegistrationFormDTO.java
  5. 1
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActSignInFormDTO.java
  6. 13
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiVolunteerAuthenticateFormDTO.java
  7. 14
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  8. 8
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java
  9. 14
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java
  10. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java
  11. 12
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActUserLogDao.java
  12. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/HeartUserInfoDao.java
  13. 26
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/VolunteerInfoDao.java
  14. 4
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/VolunteerInfoEntity.java
  15. 12
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActInfoService.java
  16. 12
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserLogService.java
  17. 12
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java
  18. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/HeartUserInfoService.java
  19. 5
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActInfoServiceImpl.java
  20. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserLogServiceImpl.java
  21. 102
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java
  22. 5
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/HeartUserInfoServiceImpl.java
  23. 39
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java
  24. 13
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml
  25. 12
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActUserLogDao.xml
  26. 23
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/HeartUserInfoDao.xml
  27. 28
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/VolunteerInfoDao.xml
  28. 14
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -76,6 +76,8 @@ public enum EpmetErrorCode {
// 爱心互助 居民端
NOT_IN_THE_SIGN_IN_RANGE(8510, "您还未进入指定的签到范围~"),
NON_CERTIFIED_VOLUNTEER(8511, "活动报名失败,请先认证志愿者"),
ACT_TIME_CONFLICT(8512, "活动时间冲突"),
// 该错误不会提示给前端,只是后端传输错误信息用。
ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"),

9
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActInfoDTO.java

@ -247,4 +247,11 @@ public class ActInfoDTO implements Serializable {
*/
private String delFlag;
}
// 虚字段
/**
* 用户id
*/
private String userId;
}

81
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ActUserClockLogFormDTO.java

@ -1,81 +0,0 @@
/**
* 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.epmet.dto.form.resi;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
/**
* 用户活动打卡参数
*
* @author zhangyong
* @since v1.0.0 2020-07-14
*/
@Data
public class ActUserClockLogFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private String userId;
/**
* 活动ID
*/
@NotBlank(message = "活动ID不能为空")
private String actId;
/**
* 打卡类型0-打卡1-更新打卡
*/
@NotBlank(message = "打卡类型不能为空")
private String clockType;
/**
* 打卡位置经度
*/
@NotBlank(message = "打卡位置经度不能为空")
private BigDecimal clockLongitude;
/**
* 打卡位置纬度
*/
@NotBlank(message = "打卡位置纬度不能为空")
private BigDecimal clockLatitude;
/**
* 打卡地址
*/
@NotBlank(message = "打卡地址不能为空")
private String clockAddress;
/**
* 打卡描述
*/
@NotBlank(message = "打卡描述不能为空")
private String clockDesc;
/**
* 打卡是否有效0-1-
*/
@NotBlank(message = "打卡是否有效不能为空")
private String effectiveFlag;
/**
* 打卡图片
*/
private ArrayList<String> images;
}

61
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActRegistrationFormDTO.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.epmet.dto.form.resi;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 活动报名参数
*
* @author zhangyong
* @since v1.0.0 2020-07-20
*/
@Data
public class ResiActRegistrationFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
//>>>>>>>>>>>>>>>>>校验分组开始>>>>>>>>>>>>>>>>>>>>>
/**
* 添加用户操作的内部异常分组
* 出现错误会提示给前端7000错误码返回信息为服务器开小差...
*/
public interface AddUserInternalGroup {}
// <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<<
/**
* 用户Id
*/
private String userId;
/**
* 活动ID
*/
@NotBlank(message = "活动ID不能为空", groups = { AddUserInternalGroup.class })
private String actId;
/**
* 客户ID
*/
@NotBlank(message = "客户ID不能为空", groups = { AddUserInternalGroup.class })
private String customerId;
}

1
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActSignInFormDTO.java

@ -21,7 +21,6 @@ import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.awt.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

13
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiVolunteerAuthenticateFormDTO.java

@ -34,6 +34,17 @@ public class ResiVolunteerAuthenticateFormDTO implements Serializable {
// <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<<
/**
* 用户id
*/
private String userId;
/**
* 客户id
*/
@NotBlank(message = "客户id不能为空", groups = {AddUserShowGroup.class })
private String customerId;
/**
*
*/
@ -97,7 +108,7 @@ public class ResiVolunteerAuthenticateFormDTO implements Serializable {
* 头像
*/
@NotBlank(message = "头像不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class })
private String headImgUrl;
private String avatarUrl;
/**
* 志愿者签名

14
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetUserFeignClient.java

@ -1,7 +1,10 @@
package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.UserRoleFormDTO;
import com.epmet.dto.form.WxUserInfoFormDTO;
import com.epmet.dto.result.UserBaseInfoResultDTO;
import com.epmet.dto.result.UserRoleResultDTO;
import com.epmet.feign.fallback.EpmetUserFeignClientFallBack;
@ -43,4 +46,15 @@ public interface EpmetUserFeignClient {
**/
@PostMapping(value = "epmetuser/userrole/getuserroleinfobyuserid/{userId}", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<List<UserRoleResultDTO>> getUserRoleInfoByUserId(@PathVariable("userId") String userId);
/**
* 同步-居民基础信息用户微信信息
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
* @Author zhangyong
* @Date 14:37 2020-07-23
**/
@PostMapping("epmetuser/user/updateUserBaseAndWxUserInfo")
Result updateUserBaseAndWxUserInfo(@RequestBody WxUserInfoFormDTO formDTO);
}

8
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java

@ -1,9 +1,10 @@
package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.WxUserInfoFormDTO;
import com.epmet.dto.result.UserBaseInfoResultDTO;
import com.epmet.dto.result.UserRoleResultDTO;
import com.epmet.feign.EpmetUserFeignClient;
@ -28,4 +29,9 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient {
public Result<List<UserRoleResultDTO>> getUserRoleInfoByUserId(String userId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserRoleInfoByUserId", userId);
}
@Override
public Result updateUserBaseAndWxUserInfo(WxUserInfoFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "updateUserBaseAndWxUserInfo", formDTO);
}
}

14
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java

@ -282,4 +282,18 @@ public class ResiActListController {
return actSignInRecService.actSignIn(tokenDto, formDTO);
}
/**
* 活动报名
*
* @param tokenDto
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
* @Author zhangyong
* @Date 16:46 2020-07-23
**/
@PostMapping("registration")
public Result registration(@LoginUser TokenDto tokenDto, @RequestBody ResiActRegistrationFormDTO formDTO) {
return actUserRelationService.registration(tokenDto, formDTO);
}
}

10
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java

@ -215,4 +215,14 @@ public interface ActInfoDao extends BaseDao<ActInfoEntity> {
* @Date 09:56 2020-07-22
**/
List<ResiActContentResultDTO> selectListActContent(@Param("actId") String actId);
/**
* 查询当前报名的活动开始时间-结束时间是否与其他已报名未结束的活动存在交集情况
*
* @param actInfoDTO
* @return java.lang.Integer
* @Author zhangyong
* @Date 17:17 2020-07-23
**/
Integer checkActTime(ActInfoDTO actInfoDTO);
}

12
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActUserLogDao.java

@ -51,4 +51,14 @@ public interface ActUserLogDao extends BaseDao<ActUserLogEntity> {
* @Date 2020/7/23 14:13
**/
ActUserLogDTO selectLatestRefused(@Param("actId") String actId, @Param("userId") String userId);
}
/**
* 查询我累计报名过的活动次数
*
* @param userId
* @return java.lang.Integer
* @Author zhangyong
* @Date 16:12 2020-07-23
**/
Integer countActTimesOfParticipation(@Param("userId") String userId);
}

10
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/HeartUserInfoDao.java

@ -66,4 +66,14 @@ public interface HeartUserInfoDao extends BaseDao<HeartUserInfoEntity> {
* @Date 18:06 2020-07-22
**/
List<HeartUserInfoDTO> selectListLeaderboard(ResiActBaseFormDTO formDTO);
/**
* 根据用户id修改用户信息表
*
* @param dto
* @return void
* @Author zhangyong
* @Date 16:27 2020-07-23
**/
void updateHeartUserInfoByUserId(HeartUserInfoDTO dto);
}

26
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/VolunteerInfoDao.java

@ -20,6 +20,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.VolunteerInfoEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 志愿者信息
@ -29,5 +30,26 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface VolunteerInfoDao extends BaseDao<VolunteerInfoEntity> {
}
/**
* 查询用户是否是志愿者身份
* >0
* 0 不是
*
* @param userId
* @return java.lang.String
* @Author zhangyong
* @Date 14:33 2020-07-23l
**/
Integer queryVolunteerFlagByUserId(@Param("userId") String userId);
/**
* 根据用户ID修改志愿者信息
*
* @param entity
* @return void
* @Author zhangyong
* @Date 15:05 2020-07-23
**/
void updateVolunteerInfoByUserId(VolunteerInfoEntity entity);
}

4
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/VolunteerInfoEntity.java

@ -44,8 +44,8 @@ public class VolunteerInfoEntity extends BaseEpmetEntity {
private String userId;
/**
* 客户id
*/
* 客户id
*/
private String customerId;
/**

12
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActInfoService.java

@ -26,6 +26,8 @@ import com.epmet.dto.result.resi.*;
import com.epmet.entity.ActInfoEntity;
import com.epmet.commons.tools.utils.Result;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -212,4 +214,14 @@ public interface ActInfoService extends BaseService<ActInfoEntity> {
* @Date 13:39 2020-07-21
**/
Result<ResiActRefusedDetailResultDTO> rejectDetail(TokenDto tokenDto, ResiActDetailFormDTO formDto);
/**
* 查询当前报名的活动开始时间-结束时间是否与其他已报名未结束的活动存在交集情况
*
* @param actInfoDTO
* @return java.lang.Integer
* @Author zhangyong
* @Date 17:17 2020-07-23
**/
Integer checkActTime(ActInfoDTO actInfoDTO);
}

12
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserLogService.java

@ -92,4 +92,14 @@ public interface ActUserLogService extends BaseService<ActUserLogEntity> {
* @date 2020-07-19
*/
void delete(String[] ids);
}
/**
* 查询我累计报名过的活动次数
*
* @param userId
* @return java.lang.Integer
* @Author zhangyong
* @Date 16:12 2020-07-23
**/
Integer countActTimesOfParticipation(String userId);
}

12
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java

@ -22,6 +22,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.ActUserRelationDTO;
import com.epmet.dto.form.resi.ResiActRegistrationFormDTO;
import com.epmet.dto.form.resi.ResiActUserCancelSignUpFormDTO;
import com.epmet.entity.ActUserRelationEntity;
import org.apache.ibatis.annotations.Param;
@ -138,4 +139,15 @@ public interface ActUserRelationService extends BaseService<ActUserRelationEntit
* @Date 09:29 2020-07-20
**/
Result cancelSignUp(TokenDto tokenDto, ResiActUserCancelSignUpFormDTO formDTO);
/**
* 活动报名
*
* @param tokenDto
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
* @Author zhangyong
* @Date 16:46 2020-07-23
**/
Result registration(TokenDto tokenDto, ResiActRegistrationFormDTO formDTO);
}

10
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/HeartUserInfoService.java

@ -117,4 +117,14 @@ public interface HeartUserInfoService extends BaseService<HeartUserInfoEntity> {
* @Date 17:42 2020-07-22
**/
Result<List<ResiLeaderboardResultDTO>> leaderboard(ResiActBaseFormDTO formDTO);
/**
* 根据用户id修改用户信息表
*
* @param dto
* @return void
* @Author zhangyong
* @Date 16:27 2020-07-23
**/
void updateHeartUserInfoByUserId(HeartUserInfoDTO dto);
}

5
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActInfoServiceImpl.java

@ -370,4 +370,9 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
throw new RenException(EpmetErrorCode.NOT_IN_THE_SIGN_IN_RANGE.getCode());
}
}
@Override
public Integer checkActTime(ActInfoDTO actInfoDTO) {
return baseDao.checkActTime(actInfoDTO);
}
}

6
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserLogServiceImpl.java

@ -101,4 +101,8 @@ public class ActUserLogServiceImpl extends BaseServiceImpl<ActUserLogDao, ActUse
baseDao.deleteBatchIds(Arrays.asList(ids));
}
}
@Override
public Integer countActTimesOfParticipation(String userId) {
return baseDao.countActTimesOfParticipation(userId);
}
}

102
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java

@ -20,21 +20,36 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.EpmetRoleKeyConstant;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.ActUserRelationDao;
import com.epmet.dao.HeartUserInfoDao;
import com.epmet.dao.VolunteerInfoDao;
import com.epmet.dto.ActInfoDTO;
import com.epmet.dto.ActUserLogDTO;
import com.epmet.dto.ActUserRelationDTO;
import com.epmet.dto.form.resi.ResiActRegistrationFormDTO;
import com.epmet.dto.form.resi.ResiActUserCancelSignUpFormDTO;
import com.epmet.dto.result.UserRoleResultDTO;
import com.epmet.entity.ActUserLogEntity;
import com.epmet.entity.ActUserRelationEntity;
import com.epmet.entity.HeartUserInfoEntity;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.redis.ActUserRelationRedis;
import com.epmet.service.ActInfoService;
import com.epmet.service.ActUserLogService;
import com.epmet.service.ActUserRelationService;
import com.epmet.utils.ActUserRelationStatusConstant;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -56,6 +71,16 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD
private ActUserRelationRedis actUserRelationRedis;
@Autowired
private ActUserLogService actUserLogService;
@Autowired
private ActInfoService actInfoService;
@Autowired
private VolunteerInfoDao volunteerInfoDao;
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
private HeartUserInfoDao heartUserInfoDao;
private Logger logger = LogManager.getLogger(WorkActDraftServiceImpl.class);
@Override
public PageData<ActUserRelationDTO> page(Map<String, Object> params) {
@ -168,4 +193,79 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD
actUserLogService.save(userLogDTO);
return new Result();
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result registration(TokenDto tokenDto, ResiActRegistrationFormDTO formDTO) {
formDTO.setUserId(tokenDto.getUserId());
boolean satisfy = false;
// 查询活动信息
ActInfoDTO actInfoDTO = actInfoService.get(formDTO.getActId());
if (actInfoDTO.getVolunteerLimit()){
// 活动只能志愿者参加
Integer volunteerFlag = volunteerInfoDao.queryVolunteerFlagByUserId(formDTO.getUserId());
if (volunteerFlag > NumConstant.ZERO){
satisfy = true;
} else {
logger.info("活动报名失败,请先认证志愿者");
throw new RenException(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER.getCode());
}
} else {
// 活动不限制志愿者身份,但要求是 居民身份
Result<List<UserRoleResultDTO>> userRoleInfo = epmetUserFeignClient.getUserRoleInfoByUserId(formDTO.getUserId());
for (UserRoleResultDTO roleResultDTO :userRoleInfo.getData()){
if (EpmetRoleKeyConstant.REGISTERED_RESI.equals(roleResultDTO.getRoleKey())){
satisfy = true;
}
}
if (!satisfy){
logger.info("活动报名失败,请完善居民信息");
throw new RenException(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode());
}
}
if (satisfy){
this.actStartSignUp(actInfoDTO, formDTO);
}
return new Result();
}
private void actStartSignUp(ActInfoDTO actInfoDTO, ResiActRegistrationFormDTO formDTO){
boolean signUp = true;
Integer auditingNum = actUserLogService.countActTimesOfParticipation(formDTO.getUserId());
if (auditingNum > NumConstant.ZERO){
// 2.判断本次报名的活动与之前未结束的活动报名时间 是否产生交集,产生则 报名失败
actInfoDTO.setUserId(formDTO.getUserId());
Integer actTimeFlag = actInfoService.checkActTime(actInfoDTO);
if (actTimeFlag > NumConstant.ZERO){
signUp = false;
logger.info("活动报名失败,活动时间冲突");
throw new RenException(EpmetErrorCode.ACT_TIME_CONFLICT.getCode());
}
} else {
// 3.第一次报名
HeartUserInfoEntity entity = new HeartUserInfoEntity();
entity.setCustomerId(formDTO.getCustomerId());
entity.setUserId(formDTO.getUserId());
entity.setVolunteerFlag(true);
entity.setKindnessTime(NumConstant.ZERO);
entity.setParticipationNum(NumConstant.ZERO);
entity.setObtainPointNum(NumConstant.ZERO);
heartUserInfoDao.insert(entity);
}
if (signUp){
// 4.插入用户活动关系表
ActUserRelationEntity entity = new ActUserRelationEntity();
entity.setActId(formDTO.getActId());
entity.setUserId(formDTO.getUserId());
entity.setStatus(ActUserRelationStatusConstant.AUDITING);
baseDao.insert(entity);
// 5.插入活动日志表
ActUserLogEntity userLogEntity = new ActUserLogEntity();
userLogEntity.setActId(formDTO.getActId());
userLogEntity.setUserId(formDTO.getUserId());
userLogEntity.setOperationType(ActUserRelationStatusConstant.AUDITING);
actUserLogService.insert(userLogEntity);
}
}
}

5
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/HeartUserInfoServiceImpl.java

@ -150,4 +150,9 @@ public class HeartUserInfoServiceImpl extends BaseServiceImpl<HeartUserInfoDao,
}
return new Result<List<ResiLeaderboardResultDTO>>().ok(resultDTOS);
}
@Override
public void updateHeartUserInfoByUserId(HeartUserInfoDTO dto) {
baseDao.updateHeartUserInfoByUserId(dto);
}
}

39
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java

@ -20,16 +20,21 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.VolunteerInfoDao;
import com.epmet.dto.HeartUserInfoDTO;
import com.epmet.dto.VolunteerInfoDTO;
import com.epmet.dto.form.WxUserInfoFormDTO;
import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO;
import com.epmet.entity.VolunteerInfoEntity;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.redis.VolunteerInfoRedis;
import com.epmet.service.HeartUserInfoService;
import com.epmet.service.VolunteerInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -52,19 +57,33 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao,
@Autowired
private VolunteerInfoRedis volunteerInfoRedis;
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
private HeartUserInfoService heartUserInfoService;
@Override
@Transactional(rollbackFor = Exception.class)
public Result authenticate(TokenDto tokenDto, ResiVolunteerAuthenticateFormDTO formDTO) {
formDTO.setUserId(tokenDto.getUserId());
// 检查是否是志愿者
// 是志愿者
// 更新志愿者信息表
// 更新用户基础信息表
// 更新用户微信表
// 不是志愿者
// 插入志愿者信息表
// 更新用户基础信息表
// 更新用户微信表
return null;
Integer volunteerFlag = baseDao.queryVolunteerFlagByUserId(tokenDto.getUserId());
VolunteerInfoEntity volunteerInfoEntity = ConvertUtils.sourceToTarget(formDTO, VolunteerInfoEntity.class);
if (volunteerFlag > NumConstant.ZERO){
// 是志愿者:更新志愿者信息表
baseDao.updateVolunteerInfoByUserId(volunteerInfoEntity);
} else {
// 不是志愿者:插入志愿者信息表
baseDao.insert(volunteerInfoEntity);
// 更新用户信息表的 是否是志愿者标识
HeartUserInfoDTO userInfoDTO = new HeartUserInfoDTO();
userInfoDTO.setUserId(tokenDto.getUserId());
userInfoDTO.setVolunteerFlag(true);
heartUserInfoService.updateHeartUserInfoByUserId(userInfoDTO);
}
// 更新用户基础信息表 并 更新用户微信表
WxUserInfoFormDTO wxUserInfoFormDTO = ConvertUtils.sourceToTarget(formDTO, WxUserInfoFormDTO.class);
return epmetUserFeignClient.updateUserBaseAndWxUserInfo(wxUserInfoFormDTO);
}
}

13
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml

@ -444,4 +444,17 @@
AND c.ACT_ID = #{actId}
ORDER BY c.ORDER_NUM ASC
</select>
<!-- 查询当前报名的活动开始时间-结束时间,是否与其他已报名,未结束的活动,存在交集情况 -->
<select id="checkActTime" parameterType="com.epmet.dto.ActInfoDTO"
resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM act_info
WHERE DEL_FLAG = '0'
AND USER_ID = #{userId}
AND ACT_STATUS = 'published'
AND ((#{actStartTime} BETWEEN ACT_START_TIME AND ACT_END_TIME OR #{actEndTime} BETWEEN ACT_START_TIME AND ACT_END_TIME)
or (ACT_START_TIME BETWEEN #{actStartTime} AND #{actEndTime} OR ACT_END_TIME BETWEEN #{actStartTime} AND #{actEndTime}));
</select>
</mapper>

12
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActUserLogDao.xml

@ -42,4 +42,14 @@
order by acl.CREATED_TIME desc
limit 1
</select>
</mapper>
<!-- 查询我累计报名过的活动次数 -->
<select id="countActTimesOfParticipation" parameterType="java.lang.String" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM act_user_log
WHERE DEL_FLAG = '0'
AND USER_ID = #{userId}
AND OPERATION_TYPE = 'auditing'
</select>
</mapper>

23
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/HeartUserInfoDao.xml

@ -55,4 +55,27 @@
ORDER BY ui.KINDNESS_TIME DESC, ui.PARTICIPATION_NUM DESC
LIMIT #{pageNo}, #{pageSize}
</select>
<update id="updateHeartUserInfoByUserId" parameterType="com.epmet.dto.HeartUserInfoDTO">
UPDATE heart_user_info
SET
<if test="volunteerFlag != null and volunteerFlag != ''">
VOLUNTEER_FLAG = 1,
</if>
<if test="kindnessTime != null and kindnessTime != ''">
KINDNESS_TIME = #{kindnessTime},
</if>
<if test="participationNum != null and participationNum != ''">
PARTICIPATION_NUM = #{participationNum},
</if>
<if test="obtainPointNum != null and obtainPointNum != ''">
OBTAIN_POINT_NUM = #{obtainPointNum},
</if>
<if test="userId != null and userId != ''">
UPDATED_BY = #{userId},
</if>
UPDATED_TIME = now()
WHERE DEL_FLAG = '0'
AND USER_ID = #{userId}
</update>
</mapper>

28
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/VolunteerInfoDao.xml

@ -17,5 +17,31 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="queryVolunteerFlagByUserId" parameterType="java.lang.String" resultType="java.lang.Integer">
SELECT
count(1)
FROM volunteer_info
WHERE DEL_FLAG = '0'
AND USER_ID = #{userId}
</select>
</mapper>
<update id="updateVolunteerInfoByUserId" parameterType="com.epmet.entity.VolunteerInfoEntity">
UPDATE volunteer_info
SET
<if test="customerId != null and customerId != ''">
CUSTOMER_ID = #{customerId},
</if>
<if test="volunteerIntroduce != null and volunteerIntroduce.trim() != ''">
VOLUNTEER_INTRODUCE = #{volunteerIntroduce},
</if>
<if test="volunteerSignature != null and volunteerSignature.trim() != ''">
VOLUNTEER_SIGNATURE = #{volunteerSignature},
</if>
<if test="userId != null and userId != ''">
UPDATED_BY = #{userId},
</if>
UPDATED_TIME = now()
WHERE DEL_FLAG = '0'
AND USER_ID = #{userId}
</update>
</mapper>

14
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java

@ -132,4 +132,18 @@ public class UserController {
return new Result<UserDTO>().ok(userService.saveWxUser(formDTO));
}
/**
* 居民端个人信息-同步用户微信信息
* 供Feign调用
*
* @param wxUserInfoFormDTO
* @return com.epmet.commons.tools.utils.Result
* @Author zhangyong
* @Date 14:51 2020-07-23
**/
@PostMapping("updateUserBaseAndWxUserInfo")
public Result updateUserBaseAndWxUserInfo(@RequestBody WxUserInfoFormDTO wxUserInfoFormDTO) { ;
ValidatorUtils.validateEntity(wxUserInfoFormDTO);
return userService.updateWxUserInfo(wxUserInfoFormDTO);
}
}

Loading…
Cancel
Save