Browse Source

取消活动

dev_shibei_match
yinzuomei 4 years ago
parent
commit
44667fad07
  1. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 2
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/GroupActIdDTO.java
  3. 38
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CancelActFormDTO.java
  4. 15
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java
  5. 9
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActSignInRecordDao.java
  6. 8
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActSignInRecordService.java
  7. 9
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java
  8. 15
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActSignInRecordServiceImpl.java
  9. 111
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java
  10. 4
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/GroupActConstant.java
  11. 12
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActSignInRecordDao.xml

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -167,7 +167,9 @@ public enum EpmetErrorCode {
GROUP_ACT_CONTENT_MAX(8904,"活动内容至多输入1000字"),
GROUP_ACT_IMG_MAX(8905,"最多可添加3张图片"),
PARTY_MEMBER_CREATE_BRANCH_GROUP(8906,"您不是党员,不能创建支部小组"),
NOT_IN_GROUP_CAN_NOT_VIEW(8907,"当前内容仅允许组内成员查看");
NOT_IN_GROUP_CAN_NOT_VIEW(8907,"当前内容仅允许组内成员查看"),
CAN_NOT_CANCEL(8908,"活动%s,不能取消");
private int code;
private String msg;

2
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/GroupActIdDTO.java

@ -5,7 +5,7 @@ import lombok.Data;
import java.io.Serializable;
/**
* 描述一下
* 组织活动id
*
* @author yinzuomei@elink-cn.com
* @date 2021/4/19 15:11

38
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CancelActFormDTO.java

@ -0,0 +1,38 @@
package com.epmet.resi.group.dto.act.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 011取消活动
*
* @author yinzuomei@elink-cn.com
* @date 2021/4/20 12:04
*/
@Data
public class CancelActFormDTO implements Serializable {
private static final long serialVersionUID = 6126854423030661426L;
public interface AddUserInternalGroup {
}
public interface AddUserShowGroup extends CustomerClientShowGroup {
}
@NotBlank(message = "groupActId不能为空", groups = AddUserInternalGroup.class)
private String groupActId;
@NotBlank(message = "取消原因不能为空", groups = AddUserShowGroup.class)
@Length(max = 300, message = "取消原因最多输入300字", groups = AddUserShowGroup.class)
private String reason;
/**
* 当前用户id
*/
@NotBlank(message = "tokenDto获取userId为空", groups = AddUserInternalGroup.class)
private String userId;
}

15
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java

@ -25,6 +25,7 @@ import com.epmet.modules.act.service.GroupActInfoService;
import com.epmet.resi.group.dto.act.GroupActIdDTO;
import com.epmet.resi.group.dto.act.form.ActDetailFormDTO;
import com.epmet.resi.group.dto.act.form.ActReadViewFormDTO;
import com.epmet.resi.group.dto.act.form.CancelActFormDTO;
import com.epmet.resi.group.dto.act.form.PublishGroupActFormDTO;
import com.epmet.resi.group.dto.act.result.ActDetailResultDTO;
import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO;
@ -93,4 +94,18 @@ public class GroupActInfoController {
ValidatorUtils.validateEntity(actReadViewFormDTO,ActReadViewFormDTO.AddUserInternalGroup.class);
return new Result<NoticeReadListResultDTO>().ok(groupActInfoService.queryReadList(actReadViewFormDTO));
}
/**
* @return
* @param formDTO
* @author yinzuomei
* @description 011取消活动
* @Date 2021/4/20 12:09
**/
@PostMapping("cancel")
public Result<GroupActIdDTO> cancelAct(@LoginUser TokenDto tokenDto,@RequestBody CancelActFormDTO formDTO){
formDTO.setUserId(tokenDto.getUserId());
ValidatorUtils.validateEntity(formDTO,CancelActFormDTO.AddUserShowGroup.class,CancelActFormDTO.AddUserInternalGroup.class);
return new Result<GroupActIdDTO>().ok(groupActInfoService.cancelAct(formDTO));
}
}

