Browse Source

活动扫码签到接口 init

1、居民扫码接口
2、居民扫码签到接口
feature/syp_points
liuchuang 5 years ago
parent
commit
fe768bb0ca
  1. 1
      esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/NumConstant.java
  2. 57
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiActSignInController.java
  3. 28
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/ActInfoFeignClient.java
  4. 15
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/ActInfoFeignClientFallback.java
  5. 27
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/ActSignInService.java
  6. 17
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/ActSignInServiceImpl.java
  7. 5
      esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActPointCheckFormDTO.java
  8. 26
      esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActSignInFormDTO.java
  9. 26
      esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActSignInScanQrCodeFormDTO.java
  10. 49
      esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/result/ActSignInScanQrCodeResultDTO.java
  11. 44
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/AppActSignInQrCodeController.java
  12. 11
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActUserPointsLogDao.java
  13. 24
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActSignInQrCodeService.java
  14. 12
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActUserPointsLogService.java
  15. 25
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java
  16. 154
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActSignInQrCodeServiceImpl.java
  17. 8
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActUserClockLogServiceImpl.java
  18. 6
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActUserPointsLogServiceImpl.java
  19. 26
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/constant/ActSignInQrCodeConstant.java
  20. 14
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserPointsLogDao.xml
  21. 3
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserRelationDao.xml

1
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;

57
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<com.elink.esua.epdc.activity.result.ActSignInScanQrCodeResultDTO>
* @author Liuchuang
* @since 2021/2/24 18:00
*/
@GetMapping("actInfo")
public Result<ActSignInScanQrCodeResultDTO> 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);
}
}

28
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<ActSignInRecordsResultDTO> getSignInList(ActSignInRecordFormDTO formDto);
/**
* 居民扫签到码获取活动信息接口
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.activity.result.ActSignInScanQrCodeResultDTO>
* @author Liuchuang
* @since 2021/2/25 9:38
*/
@GetMapping(value ="heart/epdc-app/actsigninqrcode/actInfo", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<ActSignInScanQrCodeResultDTO> 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);
}

15
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<ActSignInScanQrCodeResultDTO> 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);
}
}

27
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<ActSignInRecordsResultDTO> listOfSignInRecords(ActSignInRecordFormDTO formDto);
/**
* 居民扫签到码获取活动信息接口
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.activity.result.ActSignInScanQrCodeResultDTO>
* @author Liuchuang
* @since 2021/2/25 9:34
*/
Result<ActSignInScanQrCodeResultDTO> 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);
}

17
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<ActSignInRecordsResultDTO> listOfSignInRecords(ActSignInRecordFormDTO formDto) {
return actInfoFeignClient.getSignInList(formDto);
}
@Override
public Result<ActSignInScanQrCodeResultDTO> getSignInActInfo(ActSignInScanQrCodeFormDTO formDto) {
return actInfoFeignClient.getActInfo(formDto);
}
@Override
public Result scanSignIn(ActSignInFormDTO formDto) {
return actInfoFeignClient.scanSignIn(formDto);
}
}

5
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;
}

26
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;
}

26
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;
}

49
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;
}

44
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<ActSignInRecordsResultDTO> getSignInList(ActSignInRecordFormDTO formDto) {
public Result<ActSignInRecordsResultDTO> getSignInList(@RequestBody ActSignInRecordFormDTO formDto) {
ValidatorUtils.validateEntity(formDto);
ActSignInRecordsResultDTO data = actSignInQrCodeService.listOfSignInRecords(formDto);
return new Result<ActSignInRecordsResultDTO>().ok(data);
}
/**
* 居民扫签到码获取活动信息接口
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.activity.result.ActSignInScanQrCodeResultDTO>
* @author Liuchuang
* @since 2021/2/25 9:41
*/
@GetMapping("actInfo")
public Result<ActSignInScanQrCodeResultDTO> getActInfo(@RequestBody ActSignInScanQrCodeFormDTO formDto) {
ValidatorUtils.validateEntity(formDto);
ActSignInScanQrCodeResultDTO data = actSignInQrCodeService.getSignInActInfo(formDto);
return new Result<ActSignInScanQrCodeResultDTO>().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);
}
}

