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 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);
updateById(entity);
}
/**
* 活动列表-移动app端用
*
* @Params: [formDto]
* @Return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.item.result.ItemResultDTO>>
* @Author: lipengfei
@ -166,8 +168,10 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
List<ActInfoAppResultDTO> data = baseDao.signupListItemsByApp(formDto);
return new Result<List<ActInfoAppResultDTO>>().ok(data);
}
/**
* 活动列表-移动app端用
*
* @Params: [formDto]
* @Return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.item.result.ItemResultDTO>>
* @Author: lipengfei
@ -281,6 +285,7 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
return new Result<ActInfoDetailAppResultDTO>().ok(resultDTO);
}
/**
* @param actId 活动id
* @param userId 用户id
@ -291,111 +296,156 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
**/
public String getCurrentUserStatus(String actId, String userId) {
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<>();
actUserRelationWrapper.eq("ACT_ID", actId)
.eq("USER_ID", userId)
.orderByDesc("CREATED_TIME").last("limit 1");
ActUserRelationEntity actUserRelationEntity = actUserRelationDao.selectOne(actUserRelationWrapper);
//2、查询用户打卡记录
List<ActUserClockLogEntity> actUserClockLogList = new ArrayList<ActUserClockLogEntity>();
if (null != actUserRelationEntity) {
if (null == actUserRelationEntity) {
return getCurrentUserStatusNotSignUp(actInfoEntity, currentTime);
} 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<>();
actUserClockLogWrapper.eq("ACT_USER_ID", actUserRelationEntity.getId());
actUserClockLogList = actUserClockLogDao.selectList(actUserClockLogWrapper);
actUserClockLogWrapper.eq("ACT_USER_ID", actUserRelationId);
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())) {
// 活动已经结束:当前时间已经过了活动结束时间并且也已经过了打卡截止时间
currentUserStatus = ActUserStatusConstant.FINISHED;
} else if (currentTime.after(actInfoEntity.getActEndTime()) && currentTime.before(actInfoEntity.getSigninEndTime())) {
/*活动结束-打卡截止时间
1当前用户未报名 显示一结束
2当前用户已报名审核通过未打卡的显示 我要打卡
3当前用户已报名已经打过卡的显示更新打卡
4当前用户已经报名未审核的审核未通过已经取消报名的-已结束*/
if (null == actUserRelationEntity) {
currentUserStatus = ActUserStatusConstant.FINISHED;
} else if (null != actUserRelationEntity
&& ActUserRelationStatusConstant.APPROVED.equals(actUserRelationEntity.getStatus())
&& CollUtil.isEmpty(actUserClockLogList)) {
currentUserStatus = ActUserStatusConstant.CLOCK;
} else if (null != actUserRelationEntity
&& ActUserRelationStatusConstant.CLOCK.equals(actUserRelationEntity.getStatus())
&& CollUtil.isNotEmpty(actUserClockLogList)) {
currentUserStatus = ActUserStatusConstant.UPDATE_CLOCK;
} else if (null != actUserRelationEntity && (ActUserRelationStatusConstant.SIGN_UP.equals(actUserRelationEntity.getStatus())
|| ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserRelationEntity.getStatus())
|| ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserRelationEntity.getStatus()))) {
currentUserStatus = ActUserStatusConstant.FINISHED;
/**
* 用户已报名活动时判断用户活动状态
*
* @param actInfoEntity 当前活动
* @param actUserRelationEntity 用户活动关系
* @param currentTime 当前时间
* @return java.lang.String
* @author work@yujt.net.cn
* @date 2020/4/8 17:11
*/
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())) {
/*活动打卡时间段内
1当前用户未报名 不显示:进行中
2当前用户已报名且未打卡 我要打卡
3当前用户已报名且已打卡 更新打卡
4当前用户报名未审核取消报名或者审核不通过的-显示进行中*/
if (null == actUserRelationEntity) {
currentUserStatus = ActUserStatusConstant.ON_GOING;
} else if (null != actUserRelationEntity
&& ActUserRelationStatusConstant.APPROVED.equals(actUserRelationEntity.getStatus())
&& CollUtil.isEmpty(actUserClockLogList)) {
currentUserStatus = ActUserStatusConstant.CLOCK;
} else if (null != actUserRelationEntity
&& ActUserRelationStatusConstant.CLOCK.equals(actUserRelationEntity.getStatus())
&& CollUtil.isNotEmpty(actUserClockLogList)) {
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;
/* 活动打卡时间段内 */
// 审核通过且未打卡的显示 我要打卡
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.CANCEL_SIGN_UP.equals(actUserStatus)
|| ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserStatus)) {
return ActUserStatusConstant.ON_GOING;
}
} else if (currentTime.before(actInfoEntity.getSignupEndTime())) {
/*报名截至时间前
1当前用户未报名底部显示按钮 我要报名(不限名额或者未报满的)
2当前用户未报名且活动名额已满底部显示按钮 已报满限制名额且已经报满的
3当前用户已报名未审核审核通过的底部显示按钮 取消报名
4当前用户报名审核未通过或者已经取消报名的可再次报名-我要报名*/
if (null == actUserRelationEntity && (NumConstant.ZERO==actInfoEntity.getActQuotaCategory()
||actInfoEntity.getActQuota() > actInfoEntity.getSignupNum())) {
currentUserStatus = 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;
/*报名截至时间前 */
//(未审核、审核通过的)底部显示按钮 取消报名
if (ActUserRelationStatusConstant.SIGN_UP.equals(actUserStatus) || ActUserRelationStatusConstant.APPROVED.equals(actUserStatus)) {
return ActUserStatusConstant.CANCEL_SIGN_UP;
}
// (报名审核未通过或者已经取消报名的)可再次报名-我要报名
if (ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserStatus) || ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserStatus)) {
return ActUserStatusConstant.SIGN_UP;
}
} else if (currentTime.after(actInfoEntity.getSignupEndTime()) && currentTime.before(actInfoEntity.getActStartTime())) {
/*报名截至时间到活动未开始时间段内
1当前用户未报名底部显示按钮 -未开始
2当前用户已经取消报名的-未开始
3当前用户已报名且审核通过未审核 -取消报名
4当前用户已报名审核不通过 -未开始*/
if (null == actUserRelationEntity) {
currentUserStatus = ActUserStatusConstant.NOT_STARTED;
} else if (null != actUserRelationEntity && ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserRelationEntity.getStatus())) {
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.CANCEL_SIGN_UP.equals(actUserStatus)) {
return ActUserStatusConstant.NOT_STARTED;
}
// 已报名审核不通过 -未开始
if (ActUserRelationStatusConstant.NOT_APPROVED.equals(actUserStatus)) {
return 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
@ -434,11 +484,10 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
}
/**
*
* 活动保存到banner
*
* @params [entity]
* @return void
* @params [entity]
* @author liuchuang
* @since 2020/2/6 20:44
*/
@ -461,11 +510,10 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
}
/**
*
* 创建定时任务活动开始后将未审核的报名人员自动置为审核通过或不通过
*
* @params [actId, actStartTime]
* @return Result
* @params [actId, actStartTime]
* @author liuchuang
* @since 2020/2/6 21:10
*/

Loading…
Cancel
Save