| | |
| | | package com.ruoyi.errand.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<List<CommunityListVO>> getTotalCommunityList() { |
| | | List<CommunityListVO> communityListVOS = this.getBaseMapper().getTotalCommunityList(); |
| | | public R<List<CommunityListVO>> getTotalCommunityList(String name) { |
| | | List<CommunityListVO> communityListVOS = this.getBaseMapper().getTotalCommunityList(name); |
| | | return R.ok(communityListVOS); |
| | | } |
| | | |
| | | @Override |
| | | public List<AllCommunityListVO> getAllCommunityList() { |
| | | List<Integer> list=communityCourierMapper.getAllCommunityList(); |
| | | |
| | | return this.baseMapper.getAllCommunityList(list); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | iPage.getRecords().forEach(x->{ |
| | | List<Order> orderList = orderMapper.selectList(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getCommunityId, x.getId()) |
| | | .ne(Order::getOrderStatus,3) |
| | | .eq(Order::getDelFlag, DelFlagConstant.UNDELETE) |
| | | .eq(Order::getPayStatus,2)); |
| | | if (orderList!=null&& !orderList.isEmpty()){ |
| | |
| | | //添加小区 |
| | | Community community = new Community(); |
| | | BeanUtils.copyProperties(addCommunityDTO,community); |
| | | community.setDelFlag(0); |
| | | community.setStatus(0); |
| | | community.setCreateTime(LocalDateTime.now()); |
| | | this.save(community); |
| | | if (addCommunityDTO.getServicePhone()!=null){ |
| | | //保存客服电话 |
| | | Phone phone = new Phone(); |
| | | phone.setType(2); |
| | | phone.setCommunity_id(community.getId()); |
| | | phone.setCommunityId(community.getId()); |
| | | phone.setPhone(addCommunityDTO.getServicePhone()); |
| | | phoneMapper.insert(phone); |
| | | } |
| | |
| | | //检查客服电话是否更改 |
| | | if (editCommunityDTO.getServicePhone()!=null){ |
| | | Phone phone = phoneMapper.selectOne(new LambdaQueryWrapper<Phone>() |
| | | .eq(Phone::getCommunity_id, editCommunityDTO.getId()) |
| | | .eq(Phone::getCommunityId, editCommunityDTO.getId()) |
| | | .eq(Phone::getType, 2)); |
| | | if (phone==null){ |
| | | //添加 |
| | | //保存客服电话 |
| | | phone = new Phone(); |
| | | phone.setType(2); |
| | | phone.setCommunity_id(community.getId()); |
| | | phone.setCommunityId(community.getId()); |
| | | phone.setPhone(editCommunityDTO.getServicePhone()); |
| | | phoneMapper.insert(phone); |
| | | }else { |
| | |
| | | throw new ServiceException("跑腿人员不存在"); |
| | | } |
| | | //检查跑腿员是否绑定 |
| | | Long count = communityCourierMapper.selectCount(new LambdaQueryWrapper<CommunityCourier>() |
| | | CommunityCourier one = communityCourierMapper.selectOne(new LambdaQueryWrapper<CommunityCourier>() |
| | | .eq(CommunityCourier::getCourierId, editCommunityDTO.getCourierId())); |
| | | if (count>0){ |
| | | throw new ServiceException("跑腿人员已绑定"); |
| | | if (one != null && !Objects.equals(one.getCommunityId(), editCommunityDTO.getId())){ |
| | | throw new ServiceException("跑腿人员已绑定其他小区"); |
| | | } |
| | | //检查跑腿员是否更改 |
| | | CommunityCourier communityCourier = communityCourierMapper.selectOne(new LambdaQueryWrapper<CommunityCourier>() |
| | |
| | | communityCourier = new CommunityCourier(); |
| | | communityCourier.setCommunityId(editCommunityDTO.getId()); |
| | | communityCourier.setCourierId(editCommunityDTO.getCourierId()); |
| | | communityCourierMapper.insert(communityCourier); |
| | | }else { |
| | | //修改 |
| | | communityCourier.setCourierId(editCommunityDTO.getCourierId()); |
| | | communityCourierMapper.updateById(communityCourier); |
| | | } |
| | | |
| | | //修改小区 |
| | | BeanUtils.copyProperties(editCommunityDTO,community); |
| | | this.updateById(community); |
| | | } |
| | | |
| | | @Override |
| | |
| | | Community community = this.baseMapper.selectById(id); |
| | | if (community==null|| Objects.equals(community.getDelFlag(), DelFlagConstant.DELETE)){ |
| | | throw new ServiceException("未找到该小区"); |
| | | } |
| | | //查找小区是否有订单未完成 |
| | | //查找小区是否有订单未完成 |
| | | Long count = orderMapper.selectCount(new LambdaUpdateWrapper<Order>().eq(Order::getCommunityId, id) |
| | | .eq(Order::getDelFlag, DelFlagConstant.UNDELETE) |
| | | .in(Order::getOrderStatus, Arrays.asList(1,2))); |
| | | if (count > 0) { |
| | | throw new ServiceException("该小区还有订单未完成,无法冻结"); |
| | | } |
| | | //删除关系 |
| | | CommunityCourier communityCourier = communityCourierMapper.selectOne(new LambdaQueryWrapper<CommunityCourier>() |
| | |
| | | if (community==null|| Objects.equals(community.getDelFlag(), DelFlagConstant.DELETE)){ |
| | | throw new ServiceException("未找到该小区"); |
| | | } |
| | | if (community.getStatus()==1){ |
| | | //查找小区是否有订单未完成 |
| | | Long count = orderMapper.selectCount(new LambdaUpdateWrapper<Order>().eq(Order::getCommunityId, id) |
| | | .eq(Order::getDelFlag, DelFlagConstant.UNDELETE) |
| | | .in(Order::getOrderStatus, Arrays.asList(1,2))); |
| | | if (count > 0) { |
| | | throw new ServiceException("该小区还有订单未完成,无法冻结"); |
| | | } |
| | | } |
| | | |
| | | community.setStatus(community.getStatus()==0?1:0); |
| | | community.setUpdateTime(LocalDateTime.now()); |
| | | this.baseMapper.updateById(community); |
| | |
| | | } |
| | | } |
| | | //客服电话 |
| | | Phone phone = phoneMapper.selectOne(new LambdaQueryWrapper<Phone>().eq(Phone::getCommunity_id, community.getId())); |
| | | Phone phone = phoneMapper.selectOne(new LambdaQueryWrapper<Phone>().eq(Phone::getCommunityId, community.getId())); |
| | | if (phone!=null){ |
| | | vo.setServicePhone(phone.getPhone()); |
| | | } |
| | | //订单统计 |
| | | List<Order> orderList = orderMapper.selectList(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getCommunityId,id) |
| | | .ne(Order::getOrderStatus,3) |
| | | .eq(Order::getDelFlag, DelFlagConstant.UNDELETE) |
| | | .eq(Order::getPayStatus,2)); |
| | | if (orderList!=null&& !orderList.isEmpty()){ |
| | | vo.setTotal(orderList.size());//总订单数 |
| | | LocalDateTime start = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); |
| | | LocalDateTime end = LocalDateTime.of(LocalDate.now(), LocalTime.MAX); |
| | | long today = orderList.stream().filter(order -> order.getOrderTime().isAfter(start.minusNanos(1))) |
| | | .filter(order -> order.getOrderTime().isBefore(end.plusNanos(1))).count(); |
| | | vo.setToday((int) today);//今日订单数 |
| | | } |
| | | return vo; |
| | | } |
| | | |