17 changed files with 570 additions and 15 deletions
@ -0,0 +1,30 @@ |
|||||
|
package com.epmet.dto.form.work; |
||||
|
|
||||
|
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 积分发放给分,不给分,通用入参 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/7/24 13:10 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class GrantPointsFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 4785107755585941804L; |
||||
|
public interface AddUserInternalGroup { |
||||
|
} |
||||
|
public interface DenyUserShowGroup extends CustomerClientShowGroup { |
||||
|
} |
||||
|
/** |
||||
|
* 积分发放待处理列表返参中的actUserRelationId |
||||
|
*/ |
||||
|
@NotBlank(message = "主键不能为空", groups = {AddUserInternalGroup.class,DenyUserShowGroup.class}) |
||||
|
private String actUserRelationId; |
||||
|
|
||||
|
@NotBlank(message = "理由不能为空", groups = {DenyUserShowGroup.class}) |
||||
|
private String denyRewardReason; |
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
package com.epmet.dto.result.work; |
||||
|
|
||||
|
import com.epmet.commons.tools.constant.StrConstant; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 积分发放-待处理列表 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/7/24 12:20 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PendingUserResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -5744298386442386198L; |
||||
|
/** |
||||
|
* 活动id |
||||
|
*/ |
||||
|
private String actId; |
||||
|
|
||||
|
/** |
||||
|
* 活动标题 |
||||
|
*/ |
||||
|
private String title; |
||||
|
|
||||
|
/** |
||||
|
* 积分奖励 |
||||
|
*/ |
||||
|
private Integer reward; |
||||
|
|
||||
|
/** |
||||
|
* 已签到人员列表 |
||||
|
*/ |
||||
|
private List<UserBaseInfo> signedInList; |
||||
|
|
||||
|
/** |
||||
|
* 未签到人员列表 |
||||
|
*/ |
||||
|
private List<UserBaseInfo> noSignInList; |
||||
|
public PendingUserResultDTO(String actId){ |
||||
|
this.actId= actId; |
||||
|
this.title=StrConstant.EPMETY_STR; |
||||
|
this.reward=0; |
||||
|
this.signedInList=new ArrayList<>(); |
||||
|
this.noSignInList=new ArrayList<>(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
package com.epmet.dto.result.work; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 积分发放待处理界面,用户基本信息 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/7/24 12:22 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class UserBaseInfo implements Serializable { |
||||
|
private static final long serialVersionUID = 4316319460642833716L; |
||||
|
/** |
||||
|
* act_user_relation主键 |
||||
|
*/ |
||||
|
private String actUserRelationId; |
||||
|
|
||||
|
/** |
||||
|
* 用户id |
||||
|
*/ |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 姓名 |
||||
|
*/ |
||||
|
private String realName; |
||||
|
|
||||
|
/** |
||||
|
* 微信昵称 |
||||
|
*/ |
||||
|
private String nickName; |
||||
|
|
||||
|
/** |
||||
|
* 头像 |
||||
|
*/ |
||||
|
private String headImgUrl; |
||||
|
|
||||
|
/** |
||||
|
* true: 是志愿者 false : 不是志愿者 |
||||
|
*/ |
||||
|
private Boolean volunteerFlag; |
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.dto.form.work.GrantPointsFormDTO; |
||||
|
import com.epmet.dto.result.work.PendingUserResultDTO; |
||||
|
|
||||
|
/** |
||||
|
* 描述一下 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/7/24 12:26 |
||||
|
*/ |
||||
|
public interface GrantPointsService { |
||||
|
/** |
||||
|
* @return com.epmet.dto.result.work.PendingUserResultDTO |
||||
|
* @param actId |
||||
|
* @author yinzuomei |
||||
|
* @description 积分发放-待处理列表 |
||||
|
* @Date 2020/7/24 12:28 |
||||
|
**/ |
||||
|
PendingUserResultDTO queryPendingList(String actId); |
||||
|
|
||||
|
/** |
||||
|
* @return void |
||||
|
* @param formDTO |
||||
|
* @author yinzuomei |
||||
|
* @description 积分发放-给分 |
||||
|
* @Date 2020/7/24 13:34 |
||||
|
**/ |
||||
|
void agree(GrantPointsFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* @return void |
||||
|
* @param formDTO |
||||
|
* @author yinzuomei |
||||
|
* @description 积分发放-不给分 |
||||
|
* @Date 2020/7/24 15:03 |
||||
|
**/ |
||||
|
void deny(GrantPointsFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* @return void |
||||
|
* @param formDTO |
||||
|
* @author yinzuomei |
||||
|
* @description 积分发放-重新处理 |
||||
|
* @Date 2020/7/24 15:16 |
||||
|
**/ |
||||
|
void reset(GrantPointsFormDTO formDTO); |
||||
|
} |
@ -0,0 +1,236 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.constant.StrConstant; |
||||
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
||||
|
import com.epmet.commons.tools.exception.RenException; |
||||
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
||||
|
import com.epmet.constant.ActConstant; |
||||
|
import com.epmet.dao.ActUserRelationDao; |
||||
|
import com.epmet.dto.ActInfoDTO; |
||||
|
import com.epmet.dto.ActPointLogDTO; |
||||
|
import com.epmet.dto.ActUserRelationDTO; |
||||
|
import com.epmet.dto.form.work.GrantPointsFormDTO; |
||||
|
import com.epmet.dto.result.UserBaseInfoResultDTO; |
||||
|
import com.epmet.dto.result.work.PendingUserResultDTO; |
||||
|
import com.epmet.dto.result.work.UserBaseInfo; |
||||
|
import com.epmet.service.*; |
||||
|
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 java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 积分发放 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/7/24 12:27 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class GrantPointsServiceImpl implements GrantPointsService { |
||||
|
private Logger logger = LogManager.getLogger(GrantPointsServiceImpl.class); |
||||
|
@Autowired |
||||
|
private ActInfoService actInfoService; |
||||
|
@Autowired |
||||
|
private ActUserRelationDao actUserRelationDao; |
||||
|
@Autowired |
||||
|
private WorkActUserService workActUserService; |
||||
|
@Autowired |
||||
|
private ActUserRelationService actUserRelationService; |
||||
|
@Autowired |
||||
|
private ActPointLogService actPointLogService; |
||||
|
@Autowired |
||||
|
private LoginUserUtil loginUserUtil; |
||||
|
/** |
||||
|
* @param actId |
||||
|
* @return com.epmet.dto.result.work.PendingUserResultDTO |
||||
|
* @author yinzuomei |
||||
|
* @description 积分发放-待处理列表 |
||||
|
* @Date 2020/7/24 12:28 |
||||
|
**/ |
||||
|
@Override |
||||
|
public PendingUserResultDTO queryPendingList(String actId) { |
||||
|
PendingUserResultDTO pendingUserResultDTO = new PendingUserResultDTO(actId); |
||||
|
ActInfoDTO actInfoDTO = actInfoService.get(actId); |
||||
|
if (null == actInfoDTO) { |
||||
|
return pendingUserResultDTO; |
||||
|
} |
||||
|
pendingUserResultDTO.setActId(actId); |
||||
|
pendingUserResultDTO.setReward(actInfoDTO.getReward()); |
||||
|
pendingUserResultDTO.setTitle(actInfoDTO.getTitle()); |
||||
|
//已签到人员列表
|
||||
|
List<UserBaseInfo> signedInList = new ArrayList<>(); |
||||
|
//未签到人员列表
|
||||
|
List<UserBaseInfo> noSignInList = new ArrayList<>(); |
||||
|
List<ActUserRelationDTO> signedActUserList = actUserRelationDao.selectInProgress(actId); |
||||
|
List<String> userIdList = actUserRelationDao.selectInProgressUserIds(actId); |
||||
|
List<UserBaseInfoResultDTO> userInfoList = workActUserService.queryUserBaseInfoList(userIdList); |
||||
|
for (ActUserRelationDTO actUserRelation : signedActUserList) { |
||||
|
UserBaseInfo userBaseInfo = new UserBaseInfo(); |
||||
|
userBaseInfo.setActUserRelationId(actUserRelation.getId()); |
||||
|
userBaseInfo.setUserId(actUserRelation.getUserId()); |
||||
|
userBaseInfo.setVolunteerFlag(workActUserService.getVolunteerFlag(actUserRelation.getUserId())); |
||||
|
for (UserBaseInfoResultDTO userBaseInfoResultDTO : userInfoList) { |
||||
|
if (actUserRelation.getUserId().equals(userBaseInfoResultDTO.getUserId())) { |
||||
|
userBaseInfo.setRealName(userBaseInfoResultDTO.getRealName()); |
||||
|
userBaseInfo.setNickName(userBaseInfoResultDTO.getNickname()); |
||||
|
userBaseInfo.setHeadImgUrl(userBaseInfoResultDTO.getHeadImgUrl()); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
if (ActConstant.ACT_USER_STATUS_SIGNED_IN.equals(actUserRelation.getSignInFlag())) { |
||||
|
//已签到
|
||||
|
signedInList.add(userBaseInfo); |
||||
|
} else { |
||||
|
//未签到
|
||||
|
noSignInList.add(userBaseInfo); |
||||
|
} |
||||
|
} |
||||
|
pendingUserResultDTO.setNoSignInList(noSignInList); |
||||
|
pendingUserResultDTO.setSignedInList(signedInList); |
||||
|
return pendingUserResultDTO; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return void |
||||
|
* @author yinzuomei |
||||
|
* @description 积分发放-给分 |
||||
|
* @Date 2020/7/24 13:34 |
||||
|
**/ |
||||
|
@Override |
||||
|
public void agree(GrantPointsFormDTO formDTO) { |
||||
|
//是否是待处理
|
||||
|
ActUserRelationDTO actUserRelationDTO=actUserRelationService.get(formDTO.getActUserRelationId()); |
||||
|
if(null==actUserRelationDTO){ |
||||
|
logger.warn("积分发放-给分act_user_relation is null,actUserRelationId="+formDTO.getActUserRelationId()); |
||||
|
return; |
||||
|
} |
||||
|
//如果是已处理直接返回
|
||||
|
if(ActConstant.HANDLED.equals(actUserRelationDTO.getProcessFlag())){ |
||||
|
logger.info("积分发放-给分act_user_relation already handled,actUserRelationId="+formDTO.getActUserRelationId()); |
||||
|
return; |
||||
|
} |
||||
|
//查取分值
|
||||
|
ActInfoDTO actInfoDTO=actInfoService.get(actUserRelationDTO.getActId()); |
||||
|
if (null == actInfoDTO || ActConstant.ACT_STATUS_FINISHED.equals(actInfoDTO.getActStatus())) { |
||||
|
logger.warn("积分发放-给分act_info is null or act_info is finished"); |
||||
|
return; |
||||
|
} |
||||
|
if(!loginUserUtil.getLoginUserId().equals(actInfoDTO.getCreatedBy())){ |
||||
|
throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode()); |
||||
|
} |
||||
|
//更新act_user_relation改为已处理,给分
|
||||
|
actUserRelationDTO.setProcessFlag(ActConstant.HANDLED); |
||||
|
actUserRelationDTO.setRewardFlag(ActConstant.ACT_USER_STATUS_AGREE); |
||||
|
actUserRelationDTO.setDenyRewardReason(StrConstant.EPMETY_STR); |
||||
|
actUserRelationService.update(actUserRelationDTO); |
||||
|
//增加一条act_point_log
|
||||
|
ActPointLogDTO actPointLogDTO=new ActPointLogDTO(); |
||||
|
actPointLogDTO.setActId(actUserRelationDTO.getActId()); |
||||
|
actPointLogDTO.setUserId(actUserRelationDTO.getUserId()); |
||||
|
actPointLogDTO.setPoints(actInfoDTO.getReward()); |
||||
|
actPointLogDTO.setOperateType(ActConstant.ACT_USER_STATUS_AGREE); |
||||
|
actPointLogDTO.setRemark(StrConstant.EPMETY_STR); |
||||
|
/** |
||||
|
* 1有效0无效,只有在活动真正结束后才是1 |
||||
|
* true有效 false无效 |
||||
|
*/ |
||||
|
actPointLogDTO.setEffectFlag(false); |
||||
|
actPointLogService.save(actPointLogDTO); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return void |
||||
|
* @author yinzuomei |
||||
|
* @description 积分发放-不给分 |
||||
|
* @Date 2020/7/24 15:03 |
||||
|
**/ |
||||
|
@Override |
||||
|
public void deny(GrantPointsFormDTO formDTO) { |
||||
|
//是否是待处理
|
||||
|
ActUserRelationDTO actUserRelationDTO=actUserRelationService.get(formDTO.getActUserRelationId()); |
||||
|
if(null==actUserRelationDTO){ |
||||
|
logger.warn("积分发放-不给分act_user_relation is null,actUserRelationId="+formDTO.getActUserRelationId()); |
||||
|
return; |
||||
|
} |
||||
|
//如果是已处理直接返回
|
||||
|
if(ActConstant.HANDLED.equals(actUserRelationDTO.getProcessFlag())){ |
||||
|
logger.info("积分发放-不给分act_user_relation already handled,actUserRelationId="+formDTO.getActUserRelationId()); |
||||
|
return; |
||||
|
} |
||||
|
//查取分值
|
||||
|
ActInfoDTO actInfoDTO=actInfoService.get(actUserRelationDTO.getActId()); |
||||
|
if (null == actInfoDTO || ActConstant.ACT_STATUS_FINISHED.equals(actInfoDTO.getActStatus())) { |
||||
|
logger.warn("积分发放-不给分act_info is null or act_info is finished"); |
||||
|
return; |
||||
|
} |
||||
|
if(!loginUserUtil.getLoginUserId().equals(actInfoDTO.getCreatedBy())){ |
||||
|
throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode()); |
||||
|
} |
||||
|
//更新act_user_relation改为已处理,给分
|
||||
|
actUserRelationDTO.setProcessFlag(ActConstant.HANDLED); |
||||
|
actUserRelationDTO.setRewardFlag(ActConstant.ACT_USER_STATUS_DENY); |
||||
|
actUserRelationDTO.setDenyRewardReason(formDTO.getDenyRewardReason()); |
||||
|
actUserRelationService.update(actUserRelationDTO); |
||||
|
//增加一条act_point_log
|
||||
|
ActPointLogDTO actPointLogDTO=new ActPointLogDTO(); |
||||
|
actPointLogDTO.setActId(actUserRelationDTO.getActId()); |
||||
|
actPointLogDTO.setUserId(actUserRelationDTO.getUserId()); |
||||
|
actPointLogDTO.setPoints(actInfoDTO.getReward()); |
||||
|
actPointLogDTO.setOperateType(ActConstant.ACT_USER_STATUS_DENY); |
||||
|
actPointLogDTO.setRemark(formDTO.getDenyRewardReason()); |
||||
|
/** |
||||
|
* 1有效0无效,只有在活动真正结束后才是1 |
||||
|
* true有效 false无效 |
||||
|
*/ |
||||
|
actPointLogDTO.setEffectFlag(false); |
||||
|
actPointLogService.save(actPointLogDTO); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return void |
||||
|
* @author yinzuomei |
||||
|
* @description 积分发放-重新处理 |
||||
|
* @Date 2020/7/24 15:16 |
||||
|
**/ |
||||
|
@Override |
||||
|
public void reset(GrantPointsFormDTO formDTO) { |
||||
|
ActUserRelationDTO actUserRelationDTO=actUserRelationService.get(formDTO.getActUserRelationId()); |
||||
|
if(null==actUserRelationDTO){ |
||||
|
logger.warn("积分发放-重新处理act_user_relation is null,actUserRelationId="+formDTO.getActUserRelationId()); |
||||
|
return; |
||||
|
} |
||||
|
//查取分值
|
||||
|
ActInfoDTO actInfoDTO=actInfoService.get(actUserRelationDTO.getActId()); |
||||
|
if (null == actInfoDTO || ActConstant.ACT_STATUS_FINISHED.equals(actInfoDTO.getActStatus())) { |
||||
|
logger.warn("积分发放-重新处理act_info is null or act_info is finished"); |
||||
|
return; |
||||
|
} |
||||
|
if(!loginUserUtil.getLoginUserId().equals(actInfoDTO.getCreatedBy())){ |
||||
|
throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode()); |
||||
|
} |
||||
|
//更新act_user_relation改为未处理 初始状态
|
||||
|
actUserRelationDTO.setProcessFlag(StrConstant.EPMETY_STR); |
||||
|
actUserRelationDTO.setRewardFlag(StrConstant.EPMETY_STR); |
||||
|
actUserRelationDTO.setDenyRewardReason(StrConstant.EPMETY_STR); |
||||
|
actUserRelationService.update(actUserRelationDTO); |
||||
|
//增加一条act_point_log
|
||||
|
ActPointLogDTO actPointLogDTO=new ActPointLogDTO(); |
||||
|
actPointLogDTO.setActId(actUserRelationDTO.getActId()); |
||||
|
actPointLogDTO.setUserId(actUserRelationDTO.getUserId()); |
||||
|
actPointLogDTO.setPoints(actInfoDTO.getReward()); |
||||
|
actPointLogDTO.setOperateType(ActConstant.RESET); |
||||
|
actPointLogDTO.setRemark(StrConstant.EPMETY_STR); |
||||
|
/** |
||||
|
* 1有效0无效,只有在活动真正结束后才是1 |
||||
|
* true有效 false无效 |
||||
|
*/ |
||||
|
actPointLogDTO.setEffectFlag(false); |
||||
|
actPointLogService.save(actPointLogDTO); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue