From e304fbcb9c00b52d0a9112e149517000efb301f3 Mon Sep 17 00:00:00 2001 From: yujintao Date: Wed, 8 Apr 2020 17:33:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E7=A7=AF=E5=88=86=E5=90=8E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B4=BB=E5=8A=A8=E7=8A=B6=E6=80=81=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epdc/constant/ActUserStatusConstant.java | 89 ++++--- .../service/impl/ActInfoServiceImpl.java | 252 +++++++++++------- 2 files changed, 197 insertions(+), 144 deletions(-) diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/constant/ActUserStatusConstant.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/constant/ActUserStatusConstant.java index 99c835d8c..0afe1a3f8 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/constant/ActUserStatusConstant.java +++ b/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 */ public interface ActUserStatusConstant { - /** - * 我要报名 - */ - String SIGN_UP="0"; - - /** - * 取消报名 - */ - String CANCEL_SIGN_UP="1"; - - /** - * 已报满 - */ - String FULL_SIGN_UP="2"; - - /** - * 未开始 - */ - String NOT_STARTED="3"; - - /** - * 我要打卡 - */ - String CLOCK="4"; - - /** - * 更新打卡 - */ - String UPDATE_CLOCK = "5"; - /** - * 已结束 - */ - String FINISHED = "6"; - /** - * 已取消 - */ - String CANCELED = "7"; - - /** - * 进行中 - */ - String ON_GOING = "8"; + /** + * 我要报名 + */ + String SIGN_UP = "0"; + + /** + * 取消报名 + */ + String CANCEL_SIGN_UP = "1"; + + /** + * 已报满 + */ + String FULL_SIGN_UP = "2"; + + /** + * 未开始 + */ + String NOT_STARTED = "3"; + + /** + * 我要打卡 + */ + String CLOCK = "4"; + + /** + * 更新打卡 + */ + String UPDATE_CLOCK = "5"; + /** + * 已结束 + */ + String FINISHED = "6"; + /** + * 已取消 + */ + String CANCELED = "7"; + + /** + * 进行中 + */ + String ON_GOING = "8"; + + /** + * 已确认积分 + */ + String POINTS_CONFIRM = "9"; } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java index f98256197..38133b4b7 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java +++ b/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 getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); @@ -152,10 +152,12 @@ public class ActInfoServiceImpl extends BaseServiceImpl> + * @Return: com.elink.esua.epdc.commons.tools.utils.Result> * @Author: lipengfei * @Date: 2019/10/19 16:47 */ @@ -166,10 +168,12 @@ public class ActInfoServiceImpl extends BaseServiceImpl data = baseDao.signupListItemsByApp(formDto); return new Result>().ok(data); } + /** * 活动列表-移动app端用 + * * @Params: [formDto] - * @Return: com.elink.esua.epdc.commons.tools.utils.Result> + * @Return: com.elink.esua.epdc.commons.tools.utils.Result> * @Author: lipengfei * @Date: 2019/10/19 16:47 */ @@ -281,6 +285,7 @@ public class ActInfoServiceImpl extends BaseServiceImpl().ok(resultDTO); } + /** * @param actId 活动id * @param userId 用户id @@ -291,111 +296,156 @@ public class ActInfoServiceImpl extends BaseServiceImpl 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 actUserClockLogList = new ArrayList(); - if (null != actUserRelationEntity) { - QueryWrapper actUserClockLogWrapper = new QueryWrapper<>(); - actUserClockLogWrapper.eq("ACT_USER_ID", actUserRelationEntity.getId()); - actUserClockLogList = actUserClockLogDao.selectList(actUserClockLogWrapper); + if (null == actUserRelationEntity) { + return getCurrentUserStatusNotSignUp(actInfoEntity, currentTime); + } else { + return getCurrentUserStatusHasSignUp(actInfoEntity, actUserRelationEntity, currentTime); } - 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 actUserRelationId 用户活动关系id + * @return boolean + * @author work@yujt.net.cn + * @date 2020/4/8 17:31 + */ + private boolean isClocked(String actUserRelationId) { + QueryWrapper actUserClockLogWrapper = new QueryWrapper<>(); + actUserClockLogWrapper.eq("ACT_USER_ID", actUserRelationId); + Integer count = actUserClockLogDao.selectCount(actUserClockLogWrapper); + return count > NumConstant.ZERO; + } + + /** + * 用户已报名活动时,判断用户活动状态 + * + * @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 @@ -426,7 +476,7 @@ public class ActInfoServiceImpl extends BaseServiceImpl