Browse Source

确认积分后用户活动状态判断

feature/dangjian
yujintao 6 years ago
parent
commit
e304fbcb9c
  1. 89
      esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/constant/ActUserStatusConstant.java
  2. 252
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java

89
esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/constant/ActUserStatusConstant.java

@ -6,46 +6,51 @@ package com.elink.esua.epdc.constant;
* @Date 2020/2/5 14:49 * @Date 2020/2/5 14:49
*/ */
public interface ActUserStatusConstant { public interface ActUserStatusConstant {
/** /**
* 我要报名 * 我要报名
*/ */
String SIGN_UP="0"; String SIGN_UP = "0";
/** /**
* 取消报名 * 取消报名
*/ */
String CANCEL_SIGN_UP="1"; String CANCEL_SIGN_UP = "1";
/** /**
* 已报满 * 已报满
*/ */
String FULL_SIGN_UP="2"; String FULL_SIGN_UP = "2";
/** /**
* 未开始 * 未开始
*/ */
String NOT_STARTED="3"; String NOT_STARTED = "3";
/** /**
* 我要打卡 * 我要打卡
*/ */
String CLOCK="4"; String CLOCK = "4";
/** /**
* 更新打卡 * 更新打卡
*/ */
String UPDATE_CLOCK = "5"; String UPDATE_CLOCK = "5";
/** /**
* 已结束 * 已结束
*/ */
String FINISHED = "6"; String FINISHED = "6";
/** /**
* 已取消 * 已取消
*/ */
String CANCELED = "7"; String CANCELED = "7";
/** /**
* 进行中 * 进行中
*/ */
String ON_GOING = "8"; String ON_GOING = "8";
/**
* 已确认积分
*/
String POINTS_CONFIRM = "9";
} }

252
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java

