From 8e2d30fd6ac9c8cd3ee6d68c8fd575848f37390d Mon Sep 17 00:00:00 2001 From: 罗元桥 <2376770955@qq.com> Date: 星期二, 31 八月 2021 10:42:13 +0800 Subject: [PATCH] Merge branch 'test' into 'master' --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActMicroWishServiceImpl.java | 222 ++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 169 insertions(+), 53 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActMicroWishServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActMicroWishServiceImpl.java index 17421bd..5d7a6aa 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActMicroWishServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActMicroWishServiceImpl.java @@ -1,22 +1,31 @@ package com.panzhihua.service_community.service.impl; +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.panzhihua.common.model.dtos.community.bigscreen.work.ScreenMicroListDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComActMicroWishVO; +import com.panzhihua.common.model.vos.community.TodoEventsVO; +import com.panzhihua.common.model.vos.community.screen.work.MicroListVO; +import com.panzhihua.common.utlis.SensitiveUtil; import com.panzhihua.service_community.dao.ComActMicroWishDAO; import com.panzhihua.service_community.dao.ComActMicroWishUserDAO; import com.panzhihua.service_community.model.dos.ComActMicroWishDO; import com.panzhihua.service_community.model.dos.ComActMicroWishUserDO; import com.panzhihua.service_community.service.ComActMicroWishService; -import org.springframework.stereotype.Service; -import org.springframework.util.ObjectUtils; -import javax.annotation.Resource; -import java.util.Date; -import java.util.List; +import lombok.extern.slf4j.Slf4j; /** * @program: springcloud_k8s_panzhihuazhihuishequ @@ -25,7 +34,9 @@ * @create: 2020-12-07 14:34 **/ @Service -public class ComActMicroWishServiceImpl extends ServiceImpl<ComActMicroWishDAO, ComActMicroWishDO> implements ComActMicroWishService { +@Slf4j +public class ComActMicroWishServiceImpl extends ServiceImpl<ComActMicroWishDAO, ComActMicroWishDO> + implements ComActMicroWishService { @Resource private ComActMicroWishDAO comActMicroWishDAO; @Resource @@ -34,7 +45,8 @@ /** * 分页查询微心愿 * - * @param comActMicroWishVO 查询参数 + * @param comActMicroWishVO + * 查询参数 * @return 心愿列表 */ @Override @@ -43,25 +55,32 @@ Page page = new Page<>(); Long pageNum = comActMicroWishVO.getPageNum(); Long pageSize = comActMicroWishVO.getPageSize(); - if (ObjectUtils.isEmpty(pageNum) || 0 == pageNum) { + if (null == pageNum || 0 == pageNum) { pageNum = 1l; } - if (ObjectUtils.isEmpty(pageSize) || 0 == pageSize) { + if (null == pageSize || 0 == pageSize) { pageSize = 10l; } page.setSize(pageSize); page.setCurrent(pageNum); IPage<ComActMicroWishVO> iPage = comActMicroWishDAO.pageMicroWish(page, comActMicroWishVO); + List<ComActMicroWishVO> records = iPage.getRecords(); if (!ObjectUtils.isEmpty(records)) { records.forEach(comActMicroWishVO1 -> { - Long id = comActMicroWishVO1.getId(); - ComActMicroWishUserDO comActMicroWishUserDO = comActMicroWishUserDAO.selectOne(new QueryWrapper<ComActMicroWishUserDO>().lambda().eq(ComActMicroWishUserDO::getMicroWishId, id).eq(ComActMicroWishUserDO::getUserId, userId)); - if (ObjectUtils.isEmpty(comActMicroWishUserDO)) { - comActMicroWishVO1.setHaveGiveThumbsUp(0); - } else { - comActMicroWishVO1.setHaveGiveThumbsUp(1); + if (userId != null) { + Long id = comActMicroWishVO1.getId(); + ComActMicroWishUserDO comActMicroWishUserDO = comActMicroWishUserDAO.selectOne( + new QueryWrapper<ComActMicroWishUserDO>().lambda().eq(ComActMicroWishUserDO::getMicroWishId, id) + .eq(ComActMicroWishUserDO::getUserId, userId)); + if (ObjectUtils.isEmpty(comActMicroWishUserDO)) { + comActMicroWishVO1.setHaveGiveThumbsUp(0); + } else { + comActMicroWishVO1.setHaveGiveThumbsUp(1); + } } + comActMicroWishVO1 + .setSponsorPhone(SensitiveUtil.desensitizedPhoneNumber(comActMicroWishVO1.getSponsorPhone())); }); iPage.setRecords(records); } @@ -71,79 +90,97 @@ /** * 心愿详情 * - * @param id 查询主键 - * @param userId 登录用户id + * @param id + * 查询主键 + * @param userId + * 登录用户id * @return 心愿内容 */ @Override public R detailMicroWish(Long id, Long userId) { ComActMicroWishVO comActMicroWishVO = comActMicroWishDAO.detailMicroWish(id); if (ObjectUtils.isEmpty(comActMicroWishVO)) { - return R.fail(); + return R.fail("微心愿不存在"); } - ComActMicroWishUserDO comActMicroWishUserDO = comActMicroWishUserDAO.selectOne(new QueryWrapper<ComActMicroWishUserDO>().lambda().eq(ComActMicroWishUserDO::getUserId, userId).eq(ComActMicroWishUserDO::getMicroWishId, id)); - if (ObjectUtils.isEmpty(comActMicroWishUserDO)) { - comActMicroWishVO.setHaveGiveThumbsUp(0); - }else { - comActMicroWishVO.setHaveGiveThumbsUp(1); + Integer starNum = comActMicroWishVO.getStarNum(); + if (null == starNum) { + comActMicroWishVO.setStarNum(0); } + if (ObjectUtils.isEmpty(comActMicroWishVO)) { + return R.fail("心愿不存在"); + } + if (userId != null) { + ComActMicroWishUserDO comActMicroWishUserDO = + comActMicroWishUserDAO.selectOne(new QueryWrapper<ComActMicroWishUserDO>().lambda() + .eq(ComActMicroWishUserDO::getUserId, userId).eq(ComActMicroWishUserDO::getMicroWishId, id)); + if (ObjectUtils.isEmpty(comActMicroWishUserDO)) { + comActMicroWishVO.setHaveGiveThumbsUp(0); + } else { + comActMicroWishVO.setHaveGiveThumbsUp(1); + } + } + comActMicroWishVO.setSponsorPhone(SensitiveUtil.desensitizedPhoneNumber(comActMicroWishVO.getSponsorPhone())); return R.ok(comActMicroWishVO); } /** * 审核、分配、反馈心愿 * - * @param comActMicroWishVO 具体操作 + * @param comActMicroWishVO + * 具体操作 * @return 操作结果 */ @Override public R putlMicroWish(ComActMicroWishVO comActMicroWishVO) { Long id = comActMicroWishVO.getId(); - Integer type = comActMicroWishVO.getType(); - if (ObjectUtils.isEmpty(type)||type>5||type<1) { - return R.fail("操作类型不对"); - } + int type = comActMicroWishVO.getType().intValue(); String rejectReason = comActMicroWishVO.getRejectReason(); Long responsibleId = comActMicroWishVO.getResponsibleId(); String feedback = comActMicroWishVO.getFeedback(); String feedbackPhotoPathList = comActMicroWishVO.getFeedbackPhotoPathList(); - ComActMicroWishDO comActMicroWishDO=new ComActMicroWishDO(); + ComActMicroWishDO comActMicroWishDO = new ComActMicroWishDO(); comActMicroWishDO.setId(id); -// 1 审核通过 2驳回 3分配人员 4发起活动 5反馈 - switch (type){ + Date date = new Date(); + // 1 审核通过 2驳回 3分配人员 4发起活动 5反馈 + switch (type) { case 1: - comActMicroWishDO.setExamineAt(new Date()); - comActMicroWishDO.setStatus(2);//待分配 + comActMicroWishDO.setExamineAt(date); + comActMicroWishDO.setStatus(2);// 待分配 break; case 2: - comActMicroWishDO.setExamineAt(new Date()); + comActMicroWishDO.setExamineAt(date); comActMicroWishDO.setRejectReason(rejectReason); - comActMicroWishDO.setStatus(4);//驳回 + comActMicroWishDO.setStatus(4);// 驳回 break; case 3: - comActMicroWishDO.setDistributionAt(new Date()); + comActMicroWishDO.setDistributionAt(date); comActMicroWishDO.setResponsibleId(responsibleId); - comActMicroWishDO.setStatus(3);//进行中 + comActMicroWishDO.setStatus(3);// 进行中 comActMicroWishDO.setForm(1); break; case 4: - comActMicroWishDO.setDistributionAt(new Date()); + comActMicroWishDO.setDistributionAt(date); comActMicroWishDO.setResponsibleId(responsibleId); - comActMicroWishDO.setStatus(3);//进行中 + comActMicroWishDO.setStatus(3);// 待确认 comActMicroWishDO.setForm(2); -// todo 给负责人增加一个待办事件 break; case 5: - comActMicroWishDO.setFeedbackAt(new Date()); - comActMicroWishDO.setStatus(5);//待确认 + if (comActMicroWishVO.getFeedback().length() > 200) { + return R.fail("反馈字数不得超过200字"); + } + comActMicroWishDO.setFeedbackAt(date); + comActMicroWishDO.setStatus(5);// 待确认 comActMicroWishDO.setFeedback(feedback); + comActMicroWishDO.setFinish(feedback); + comActMicroWishDO.setFinishPhotoPathList(feedbackPhotoPathList); + comActMicroWishDO.setFinishAt(date); comActMicroWishDO.setFeedbackPhotoPathList(feedbackPhotoPathList); break; default: break; } int update = comActMicroWishDAO.updateById(comActMicroWishDO); - if (update>0) { + if (update > 0) { return R.ok(); } return R.fail(); @@ -152,7 +189,8 @@ /** * 点赞/取消点赞微心愿 * - * @param comActMicroWishVO 操作参数 + * @param comActMicroWishVO + * 操作参数 * @return 操作结果 */ @Override @@ -160,30 +198,108 @@ Integer haveGiveThumbsUp = comActMicroWishVO.getHaveGiveThumbsUp(); Long userId = comActMicroWishVO.getSponsorId(); Long microWishId = comActMicroWishVO.getId(); - ComActMicroWishUserDO comActMicroWishUserDO = comActMicroWishUserDAO.selectOne(new QueryWrapper<ComActMicroWishUserDO>().lambda().eq(ComActMicroWishUserDO::getMicroWishId, microWishId).eq(ComActMicroWishUserDO::getUserId, userId)); + ComActMicroWishUserDO comActMicroWishUserDO = + comActMicroWishUserDAO.selectOne(new QueryWrapper<ComActMicroWishUserDO>().lambda() + .eq(ComActMicroWishUserDO::getMicroWishId, microWishId).eq(ComActMicroWishUserDO::getUserId, userId)); boolean empty = ObjectUtils.isEmpty(comActMicroWishUserDO); - int num=0; - if (haveGiveThumbsUp.intValue()==1) { + int num = 0; + if (haveGiveThumbsUp.intValue() == 1) { if (empty) { - ComActMicroWishUserDO comActMicroWishUserDO1=new ComActMicroWishUserDO(); + ComActMicroWishUserDO comActMicroWishUserDO1 = new ComActMicroWishUserDO(); comActMicroWishUserDO1.setMicroWishId(microWishId); comActMicroWishUserDO1.setUserId(userId); - num=comActMicroWishUserDAO.insert(comActMicroWishUserDO1); - }else{ + num = comActMicroWishUserDAO.insert(comActMicroWishUserDO1); + } else { return R.ok(); } - }else { + } else { if (empty) { return R.ok(); } else { - num= comActMicroWishUserDAO.deleteById(comActMicroWishUserDO.getId()); + num = comActMicroWishUserDAO.deleteById(comActMicroWishUserDO.getId()); } } - if (num>0) { + if (num > 0) { return R.ok(); } return R.fail(); } + /** + * 用户确认心愿 + * + * @param comActMicroWishVO + * 用户评价 + * @return 确认结果 + */ + @Override + public R putMicroWishConfirm(ComActMicroWishVO comActMicroWishVO) { + ComActMicroWishDO comActMicroWishDO1 = comActMicroWishDAO.selectById(comActMicroWishVO.getId()); + if (ObjectUtils.isEmpty(comActMicroWishDO1)) { + return R.fail("心愿不存在"); + } + Integer status = comActMicroWishDO1.getStatus(); + if (status.intValue() != 5) { + return R.fail("心愿状态不是待确认"); + } + ComActMicroWishDO comActMicroWishDO = new ComActMicroWishDO(); + comActMicroWishDO.setId(comActMicroWishVO.getId()); + comActMicroWishDO.setEvaluateAt(comActMicroWishVO.getEvaluateAt()); + comActMicroWishDO.setStatus(comActMicroWishVO.getStatus()); + comActMicroWishDO.setScore(comActMicroWishVO.getScore()); + comActMicroWishDO.setEvaluate(comActMicroWishVO.getEvaluate()); + int update = comActMicroWishDAO.updateById(comActMicroWishDO); + if (update > 0) { + return R.ok(); + } + return R.fail(); + } + /** + * 社区首页代办事件集合 + * + * @param communityId + * 社区id + * @param userId + * 登录用户 + * @return 代办事件集合 + */ + @Override + public List<TodoEventsVO> selectNeedToDo(Long communityId, Long userId) { + List<TodoEventsVO> todoEventsVOS = comActMicroWishDAO.selectNeedToDo(communityId, userId); + return todoEventsVOS; + } + + @Override + public R deleteMicroWish(Long id) { + ComActMicroWishDO comActMicroWishDO = comActMicroWishDAO.selectById(id); + if (comActMicroWishDO == null) { + return R.fail("id有误!"); + } + comActMicroWishDAO.deleteById(id); + comActMicroWishUserDAO + .delete(new LambdaQueryWrapper<ComActMicroWishUserDO>().eq(ComActMicroWishUserDO::getMicroWishId, id)); + return R.ok(); + } + + @Override + public R timedTaskActMicroWishAll() { + int num = comActMicroWishDAO.updateStatusAutoConfirm(); + log.info("定时任务--修改待自动确认微心愿状态数量【{}】", num); + return R.ok(); + } + + @Override + public R getScreenMicroList(ScreenMicroListDTO microListDTO) { + IPage<MicroListVO> microListVOIPage = comActMicroWishDAO + .getScreenMicroList(new Page(microListDTO.getPageNum(), microListDTO.getPageSize()), microListDTO); + if (!microListVOIPage.getRecords().isEmpty()) { + microListVOIPage.getRecords().forEach(microListVO -> { + Integer count = comActMicroWishUserDAO.selectCount(new QueryWrapper<ComActMicroWishUserDO>().lambda() + .eq(ComActMicroWishUserDO::getMicroWishId, microListVO.getId())); + microListVO.setStarNum(count); + }); + } + return R.ok(microListVOIPage); + } } -- Gitblit v1.7.1