Browse Source

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

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

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

@ -48,4 +48,9 @@ public interface ActUserStatusConstant {
* 进行中 * 进行中
*/ */
String ON_GOING = "8"; String ON_GOING = "8";
/**
* 已确认积分
*/
String POINTS_CONFIRM = "9";
} }

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

@ -152,8 +152,10 @@ 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
@ -166,8 +168,10 @@ 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
@ -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 {
return getCurrentUserStatusHasSignUp(actInfoEntity, actUserRelationEntity, currentTime);
}
}
/**
* 用户是否有活动打卡记录
*
* @param actUserRelationId 用户活动关系id
* @return boolean
* @author work@yujt.net.cn
* @date 2020/4/8 17:31
*/
private boolean isClocked(String actUserRelationId) {
QueryWrapper<ActUserClockLogEntity> actUserClockLogWrapper = new QueryWrapper<>(); QueryWrapper<ActUserClockLogEntity> actUserClockLogWrapper = new QueryWrapper<>();
actUserClockLogWrapper.eq("ACT_USER_ID", actUserRelationEntity.getId()); actUserClockLogWrapper.eq("ACT_USER_ID", actUserRelationId);
actUserClockLogList = actUserClockLogDao.selectList(actUserClockLogWrapper); Integer count = actUserClockLogDao.selectCount(actUserClockLogWrapper);
return count > NumConstant.ZERO;
} }
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 actInfoEntity 当前活动
// 活动已经结束:当前时间已经过了活动结束时间并且也已经过了打卡截止时间 * @param actUserRelationEntity 用户活动关系
currentUserStatus = ActUserStatusConstant.FINISHED; * @param currentTime 当前时间
} else if (currentTime.after(actInfoEntity.getActEndTime()) && currentTime.before(actInfoEntity.getSigninEndTime())) { * @return java.lang.String
/*活动结束-打卡截止时间 * @author work@yujt.net.cn
1当前用户未报名 显示一结束 * @date 2020/4/8 17:11
2当前用户已报名审核通过未打卡的显示 我要打卡 */
3当前用户已报名已经打过卡的显示更新打卡 private String getCurrentUserStatusHasSignUp(ActInfoEntity actInfoEntity, ActUserRelationEntity actUserRelationEntity, Date currentTime) {
4当前用户已经报名未审核的审核未通过已经取消报名的-已结束*/
if (null == actUserRelationEntity) { String actUserStatus = actUserRelationEntity.getStatus();
currentUserStatus = ActUserStatusConstant.FINISHED;
} else if (null != actUserRelationEntity // 已确认过积分,直接返回
&& ActUserRelationStatusConstant.APPROVED.equals(actUserRelationEntity.getStatus()) if (ActUserRelationStatusConstant.CONFIRM_ADD_POINTS.equals(actUserStatus)
&& CollUtil.isEmpty(actUserClockLogList)) { || ActUserRelationStatusConstant.REFUSE_ADD_POINTS.equals(actUserStatus)) {
currentUserStatus = ActUserStatusConstant.CLOCK; return ActUserStatusConstant.POINTS_CONFIRM;
} else if (null != actUserRelationEntity }
&& ActUserRelationStatusConstant.CLOCK.equals(actUserRelationEntity.getStatus())
&& CollUtil.isNotEmpty(actUserClockLogList)) { boolean isClocked = isClocked(actUserRelationEntity.getId());
currentUserStatus = ActUserStatusConstant.UPDATE_CLOCK;
} else if (null != actUserRelationEntity && (ActUserRelationStatusConstant.SIGN_UP.equals(actUserRelationEntity.getStatus()) if (currentTime.after(actInfoEntity.getActEndTime()) && currentTime.before(actInfoEntity.getSigninEndTime())) {
|| ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserRelationEntity.getStatus()) /*活动结束;打卡未截止*/
|| ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserRelationEntity.getStatus()))) { // 审核通过且未打卡的显示 我要打卡
currentUserStatus = ActUserStatusConstant.FINISHED; 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())
|| ActUserRelationStatusConstant.SIGN_UP.equals(actUserRelationEntity.getStatus()))) {
currentUserStatus = ActUserStatusConstant.CANCEL_SIGN_UP;
} else if (null != actUserRelationEntity && ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserRelationEntity.getStatus())) {
currentUserStatus = ActUserStatusConstant.NOT_STARTED;
} }
// 已报名且审核通过、未审核 -取消报名
if (ActUserRelationStatusConstant.APPROVED.equals(actUserStatus) || ActUserRelationStatusConstant.SIGN_UP.equals(actUserStatus)) {
return ActUserStatusConstant.CANCEL_SIGN_UP;
}
}
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
@ -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
*/ */

Loading…
Cancel
Save