From eb1456da5058bbb08569da4fcae768c3e043cc39 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 17 五月 2024 12:00:07 +0800
Subject: [PATCH] 提交一把
---
server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java | 93 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 80 insertions(+), 13 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 895e124..6f0308e 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
@@ -32,6 +32,7 @@
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@@ -79,6 +80,8 @@
@Autowired
private MemberInsuranceJoinMapper memberInsuranceJoinMapper;
+ @Autowired
+ private MemberMapper memberMapper;
@Value("${debug_model}")
private boolean debugModel;
@@ -154,6 +157,20 @@
.selectAs(Solutions::getSpecialAgreement,UnionApply::getSpecialAgreement)
.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 ");
+
+ 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.leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId);
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
if(Constants.equalsInteger(user.getType(),Constants.TWO)){
@@ -370,7 +387,6 @@
}
}
}
-
}
@@ -433,13 +449,22 @@
Integer maxDays = DateUtil.calculateBetween(saveUnionApplyDTO.getStartDate(),saveUnionApplyDTO.getEndDate(),0);
- List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda().select(ApplyDetail::getId,ApplyDetail::getPrice)
+ List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda()
+ .select(ApplyDetail::getId,ApplyDetail::getPrice,ApplyDetail::getStartTime,ApplyDetail::getEndTime,ApplyDetail::getFee)
.in(ApplyDetail::getApplyId,saveUnionApplyDTO.getApplyIds())
.eq(ApplyDetail::getIsdeleted,Constants.ZERO));
if(applyDetailList.size()==0){
throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝瀛樺湪濮旀墭鎶曚繚鐢宠璁板綍淇℃伅鏈夎锛岃杩斿洖鏌ョ湅鐢宠浜哄憳鏄惁涓虹┖锛�");
}
- unionApply.setFee(applyDetailList.stream().map(i->Constants.formatBigdecimal(i.getPrice()).multiply(new BigDecimal(maxDays))).reduce(BigDecimal.ZERO,BigDecimal::add));
+ BigDecimal fee = BigDecimal.ZERO;
+ for (ApplyDetail applyDetail:applyDetailList) {
+ Integer oldDays = DateUtil.calculateBetween(applyDetail.getStartTime(),applyDetail.getEndTime(),0);
+ fee =fee.add(new BigDecimal(maxDays).multiply( applyDetail.getFee()).divide(new BigDecimal(oldDays),2,RoundingMode.HALF_UP));
+ }
+ unionApply.setFee(fee);
+
+// unionApply.setFee(applyDetailList.stream()
+// .map(i->Constants.formatBigdecimal(i.getPrice()).multiply(new BigDecimal(maxDays))).reduce(BigDecimal.ZERO,BigDecimal::add));
unionApplyMapper.insert(unionApply);
@@ -568,6 +593,10 @@
if(CollectionUtils.isNotEmpty(uploadMultifileDTO.getMultifileList())){
List<Multifile> multifileList = uploadMultifileDTO.getMultifileList();
for (Multifile multifile:multifileList) {
+ if(StringUtils.isBlank(multifile.getName())
+ || StringUtils.isBlank(multifile.getFileurl()) ){
+ continue;
+ }
if(Objects.isNull(multifile.getObjId())
||Objects.isNull(multifile.getName())
||Objects.isNull(multifile.getFileurl())){
@@ -618,6 +647,13 @@
multifile.setFileurl(uploadMultifileDTO.getFileurl());
multifile.setName(uploadMultifileDTO.getName());
multifileMapper.insert(multifile);
+
+
+ Constants.ApplyLogType applyLogType = Constants.ApplyLogType.IA_HBD_UPLOAD_TBD;
+ ApplyLog log = new ApplyLog(unionApply,applyLogType.getName(), null
+ ,unionApply.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionApply));
+ applyLogMapper.insert(log);
+
}
@@ -630,14 +666,14 @@
public String getSignLink(SmsCheckDTO smsCheckDTO) {
if(Objects.isNull(smsCheckDTO)
|| Objects.isNull(smsCheckDTO.getBusinessId())
- || StringUtils.isBlank(smsCheckDTO.getCode())
+// || StringUtils.isBlank(smsCheckDTO.getCode())
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
//楠岃瘉 楠岃瘉鐮�
- if(!debugModel){
- smsEmailService.validateCode(smsCheckDTO.getCode());
- }
+// if(!debugModel){
+// smsEmailService.validateCode(smsCheckDTO.getCode());
+// }
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
if(!user.getType().equals(Constants.TWO)){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣滐紒");
@@ -720,9 +756,22 @@
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));
//鎬诲ぉ鏁�
Integer maxDays = DateUtil.calculateBetween(unionApplyBXDDTO.getStartTime(),unionApplyBXDDTO.getEndTime(),0);
//瀹為檯宸茬粡浜х敓璐圭敤鐨勫ぉ鏁�
@@ -746,12 +795,15 @@
}
BigDecimal price = Constants.formatBigdecimal(applyDetails.get(Constants.ZERO).getPrice());
-
Optional<UnionApplyBXDDetailDTO> unionApplyBXDDDetailTO= unionApplyBXDDetailDTOList.stream().filter(
m->m.getApplyId().equals(insuranceApply.getId())).findFirst();
+ BigDecimal serverCost = BigDecimal.ZERO;
if(unionApplyBXDDDetailTO.isPresent()){
UnionApplyBXDDetailDTO unionApplyBXDDetailDTO = unionApplyBXDDDetailTO.get();
- price = Constants.formatBigdecimal(price).add(Constants.formatBigdecimal(unionApplyBXDDetailDTO.getServerMoney()));
+ serverCost = unionApplyBXDDetailDTO.getServerMoney();
+ BigDecimal dayServerMoney = unionApplyBXDDetailDTO.getServerMoney().divide(new BigDecimal(maxDays),6, RoundingMode.HALF_UP);
+
+ price = Constants.formatBigdecimal(price).add(Constants.formatBigdecimal(dayServerMoney));
//涓婁紶淇濆崟淇℃伅
if(StringUtils.isNotBlank(unionApplyBXDDetailDTO.getFileUrl())){
Multifile multifile = new Multifile();
@@ -779,12 +831,26 @@
//鐢熸垚鎶曚繚璁板綍
if(CollectionUtils.isNotEmpty(applyDetailList)){
List<MemberInsurance> memberInsuranceList = new ArrayList<>();
- for (ApplyDetail applyDetail:applyDetailList) {
+ for (ApplyDetail applyDetail:applyDetailList.stream()
+ .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);
}
@@ -799,6 +865,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()));
//鏇存柊鎶曚繚鍗曟槑缁嗛噾棰�
@@ -842,7 +909,7 @@
multifileMapper.insert(multifile);
}
- Constants.ApplyLogType applyLogType = Constants.ApplyLogType.IA_HBD_UPLOAD_TBD;
+ Constants.ApplyLogType applyLogType = Constants.ApplyLogType.IA_HBD_UPLOAD_BXD;
String info = "";
if(Objects.nonNull(unionApplyBXDDTO.getStartTime())&&Objects.nonNull(unionApplyBXDDTO.getEndTime())){
info =applyLogType.getInfo();
--
Gitblit v1.9.3