From 9dd5d877978595c27b044b795ea31bc0347438c9 Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期二, 09 四月 2024 19:06:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/1.0.1' into 1.0.1

---
 server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java |   52 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
index a2e652a..21bcaee 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
@@ -80,6 +80,8 @@
 
     @Autowired
     private MemberInsuranceJoinMapper memberInsuranceJoinMapper;
+    @Autowired
+    private MemberMapper memberMapper;
     @Value("${debug_model}")
     private boolean debugModel;
 
@@ -156,12 +158,19 @@
                 .selectAs(Solutions::getSpecialInfo,UnionApply::getSpecialInfo);
         queryWrapper.select("(select count(b.id) from apply_detail b where b.isdeleted=0 and b.union_apply_id=t.id) as insureNum ");
 
-        queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id=t.id " +
-                "and b.status = "+Constants.InsuranceApplyStatus.WTB_TOUBAOING.getKey()+" and a.type = 0  ) as addApplyNum ");
+        if(pageWrap.getModel().getQueryFlag() == 1){
+            queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id=t.id " +
+                    "and a.status = "+Constants.ApplyChangeStatus.CHECHED_PASSED.getKey()+" and a.type = 0  ) as addApplyNum ");
+        }else  if(pageWrap.getModel().getQueryFlag() ==2){
+            queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id=t.id " +
+                    "and a.status = "+Constants.ApplyChangeStatus.CHECHED_PASSED.getKey()+" and a.type = 1  ) as changeApplyNum ");
+        }else{
+            queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id=t.id " +
+                    "and b.status = "+Constants.InsuranceApplyStatus.WTB_TOUBAOING.getKey()+" and a.type = 0  ) as addApplyNum ");
 
-        queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id=t.id " +
-                "and b.status = "+Constants.InsuranceApplyStatus.WTB_TOUBAOING.getKey()+" and a.type = 1  ) as changeApplyNum ");
-
+            queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id=t.id " +
+                    "and b.status = "+Constants.InsuranceApplyStatus.WTB_TOUBAOING.getKey()+" and a.type = 1  ) as changeApplyNum ");
+        }
         queryWrapper.leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId);
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         if(Constants.equalsInteger(user.getType(),Constants.TWO)){
@@ -735,8 +744,20 @@
         List<UnionApplyBXDDetailDTO> unionApplyBXDDetailDTOList = unionApplyBXDDTO.getUnionApplyBXDDDetailDTOList();
 
         //鎵�鏈夋姇淇濈敵璇蜂繚鍗曟槑缁嗚
-        List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda()
-                .select(ApplyDetail::getId,ApplyDetail::getApplyId,ApplyDetail::getPrice)
+        List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class,new MPJLambdaWrapper<ApplyDetail>()
+                        .selectAll(ApplyDetail.class)
+                .selectAs(DispatchUnit::getName,ApplyDetail::getDuName)
+                .selectAs(InsuranceApply::getCode,ApplyDetail::getApplyCode)
+                .selectAs(Solutions::getId,ApplyDetail::getSolutionId)
+                .selectAs(Solutions::getName,ApplyDetail::getSolutionName)
+                .selectAs(Worktype::getName,ApplyDetail::getWorkTypeName)
+                .selectAs(Member::getIdcardNo,ApplyDetail::getIdcardNo)
+                .selectAs(Member::getName,ApplyDetail::getMemberName)
+                .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyDetail::getDuId)
+                .leftJoin(Worktype.class,Worktype::getId,ApplyDetail::getWorktypeId)
+                .leftJoin(Member.class,Member::getId,ApplyDetail::getMemberId)
+                .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId)
+                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                 .in(ApplyDetail::getUnionApplyId,unionApply.getId()));
         unionApplyBXDDTO.setEndTime(DateUtil.getMontageDate(unionApplyBXDDTO.getEndTime(),2));
         //鎬诲ぉ鏁�
@@ -764,9 +785,10 @@
 
             Optional<UnionApplyBXDDetailDTO> unionApplyBXDDDetailTO= unionApplyBXDDetailDTOList.stream().filter(
                     m->m.getApplyId().equals(insuranceApply.getId())).findFirst();
+            BigDecimal serverCost = BigDecimal.ZERO;
             if(unionApplyBXDDDetailTO.isPresent()){
                 UnionApplyBXDDetailDTO unionApplyBXDDetailDTO = unionApplyBXDDDetailTO.get();
-
+                serverCost = unionApplyBXDDetailDTO.getServerMoney();
                 BigDecimal dayServerMoney = unionApplyBXDDetailDTO.getServerMoney().divide(new BigDecimal(maxDays),2, RoundingMode.HALF_UP);
 
                 price = Constants.formatBigdecimal(price).add(Constants.formatBigdecimal(dayServerMoney));
@@ -801,9 +823,22 @@
                         .filter(m->Constants.equalsInteger(m.getApplyId(),(insuranceApply.getId()))).collect(Collectors.toList())) {
                     applyDetail.setPrice(price);
                     applyDetail.setFee(price.multiply(new BigDecimal(maxDays)));
+                    applyDetail.setStartTime(unionApplyBXDDTO.getStartTime());
+                    applyDetail.setEndTime(unionApplyBXDDTO.getEndTime());
                     MemberInsurance memberInsurance = new MemberInsurance(applyDetail,user.getId());
+                    memberInsurance.setBdCode(unionApplyBXDDTO.getCode());
                     memberInsurance.setRelationType(Constants.ZERO);
                     memberInsuranceList.add(memberInsurance);
+                    //鏇存柊鍛樺伐鎶曚繚鏃堕棿
+                    memberMapper.update(null,new UpdateWrapper<Member>()
+                            .lambda()
+                            .set(Member::getStartTime,memberInsurance.getStartTime())
+                            .set(Member::getEndTime,memberInsurance.getEndTime())
+                            .set(Member::getDuId,memberInsurance.getDuId())
+                            .set(Member::getWorktypeId,memberInsurance.getWorktypeId())
+                            .eq(Member::getId, memberInsurance.getMemberId())
+                    );
+
                 }
                 memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
             }
@@ -818,6 +853,7 @@
                     .set(InsuranceApply::getEndTime,unionApplyBXDDTO.getEndTime())
                     .set(InsuranceApply::getEditDate,new Date())
                     .set(InsuranceApply::getEditor,user.getId())
+                    .set(InsuranceApply::getServerCost,serverCost)
                     .set(InsuranceApply::getCode,unionApplyBXDDTO.getCode())
                     .eq(InsuranceApply::getId,insuranceApply.getId()));
             //鏇存柊鎶曚繚鍗曟槑缁嗛噾棰�

--
Gitblit v1.9.3