From 520433f6d88c1f4c1a2d31ca950f2309da2d4a9a Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期二, 01 七月 2025 14:02:25 +0800
Subject: [PATCH] git ch

---
 server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java |   61 +++++++++++++++++++++++-------
 1 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
index acc8c9a..54105ea 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
@@ -229,27 +229,27 @@
         LoginUserInfo loginUserInfo =(LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         //浼佷笟浜哄憳鏌ョ湅鏈紒涓氭暟鎹�
         if(loginUserInfo.getType().equals(Constants.ONE)){
-            queryWrapper.eq(InsuranceApply::getCompanyId, loginUserInfo.getCompanyId())
-                    .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id  where a.member_id = t.id and b.company_id = "+loginUserInfo.getCompanyId()+"  and b.status in (" +
-                            " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " +
-                            " and  a.end_time >= now() ) ", Member::getValidNum )
-
-                    .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id  where a.member_id = t.id and b.company_id = "+loginUserInfo.getCompanyId()+"  and b.status in (" +
-                            " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " +
-                            " and a.end_time < now() ) ", Member::getInvalidNum );
+            queryWrapper.eq(InsuranceApply::getCompanyId, loginUserInfo.getCompanyId());
+//                    .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id  where a.member_id = t.id and b.company_id = "+loginUserInfo.getCompanyId()+"  and b.status in (" +
+//                            " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " +
+//                            " and  a.end_time >= now() ) ", Member::getValidNum )
+//
+//                    .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id  where a.member_id = t.id and b.company_id = "+loginUserInfo.getCompanyId()+"  and b.status in (" +
+//                            " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " +
+//                            " and a.end_time < now() ) ", Member::getInvalidNum );
         }else{
             if(loginUserInfo.getCompanyIdList()!=null && loginUserInfo.getCompanyIdList().size()>0){
                 queryWrapper.in(InsuranceApply::getCompanyId, loginUserInfo.getCompanyIdList());
             }else{
                 queryWrapper.eq(InsuranceApply::getCompanyId, -1);
             }
-            queryWrapper.eq(pageWrap.getModel().getCompanyId()!=null,InsuranceApply::getCompanyId, pageWrap.getModel().getCompanyId())
-                    .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id  where a.member_id = t.id and b.status in (" +
-                            " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " +
-                            " and  a.end_time >= now() ) ", Member::getValidNum )
-                    .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id  where a.member_id = t.id and b.status in (" +
-                            " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " +
-                            " and a.end_time < now() ) ", Member::getInvalidNum );
+            queryWrapper.eq(pageWrap.getModel().getCompanyId()!=null,InsuranceApply::getCompanyId, pageWrap.getModel().getCompanyId());
+//                    .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id  where a.member_id = t.id and b.status in (" +
+//                            " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " +
+//                            " and  a.end_time >= now() ) ", Member::getValidNum )
+//                    .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id  where a.member_id = t.id and b.status in (" +
+//                            " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " +
+//                            " and a.end_time < now() ) ", Member::getInvalidNum );
         }
         queryWrapper.selectAll(Member.class)
                 .and(StringUtils.isNotBlank(memberQueryDTO.getKeywords()),
@@ -268,6 +268,7 @@
          queryWrapper.orderByAsc(Member::getName);
         PageData<Member> pageData = PageData.from(memberJoinMapper.selectJoinPage(page,Member.class, queryWrapper));
 
+        this.getValidNum(pageData,loginUserInfo);
         Integer sn = 0;
         for (Member member:pageData.getRecords()) {
             sn = sn + 1;
@@ -280,6 +281,36 @@
         return pageData;
     }
 
+    public void getValidNum(PageData<Member> pageData,LoginUserInfo loginUserInfo){
+        List<Integer> listId = pageData.getRecords().stream().map(i->i.getId()).collect(Collectors.toList());
+        if(CollectionUtils.isNotEmpty(listId)){
+            Integer companyId = null;
+            if(Objects.nonNull(loginUserInfo.getType())&&Constants.equalsInteger(loginUserInfo.getType(),Constants.ONE)){
+                companyId = loginUserInfo.getShowCompany().getId();
+            }
+            List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class,
+                    new MPJLambdaWrapper<ApplyDetail>()
+                            .select(ApplyDetail::getMemberId,ApplyDetail::getStartTime,ApplyDetail::getEndTime,ApplyDetail::getId)
+                            .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId)
+                            .in(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_DONE.getKey(),Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())
+                            .in(ApplyDetail::getMemberId,listId)
+                            .eq(Objects.nonNull(companyId)
+                                    ,InsuranceApply::getCompanyId,companyId)
+            );
+
+            if(CollectionUtils.isNotEmpty(applyDetailList)){
+                for (Member member:pageData.getRecords()) {
+                    member.setInvalidNum(applyDetailList.stream().filter(i->Constants.equalsInteger(i.getMemberId(),member.getId())&&i.getEndTime().getTime()<System.currentTimeMillis()).collect(Collectors.toList()).size());
+                    member.setValidNum(
+                            applyDetailList.stream().filter(i->Constants.equalsInteger(i.getMemberId(),member.getId())&&i.getEndTime().getTime()>=System.currentTimeMillis()).collect(Collectors.toList()).size()
+                    );
+                }
+            }
+        }
+    }
+
+
+
     @Override
     public long count(Member member) {
         QueryWrapper<Member> wrapper = new QueryWrapper<>(member);

--
Gitblit v1.9.3