Browse Source

打卡成功更新act_info表活动打卡人数;打卡积分-确定/拒绝给用户发送消息通知

feature/dangjian
尹作梅 6 years ago
parent
commit
6db511cf05
  1. 2
      esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/ActUserLogDTO.java
  2. 5
      esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActPointCheckFormDTO.java
  3. 10
      esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/constant/HeartNoticeConstant.java
  4. 9
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActInfoDao.java
  5. 9
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActInfoService.java
  6. 5
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java
  7. 169
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActUserClockLogServiceImpl.java
  8. 8
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActInfoDao.xml
  9. 9
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/constant/PointsNoticeConstant.java
  10. 13
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/logs/service/impl/PointsLogsServiceImpl.java

2
esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/ActUserLogDTO.java

@ -55,7 +55,7 @@ public class ActUserLogDTO implements Serializable {
private String actUserRelationId;
/**
* 操作类别0-报名1-审核通过2-打卡3-取消报名4-审核不通过
* 操作类别0-报名1-审核通过2-打卡3-取消报名4-审核不通过5-确认积分6-拒绝加积分
*/
private String operationType;

5
esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/form/ActPointCheckFormDTO.java

@ -21,7 +21,6 @@ import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 活动信息表
@ -35,7 +34,7 @@ public class ActPointCheckFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* epdc_act_user_relation表主键
*/
@NotBlank(message = "id不能为空")
private String id;
@ -56,4 +55,4 @@ public class ActPointCheckFormDTO implements Serializable {
private String failureReason;
}
}

10
esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/constant/HeartNoticeConstant.java

@ -35,4 +35,14 @@ public interface HeartNoticeConstant {
* 我的消息类型1互动通知
*/
String NOTICE_TYPE_INTERACTIVE_NOTICE = "1";
/**
* 打卡积分-拒绝加积分
*/
String NOTICE_REFUSE_ADD_ACT_POINTS = "您参与的活动【拒绝积分】";
/**
* 打卡积分-确认加积分
*/
String NOTICE_CONFIRM_ADD_ACT_POINTS = "您参与的活动【确认积分】";
}

9
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActInfoDao.java

@ -94,4 +94,13 @@ public interface ActInfoDao extends BaseDao<ActInfoEntity> {
* @Date 2020/2/5 16:31
**/
ActInfoDetailResultDTO selectActInfoDetailResultDTO(String actId);
/**
* @param actId
* @return void
* @Author yinzuomei
* @Description 活动打卡人数+1
* @Date 2020/2/8 13:08
**/
void addClockNum(String actId);
}

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

@ -167,4 +167,13 @@ public interface ActInfoService extends BaseService<ActInfoEntity> {
* @date 2019-12-11
*/
void delete(String[] ids);
/**
* @param actId
* @return void
* @Author yinzuomei
* @Description 活动打卡人数+1
* @Date 2020/2/8 13:07
**/
void addClockNum(String actId);
}

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

@ -235,6 +235,11 @@ public class ActInfoServiceImpl extends BaseServiceImpl<ActInfoDao, ActInfoEntit
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public void addClockNum(String actId) {
baseDao.addClockNum(actId);
}
@Override
public Result<ActInfoDetailAppResultDTO> getDetailByApp(ActInfoAppFormDTO formDto) {

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

@ -24,27 +24,36 @@ import com.elink.esua.epdc.activity.form.ActPointCheckFormDTO;
import com.elink.esua.epdc.activity.result.ActUserClockLogResultDTO;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.constant.PointsConstant;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum;
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsBehaviorCodeEnum;
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationEnum;
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationModeEnum;
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsRuleCodeEnum;
import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.constant.ActStateConstant;
import com.elink.esua.epdc.constant.ActUserRelationStatusConstant;
import com.elink.esua.epdc.constant.HeartNoticeConstant;
import com.elink.esua.epdc.dto.UserDTO;
import com.elink.esua.epdc.dto.VolunteerInfoDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcVolunteerKindnessTimeFormDTO;
import com.elink.esua.epdc.dto.logs.PointsLogsDTO;
import com.elink.esua.epdc.modules.activity.dao.ActUserClockLogDao;
import com.elink.esua.epdc.modules.activity.entity.ActUserClockLogEntity;
import com.elink.esua.epdc.modules.activity.entity.ActUserPointsLogEntity;
import com.elink.esua.epdc.modules.activity.service.*;
import com.elink.esua.epdc.modules.async.NewsTask;
import com.elink.esua.epdc.modules.feign.PointsFeignClient;
import com.elink.esua.epdc.modules.feign.UserInfoFeignClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.text.DecimalFormat;
import java.util.*;
@ -79,6 +88,8 @@ public class ActUserClockLogServiceImpl extends BaseServiceImpl<ActUserClockLogD
@Autowired
private PointsFeignClient pointsFeignClient;
@Autowired
private NewsTask newsTask;
@Override
public PageData<ActUserClockLogDTO> page(Map<String, Object> params) {
@ -88,6 +99,7 @@ public class ActUserClockLogServiceImpl extends BaseServiceImpl<ActUserClockLogD
);
return getPageData(page, ActUserClockLogDTO.class);
}
@Override
public PageData<ActUserClockLogResultDTO> getActUserClockLogFromPC(Map<String, Object> params) {
IPage<ActUserClockLogResultDTO> page = getPage(params);
@ -134,94 +146,124 @@ public class ActUserClockLogServiceImpl extends BaseServiceImpl<ActUserClockLogD
@Override
@Transactional(rollbackFor = Exception.class)
public Result pointCheck(ActPointCheckFormDTO dto) {
ActUserRelationDTO actUserRelationDTO = actUserRelationService.get(dto.getId());
ActInfoDTO actInfoDTO = actInfoService.get(dto.getActId());
ActUserPointsLogDTO pointsLogDTO = new ActUserPointsLogDTO();
pointsLogDTO.setActUserId(dto.getId());
pointsLogDTO.setOperationReason(dto.getFailureReason());
ActUserPointsLogDTO actUserPointsLogDTO = new ActUserPointsLogDTO();
actUserPointsLogDTO.setActUserId(dto.getId());
actUserPointsLogDTO.setOperationReason(dto.getFailureReason());
//确认加积分
Integer point = 0;
if (ActStateConstant.ACT_USER_RELATION_STATUS_POINTPASS.equals(dto.getStatus())) {
pointsLogDTO.setOperationType(ActStateConstant.POINT_OPERATION_TYPE_ADMINPASS);
pointsLogDTO.setOperationPointsType(ActStateConstant.OPERATION_POINTS_TYPE_ADD);
point =actInfoDTO.getReward();
pointsLogDTO.setPoints(point);
//操作类型 0-系统确认积分,2-管理员确认积分,4-取消报名扣减积分,6-管理员扣减积分,8-拒绝积分
actUserPointsLogDTO.setOperationType(NumConstant.TWO_STR);
actUserPointsLogDTO.setOperationPointsType(ActStateConstant.OPERATION_POINTS_TYPE_ADD);//0-减积分,1-加积分
actUserPointsLogDTO.setPoints(actInfoDTO.getReward());
// 志愿者增加爱心时长
Result result = this.calculationKindnessTime(actInfoDTO, dto.getId());
if (!result.success()) {
return result;
}
//拒绝加积分
//增加用户活动积分记录
ActUserPointsLogEntity actUserPointsLogEntity = actUserPointsLogService.insertActUserPointsLogDTO(actUserPointsLogDTO);
//更新用户积分余额、插入积分日志表
Result updateUserPointsResult = this.updateUserPoints(dto, actInfoDTO, actUserRelationDTO, actUserPointsLogEntity);
if (!updateUserPointsResult.success()) {
return updateUserPointsResult;
}
//拒绝加积分
} else if (ActStateConstant.ACT_USER_RELATION_STATUS_POINTREJECT.equals(dto.getStatus())) {
pointsLogDTO.setOperationType(ActStateConstant.POINT_OPERATION_TYPE_ADMINREJECT);
pointsLogDTO.setOperationPointsType(ActStateConstant.OPERATION_POINTS_TYPE_DEDUCT);
pointsLogDTO.setPoints(point);
actUserPointsLogDTO.setOperationType(ActStateConstant.POINT_OPERATION_TYPE_ADMINREJECT);
actUserPointsLogDTO.setOperationPointsType(ActStateConstant.OPERATION_POINTS_TYPE_DEDUCT);
actUserPointsLogDTO.setPoints(actInfoDTO.getReward());
//增加用户活动积分记录
ActUserPointsLogEntity actUserPointsLogEntity = actUserPointsLogService.insertActUserPointsLogDTO(actUserPointsLogDTO);
}
PointsLogsDTO pointsLogsEntity = new PointsLogsDTO();
pointsLogsEntity.setVolunteerId(dto.getId());
pointsLogsEntity.setOperationTime(new Date());
pointsLogsEntity.setOperationMode(PointsOperationModeEnum.OPERATION_MODE_ADMIN.getOperationMode());
pointsLogsEntity.setStatus(YesOrNoEnum.YES.value());
pointsLogsEntity.setFailureReason("");
pointsLogsEntity.setRuleCode(PointsConstant.ruleCode);
pointsLogsEntity.setOperationDesc("积分操作");
//操作描述
pointsLogsEntity.setPoints(point);
pointsLogsEntity.setOperationType(pointsLogDTO.getOperationType());
pointsLogsEntity.setBehaviorCode("like");
//增加积分记录
actUserPointsLogService.save(pointsLogDTO);
// 更新用户状态
return userInfoHandle(dto,pointsLogsEntity);
//更新用户活动关系表状态
this.updateActUserRelation(dto);
//插入用户活动关系日志表记录
this.insertActUserLogDTO(dto);
//发送消息通知
this.insertUserInformation(dto, actInfoDTO, actUserRelationDTO);
return new Result();
}
private Result userInfoHandle(ActPointCheckFormDTO dto, PointsLogsDTO pointsLogsEntity){
private void updateActUserRelation(ActPointCheckFormDTO dto) {
//用户关系表状态更新
ActUserRelationDTO checkDTO =actUserRelationService.get(dto.getId());
ActUserRelationDTO actUserRelationEntity = new ActUserRelationDTO();
actUserRelationEntity.setId(dto.getId());
actUserRelationEntity.setStatus(dto.getStatus());
actUserRelationEntity.setFailureReason(dto.getFailureReason());
actUserRelationService.update(actUserRelationEntity);
}
private void insertActUserLogDTO(ActPointCheckFormDTO dto) {
//存储活动日志表 epdc_act_user_log
ActUserLogDTO actUserLogDTO = new ActUserLogDTO();
actUserLogDTO.setActUserRelationId(checkDTO.getId());
actUserLogDTO.setActUserRelationId(dto.getId());
actUserLogDTO.setOperationType(dto.getStatus());
actUserLogDTO.setOperationTime(new Date());
actUserLogDTO.setFailureReason(dto.getFailureReason());
actUserLogService.save(actUserLogDTO);
//更新用户积分
Result<UserDTO> result = userInfoFeignClient.getUserInfoById(checkDTO.getUserId());
if (result.success() && null != result.getData()) {
UserDTO updateUserDTO = result.getData();
//增加用户积分
System.out.println(updateUserDTO.toString());
updateUserDTO.setPoints(updateUserDTO.getPoints() + pointsLogsEntity.getPoints());
pointsLogsEntity.setUserId(checkDTO.getUserId());
pointsLogsEntity.setLavePoints(updateUserDTO.getPoints() + pointsLogsEntity.getPoints());
Result userResult = userInfoFeignClient.updateUserInfo(updateUserDTO);
if (userResult.success()) {
// 用户积分记录
Result pointResult = pointsFeignClient.addPointsLog(pointsLogsEntity);
if(pointResult.success()){
return new Result();
} else {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return new Result().error("积分记录增加失败。");
}
} else {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return new Result().error("用户信息更新失败。");
}
}
} else {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return new Result().error("用户信息获取失败。");
private Result updateUserPoints(ActPointCheckFormDTO actPointCheckFormDTO, ActInfoDTO actInfoDTO, ActUserRelationDTO actUserRelationDTO, ActUserPointsLogEntity actUserPointsLogEntity) {
PointsLogsDTO pointsLogsDTO = new PointsLogsDTO();
//根据用户id查询志愿者信息
Result<VolunteerInfoDTO> volunteerInfoDTOResult = userInfoFeignClient.getVolunteerInfoDTOByUserId(actUserRelationDTO.getUserId());
if (!volunteerInfoDTOResult.success() || null == volunteerInfoDTOResult.getData()) {
throw new RenException("查询志愿者信息异常");
}
//直接调用fegin,返回剩余积分值
EpdcUserPointsFormDTO userPointsFormDTO = new EpdcUserPointsFormDTO();
userPointsFormDTO.setUserId(actUserRelationDTO.getUserId());
userPointsFormDTO.setPoints(actInfoDTO.getReward());
userPointsFormDTO.setOperationType(PointsOperationEnum.OPERATION_TYPE_ADD.getOperationType());
Result<UserDTO> result = userInfoFeignClient.handleUserPoints(userPointsFormDTO);
if (!result.success()) {
throw new RenException("更新用户积分异常");
}
pointsLogsDTO.setVolunteerId(volunteerInfoDTOResult.getData().getId());
pointsLogsDTO.setUserId(actUserRelationDTO.getUserId());
pointsLogsDTO.setOperationType(PointsOperationEnum.OPERATION_TYPE_ADD.getOperationType());//(0-减积分,1-加积分)
pointsLogsDTO.setPoints(actInfoDTO.getReward());
pointsLogsDTO.setOperationTime(new Date());
pointsLogsDTO.setOperationMode(PointsOperationModeEnum.OPERATION_MODE_ADMIN.getOperationMode());
pointsLogsDTO.setRuleCode(PointsRuleCodeEnum.CONFIRM_JOIN_ACT.getRuleCode());
pointsLogsDTO.setLavePoints(result.getData().getPoints());//剩余积分值
pointsLogsDTO.setBehaviorCode(PointsBehaviorCodeEnum.JOIN_ACT.getBehaviorCode());
pointsLogsDTO.setStatus(YesOrNoEnum.YES.value());
pointsLogsDTO.setReferenceId(actUserPointsLogEntity.getId());
pointsLogsDTO.setOperationDesc(actPointCheckFormDTO.getFailureReason());
return pointsFeignClient.addPointsLog(pointsLogsDTO);
}
/**
* @param dto
* @param actInfoDTO
* @param actUserRelationDTO
* @return void
* @Author yinzuomei
* @Description 管理员确认积分拒绝积分后给用户发送通知
* @Date 2020/2/8 12:06
**/
private void insertUserInformation(ActPointCheckFormDTO dto, ActInfoDTO actInfoDTO, ActUserRelationDTO actUserRelationDTO) {
EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO();
//确认积分或者拒绝积分
if (ActStateConstant.ACT_USER_RELATION_STATUS_POINTPASS.equals(dto.getStatus())) {
informationFormDTO.setTitle(HeartNoticeConstant.NOTICE_CONFIRM_ADD_ACT_POINTS);
} else if (ActStateConstant.ACT_USER_RELATION_STATUS_POINTREJECT.equals(dto.getStatus())) {
informationFormDTO.setTitle(HeartNoticeConstant.NOTICE_REFUSE_ADD_ACT_POINTS);
} else {
return;
}
informationFormDTO.setUserId(actUserRelationDTO.getUserId());
informationFormDTO.setType(HeartNoticeConstant.NOTICE_TYPE_INTERACTIVE_NOTICE);
informationFormDTO.setBusinessType(HeartNoticeConstant.NOTICE__BUSINESS_TYPE_ACTIVITY);
informationFormDTO.setBusinessId(actUserRelationDTO.getActId());
informationFormDTO.setContent(dto.getFailureReason());
informationFormDTO.setRelBusinessContent(actInfoDTO.getTitle());
newsTask.insertUserInformation(informationFormDTO);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ActUserClockLogDTO dto) {
@ -276,6 +318,7 @@ public class ActUserClockLogServiceImpl extends BaseServiceImpl<ActUserClockLogD
actClockPicDTO.setClockPic(imgUrl);
actClockPicService.save(actClockPicDTO);
}
actInfoService.addClockNum(appActUserClockLogDTO.getActId());
return new Result().ok("打卡成功");
}

8
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActInfoDao.xml

@ -496,4 +496,12 @@
where eai.DEL_FLAG='0'
and eai.id=#{actId}
</select>
<!-- 活动打卡人数+1 -->
<update id="addClockNum" parameterType="java.lang.String">
update epdc_act_info eai
set eai.CLOCK_NUM=eai.CLOCK_NUM+1
where eai.DEL_FLAG='0'
and eai.id=#{actId}
</update>
</mapper>

9
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/constant/PointsNoticeConstant.java

@ -6,15 +6,20 @@ package com.elink.esua.epdc.constant;
* @Date 2020/2/7 20:14
*/
public interface PointsNoticeConstant {
/**
* 积分变更
*/
String CHANGE_POINTS_NOTICE = "积分变更";
/**
* 减积分
*/
String SUBTRACT_POINTS_NOTICE = "积分变更【扣减积分】-";
String SUBTRACT_POINTS_NOTICE = "【扣减积分】:";
/**
* 加积分
*/
String ADD_POINTS_NOTICE = "积分变更【增加积分】+";
String ADD_POINTS_NOTICE = "【增加积分】:";
/**
* 消息所属业务类型points积分商城

13
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/logs/service/impl/PointsLogsServiceImpl.java

@ -179,19 +179,20 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points
private void issueSmsNotification(PointsLogsEntity pointsLogsEntity) {
EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO();
informationFormDTO.setUserId(pointsLogsEntity.getUserId());
informationFormDTO.setContent(pointsLogsEntity.getOperationDesc());
String title = "";
String content = "";
//积分操作类型(0-减积分,1-加积分)
if (PointsOperationEnum.OPERATION_TYPE_ADD.getOperationType().equals(pointsLogsEntity.getOperationType())) {
title = PointsNoticeConstant.ADD_POINTS_NOTICE;
content = PointsNoticeConstant.ADD_POINTS_NOTICE + pointsLogsEntity.getPoints() + ",原因:";
} else if (PointsOperationEnum.OPERATION_TYPE_SUBSTRACT.getOperationType().equals(pointsLogsEntity.getOperationType())) {
title = PointsNoticeConstant.SUBTRACT_POINTS_NOTICE;
content = PointsNoticeConstant.SUBTRACT_POINTS_NOTICE + pointsLogsEntity.getPoints() + ",原因:";
}
title = title.concat(pointsLogsEntity.getPoints().toString());
informationFormDTO.setTitle(title);
informationFormDTO.setContent(content);
informationFormDTO.setTitle(PointsNoticeConstant.CHANGE_POINTS_NOTICE);
informationFormDTO.setType(PointsNoticeConstant.NOTICE_TYPE_INTERACTIVE_NOTICE);
informationFormDTO.setBusinessType(PointsNoticeConstant.NOTICE__BUSINESS_TYPE_ACTIVITY);
informationFormDTO.setBusinessId(pointsLogsEntity.getId());
informationFormDTO.setRelBusinessContent(pointsLogsEntity.getOperationDesc());
// 发送消息
newsTask.insertUserInformation(informationFormDTO);
}

Loading…
Cancel
Save