From 1c7e22837254781947366d09282d48a45347d0e5 Mon Sep 17 00:00:00 2001
From: huliguo <2023611923@qq.com>
Date: 星期三, 06 八月 2025 10:20:45 +0800
Subject: [PATCH] 发送小程序订单数量
---
pt-errand/src/main/java/com/ruoyi/errand/service/impl/CommunityServiceImpl.java | 65 +++++++++++++++++++++++++++-----
1 files changed, 55 insertions(+), 10 deletions(-)
diff --git a/pt-errand/src/main/java/com/ruoyi/errand/service/impl/CommunityServiceImpl.java b/pt-errand/src/main/java/com/ruoyi/errand/service/impl/CommunityServiceImpl.java
index 2ae8dbb..75ccc9c 100644
--- a/pt-errand/src/main/java/com/ruoyi/errand/service/impl/CommunityServiceImpl.java
+++ b/pt-errand/src/main/java/com/ruoyi/errand/service/impl/CommunityServiceImpl.java
@@ -1,6 +1,7 @@
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;
@@ -25,6 +26,7 @@
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;
@@ -55,15 +57,18 @@
}
@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);
+
+ return this.baseMapper.getAllCommunityList(list);
+
+
}
@Override
@@ -73,6 +78,7 @@
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()){
@@ -111,12 +117,15 @@
//添加小区
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);
}
@@ -148,14 +157,14 @@
//检查客服电话是否更改
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 {
@@ -171,10 +180,10 @@
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>()
@@ -184,12 +193,16 @@
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
@@ -197,6 +210,14 @@
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>()
@@ -217,6 +238,16 @@
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);
@@ -244,10 +275,24 @@
}
}
//客服电话
- 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;
}
--
Gitblit v1.7.1