From d94776ba25ffcd19cdd7970048ed88d9212bd394 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期六, 08 二月 2025 10:10:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java | 87 +++++++++++++++++++++++++++++++------------ 1 files changed, 63 insertions(+), 24 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java index eb3323e..37bcda1 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java @@ -129,35 +129,52 @@ if(2 == sysUser.getRoleType()){ shopId = sysUser.getObjectId(); } - List<Long> appUserIds = new ArrayList<>(); //搜索条件,用户姓名和电话 if(StringUtils.isNotEmpty(refundPassListVo.getUserName()) || StringUtils.isNotEmpty(refundPassListVo.getPhone())){ - List<AppUser> data = appUserClient.getAppUserByName(refundPassListVo.getUserName()).getData(); - List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); - if (collect.isEmpty()){ - appUserIds.add(-1L); - } - appUserIds.addAll(collect); - - List<AppUser> data2 = appUserClient.getAppUserByPhone(refundPassListVo.getPhone()).getData(); - List<Long> collect2 = data2.stream().map(AppUser::getId).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(data)){ - for (AppUser datum : data) { - for (AppUser appUser : data2) { - if (!datum.getId().equals(appUser.getId())){ - collect2.remove(appUser.getId()); - } - } - } - } - if (collect2.isEmpty()){ - appUserIds.add(-1L); - } - appUserIds.addAll(collect2); } + //搜索条件,用户姓名 + if(StringUtils.isNotEmpty(refundPassListVo.getName())){ + List<AppUser> data = appUserClient.getAppUserByNameNoFilter(refundPassListVo.getName()).getData(); + List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect)){ + return new PageInfo<>(); + } + if(null != refundPassListVo.getAppUserIds()){ + List<Long> appUserIds = refundPassListVo.getAppUserIds(); + appUserIds.addAll(collect); + refundPassListVo.setAppUserIds(appUserIds); + }else{ + refundPassListVo.setAppUserIds(collect); + } + } + //搜索条件,用户电话 + if(StringUtils.isNotEmpty(refundPassListVo.getPhone())){ + List<AppUser> data = appUserClient.getAppUserByPhoneNoFilter(refundPassListVo.getPhone()).getData(); + List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect)){ + return new PageInfo<>(); + } + + if(null != refundPassListVo.getAppUserIds()){ + List<Long> appUserIds = refundPassListVo.getAppUserIds(); + if (!containsAny(appUserIds,collect)) { + return new PageInfo<>(); + } + appUserIds.addAll(collect); + refundPassListVo.setAppUserIds(appUserIds); + }else{ + refundPassListVo.setAppUserIds(collect); + } + } + if (null != refundPassListVo.getAppUserIds()){ + refundPassListVo.setAppUserIds(refundPassListVo.getAppUserIds().stream().distinct().collect(Collectors.toList())); + } + + + PageInfo<OrderRefundPassList> pageInfo = new PageInfo(refundPassListVo.getPageCurr(), refundPassListVo.getPageSize()); - List<OrderRefundPassList> orderRefundPassList = this.baseMapper.getOrderRefundPassList(pageInfo, refundPassListVo.getCode(), appUserIds, shopId, refundPassListVo.getRefundMethod(), refundPassListVo.getStatus()); + List<OrderRefundPassList> orderRefundPassList = this.baseMapper.getOrderRefundPassList(pageInfo, refundPassListVo.getCode(), refundPassListVo.getAppUserIds(), shopId, refundPassListVo.getRefundMethod(), refundPassListVo.getStatus()); for (OrderRefundPassList refundPassList : orderRefundPassList) { AppUser appUser = appUserClient.getAppUserById(refundPassList.getAppUserId()); if(null != appUser){ @@ -168,6 +185,28 @@ return pageInfo.setRecords(orderRefundPassList); } + /** + * 判断 list1 是否包含 list2 中的至少一个元素 + * + * @param list1 第一个列表 + * @param list2 第二个列表 + * @return 如果 list1 包含 list2 中的至少一个元素,返回 true;否则返回 false + */ + private boolean containsAny(List<Long> list1, List<Long> list2) { + // 将 list1 转换为 HashSet 以提高查询效率 + Set<Long> set1 = new HashSet<>(list1); + + // 遍历 list2,检查是否有元素存在于 set1 中 + for (Long element : list2) { + if (set1.contains(element)) { + return true; + } + } + + // 如果没有找到共同元素,返回 false + return false; + } + // public void processAppUserIds(List<Long> appUserIds , String searchKey, Function<String, R<List<AppUser>>> userSearchFunction){ // if (StringUtils.isNotEmpty(searchKey)) { // List<Long> userIds = Optional.ofNullable(userSearchFunction.apply(searchKey).getData()) -- Gitblit v1.7.1