11
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<ActUserPointsLogEntity> {
*/
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);
}

24
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<ActSignInQrCodeEntit
* @since 2021/2/24 15:27
*/
ActSignInRecordsResultDTO listOfSignInRecords(ActSignInRecordFormDTO formDto);
/**
* 居民扫签到码获取活动信息接口
*
* @param formDto
* @return com.elink.esua.epdc.activity.result.ActSignInScanQrCodeResultDTO
* @author Liuchuang
* @since 2021/2/25 9:43
*/
ActSignInScanQrCodeResultDTO getSignInActInfo(ActSignInScanQrCodeFormDTO formDto);
/**
* 居民扫码签到
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author Liuchuang
* @since 2021/2/25 14:02
*/
Result scanSignIn(ActSignInFormDTO formDto);
}

12
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActUserPointsLogService.java

@ -114,4 +114,16 @@ public interface ActUserPointsLogService extends BaseService<ActUserPointsLogEnt
* @since 2021/2/24 15:27
*/
ActSignInRecordsResultDTO listOfSignInRecords(ActSignInRecordFormDTO formDto);
/**
* 校验用户是否已扫码签到
*
* @param userId
* @param actId
* @return boolean
* @author Liuchuang
* @since 2021/2/25 10:27
*/
boolean checkUserScanSignInStatus(String userId, String actId);
}

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

