| | |
| | | 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.ComActEasyPhotoCommentDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageComActEasyPhotoCommentDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComActEasyPhotoCommentUserDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActEasyPhotoCommentVO; |
| | | import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO; |
| | | import com.panzhihua.service_community.dao.ComActEasyPhotoDAO; |
| | | import com.panzhihua.service_community.dao.ComActEasyPhotoUserDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActEasyPhotoDO; |
| | | import com.panzhihua.service_community.model.dos.ComActEasyPhotoUserDO; |
| | | import com.panzhihua.common.model.vos.community.TodoEventsVO; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import com.panzhihua.common.utlis.SensitiveUtil; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.*; |
| | | import com.panzhihua.service_community.model.dos.*; |
| | | import com.panzhihua.service_community.service.ComActEasyPhotoService; |
| | | import com.panzhihua.service_community.service.ComActUserWalletService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | private ComActEasyPhotoDAO comActEasyPhotoDAO; |
| | | @Resource |
| | | private ComActEasyPhotoUserDAO comActEasyPhotoUserDAO; |
| | | @Resource |
| | | private ComActEasyPhotoCommentDAO comActEasyPhotoCommentDAO ; |
| | | @Resource |
| | | private ComActEasyPhotoCommentUserDAO comActEasyPhotoCommentUserDAO ; |
| | | @Resource |
| | | private ComActEasyPhotoActivityMapper comActEasyPhotoActivityMapper; |
| | | @Resource |
| | | private ComActUserWalletService comActUserWalletService; |
| | | /** |
| | | * 分页查询随手拍 |
| | | * |
| | |
| | | }else { |
| | | comActEasyPhotoVO1.setHaveGiveThumbsUp(1); |
| | | } |
| | | comActEasyPhotoVO1.setPhone(SensitiveUtil.desensitizedPhoneNumber(comActEasyPhotoVO1.getPhone())); |
| | | }); |
| | | iPage.setRecords(records); |
| | | } |
| | |
| | | @Override |
| | | public R detailEasyPhoto(Long id, Long userId) { |
| | | ComActEasyPhotoVO comActEasyPhotoVO=comActEasyPhotoDAO.detailEasyPhoto(id); |
| | | if (ObjectUtils.isEmpty(comActEasyPhotoVO)) { |
| | | Integer status = comActEasyPhotoVO.getStatus(); |
| | | if (ObjectUtils.isEmpty(comActEasyPhotoVO)||null== status) { |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | ComActEasyPhotoUserDO comActEasyPhotoUserDO = comActEasyPhotoUserDAO.selectOne(new QueryWrapper<ComActEasyPhotoUserDO>().lambda().eq(ComActEasyPhotoUserDO::getEasyPhotoId, id).eq(ComActEasyPhotoUserDO::getUserId, userId)); |
| | |
| | | comActEasyPhotoVO.setHaveGiveThumbsUp(0); |
| | | } else { |
| | | comActEasyPhotoVO.setHaveGiveThumbsUp(1); |
| | | } |
| | | |
| | | if (status.intValue()==4) { |
| | | Date feedbackAt = comActEasyPhotoVO.getFeedbackAt(); |
| | | if (null==feedbackAt) { |
| | | comActEasyPhotoVO.setFeedbackAt(comActEasyPhotoVO.getExamineAt()); |
| | | } |
| | | } |
| | | comActEasyPhotoVO.setPhone(SensitiveUtil.desensitizedPhoneNumber(comActEasyPhotoVO.getPhone())); |
| | | if(comActEasyPhotoVO.getAddrRemark()==null){ |
| | | comActEasyPhotoVO.setAddrRemark(""); |
| | | } |
| | | return R.ok(comActEasyPhotoVO); |
| | | } |
| | |
| | | public R addEasyPhoto(ComActEasyPhotoVO comActEasyPhotoVO) { |
| | | ComActEasyPhotoDO comActEasyPhotoDO=new ComActEasyPhotoDO(); |
| | | BeanUtils.copyProperties(comActEasyPhotoVO,comActEasyPhotoDO); |
| | | //查询是否在活动时间内 |
| | | Date nowDate = DateUtils.getCurrentDate(DateUtils.ymdhms_format); |
| | | List<ComActEasyPhotoActivityDO> photoActivityDOS = comActEasyPhotoActivityMapper.selectList( |
| | | new QueryWrapper<ComActEasyPhotoActivityDO>().lambda().eq(ComActEasyPhotoActivityDO::getCommunityId,comActEasyPhotoVO.getCommunityId()) |
| | | .le(ComActEasyPhotoActivityDO::getActivityStartAt,nowDate).ge(ComActEasyPhotoActivityDO::getActivityEndAt,nowDate) |
| | | .eq(ComActEasyPhotoActivityDO::getStatus,ComActEasyPhotoActivityDO.status.jxz)); |
| | | if(!photoActivityDOS.isEmpty()){ |
| | | ComActEasyPhotoActivityDO photoActivityDO = photoActivityDOS.get(0); |
| | | photoActivityDO.setCount(photoActivityDO.getCount() + 1); |
| | | comActEasyPhotoDO.setActivityId(photoActivityDO.getId()); |
| | | comActEasyPhotoActivityMapper.updateById(photoActivityDO); |
| | | } |
| | | int insert = comActEasyPhotoDAO.insert(comActEasyPhotoDO); |
| | | if (insert>0) { |
| | | return R.ok(); |
| | |
| | | // 操作类型 1审核通过 2驳回 3反馈 |
| | | ComActEasyPhotoDO cmActEasyPhotoDO=new ComActEasyPhotoDO(); |
| | | cmActEasyPhotoDO.setId(comActEasyPhotoVO.getId()); |
| | | int isNeedFeedBack = comActEasyPhotoVO.getIsNeedFeedBack().intValue(); |
| | | cmActEasyPhotoDO.setHandlerId(comActEasyPhotoVO.getUserId()); |
| | | // cmActEasyPhotoDO.setActivityType(comActEasyPhotoVO.getActivityType()); |
| | | Date date = new Date(); |
| | | switch (type){ |
| | | case 1: |
| | | cmActEasyPhotoDO = this.comActEasyPhotoDAO.selectById(comActEasyPhotoVO.getId()); |
| | | if(!cmActEasyPhotoDO.getStatus().equals(ComActEasyPhotoDO.status.dsh)){ |
| | | return R.fail("该随手拍已审核,不可重复操作"); |
| | | } |
| | | Integer isNeedFeedBack = comActEasyPhotoVO.getIsNeedFeedBack(); |
| | | if (isNeedFeedBack==1) { |
| | | cmActEasyPhotoDO.setStatus(2);//进行中 |
| | | cmActEasyPhotoDO.setIsNeedFeedBack(1); |
| | | }else{ |
| | | cmActEasyPhotoDO.setStatus(4);//已完成 |
| | | } |
| | | cmActEasyPhotoDO.setExamineAt(new Date()); |
| | | cmActEasyPhotoDO.setExamineAt(date); |
| | | //审核通过判断随手拍是否有活动并计算用户收益 |
| | | comActUserWalletService.examineAddMoney(comActEasyPhotoVO.getActivityType(),comActEasyPhotoVO.getId(),comActEasyPhotoVO.getUserId()); |
| | | break; |
| | | case 2: |
| | | cmActEasyPhotoDO = this.comActEasyPhotoDAO.selectById(comActEasyPhotoVO.getId()); |
| | | if(!cmActEasyPhotoDO.getStatus().equals(ComActEasyPhotoDO.status.dsh)){ |
| | | return R.fail("该随手拍已审核,不可重复操作"); |
| | | } |
| | | cmActEasyPhotoDO.setStatus(3);//已驳回 |
| | | cmActEasyPhotoDO.setExamineAt(new Date()); |
| | | cmActEasyPhotoDO.setExamineAt(date); |
| | | cmActEasyPhotoDO.setRejectReason(comActEasyPhotoVO.getRejectReason()); |
| | | break; |
| | | case 3: |
| | | cmActEasyPhotoDO = this.comActEasyPhotoDAO.selectById(comActEasyPhotoVO.getId()); |
| | | if(!cmActEasyPhotoDO.getStatus().equals(ComActEasyPhotoDO.status.dfk)){ |
| | | return R.fail("该随手拍不是待反馈状态,不可进行反馈"); |
| | | } |
| | | cmActEasyPhotoDO.setHandleResult(comActEasyPhotoVO.getHandleResult()); |
| | | cmActEasyPhotoDO.setHandlePhotoList(comActEasyPhotoVO.getHandlePhotoList()); |
| | | cmActEasyPhotoDO.setStatus(4);//已完成 |
| | | cmActEasyPhotoDO.setFeedbackAt(new Date()); |
| | | cmActEasyPhotoDO.setFeedbackAt(date); |
| | | break; |
| | | default:break; |
| | | } |
| | |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 随手拍是否有待审核和带反馈的事件 |
| | | * |
| | | * @param communityId 社区id |
| | | * @param userId 登录用户id |
| | | * @return 待处理事件集合 |
| | | */ |
| | | @Override |
| | | public List<TodoEventsVO> selectNeedToDo(Long communityId, Long userId) { |
| | | List<TodoEventsVO> todoEventsVOS=comActEasyPhotoDAO.selectNeedToDo(communityId,userId); |
| | | return todoEventsVOS; |
| | | } |
| | | |
| | | /** |
| | | * 小程序分页查询随手拍 |
| | | * |
| | | * @param comActEasyPhotoVO 查询参数 |
| | | * @return 返回结果 |
| | | */ |
| | | @Override |
| | | public R pageEasyPhotoApplets(ComActEasyPhotoVO comActEasyPhotoVO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = comActEasyPhotoVO.getPageNum(); |
| | | Long pageSize = comActEasyPhotoVO.getPageSize(); |
| | | Long userId = comActEasyPhotoVO.getLogInUserId(); |
| | | if (null==pageNum||0==pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (null==pageSize||0==pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<ComActEasyPhotoVO> iPage = comActEasyPhotoDAO.pageEasyPhotoApplets(page, comActEasyPhotoVO); |
| | | List<ComActEasyPhotoVO> records = iPage.getRecords(); |
| | | if (!ObjectUtils.isEmpty(records)) { |
| | | records.forEach(comActEasyPhotoVO1 -> { |
| | | Long id = comActEasyPhotoVO1.getId(); |
| | | Integer status = comActEasyPhotoVO1.getStatus(); |
| | | Date feedbackAt = comActEasyPhotoVO1.getFeedbackAt(); |
| | | List<ComActEasyPhotoUserDO> comActEasyPhotoUserDO = |
| | | comActEasyPhotoUserDAO.selectList(new QueryWrapper<ComActEasyPhotoUserDO>().lambda().eq(ComActEasyPhotoUserDO::getEasyPhotoId, id).eq(ComActEasyPhotoUserDO::getUserId, userId)); |
| | | if (comActEasyPhotoUserDO==null||comActEasyPhotoUserDO.size()==0) { |
| | | comActEasyPhotoVO1.setHaveGiveThumbsUp(0); |
| | | }else { |
| | | comActEasyPhotoVO1.setHaveGiveThumbsUp(1); |
| | | } |
| | | if(status.intValue()==4&&null==feedbackAt){ |
| | | comActEasyPhotoVO1.setFeedbackAt(comActEasyPhotoVO1.getExamineAt()); |
| | | } |
| | | }); |
| | | iPage.setRecords(records); |
| | | } |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | /** |
| | | * 随手拍评论分页查询 |
| | | * |
| | | * @param pageComActEasyPhotoCommentDTO 查询参数 |
| | | * @return 查询结果 |
| | | */ |
| | | @Override |
| | | public R pageComActEasyPhotoComment(PageComActEasyPhotoCommentDTO pageComActEasyPhotoCommentDTO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = pageComActEasyPhotoCommentDTO.getPageNum(); |
| | | Long pageSize = pageComActEasyPhotoCommentDTO.getPageSize(); |
| | | if (null==pageNum||0==pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (null==pageSize||0==pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<ComActEasyPhotoCommentVO> iPage = comActEasyPhotoCommentDAO.pageComActEasyPhotoComment(page, pageComActEasyPhotoCommentDTO); |
| | | if(!iPage.getRecords().isEmpty()){ |
| | | for (ComActEasyPhotoCommentVO commentVO:iPage.getRecords()) { |
| | | if(StringUtils.isEmpty(commentVO.getName())){ |
| | | commentVO.setName(commentVO.getNickName()); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | /** |
| | | * 评论点赞/取消点赞 |
| | | * |
| | | * @param comActEasyPhotoCommentUserDTO 操作 |
| | | * @return 操作结果 |
| | | */ |
| | | @Override |
| | | public R commentSign(ComActEasyPhotoCommentUserDTO comActEasyPhotoCommentUserDTO) { |
| | | Long id = comActEasyPhotoCommentUserDTO.getId(); |
| | | if (null==id||0==id) { |
| | | return R.fail("主键不能为空"); |
| | | } |
| | | ComActEasyPhotoCommentDO comActEasyPhotoCommentDO = comActEasyPhotoCommentDAO.selectById(id); |
| | | if (ObjectUtils.isEmpty(comActEasyPhotoCommentDO)) { |
| | | return R.fail("评论不存在"); |
| | | } |
| | | Integer type = comActEasyPhotoCommentUserDTO.getType(); |
| | | if (null==type||type.intValue()>2||type.intValue()==0) { |
| | | return R.fail("操作类型错误"); |
| | | } |
| | | Long userId = comActEasyPhotoCommentUserDTO.getUserId(); |
| | | int num=0; |
| | | if (type.intValue()==1) { |
| | | ComActEasyPhotoCommentUserDO comActEasyPhotoCommentUserDO=new ComActEasyPhotoCommentUserDO(); |
| | | comActEasyPhotoCommentUserDO.setUserId(userId); |
| | | comActEasyPhotoCommentUserDO.setEasyPhotoCommentId(id); |
| | | ComActEasyPhotoCommentUserDO actEasyPhotoCommentUserDO = comActEasyPhotoCommentUserDAO.selectOne(new QueryWrapper<ComActEasyPhotoCommentUserDO>().lambda().eq(ComActEasyPhotoCommentUserDO::getUserId, userId).eq(ComActEasyPhotoCommentUserDO::getEasyPhotoCommentId, id)); |
| | | if (!ObjectUtils.isEmpty(actEasyPhotoCommentUserDO)) { |
| | | num=1; |
| | | }else{ |
| | | num=comActEasyPhotoCommentUserDAO.insert(comActEasyPhotoCommentUserDO); |
| | | } |
| | | }else{ |
| | | num=comActEasyPhotoCommentUserDAO.delete(new QueryWrapper<ComActEasyPhotoCommentUserDO>().lambda().eq(ComActEasyPhotoCommentUserDO::getUserId,userId).eq(ComActEasyPhotoCommentUserDO::getEasyPhotoCommentId,id)); |
| | | } |
| | | if (num>0) { |
| | | return R.ok(); |
| | | } else { |
| | | return R.fail(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 随手拍--评论--新增评论 |
| | | * |
| | | * @param comActEasyPhotoCommentDTO 新增内容 |
| | | * @return 新增结果 |
| | | */ |
| | | @Override |
| | | public R addComActEasyPhotoComment(ComActEasyPhotoCommentDTO comActEasyPhotoCommentDTO) { |
| | | Long id = comActEasyPhotoCommentDTO.getId(); |
| | | ComActEasyPhotoDO comActEasyPhotoDO = comActEasyPhotoDAO.selectById(id); |
| | | if (ObjectUtils.isEmpty(comActEasyPhotoDO)) { |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | ComActEasyPhotoCommentDO comActEasyPhotoCommentDO=new ComActEasyPhotoCommentDO(); |
| | | comActEasyPhotoCommentDO.setComment(comActEasyPhotoCommentDTO.getComment()); |
| | | comActEasyPhotoCommentDO.setUserId(comActEasyPhotoCommentDTO.getUserId()); |
| | | comActEasyPhotoCommentDO.setEasyPhotoId(id); |
| | | int insert = comActEasyPhotoCommentDAO.insert(comActEasyPhotoCommentDO); |
| | | if (insert>0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 社区随手拍列表统计 |
| | | * @param communityId 社区id |
| | | * @return 统计结果 |
| | | */ |
| | | @Override |
| | | public R easyPhotoStatistics(Long communityId){ |
| | | return R.ok(this.baseMapper.getEasyPhotoStatistics(communityId)); |
| | | } |
| | | |
| | | |
| | | } |