Kaynağa Gözat

fix(sys): 按月份范围完善客户跟单及待办筛选条件

- 在SysCustomerDataFollowOrderService中按月份起止时间传递筛选条件查询客户订单数据
- 修改SysCustomerDataFollowService的queryCustomerOrderSelectData方法,支持时间范围筛选
- 在SysCustomerDataFollowTodoService中根据传入日期补充当月第一天时间,调整成员数据查询
- 更新SysCustomerTodoService的queryMemberData方法,支持按月份范围筛选查询成员数据
- 全面增加订单时间范围限制,确保查询结果准确反映指定月份的数据
zhangxf 3 hafta önce
ebeveyn
işleme
c0ee4acee5

+ 6 - 8
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowOrderService.java

@@ -43,22 +43,20 @@ public class SysCustomerDataFollowOrderService {
         resultData.setStatus2Count(0);
         resultData.setTotalCount(0);
         resultData.setDateList(Lists.newArrayList());
-        // 筛选条件数据
-        resultData.setSelectData(sysCustomerDataFollowService.queryCustomerOrderSelectData(0, true));
-//        String monthStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
+
+
         String dateStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
         if (StrUtil.isNotEmpty(dto.getDatetime())) {
             dateStr = dto.getDatetime().trim();
-//            monthStr = dto.getDatetime().trim();
         }
-        //处理月份
-//        if(monthStr.length() == 7){
-//            monthStr = monthStr +"-01";
-//        }
         //当月开始时间
         DateTime startMonthDay = DateUtil.beginOfMonth(DateUtil.parse(dateStr));
 //        //当月结束时间
         DateTime endMonthDay = DateUtil.endOfMonth(DateUtil.parse(dateStr));
+        // 筛选条件数据
+        resultData.setSelectData(sysCustomerDataFollowService.queryCustomerOrderSelectData(0, true,startMonthDay,endMonthDay));
+
+
 
         //如果是 yyyy-MM 格式,则需要重新设置为当月开始时间和结束时间
         DateTime startDateTime = DateUtil.beginOfDay(DateUtil.parseDate(dateStr));

+ 6 - 1
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowService.java

@@ -5,6 +5,8 @@ import cc.uncarbon.framework.core.context.UserContextHolder;
 import cc.uncarbon.framework.core.page.PageResult;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.text.CharSequenceUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -192,7 +194,8 @@ public class SysCustomerDataFollowService {
      *
      * @return
      */
-    public SysCustomerFollowHistorySelectBO queryCustomerOrderSelectData(Integer orderType, Boolean orderStatus) {
+    public SysCustomerFollowHistorySelectBO queryCustomerOrderSelectData(Integer orderType, Boolean orderStatus,
+                                                                         DateTime startDateTime, DateTime endDateTime) {
         SysCustomerFollowHistorySelectBO resultData = SysCustomerFollowHistorySelectBO.builder().build();
         List<BindUserBO> memberData = Lists.newArrayList();
         List<OrderBO> orderStatusData = Lists.newArrayList();
@@ -207,6 +210,8 @@ public class SysCustomerDataFollowService {
                                 )
                                 .eq(SysCustomerFollowEntity::getOrderType, orderType)
                                 .eq(SysCustomerFollowEntity::getFollowId,33) //只查询方案演示
+                                .ge(startDateTime != null, SysCustomerFollowEntity::getOrderDatetime, DateUtil.toLocalDateTime(startDateTime))
+                                .le(endDateTime != null, SysCustomerFollowEntity::getOrderDatetime, DateUtil.toLocalDateTime(endDateTime))
                                 .orderByDesc(SysCustomerFollowEntity::getCreatedAt)
                 );
         if (CollUtil.isNotEmpty(followEntityList)) {

+ 9 - 21
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowTodoService.java

@@ -38,19 +38,21 @@ public class SysCustomerDataFollowTodoService {
     public SysCustomerFollowTodoDataBO queryOrderFollowData(AdminSysCustomerFollowTodoDTO dto) {
         SysCustomerFollowTodoDataBO resultData = SysCustomerFollowTodoDataBO.builder().build();
 
-        // 筛选条件数据
-        resultData.setMemberData(Lists.newArrayList());
-        if (UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            resultData.setMemberData(sysCustomerTodoService.queryMemberData());
-        } else {
-            dto.setUserId(UserContextHolder.getUserContext().getUserId());
-        }
         String dateStr;
         if (StrUtil.isEmpty(dto.getDatetime())) {
             dateStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
         } else {
             dateStr = dto.getDatetime().trim() + "-01";//当月第一天时间
         }
+
+        // 筛选条件数据
+        resultData.setMemberData(Lists.newArrayList());
+        if (UserContextHolder.getUserContext().getRoles().contains("Admin")) {
+            resultData.setMemberData(sysCustomerTodoService.queryMemberData(dateStr));
+        } else {
+            dto.setUserId(UserContextHolder.getUserContext().getUserId());
+        }
+
         //每天的待办数据
         List<SysCustomerFollowTodoDetailBO> dataList = Lists.newArrayList();
         //当月开始时间
@@ -89,18 +91,4 @@ public class SysCustomerDataFollowTodoService {
         resultData.setDataList(dataList);
         return resultData;
     }
-
-    public static void main(String[] args) {
-
-        DateTime startMonthDay = DateUtil.beginOfMonth(DateUtil.parse("2026-08-01"));
-        //当月结束时间
-        DateTime endMonthDay = DateUtil.endOfMonth(DateUtil.parse("2026-08-01"));
-
-        List<DateTime> dateTimes = DateUtil.rangeToList(startMonthDay, endMonthDay, DateField.DAY_OF_MONTH);
-        dateTimes.forEach(e -> {
-            System.out.println(DateUtil.format(e, "yyyy-MM-dd"));
-            System.out.println(DateUtil.dayOfMonth(e));
-        });
-    }
-
 }

+ 20 - 13
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerTodoService.java

@@ -5,6 +5,8 @@ import cc.uncarbon.framework.core.exception.BusinessException;
 import cc.uncarbon.framework.crud.entity.HelioBaseEntity;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.common.collect.Lists;
 import com.jtzx.crm.module.sys.entity.SysCustomerTodoEntity;
@@ -46,7 +48,10 @@ public class SysCustomerTodoService {
      *
      * @return
      */
-    public List<BindUserBO> queryMemberData() {
+    public List<BindUserBO> queryMemberData(String dateStr) {
+
+        DateTime startDateTime = DateUtil.beginOfMonth(DateUtil.parse(dateStr));
+        DateTime endDateTime = DateUtil.endOfMonth(DateUtil.parse(dateStr));
         List<SysCustomerTodoEntity> todoEntityList =
                 sysCustomerTodoMapper.selectList(
                         new LambdaQueryWrapper<>(SysCustomerTodoEntity.class)
@@ -55,24 +60,26 @@ public class SysCustomerTodoService {
                                         SysCustomerTodoEntity::getClaimUserName
                                 )
                                 .eq(SysCustomerTodoEntity::getOrderStatus, 0)
+                                .ge(SysCustomerTodoEntity::getOrderDatetime, DateUtil.toLocalDateTime(startDateTime))
+                                .le(SysCustomerTodoEntity::getOrderDatetime, DateUtil.toLocalDateTime(endDateTime))
                                 .orderByDesc(HelioBaseEntity::getCreatedAt)
                 );
         List<BindUserBO> ret = Lists.newArrayList();
-        SysCustomerFollowHistorySelectBO sysCustomerFollowHistorySelectBO = sysCustomerDataFollowService.queryCustomerOrderSelectData(1, false);
+        SysCustomerFollowHistorySelectBO sysCustomerFollowHistorySelectBO = sysCustomerDataFollowService.queryCustomerOrderSelectData(1, false, startDateTime, endDateTime);
         if (sysCustomerFollowHistorySelectBO != null && CollUtil.isNotEmpty(sysCustomerFollowHistorySelectBO.getMemberData())) {
             ret.addAll(sysCustomerFollowHistorySelectBO.getMemberData());
-            if (CollUtil.isNotEmpty(todoEntityList)) {
-                todoEntityList.forEach(
-                        entity -> {
-                            if (CollUtil.isEmpty(ret) || ret.stream().noneMatch(bo -> bo.getId().equals(entity.getClaimUserId()))) {
-                                BindUserBO bo = new BindUserBO();
-                                bo.setId(entity.getClaimUserId());
-                                bo.setUsername(entity.getClaimUserName());
-                                ret.add(bo);
-                            }
+        }
+        if (CollUtil.isNotEmpty(todoEntityList)) {
+            todoEntityList.forEach(
+                    entity -> {
+                        if (CollUtil.isEmpty(ret) || ret.stream().noneMatch(bo -> bo.getId().equals(entity.getClaimUserId()))) {
+                            BindUserBO bo = new BindUserBO();
+                            bo.setId(entity.getClaimUserId());
+                            bo.setUsername(entity.getClaimUserName());
+                            ret.add(bo);
                         }
-                );
-            }
+                    }
+            );
         }
         return ret;
     }