@ -507,21 +507,28 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
String actUserStatus = actUserRelationEntity.getStatus();
// 已确认过积分,直接返回
if (ActUserRelationStatusConstant.CONFIRM_ADD_POINTS.equals(actUserStatus)
// 注释 2021-02-25 liuchuang 已确认积分或已拒绝积分用户可打卡
/*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) {
if ((ActUserRelationStatusConstant.APPROVED.equals(actUserStatus)
|| ActUserRelationStatusConstant.CONFIRM_ADD_POINTS.equals(actUserStatus)
|| ActUserRelationStatusConstant.REFUSE_ADD_POINTS.equals(actUserStatus))
&& !isClocked) {
return ActUserStatusConstant.CLOCK;
}
// (已经打过卡的)显示更新打卡
if (ActUserRelationStatusConstant.CLOCK.equals(actUserStatus) && isClocked) {
if ((ActUserRelationStatusConstant.CLOCK.equals(actUserStatus)
|| ActUserRelationStatusConstant.CONFIRM_ADD_POINTS.equals(actUserStatus)
|| ActUserRelationStatusConstant.REFUSE_ADD_POINTS.equals(actUserStatus))
&& isClocked) {
return ActUserStatusConstant.UPDATE_CLOCK;
}
// 未审核的、审核未通过、已经取消报名的)- 已结束
@ -533,11 +540,17 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
} else if (currentTime.after(actInfoEntity.getSigninStartTime()) && currentTime.before(actInfoEntity.getSigninEndTime())) {
/* 活动打卡时间段内 */
// 审核通过且未打卡的显示 我要打卡
if (ActUserRelationStatusConstant.APPROVED.equals(actUserStatus) && !isClocked) {
if ((ActUserRelationStatusConstant.APPROVED.equals(actUserStatus)
|| ActUserRelationStatusConstant.CONFIRM_ADD_POINTS.equals(actUserStatus)
|| ActUserRelationStatusConstant.REFUSE_ADD_POINTS.equals(actUserStatus))
&& !isClocked) {
return ActUserStatusConstant.CLOCK;
}
// (已经打过卡的)显示更新打卡
if (ActUserRelationStatusConstant.CLOCK.equals(actUserStatus) && isClocked) {
if ((ActUserRelationStatusConstant.CLOCK.equals(actUserStatus)
|| ActUserRelationStatusConstant.CONFIRM_ADD_POINTS.equals(actUserStatus)
|| ActUserRelationStatusConstant.REFUSE_ADD_POINTS.equals(actUserStatus))
&& isClocked) {
return ActUserStatusConstant.UPDATE_CLOCK;
}
// 未审核的、审核未通过、已经取消报名的)- 进行中

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

@ -21,11 +21,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.activity.ActInfoDTO;
import com.elink.esua.epdc.activity.ActSignInQrCodeDTO;
import com.elink.esua.epdc.activity.ActUserRelationDTO;
import com.elink.esua.epdc.activity.form.ActPointCheckFormDTO;
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.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.constant.StrConstant;
import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.page.PageData;
@ -33,12 +39,12 @@ import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.QrCodeUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.constant.ActUserRelationStatusConstant;
import com.elink.esua.epdc.dto.UploadToOssDTO;
import com.elink.esua.epdc.modules.activity.dao.ActSignInQrCodeDao;
import com.elink.esua.epdc.modules.activity.entity.ActSignInQrCodeEntity;
import com.elink.esua.epdc.modules.activity.service.ActInfoService;
import com.elink.esua.epdc.modules.activity.service.ActSignInQrCodeService;
import com.elink.esua.epdc.modules.activity.service.ActUserPointsLogService;
import com.elink.esua.epdc.modules.activity.service.*;
import com.elink.esua.epdc.modules.constant.ActSignInQrCodeConstant;
import com.elink.esua.epdc.modules.feign.OssFeignClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -67,6 +73,12 @@ public class ActSignInQrCodeServiceImpl extends BaseServiceImpl<ActSignInQrCodeD
@Autowired
private ActUserPointsLogService actUserPointsLogService;
@Autowired
private ActUserRelationService actUserRelationService;
@Autowired
private ActUserClockLogService actUserClockLogService;
@Override
public PageData<ActSignInQrCodeDTO> page(Map<String, Object> params) {
IPage<ActSignInQrCodeEntity> page = baseDao.selectPage(
@ -120,16 +132,17 @@ public class ActSignInQrCodeServiceImpl extends BaseServiceImpl<ActSignInQrCodeD
}
@Override
@Transactional(rollbackFor = Exception.class)
public ActSignInQrCodeResultDTO getActSignInQrCode(String actId) {
if (StringUtils.isEmpty(actId)) {
throw new RenException("活动ID不能为空");
throw new RenException(ActSignInQrCodeConstant.ACT_CREATE_SIGN_IN_CODE_MSG_ACT_ID_NOT_EMPTY);
}
// 判断活动状态是否在打卡范围内
ActInfoDTO actInfoDto = actInfoService.get(actId);
if (!(System.currentTimeMillis() >= 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<ActSignInQrCodeD
return actUserPointsLogService.listOfSignInRecords(formDto);
}
@Override
public ActSignInScanQrCodeResultDTO getSignInActInfo(ActSignInScanQrCodeFormDTO formDto) {
// 校验签到码
ActSignInQrCodeEntity entity = checkSignInQrCode(formDto.getQrCodeId());
// 校验活动
ActInfoDTO actInfoDto = checkSignInActInfo(entity.getActId());
// 校验用户是否已扫码签到
String signInStatus = checkUserSignInStatus(formDto.getUserId(), actInfoDto.getId());
// 组装返回信息
ActSignInScanQrCodeResultDTO dto = ConvertUtils.sourceToTarget(actInfoDto, ActSignInScanQrCodeResultDTO.class);
dto.setSignInStatus(signInStatus);
return dto;
}
@Override
public Result scanSignIn(ActSignInFormDTO formDto) {
// 校验活动
ActInfoDTO actInfoDto = checkSignInActInfo(formDto.getActId());
// 校验用户
ActUserRelationDTO actUserRelationDto = checkSignInUser(formDto.getUserId(), actInfoDto.getId());
// 签到确认积分
ActPointCheckFormDTO dto = new ActPointCheckFormDTO();
dto.setId(actUserRelationDto.getId());
dto.setActId(actInfoDto.getId());
dto.setStatus(ActUserRelationStatusConstant.CONFIRM_ADD_POINTS);
dto.setOperationType(NumConstant.NINE_STR);
return actUserClockLogService.pointCheck(dto);
}
/**
* 生成二维码并上传 OSS
*
@ -174,4 +218,104 @@ public class ActSignInQrCodeServiceImpl extends BaseServiceImpl<ActSignInQrCodeD
return ossResult.getData();
}
/**
* 校验签到码
*
* @param qrCodeId
* @return com.elink.esua.epdc.modules.activity.entity.ActSignInQrCodeEntity
* @author Liuchuang
* @since 2021/2/25 10:56
*/
private ActSignInQrCodeEntity checkSignInQrCode(String qrCodeId) {
ActSignInQrCodeEntity entity = baseDao.selectById(qrCodeId);
if (null == entity) {
throw new RenException(ActSignInQrCodeConstant.ACT_SCAN_SIGN_IN_MSG_QR_CODE_INVALID);
}
// 签到码有效时间1分钟
long seconds = (System.currentTimeMillis() - entity.getCreatedTime().getTime()) / 1000;
if (seconds > 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;
}
}

8
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<ActUserClockLogD
actUserPointsLogDTO.setOperationReason(dto.getFailureReason());
//确认加积分
if (ActStateConstant.ACT_USER_RELATION_STATUS_POINTPASS.equals(dto.getStatus())) {
//操作类型 0-系统确认积分,2-管理员确认积分,4-取消报名扣减积分,6-管理员扣减积分,8-拒绝积分
//操作类型 0-系统确认积分,2-管理员确认积分,4-取消报名扣减积分,6-管理员扣减积分,8-拒绝积分,9-扫码签到确认积分
actUserPointsLogDTO.setOperationType(NumConstant.TWO_STR);
actUserPointsLogDTO.setOperationPointsType(ActStateConstant.OPERATION_POINTS_TYPE_ADD);//0-减积分,1-加积分
if (StringUtils.isNotEmpty(dto.getOperationType())) {
actUserPointsLogDTO.setOperationType(dto.getOperationType());
}
// 0-减积分,1-加积分
actUserPointsLogDTO.setOperationPointsType(ActStateConstant.OPERATION_POINTS_TYPE_ADD);
actUserPointsLogDTO.setPoints(actInfoDTO.getReward());
// 志愿者增加爱心时长
Result result = this.calculationKindnessTime(actInfoDTO, dto.getId());

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

@ -137,4 +137,10 @@ public class ActUserPointsLogServiceImpl extends BaseServiceImpl<ActUserPointsLo
return data;
}
@Override
public boolean checkUserScanSignInStatus(String userId, String actId) {
Integer recordNum = baseDao.selectCountOfUserSignInRecords(userId, actId);
return recordNum > NumConstant.ZERO;
}
}

26
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 = "当前活动您已被拒绝加积分,不能签到";
}

14
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}
</select>
<select id="selectCountOfUserSignInRecords" resultType="integer">
SELECT
COUNT(t.ID)
FROM
epdc_act_user_points_log t
LEFT JOIN epdc_act_user_relation r ON r.ID = t.ACT_USER_ID
AND r.DEL_FLAG = '0'
WHERE
t.DEL_FLAG = '0'
AND t.OPERATION_TYPE = '9'
AND r.ACT_ID = #{actId}
AND r.USER_ID = #{userId}
</select>
</mapper>

3
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserRelationDao.xml

@ -53,10 +53,11 @@
<select id="selectOneActUserRelationInfo" resultType="com.elink.esua.epdc.activity.ActUserRelationDTO"
parameterType="map">
select ID,ACT_ID,USER_ID,FACE_IMG,NICKNAME,REAL_NAME,PARTY_FLAG
select ID,ACT_ID,USER_ID,FACE_IMG,NICKNAME,REAL_NAME,PARTY_FLAG,STATUS
from epdc_act_user_relation
where USER_ID = #{userId}
and ACT_ID = #{actId}
and DEL_FLAG = '0'
<if test="statusList!=null and statusList.size()>0">
and status in
<foreach collection="statusList" item="status" index="index" open="(" close=")" separator=",">

Loading…
Cancel
Save