9
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActSignInRecordDao.java

@ -20,6 +20,7 @@ package com.epmet.modules.act.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.modules.act.entity.ActSignInRecordEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 组织活动签到记录
@ -30,4 +31,12 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ActSignInRecordDao extends BaseDao<ActSignInRecordEntity> {
/**
* 查询当前用户是否签到
*
* @param groupActId
* @param signUserId
* @return int
*/
int selectCountUserRec(@Param("groupActId")String groupActId, @Param("signUserId")String signUserId);
}

8
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActSignInRecordService.java

@ -28,4 +28,12 @@ import com.epmet.modules.act.entity.ActSignInRecordEntity;
*/
public interface ActSignInRecordService extends BaseService<ActSignInRecordEntity> {
/**
* 查询当前用户是否签到
*
* @param groupActId
* @param currentUserId
* @return boolean
*/
boolean queryUserSignInRec(String groupActId, String currentUserId);
}

9
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java

@ -22,6 +22,7 @@ import com.epmet.modules.act.entity.GroupActInfoEntity;
import com.epmet.resi.group.dto.act.GroupActIdDTO;
import com.epmet.resi.group.dto.act.form.ActDetailFormDTO;
import com.epmet.resi.group.dto.act.form.ActReadViewFormDTO;
import com.epmet.resi.group.dto.act.form.CancelActFormDTO;
import com.epmet.resi.group.dto.act.form.PublishGroupActFormDTO;
import com.epmet.resi.group.dto.act.result.ActDetailResultDTO;
import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO;
@ -57,4 +58,12 @@ public interface GroupActInfoService extends BaseService<GroupActInfoEntity> {
* @return com.epmet.resi.group.dto.act.result.ActDetailResultDTO
*/
NoticeReadListResultDTO queryReadList(ActReadViewFormDTO actReadViewFormDTO);
/**
* 011取消活动
*
* @param formDTO
* @return com.epmet.resi.group.dto.act.GroupActIdDTO
*/
GroupActIdDTO cancelAct(CancelActFormDTO formDTO);
}

15
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActSignInRecordServiceImpl.java

@ -32,5 +32,18 @@ import org.springframework.stereotype.Service;
@Service
public class ActSignInRecordServiceImpl extends BaseServiceImpl<ActSignInRecordDao, ActSignInRecordEntity> implements ActSignInRecordService {
/**
* 查询当前用户是否签到
*
* @param groupActId
* @param signUserId
* @return boolean
*/
@Override
public boolean queryUserSignInRec(String groupActId, String signUserId) {
if (baseDao.selectCountUserRec(groupActId, signUserId) > 0) {
return true;
}
return false;
}
}

111
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java

