|
|
@ -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、签到成功显示已签到
|
|
|
|
// 2、未到签到时间显示距离签到时间还有多久
|
|
|
|
// 3、在签到时间范围内,并且未签到的,显示签到按钮,描述显示空字符串
|
|
|
|
// 4、签到时间已过且未签到的,显示“当前时间已超过签到时间”
|
|
|
|
resultDTO.setSignInDesc("todo"); |
|
|
|
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.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; |
|
|
|
} |
|
|
|
} |