@ -115,8 +115,8 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
return ConvertUtils.sourceToTarget(entityList, ActInfoDTO.class); return ConvertUtils.sourceToTarget(entityList, ActInfoDTO.class);
} }
private QueryWrapper<ActInfoEntity> getWrapper(Map<String, Object> params){ private QueryWrapper<ActInfoEntity> getWrapper(Map<String, Object> params) {
String id = (String)params.get(FieldConstant.ID_HUMP); String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<ActInfoEntity> wrapper = new QueryWrapper<>(); QueryWrapper<ActInfoEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -152,10 +152,12 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
ActInfoEntity entity = ConvertUtils.sourceToTarget(dto, ActInfoEntity.class); ActInfoEntity entity = ConvertUtils.sourceToTarget(dto, ActInfoEntity.class);
updateById(entity); updateById(entity);
} }
/** /**
* 活动列表-移动app端用 * 活动列表-移动app端用
*
* @Params: [formDto] * @Params: [formDto]
* @Return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.item.result.ItemResultDTO>> * @Return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.item.result.ItemResultDTO>>
* @Author: lipengfei * @Author: lipengfei
* @Date: 2019/10/19 16:47 * @Date: 2019/10/19 16:47
*/ */
@ -166,10 +168,12 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
List<ActInfoAppResultDTO> data = baseDao.signupListItemsByApp(formDto); List<ActInfoAppResultDTO> data = baseDao.signupListItemsByApp(formDto);
return new Result<List<ActInfoAppResultDTO>>().ok(data); return new Result<List<ActInfoAppResultDTO>>().ok(data);
} }
/** /**
* 活动列表-移动app端用 * 活动列表-移动app端用
*
* @Params: [formDto] * @Params: [formDto]
* @Return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.item.result.ItemResultDTO>> * @Return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.item.result.ItemResultDTO>>
* @Author: lipengfei * @Author: lipengfei
* @Date: 2019/10/19 16:47 * @Date: 2019/10/19 16:47
*/ */
@ -281,6 +285,7 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
return new Result<ActInfoDetailAppResultDTO>().ok(resultDTO); return new Result<ActInfoDetailAppResultDTO>().ok(resultDTO);
} }
/** /**
* @param actId 活动id * @param actId 活动id
* @param userId 用户id * @param userId 用户id
@ -291,111 +296,156 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
**/ **/
public String getCurrentUserStatus(String actId, String userId) { public String getCurrentUserStatus(String actId, String userId) {
ActInfoEntity actInfoEntity = baseDao.selectById(actId); ActInfoEntity actInfoEntity = baseDao.selectById(actId);
String currentUserStatus = "";
//用户当前状态(0-我要报名,1-取消报名,2-已报满,3-未开始,4-我要打卡,5-更新打卡,6-已结束,7-已取消) // 活动已取消
//1、查询用户活动关系 if (ActStateConstant.ACT_INFO_STATUS_UNDERCARRIAGE.equals(actInfoEntity.getActStatus())) {
return ActUserStatusConstant.CANCELED;
}
Date currentTime = new Date();
// 活动已经结束:当前时间已经过了活动结束时间并且也已经过了打卡截止时间
if (currentTime.after(actInfoEntity.getActEndTime()) && currentTime.after(actInfoEntity.getSigninEndTime())) {
return ActUserStatusConstant.FINISHED;
}
// 查询用户活动关系
QueryWrapper<ActUserRelationEntity> actUserRelationWrapper = new QueryWrapper<>(); QueryWrapper<ActUserRelationEntity> actUserRelationWrapper = new QueryWrapper<>();
actUserRelationWrapper.eq("ACT_ID", actId) actUserRelationWrapper.eq("ACT_ID", actId)
.eq("USER_ID", userId) .eq("USER_ID", userId)
.orderByDesc("CREATED_TIME").last("limit 1"); .orderByDesc("CREATED_TIME").last("limit 1");
ActUserRelationEntity actUserRelationEntity = actUserRelationDao.selectOne(actUserRelationWrapper); ActUserRelationEntity actUserRelationEntity = actUserRelationDao.selectOne(actUserRelationWrapper);
//2、查询用户打卡记录 if (null == actUserRelationEntity) {
List<ActUserClockLogEntity> actUserClockLogList = new ArrayList<ActUserClockLogEntity>(); return getCurrentUserStatusNotSignUp(actInfoEntity, currentTime);
if (null != actUserRelationEntity) { } else {
QueryWrapper<ActUserClockLogEntity> actUserClockLogWrapper = new QueryWrapper<>(); return getCurrentUserStatusHasSignUp(actInfoEntity, actUserRelationEntity, currentTime);
actUserClockLogWrapper.eq("ACT_USER_ID", actUserRelationEntity.getId());
actUserClockLogList = actUserClockLogDao.selectList(actUserClockLogWrapper);
} }
Date currentTime = new Date(); }
// 活动取消:已取消
if (ActStateConstant.ACT_INFO_STATUS_UNDERCARRIAGE.equals(actInfoEntity.getActStatus())) { /**
currentUserStatus = ActUserStatusConstant.CANCELED; * 用户是否有活动打卡记录
} else if (currentTime.after(actInfoEntity.getActEndTime()) && currentTime.after(actInfoEntity.getSigninEndTime())) { *
// 活动已经结束:当前时间已经过了活动结束时间并且也已经过了打卡截止时间 * @param actUserRelationId 用户活动关系id
currentUserStatus = ActUserStatusConstant.FINISHED; * @return boolean
} else if (currentTime.after(actInfoEntity.getActEndTime()) && currentTime.before(actInfoEntity.getSigninEndTime())) { * @author work@yujt.net.cn
/*活动结束-打卡截止时间 * @date 2020/4/8 17:31
1当前用户未报名 显示一结束 */
2当前用户已报名审核通过未打卡的显示 我要打卡 private boolean isClocked(String actUserRelationId) {
3当前用户已报名已经打过卡的显示更新打卡 QueryWrapper<ActUserClockLogEntity> actUserClockLogWrapper = new QueryWrapper<>();
4当前用户已经报名未审核的审核未通过已经取消报名的-已结束*/ actUserClockLogWrapper.eq("ACT_USER_ID", actUserRelationId);
if (null == actUserRelationEntity) { Integer count = actUserClockLogDao.selectCount(actUserClockLogWrapper);
currentUserStatus = ActUserStatusConstant.FINISHED; return count > NumConstant.ZERO;
} else if (null != actUserRelationEntity }
&& ActUserRelationStatusConstant.APPROVED.equals(actUserRelationEntity.getStatus())
&& CollUtil.isEmpty(actUserClockLogList)) { /**
currentUserStatus = ActUserStatusConstant.CLOCK; * 用户已报名活动时判断用户活动状态
} else if (null != actUserRelationEntity *
&& ActUserRelationStatusConstant.CLOCK.equals(actUserRelationEntity.getStatus()) * @param actInfoEntity 当前活动
&& CollUtil.isNotEmpty(actUserClockLogList)) { * @param actUserRelationEntity 用户活动关系
currentUserStatus = ActUserStatusConstant.UPDATE_CLOCK; * @param currentTime 当前时间
} else if (null != actUserRelationEntity && (ActUserRelationStatusConstant.SIGN_UP.equals(actUserRelationEntity.getStatus()) * @return java.lang.String
|| ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserRelationEntity.getStatus()) * @author work@yujt.net.cn
|| ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserRelationEntity.getStatus()))) { * @date 2020/4/8 17:11
currentUserStatus = ActUserStatusConstant.FINISHED; */
private String getCurrentUserStatusHasSignUp(ActInfoEntity actInfoEntity, ActUserRelationEntity actUserRelationEntity, Date currentTime) {
String actUserStatus = actUserRelationEntity.getStatus();
// 已确认过积分,直接返回
if (ActUserRelationStatusConstant.CONFIRM_ADD_POINTS.equals(actUserStatus)
|| ActUserRelationStatusConstant.REFUSE_ADD_POINTS.equals(actUserStatus)) {
return ActUserStatusConstant.POINTS_CONFIRM;
}
boolean isClocked = isClocked(actUserRelationEntity.getId());
if (currentTime.after(actInfoEntity.getActEndTime()) && currentTime.before(actInfoEntity.getSigninEndTime())) {
/*活动结束;打卡未截止*/
// 审核通过且未打卡的显示 我要打卡
if (ActUserRelationStatusConstant.APPROVED.equals(actUserStatus) && !isClocked) {
return ActUserStatusConstant.CLOCK;
}
// (已经打过卡的)显示更新打卡
if (ActUserRelationStatusConstant.CLOCK.equals(actUserStatus) && isClocked) {
return ActUserStatusConstant.UPDATE_CLOCK;
}
// 未审核的、审核未通过、已经取消报名的)- 已结束
if (ActUserRelationStatusConstant.SIGN_UP.equals(actUserStatus)
|| ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserStatus)
|| ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserStatus)) {
return ActUserStatusConstant.FINISHED;
} }
} else if (currentTime.after(actInfoEntity.getSigninStartTime()) && currentTime.before(actInfoEntity.getSigninEndTime())) { } else if (currentTime.after(actInfoEntity.getSigninStartTime()) && currentTime.before(actInfoEntity.getSigninEndTime())) {
/*活动打卡时间段内 /* 活动打卡时间段内 */
1当前用户未报名 不显示:进行中 // 审核通过且未打卡的显示 我要打卡
2当前用户已报名且未打卡 我要打卡 if (ActUserRelationStatusConstant.APPROVED.equals(actUserStatus) && !isClocked) {
3当前用户已报名且已打卡 更新打卡 return ActUserStatusConstant.CLOCK;
4当前用户报名未审核取消报名或者审核不通过的-显示进行中*/ }
if (null == actUserRelationEntity) { // (已经打过卡的)显示更新打卡
currentUserStatus = ActUserStatusConstant.ON_GOING; if (ActUserRelationStatusConstant.CLOCK.equals(actUserStatus) && isClocked) {
} else if (null != actUserRelationEntity return ActUserStatusConstant.UPDATE_CLOCK;
&& ActUserRelationStatusConstant.APPROVED.equals(actUserRelationEntity.getStatus()) }
&& CollUtil.isEmpty(actUserClockLogList)) { // 未审核的、审核未通过、已经取消报名的)- 进行中
currentUserStatus = ActUserStatusConstant.CLOCK; if (ActUserRelationStatusConstant.SIGN_UP.equals(actUserStatus)
} else if (null != actUserRelationEntity || ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserStatus)
&& ActUserRelationStatusConstant.CLOCK.equals(actUserRelationEntity.getStatus()) || ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserStatus)) {
&& CollUtil.isNotEmpty(actUserClockLogList)) { return ActUserStatusConstant.ON_GOING;
currentUserStatus = ActUserStatusConstant.UPDATE_CLOCK;
} else if (null != actUserRelationEntity
&& (ActUserRelationStatusConstant.SIGN_UP.equals(actUserRelationEntity.getStatus())
|| ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserRelationEntity.getStatus())
|| ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserRelationEntity.getStatus()))) {
currentUserStatus = ActUserStatusConstant.ON_GOING;
} }
} else if (currentTime.before(actInfoEntity.getSignupEndTime())) { } else if (currentTime.before(actInfoEntity.getSignupEndTime())) {
/*报名截至时间前 /*报名截至时间前 */
1当前用户未报名底部显示按钮 我要报名(不限名额或者未报满的) //(未审核、审核通过的)底部显示按钮 取消报名
2当前用户未报名且活动名额已满底部显示按钮 已报满限制名额且已经报满的 if (ActUserRelationStatusConstant.SIGN_UP.equals(actUserStatus) || ActUserRelationStatusConstant.APPROVED.equals(actUserStatus)) {
3当前用户已报名未审核审核通过的底部显示按钮 取消报名 return ActUserStatusConstant.CANCEL_SIGN_UP;
4当前用户报名审核未通过或者已经取消报名的可再次报名-我要报名*/ }
if (null == actUserRelationEntity && (NumConstant.ZERO==actInfoEntity.getActQuotaCategory() // (报名审核未通过或者已经取消报名的)可再次报名-我要报名
||actInfoEntity.getActQuota() > actInfoEntity.getSignupNum())) { if (ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserStatus) || ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserStatus)) {
currentUserStatus = ActUserStatusConstant.SIGN_UP; return ActUserStatusConstant.SIGN_UP;
} else if (null == actUserRelationEntity && (NumConstant.ONE==actInfoEntity.getActQuotaCategory()
&&actInfoEntity.getActQuota().equals(actInfoEntity.getSignupNum()))) {
currentUserStatus = ActUserStatusConstant.FULL_SIGN_UP;
} else if (null != actUserRelationEntity
&& (ActUserRelationStatusConstant.SIGN_UP.equals(actUserRelationEntity.getStatus())
|| ActUserRelationStatusConstant.APPROVED.equals(actUserRelationEntity.getStatus()))) {
currentUserStatus = ActUserStatusConstant.CANCEL_SIGN_UP;
} else if (null != actUserRelationEntity
&& (ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserRelationEntity.getStatus())
|| ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserRelationEntity.getStatus()))) {
currentUserStatus = ActUserStatusConstant.SIGN_UP;
} }
} else if (currentTime.after(actInfoEntity.getSignupEndTime()) && currentTime.before(actInfoEntity.getActStartTime())) { } else if (currentTime.after(actInfoEntity.getSignupEndTime()) && currentTime.before(actInfoEntity.getActStartTime())) {
/*报名截至时间到活动未开始时间段内 /*报名截止但 活动未开始 */
1当前用户未报名底部显示按钮 -未开始 // 已经取消报名的-未开始
2当前用户已经取消报名的-未开始 if (ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserStatus)) {
3当前用户已报名且审核通过未审核 -取消报名 return ActUserStatusConstant.NOT_STARTED;
4当前用户已报名审核不通过 -未开始*/ }
if (null == actUserRelationEntity) { // 已报名审核不通过 -未开始
currentUserStatus = ActUserStatusConstant.NOT_STARTED; if (ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserStatus)) {
} else if (null != actUserRelationEntity && ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserRelationEntity.getStatus())) { return ActUserStatusConstant.NOT_STARTED;
currentUserStatus = ActUserStatusConstant.NOT_STARTED; }
} else if (null != actUserRelationEntity // 已报名且审核通过、未审核 -取消报名
&& (ActUserRelationStatusConstant.APPROVED.equals(actUserRelationEntity.getStatus()) if (ActUserRelationStatusConstant.APPROVED.equals(actUserStatus) || ActUserRelationStatusConstant.SIGN_UP.equals(actUserStatus)) {
|| ActUserRelationStatusConstant.SIGN_UP.equals(actUserRelationEntity.getStatus()))) { return ActUserStatusConstant.CANCEL_SIGN_UP;
currentUserStatus = ActUserStatusConstant.CANCEL_SIGN_UP; }
} else if (null != actUserRelationEntity && ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserRelationEntity.getStatus())) { }
currentUserStatus = ActUserStatusConstant.NOT_STARTED; return ActUserStatusConstant.FINISHED;
}
/**
* 用户未报名活动时判断用户活动状态
*
* @param actInfoEntity 当前活动
* @param currentTime 当前时间
* @return java.lang.String
* @author work@yujt.net.cn
* @date 2020/4/8 16:55
*/
private String getCurrentUserStatusNotSignUp(ActInfoEntity actInfoEntity, Date currentTime) {
if (currentTime.before(actInfoEntity.getSignupEndTime())) {
/*报名结束前*/
if (NumConstant.ZERO == actInfoEntity.getActQuotaCategory() || actInfoEntity.getActQuota() > actInfoEntity.getSignupNum()) {
// 我要报名(不限名额或者未报满的)
return ActUserStatusConstant.SIGN_UP;
} else {
// 已报满(限制名额且已经报满的)
return ActUserStatusConstant.FULL_SIGN_UP;
} }
} else if (currentTime.after(actInfoEntity.getSignupEndTime()) && currentTime.before(actInfoEntity.getActStartTime())) {
/*报名结束,活动未开始*/
return ActUserStatusConstant.NOT_STARTED;
} else if (currentTime.after(actInfoEntity.getSigninStartTime()) && currentTime.before(actInfoEntity.getSigninEndTime())) {
// 活动打卡时间段内: 显示:进行中
return ActUserStatusConstant.ON_GOING;
} else {
return ActUserStatusConstant.FINISHED;
} }
return currentUserStatus;
} }
@Override @Override
@ -426,7 +476,7 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
updateById(infoEntity); updateById(infoEntity);
//banner表 浏览数+1 //banner表 浏览数+1
ActBannerDTO bannerDto = actBannerService.getBannerInfo(actId); ActBannerDTO bannerDto = actBannerService.getBannerInfo(actId);
if (bannerDto != null){ if (bannerDto != null) {
bannerDto.setBrowseNum(bannerDto.getBrowseNum() + 1); bannerDto.setBrowseNum(bannerDto.getBrowseNum() + 1);
ActBannerEntity bannerEntity = ConvertUtils.sourceToTarget(bannerDto, ActBannerEntity.class); ActBannerEntity bannerEntity = ConvertUtils.sourceToTarget(bannerDto, ActBannerEntity.class);
actBannerService.updateById(bannerEntity); actBannerService.updateById(bannerEntity);
@ -434,11 +484,10 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
} }
/** /**
*
* 活动保存到banner * 活动保存到banner
* *
* @params [entity]
* @return void * @return void
* @params [entity]
* @author liuchuang * @author liuchuang
* @since 2020/2/6 20:44 * @since 2020/2/6 20:44
*/ */
@ -461,11 +510,10 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
} }
/** /**
*
* 创建定时任务活动开始后将未审核的报名人员自动置为审核通过或不通过 * 创建定时任务活动开始后将未审核的报名人员自动置为审核通过或不通过
* *
* @params [actId, actStartTime]
* @return Result * @return Result
* @params [actId, actStartTime]
* @author liuchuang * @author liuchuang
* @since 2020/2/6 21:10 * @since 2020/2/6 21:10
*/ */
@ -482,9 +530,9 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
int day = calendar.get(Calendar.DATE); int day = calendar.get(Calendar.DATE);
int hours = calendar.get(Calendar.HOUR_OF_DAY); int hours = calendar.get(Calendar.HOUR_OF_DAY);
int minutes = calendar.get(Calendar.MINUTE); int minutes = calendar.get(Calendar.MINUTE);
int second=calendar.get(Calendar.SECOND); int second = calendar.get(Calendar.SECOND);
cron = second +" "+ minutes +" "+ hours + " " + day + " " + month + " ? " + year + "-" + year; cron = second + " " + minutes + " " + hours + " " + day + " " + month + " ? " + year + "-" + year;
jobDTO.setCronExpression(cron); jobDTO.setCronExpression(cron);
return jobFeignClient.save(jobDTO); return jobFeignClient.save(jobDTO);
} }

Loading…
Cancel
Save