@ -46,6 +46,7 @@ import com.epmet.modules.act.entity.ActReadRecordEntity;
import com.epmet.modules.act.entity.GroupActContentEntity;
import com.epmet.modules.act.entity.GroupActInfoEntity;
import com.epmet.modules.act.service.ActCategoryDictService;
import com.epmet.modules.act.service.ActSignInRecordService;
import com.epmet.modules.act.service.GroupActInfoService;
import com.epmet.modules.constant.GroupActConstant;
import com.epmet.modules.group.service.ResiGroupService;
@ -53,6 +54,7 @@ import com.epmet.modules.member.service.ResiGroupMemberService;
import com.epmet.resi.group.dto.act.GroupActIdDTO;
import com.epmet.resi.group.dto.act.form.ActDetailFormDTO;
import com.epmet.resi.group.dto.act.form.ActReadViewFormDTO;
import com.epmet.resi.group.dto.act.form.CancelActFormDTO;
import com.epmet.resi.group.dto.act.form.PublishGroupActFormDTO;
import com.epmet.resi.group.dto.act.result.ActDetailResultDTO;
import com.epmet.resi.group.dto.group.ResiGroupDTO;
@ -103,6 +105,8 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
private ActReadRecordDao actReadRecordDao;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private ActSignInRecordService actSignInRecordService;
/**
* 003发布编辑组织活动
*
@ -378,7 +382,7 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
resultDTO.setTextList(groupActContentDao.selectContentList(formDTO.getGroupActId(),GroupActConstant.TEXT));
resultDTO.setImgList(groupActContentDao.selectContentList(formDTO.getGroupActId(),GroupActConstant.IMG));
resultDTO.setCanceledReason(GroupActConstant.CANCELED.equals(resultDTO.getStatus()) ? actOperationRecordDao.selectCanceledReason(formDTO.getGroupActId()) : StrConstant.EPMETY_STR);
handleSignInDesc(resultDTO);
handleSignInDesc(resultDTO,formDTO.getUserId());
resultDTO.setUserRole(resiGroupMemberDTO.getGroupLeaderFlag());
// 有签到后不可以修改活动时间:true可以修改,false不可以,
resultDTO.setStartTimeEditFlag(groupActInfoEntity.getSignedInNum()>NumConstant.ZERO?false:true);
@ -397,24 +401,76 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
if(GroupActConstant.UN_READ.equals(actReadRecordEntity.getRead())){
//未读->已读
actReadRecordEntity.setRead(GroupActConstant.READ);
actReadRecordEntity.setUpdatedTime(new Date());
actReadRecordDao.updateById(actReadRecordEntity);
}
}
return resultDTO;
}
private void handleSignInDesc(ActDetailResultDTO resultDTO) {
//todo
//blank: 不显示; display:显示
//在签到时间范围内,并且未签到的,显示签到按钮
resultDTO.setSignInButton("todo");
private void handleSignInDesc(ActDetailResultDTO resultDTO,String currentUserId) {
if(GroupActConstant.CANCELED.equals(resultDTO.getStatus())
||GroupActConstant.CLOSED.equals(resultDTO.getStatus())){
//活动已取消或者已关闭,不显示签到按钮,也不显示描述
resultDTO.setSignInButton(GroupActConstant.BLANK);
resultDTO.setSignInDesc(StrConstant.EPMETY_STR);
return;
}
if (null == resultDTO.getSignInStartTime() || null == resultDTO.getSignInEndTime()) {
//未设置签到开始、截止时间,默认不显示签到按钮,也不显示描述
resultDTO.setSignInButton(GroupActConstant.BLANK);
resultDTO.setSignInDesc(StrConstant.EPMETY_STR);
return;
}
//查询当前用户是否签到
boolean signedInFlag=actSignInRecordService.queryUserSignInRec(resultDTO.getGroupActId(),currentUserId);
// 1、签到成功显示已签到
if(signedInFlag){
resultDTO.setSignInButton(GroupActConstant.BLANK);
resultDTO.setSignInDesc("已签到");
return;
}
Date nowDate=new Date();
long nowTime=nowDate.getTime();
long signInStartTime=resultDTO.getSignInStartTime().getTime();
long signInEndTime=resultDTO.getSignInEndTime().getTime();
if (nowTime < signInStartTime) {
resultDTO.setSignInButton(GroupActConstant.DISPLAY);
// 2、未到签到时间显示距离签到时间还有多久
//距离签到开始还有XX天4小时32分钟
String remainStr=getDatePoor(resultDTO.getSignInStartTime(),nowDate);
resultDTO.setSignInDesc(String.format("距离签到开始还有%s",remainStr));
return;
} else if (signInStartTime <= nowTime && nowTime <= signInEndTime) {
// 3、在签到时间范围内,并且未签到的,显示签到按钮,描述显示空字符串
resultDTO.setSignInButton(GroupActConstant.DISPLAY);
resultDTO.setSignInDesc(StrConstant.EPMETY_STR);
return;
} else if (nowTime > signInEndTime) {
// 4、签到时间已过且未签到的,显示“当前时间已超过签到时间”
resultDTO.setSignInDesc("todo");
resultDTO.setSignInButton(GroupActConstant.BLANK);
resultDTO.setSignInDesc("当前时间已超过签到时间");
}
}
public static String getDatePoor(Date endDate, Date nowDate) {
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
// long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - nowDate.getTime();
// 计算差多少天
long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
// 计算差多少秒//输出结果
// long sec = diff % nd % nh % nm / ns;
return day + "天" + hour + "小时" + min + "分钟";
}
/**
* 016活动已读未读列表
*
@ -475,4 +531,45 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
resultDTO.setUnReadList(unReadList);
return resultDTO;
}
/**
* 011取消活动
*
* @param formDTO
* @return com.epmet.resi.group.dto.act.GroupActIdDTO
*/
@Override
public GroupActIdDTO cancelAct(CancelActFormDTO formDTO) {
GroupActInfoEntity actInfoEntity=baseDao.selectById(formDTO.getGroupActId());
//1、只有活动发布人才可以取消
if(!actInfoEntity.getPublishUserId().equals(formDTO.getUserId())){
throw new RenException(EpmetErrorCode.GROUP_LEADER_CAN_EDIT_GROUP_INFO.getCode(), EpmetErrorCode.GROUP_LEADER_CAN_EDIT_GROUP_INFO.getMsg());
}
//2、活动已关闭,不能取消
if (GroupActConstant.CLOSED.equals(actInfoEntity.getStatus())) {
throw new RenException(EpmetErrorCode.CAN_NOT_CANCEL.getCode(), String.format(EpmetErrorCode.CAN_NOT_CANCEL.getMsg(), "已关闭"));
} else if (GroupActConstant.CANCELED.equals(actInfoEntity.getStatus())) {
throw new RenException(EpmetErrorCode.CAN_NOT_CANCEL.getCode(), "活动已取消");
}
//3、记录取消时间
Date nowDate=new Date();
actInfoEntity.setCanceledTime(nowDate);
actInfoEntity.setStatus(GroupActConstant.CANCELED);
baseDao.updateById(actInfoEntity);
//4、插入一条操作日志
ActOperationRecordEntity actOperationRecordEntity = new ActOperationRecordEntity();
actOperationRecordEntity.setCustomerId(actInfoEntity.getCustomerId());
actOperationRecordEntity.setOperateUserId(formDTO.getUserId());
actOperationRecordEntity.setGroupActId(formDTO.getGroupActId());
actOperationRecordEntity.setOperationType(GroupActConstant.CANCEL);
actOperationRecordEntity.setCreatedTime(nowDate);
actOperationRecordEntity.setUpdatedTime(nowDate);
actOperationRecordDao.insert(actOperationRecordEntity);
baseDao.updateById(actInfoEntity);
GroupActIdDTO resultDTO=new GroupActIdDTO();
resultDTO.setGroupActId(formDTO.getGroupActId());
return resultDTO;
}
}

4
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/GroupActConstant.java

@ -33,4 +33,8 @@ public interface GroupActConstant {
// 已读: read未读:un_read
String READ="read";
String UN_READ="un_read";
// blank: 不显示; display:显示
String BLANK="blank";
String DISPLAY="display";
}

12
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActSignInRecordDao.xml

@ -3,6 +3,16 @@
<mapper namespace="com.epmet.modules.act.dao.ActSignInRecordDao">
<!-- 查询当前用户是否签到 -->
<select id="selectCountUserRec" resultType="int" parameterType="map">
SELECT
count(*)
FROM
act_sign_in_record acr
WHERE
acr.DEL_FLAG = '0'
AND acr.GROUP_ACT_ID = #{groupActId}
AND acr.SIGN_USER_ID =#{signUserId}
</select>
</mapper>
Loading…
Cancel
Save