From fe768bb0ca4c38e5ac9f92bbeded6bfff409db2c Mon Sep 17 00:00:00 2001 From: liuchuang <123456> Date: Thu, 25 Feb 2021 15:52:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=89=AB=E7=A0=81=E7=AD=BE?= =?UTF-8?q?=E5=88=B0=E6=8E=A5=E5=8F=A3=20init=201=E3=80=81=E5=B1=85?= =?UTF-8?q?=E6=B0=91=E6=89=AB=E7=A0=81=E6=8E=A5=E5=8F=A3=202=E3=80=81?= =?UTF-8?q?=E5=B1=85=E6=B0=91=E6=89=AB=E7=A0=81=E7=AD=BE=E5=88=B0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/tools/constant/NumConstant.java | 1 + .../controller/ApiActSignInController.java | 57 +++++++ .../esua/epdc/feign/ActInfoFeignClient.java | 28 +++- .../fallback/ActInfoFeignClientFallback.java | 15 +- .../esua/epdc/service/ActSignInService.java | 27 ++- .../service/impl/ActSignInServiceImpl.java | 17 +- .../activity/form/ActPointCheckFormDTO.java | 5 + .../epdc/activity/form/ActSignInFormDTO.java | 26 +++ .../form/ActSignInScanQrCodeFormDTO.java | 26 +++ .../result/ActSignInScanQrCodeResultDTO.java | 49 ++++++ .../AppActSignInQrCodeController.java | 44 ++++- .../activity/dao/ActUserPointsLogDao.java | 11 ++ .../service/ActSignInQrCodeService.java | 24 +++ .../service/ActUserPointsLogService.java | 12 ++ .../service/impl/ActInfoServiceImpl.java | 25 ++- .../impl/ActSignInQrCodeServiceImpl.java | 154 +++++++++++++++++- .../impl/ActUserClockLogServiceImpl.java | 8 +- .../impl/ActUserPointsLogServiceImpl.java | 6 + .../constant/ActSignInQrCodeConstant.java | 26 +++ .../mapper/activity/ActUserPointsLogDao.xml | 14 ++ .../mapper/activity/ActUserRelationDao.xml | 3 +- 21 files changed, 540 insertions(+), 38 deletions(-) create mode 100644 esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiActSignInController.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActSignInFormDTO.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActSignInScanQrCodeFormDTO.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/result/ActSignInScanQrCodeResultDTO.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/constant/ActSignInQrCodeConstant.java diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/NumConstant.java b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/NumConstant.java index 01de0bba..97fad29b 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/NumConstant.java +++ b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/NumConstant.java @@ -43,6 +43,7 @@ public interface NumConstant { String FIVE_STR = "5"; String SIX_STR = "6"; String SEVEN_STR = "7"; + String NINE_STR = "9"; int TWO_HUNDRED = 200; diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiActSignInController.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiActSignInController.java new file mode 100644 index 00000000..ac0ebbbf --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiActSignInController.java @@ -0,0 +1,57 @@ +package com.elink.esua.epdc.controller; + +import com.elink.esua.epdc.activity.form.ActSignInFormDTO; +import com.elink.esua.epdc.activity.form.ActSignInScanQrCodeFormDTO; +import com.elink.esua.epdc.activity.result.ActSignInScanQrCodeResultDTO; +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.commons.tools.annotation.LoginUser; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.service.ActSignInService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 居民端-活动扫码签到 + * + * @author Liuchuang + * @since 2021/2/24 17:33 + */ +@RestController +@RequestMapping("act/actsignin") +public class ApiActSignInController { + + @Autowired + private ActSignInService actSignInService; + + /** + * 居民扫签到码获取活动信息接口 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/2/24 18:00 + */ + @GetMapping("actInfo") + public Result getActInfo(@LoginUser TokenDto userDetail, ActSignInScanQrCodeFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + formDto.setUserId(userDetail.getUserId()); + return actSignInService.getSignInActInfo(formDto); + } + + /** + * 居民扫码签到 + * + * @param userDetail + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/2/25 13:55 + */ + @PostMapping("signin") + public Result scanSignIn(@LoginUser TokenDto userDetail, @RequestBody ActSignInFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + formDto.setUserId(userDetail.getUserId()); + return actSignInService.scanSignIn(formDto); + } +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/ActInfoFeignClient.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/ActInfoFeignClient.java index 4c11e66d..618dba24 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/ActInfoFeignClient.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/ActInfoFeignClient.java @@ -1,10 +1,7 @@ package com.elink.esua.epdc.feign; import com.elink.esua.epdc.activity.ActBannerDTO; -import com.elink.esua.epdc.activity.form.ActInfoAppFormDTO; -import com.elink.esua.epdc.activity.form.ActSignInListFormDTO; -import com.elink.esua.epdc.activity.form.ActSignInRecordFormDTO; -import com.elink.esua.epdc.activity.form.EpdcAppBannerFormDTO; +import com.elink.esua.epdc.activity.form.*; import com.elink.esua.epdc.activity.result.*; import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; import com.elink.esua.epdc.commons.tools.utils.Result; @@ -14,6 +11,7 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import java.util.List; @@ -120,4 +118,26 @@ public interface ActInfoFeignClient { @GetMapping(value ="heart/epdc-app/actsigninqrcode/getsigninlist", consumes = MediaType.APPLICATION_JSON_VALUE) Result getSignInList(ActSignInRecordFormDTO formDto); + /** + * 居民扫签到码获取活动信息接口 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/2/25 9:38 + */ + @GetMapping(value ="heart/epdc-app/actsigninqrcode/actInfo", consumes = MediaType.APPLICATION_JSON_VALUE) + Result getActInfo(ActSignInScanQrCodeFormDTO formDto); + + /** + * 居民扫码签到 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/2/25 14:00 + */ + @PostMapping(value ="heart/epdc-app/actsigninqrcode/signin", consumes = MediaType.APPLICATION_JSON_VALUE) + Result scanSignIn(ActSignInFormDTO formDto); + } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/ActInfoFeignClientFallback.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/ActInfoFeignClientFallback.java index e031824f..c2a6283a 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/ActInfoFeignClientFallback.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/ActInfoFeignClientFallback.java @@ -1,10 +1,7 @@ package com.elink.esua.epdc.feign.fallback; import com.elink.esua.epdc.activity.ActBannerDTO; -import com.elink.esua.epdc.activity.form.ActInfoAppFormDTO; -import com.elink.esua.epdc.activity.form.ActSignInListFormDTO; -import com.elink.esua.epdc.activity.form.ActSignInRecordFormDTO; -import com.elink.esua.epdc.activity.form.EpdcAppBannerFormDTO; +import com.elink.esua.epdc.activity.form.*; import com.elink.esua.epdc.activity.result.*; import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; @@ -73,4 +70,14 @@ public class ActInfoFeignClientFallback implements ActInfoFeignClient { return ModuleUtils.feignConError(ServiceConstant.EPDC_HEART_SERVER, "getSignInList", formDto); } + @Override + public Result getActInfo(ActSignInScanQrCodeFormDTO formDto) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_HEART_SERVER, "getActInfo", formDto); + } + + @Override + public Result scanSignIn(ActSignInFormDTO formDto) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_HEART_SERVER, "scanSignIn", formDto); + } + } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/ActSignInService.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/ActSignInService.java index b1ca5036..9196bd63 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/ActSignInService.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/ActSignInService.java @@ -1,11 +1,10 @@ package com.elink.esua.epdc.service; +import com.elink.esua.epdc.activity.form.ActSignInFormDTO; import com.elink.esua.epdc.activity.form.ActSignInListFormDTO; import com.elink.esua.epdc.activity.form.ActSignInRecordFormDTO; -import com.elink.esua.epdc.activity.result.ActSignInListResultDTO; -import com.elink.esua.epdc.activity.result.ActSignInQrCodeResultDTO; -import com.elink.esua.epdc.activity.result.ActSignInRecordsDTO; -import com.elink.esua.epdc.activity.result.ActSignInRecordsResultDTO; +import com.elink.esua.epdc.activity.form.ActSignInScanQrCodeFormDTO; +import com.elink.esua.epdc.activity.result.*; import com.elink.esua.epdc.commons.tools.utils.Result; import java.util.List; @@ -47,4 +46,24 @@ public interface ActSignInService { * @since 2021/2/24 15:22 */ Result listOfSignInRecords(ActSignInRecordFormDTO formDto); + + /** + * 居民扫签到码获取活动信息接口 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/2/25 9:34 + */ + Result getSignInActInfo(ActSignInScanQrCodeFormDTO formDto); + + /** + * 居民扫码签到 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/2/25 13:58 + */ + Result scanSignIn(ActSignInFormDTO formDto); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/ActSignInServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/ActSignInServiceImpl.java index 6af49b58..35773f1d 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/ActSignInServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/ActSignInServiceImpl.java @@ -1,11 +1,10 @@ package com.elink.esua.epdc.service.impl; +import com.elink.esua.epdc.activity.form.ActSignInFormDTO; import com.elink.esua.epdc.activity.form.ActSignInListFormDTO; import com.elink.esua.epdc.activity.form.ActSignInRecordFormDTO; -import com.elink.esua.epdc.activity.result.ActSignInListResultDTO; -import com.elink.esua.epdc.activity.result.ActSignInQrCodeResultDTO; -import com.elink.esua.epdc.activity.result.ActSignInRecordsDTO; -import com.elink.esua.epdc.activity.result.ActSignInRecordsResultDTO; +import com.elink.esua.epdc.activity.form.ActSignInScanQrCodeFormDTO; +import com.elink.esua.epdc.activity.result.*; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.feign.ActInfoFeignClient; import com.elink.esua.epdc.service.ActSignInService; @@ -34,4 +33,14 @@ public class ActSignInServiceImpl implements ActSignInService { public Result listOfSignInRecords(ActSignInRecordFormDTO formDto) { return actInfoFeignClient.getSignInList(formDto); } + + @Override + public Result getSignInActInfo(ActSignInScanQrCodeFormDTO formDto) { + return actInfoFeignClient.getActInfo(formDto); + } + + @Override + public Result scanSignIn(ActSignInFormDTO formDto) { + return actInfoFeignClient.scanSignIn(formDto); + } } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActPointCheckFormDTO.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActPointCheckFormDTO.java index b47ed5f8..eb6f99e3 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActPointCheckFormDTO.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActPointCheckFormDTO.java @@ -54,5 +54,10 @@ public class ActPointCheckFormDTO implements Serializable { @NotBlank(message = "原因不能为空") private String failureReason; + /** + * 操作类型 0-系统确认积分,2-管理员确认积分,4-取消报名扣减积分,6-管理员扣减积分,8-拒绝积分,9-扫码签到确认积分 + */ + private String operationType; + } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActSignInFormDTO.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActSignInFormDTO.java new file mode 100644 index 00000000..4f913440 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActSignInFormDTO.java @@ -0,0 +1,26 @@ +package com.elink.esua.epdc.activity.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 活动扫码签到-form + * @author Liuchuang + */ +@Data +public class ActSignInFormDTO implements Serializable { + private static final long serialVersionUID = -570057119464433688L; + + /** + * 活动ID + */ + @NotBlank(message = "活动ID不能为空") + private String actId; + + /** + * 用户ID + */ + private String userId; +} diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActSignInScanQrCodeFormDTO.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActSignInScanQrCodeFormDTO.java new file mode 100644 index 00000000..870a73ff --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActSignInScanQrCodeFormDTO.java @@ -0,0 +1,26 @@ +package com.elink.esua.epdc.activity.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 活动扫签到码-form + * @author Liuchuang + */ +@Data +public class ActSignInScanQrCodeFormDTO implements Serializable { + private static final long serialVersionUID = -6611292881727646051L; + + /** + * 二维码中的qrCodeId + */ + @NotBlank(message = "二维码信息为空,请重新扫码") + private String qrCodeId; + + /** + * 用户ID + */ + private String userId; +} diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/result/ActSignInScanQrCodeResultDTO.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/result/ActSignInScanQrCodeResultDTO.java new file mode 100644 index 00000000..bb63cdcf --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/result/ActSignInScanQrCodeResultDTO.java @@ -0,0 +1,49 @@ +package com.elink.esua.epdc.activity.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 活动扫签到码-result + * @author Liuchuang + */ +@Data +public class ActSignInScanQrCodeResultDTO implements Serializable { + private static final long serialVersionUID = 2090072774727220817L; + + /** + * 活动ID + */ + private String id; + + /** + * 标题 + */ + private String title; + + /** + * 活动头图 + */ + private String headPic; + + /** + * 打卡开始时间 + */ + private String signinStartTime; + + /** + * 打卡截止时间 + */ + private String signinEndTime; + + /** + * 签到奖励积分 + */ + private String reward; + + /** + * 签到状态:0-未签到,1-已签到 + */ + private String signInStatus; +} diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/AppActSignInQrCodeController.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/AppActSignInQrCodeController.java index 4f4f8dfe..eec29d25 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/AppActSignInQrCodeController.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/AppActSignInQrCodeController.java @@ -1,20 +1,17 @@ package com.elink.esua.epdc.modules.activity.controller; +import com.elink.esua.epdc.activity.form.ActSignInFormDTO; import com.elink.esua.epdc.activity.form.ActSignInRecordFormDTO; +import com.elink.esua.epdc.activity.form.ActSignInScanQrCodeFormDTO; import com.elink.esua.epdc.activity.result.ActSignInQrCodeResultDTO; -import com.elink.esua.epdc.activity.result.ActSignInRecordsDTO; import com.elink.esua.epdc.activity.result.ActSignInRecordsResultDTO; +import com.elink.esua.epdc.activity.result.ActSignInScanQrCodeResultDTO; import com.elink.esua.epdc.commons.tools.constant.Constant; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; import com.elink.esua.epdc.modules.activity.service.ActSignInQrCodeService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; +import org.springframework.web.bind.annotation.*; /** * 签到码移动端接口 @@ -53,10 +50,41 @@ public class AppActSignInQrCodeController { * @since 2021/2/24 15:26 */ @GetMapping("getsigninlist") - public Result getSignInList(ActSignInRecordFormDTO formDto) { + public Result getSignInList(@RequestBody ActSignInRecordFormDTO formDto) { ValidatorUtils.validateEntity(formDto); ActSignInRecordsResultDTO data = actSignInQrCodeService.listOfSignInRecords(formDto); return new Result().ok(data); } + + /** + * 居民扫签到码获取活动信息接口 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/2/25 9:41 + */ + @GetMapping("actInfo") + public Result getActInfo(@RequestBody ActSignInScanQrCodeFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + ActSignInScanQrCodeResultDTO data = actSignInQrCodeService.getSignInActInfo(formDto); + + return new Result().ok(data); + } + + /** + * 居民扫码签到 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/2/25 13:55 + */ + @PostMapping("signin") + public Result scanSignIn(@RequestBody ActSignInFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + + return actSignInQrCodeService.scanSignIn(formDto); + } } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActUserPointsLogDao.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActUserPointsLogDao.java index 61e8702b..d6d823fd 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActUserPointsLogDao.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActUserPointsLogDao.java @@ -55,4 +55,15 @@ public interface ActUserPointsLogDao extends BaseDao { */ Integer selectCountOfSignInRecords(@Param("actId") String actId); + /** + * 获取用户已扫码签到记录数量 + * + * @param userId + * @param actId + * @return java.lang.Integer + * @author Liuchuang + * @since 2021/2/25 10:30 + */ + Integer selectCountOfUserSignInRecords(String userId, String actId); + } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActSignInQrCodeService.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActSignInQrCodeService.java index db2db414..a5b972e7 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActSignInQrCodeService.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActSignInQrCodeService.java @@ -18,12 +18,16 @@ package com.elink.esua.epdc.modules.activity.service; import com.elink.esua.epdc.activity.ActSignInQrCodeDTO; +import com.elink.esua.epdc.activity.form.ActSignInFormDTO; import com.elink.esua.epdc.activity.form.ActSignInRecordFormDTO; +import com.elink.esua.epdc.activity.form.ActSignInScanQrCodeFormDTO; import com.elink.esua.epdc.activity.result.ActSignInQrCodeResultDTO; import com.elink.esua.epdc.activity.result.ActSignInRecordsDTO; import com.elink.esua.epdc.activity.result.ActSignInRecordsResultDTO; +import com.elink.esua.epdc.activity.result.ActSignInScanQrCodeResultDTO; import com.elink.esua.epdc.commons.mybatis.service.BaseService; import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.modules.activity.entity.ActSignInQrCodeEntity; import java.util.List; @@ -116,4 +120,24 @@ public interface ActSignInQrCodeService extends BaseService page(Map params) { IPage page = baseDao.selectPage( @@ -120,16 +132,17 @@ public class ActSignInQrCodeServiceImpl extends BaseServiceImpl= actInfoDto.getSigninStartTime().getTime() && System.currentTimeMillis() <= actInfoDto.getSigninEndTime().getTime())) { - throw new RenException("当前活动不在打卡时间范围内,不能生成签到码"); + throw new RenException(ActSignInQrCodeConstant.ACT_CREATE_SIGN_IN_CODE_MSG_NOT_SIGN_IN_TIME); } // 保存签到码信息 @@ -154,6 +167,37 @@ public class ActSignInQrCodeServiceImpl extends BaseServiceImpl NumConstant.SIXTY) { + throw new RenException(ActSignInQrCodeConstant.ACT_SCAN_SIGN_IN_MSG_QR_CODE_INVALID); + } + + return entity; + } + + /** + * 校验活动 + * + * @param actId + * @return com.elink.esua.epdc.activity.ActInfoDTO + * @author Liuchuang + * @since 2021/2/25 10:57 + */ + private ActInfoDTO checkSignInActInfo(String actId) { + ActInfoDTO actInfoDto = actInfoService.get(actId); + if (null == actInfoDto) { + throw new RenException(ActSignInQrCodeConstant.ACT_SCAN_SIGN_IN_MSG_ACT_NOT_FOUND); + } + + if (System.currentTimeMillis() < actInfoDto.getSigninStartTime().getTime() + || System.currentTimeMillis() > actInfoDto.getSigninEndTime().getTime()) { + throw new RenException(ActSignInQrCodeConstant.ACT_SCAN_SIGN_IN_MSG_NOT_SIGN_IN_TIME); + } + + return actInfoDto; + } + + /** + * 校验用户是否已扫码签到 + * + * @param userId + * @param actId + * @return java.lang.String + * @author Liuchuang + * @since 2021/2/25 11:00 + */ + private String checkUserSignInStatus(String userId, String actId) { + if (StringUtils.isEmpty(userId)) { + throw new RenException(ActSignInQrCodeConstant.ACT_SCAN_SIGN_IN_MSG_USER_NOT_FOUND); + } + boolean signInStatus = actUserPointsLogService.checkUserScanSignInStatus(userId, actId); + + return signInStatus ? NumConstant.ONE_STR : NumConstant.ZERO_STR; + } + + /** + * 扫码签到校验用户 + * + * @param userId + * @param actId + * @return com.elink.esua.epdc.activity.ActUserRelationDTO + * @author Liuchuang + * @since 2021/2/25 15:21 + */ + private ActUserRelationDTO checkSignInUser(String userId, String actId) { + // 校验用户 + ActUserRelationDTO actUserRelationDto = actUserRelationService.getActUserRelationId(userId, actId, null); + if (null == actUserRelationDto) { + throw new RenException(ActSignInQrCodeConstant.ACT_SIGN_IN_MSG_NOT_SIGN_UP); + } + switch (actUserRelationDto.getStatus()) { + case ActUserRelationStatusConstant.SIGN_UP: + throw new RenException(ActSignInQrCodeConstant.ACT_SIGN_IN_MSG_PENDING_SIGN_UP); + case ActUserRelationStatusConstant.CANCEL_SIGN_UP: + throw new RenException(ActSignInQrCodeConstant.ACT_SIGN_IN_MSG_CANCEL_SIGN_UP); + case ActUserRelationStatusConstant.NOT_APPROVED: + throw new RenException(ActSignInQrCodeConstant.ACT_SIGN_IN_MSG_NOT_APPROVED_SIGN_UP); + case ActUserRelationStatusConstant.REFUSE_ADD_POINTS: + throw new RenException(ActSignInQrCodeConstant.ACT_SIGN_IN_MSG_REFUSE_ADD_POINTS); + default: + break; + } + + // 校验用户是否已扫码签到 + String signInStatus = checkUserSignInStatus(userId, actId); + if (NumConstant.ONE_STR.equals(signInStatus)) { + throw new RenException(ActSignInQrCodeConstant.ACT_SIGN_IN_MSG_ALREADY_SIGN_IN); + } + + return actUserRelationDto; + } + } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActUserClockLogServiceImpl.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActUserClockLogServiceImpl.java index 3b8a6dbe..4e3206d2 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActUserClockLogServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActUserClockLogServiceImpl.java @@ -174,9 +174,13 @@ public class ActUserClockLogServiceImpl extends BaseServiceImpl NumConstant.ZERO; + } + } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/constant/ActSignInQrCodeConstant.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/constant/ActSignInQrCodeConstant.java new file mode 100644 index 00000000..cd7ec5ba --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/constant/ActSignInQrCodeConstant.java @@ -0,0 +1,26 @@ +package com.elink.esua.epdc.modules.constant; + +/** + * 活动扫码签到,提示语常量 + * + * @author Liuchuang + * @since 2021/2/25 10:43 + */ +public interface ActSignInQrCodeConstant { + + String ACT_SCAN_SIGN_IN_MSG_QR_CODE_INVALID = "签到码已失效,请重新扫码"; + String ACT_SCAN_SIGN_IN_MSG_ACT_NOT_FOUND = "活动不存在,请重新扫码"; + String ACT_SCAN_SIGN_IN_MSG_NOT_SIGN_IN_TIME = "当前活动不在打卡时间范围内,不能进行扫码签到"; + String ACT_SCAN_SIGN_IN_MSG_USER_NOT_FOUND = "获取用户信息失败,请稍后重试"; + + String ACT_CREATE_SIGN_IN_CODE_MSG_ACT_ID_NOT_EMPTY = "活动ID不能为空"; + String ACT_CREATE_SIGN_IN_CODE_MSG_NOT_SIGN_IN_TIME = "当前活动不在打卡时间范围内,不能生成签到码"; + + String ACT_SIGN_IN_MSG_ALREADY_SIGN_IN = "当前活动您已签到成功,请勿重复操作"; + String ACT_SIGN_IN_MSG_NOT_SIGN_UP = "当前活动您未报名,不能签到"; + String ACT_SIGN_IN_MSG_PENDING_SIGN_UP = "当前活动您的报名申请审核中,不能签到"; + String ACT_SIGN_IN_MSG_CANCEL_SIGN_UP = "当前活动您已取消报名,不能签到"; + String ACT_SIGN_IN_MSG_NOT_APPROVED_SIGN_UP = "当前活动您的报名申请未通过,不能签到"; + String ACT_SIGN_IN_MSG_REFUSE_ADD_POINTS = "当前活动您已被拒绝加积分,不能签到"; + +} diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserPointsLogDao.xml b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserPointsLogDao.xml index ab7585fb..1e25c863 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserPointsLogDao.xml +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserPointsLogDao.xml @@ -52,4 +52,18 @@ AND r.ACT_ID = #{formDto.actId} + + diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserRelationDao.xml b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserRelationDao.xml index b444ddd9..4ca5b441 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserRelationDao.xml +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserRelationDao.xml @@ -53,10 +53,11 @@