From 7ae08d4d53e79bc95baabc22c4206623591c70ca Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 20 六月 2024 15:11:16 +0800
Subject: [PATCH] 提交一把
---
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java | 305 +++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 272 insertions(+), 33 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
index 4a5ac91..1b8848e 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -17,6 +17,7 @@
import com.doumee.dao.business.dto.*;
import com.doumee.dao.business.join.*;
import com.doumee.dao.business.model.*;
+import com.doumee.dao.business.vo.ChangeDealTypeVO;
import com.doumee.dao.business.vo.CountCyclePriceVO;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.ApplyChangeService;
@@ -24,12 +25,14 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.doumee.service.business.InsuranceApplyService;
import com.doumee.service.business.SmsEmailService;
import com.doumee.service.business.third.SignService;
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
+import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -348,7 +351,6 @@
info = info.replace("${param}",param.getCheckInfo());
ApplyLog log = new ApplyLog(update,applyLogType.getName(), info,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
applyLogMapper.insert(log);
-
return 1;
}
@@ -577,7 +579,182 @@
// throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌鏂规鏈�鏂扮増鏈俊鎭�");
// }
// }
- for (ApplyChagneDetail detail : detailList) {
+ List<ApplyChagneDetail> addList = detailList.stream().filter(f->Constants.equalsInteger(f.getType(),Constants.ZERO)).collect(Collectors.toList());
+ List<ApplyChagneDetail> reduceList = detailList.stream().filter(f->Constants.equalsInteger(f.getType(),Constants.ONE)).collect(Collectors.toList());
+ //鍑忎繚涓氬姟
+ for (ApplyChagneDetail detail:reduceList) {
+ Member member = memberMapper.selectById(detail.getMemberId());
+ if(Objects.isNull(member)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍛樺伐鏁版嵁");
+ }
+ //鍑忎繚鎿嶄綔
+ //鏌ヨ鍛樺伐鏄湪涓诲崟涓� 鏄惁瀛樺湪鐢熸晥涓殑鏁版嵁
+ ApplyDetail oldModel = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda()
+ .eq(ApplyDetail::getApplyId, update.getApplyId())
+ .eq(ApplyDetail::getMemberId, detail.getMemberId())
+ .orderByDesc(ApplyDetail::getCreateDate)
+ .last("limit 1"));
+ if (oldModel == null || oldModel.getStartTime() == null || oldModel.getStartTime().getTime() > update.getApplyStartTime().getTime()) {
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝鐢ㄦ埛銆�" + detail.getMemberName() + "銆戝師淇濆崟淇℃伅鏈夎锛屽綋鍓嶇敵璇蜂笉鏀寔鍑忎繚澶勭悊锛�");
+ }
+ if(!(oldModel.getStartTime().getTime()<update.getDelValidTime().getTime()&& oldModel.getEndTime().getTime()>=update.getDelValidTime().getTime())){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝鐢ㄦ埛銆�" + detail.getMemberName() + "銆戝噺淇濇棩鏈熸湭鍦ㄤ繚鍗曡褰曟棩鏈熶腑锛�");
+ }
+
+ Date delValidTime = oldModel.getStartTime().compareTo(update.getDelValidTime())!=0?
+ DateUtil.getMontageDate(update.getDelValidTime(), 3):
+ DateUtil.getMontageDate(update.getDelValidTime(), 2);
+
+ BigDecimal sumFee = Objects.isNull(insuranceApply.getServerCost())?
+ solutions.getPrice():
+ solutions.getPrice().add(insuranceApply.getServerCost());
+ // 鍑忎繚鍚� 鎬昏垂鐢�
+ BigDecimal updateFee = Constants.reduceFee(
+ solutions,
+ sumFee
+ ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),oldModel.getStartTime(),delValidTime
+ ) ;
+ //褰撳鎵规椂闂� 澶т簬 鐢宠鐨勬椂闂存椂 璁$畻瀹為檯鍑忓皯閲戦 鍥犱负宸叉墸閲戦浼氬ぇ浜� 搴旀墸閲戦
+ BigDecimal updateCurrentFee = BigDecimal.ZERO;
+ if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2),oldModel.getStartTime()) > 0) {
+ //// 2024骞�5鏈�8鏃�17:37:23 淇敼 璁$畻浜х敓璐圭敤
+ updateCurrentFee = Constants.produceFee(solutions,sumFee,insuranceApply.getStartTime(),insuranceApply.getEndTime(),
+ oldModel.getStartTime()
+ );
+ }
+
+ UpdateWrapper<ApplyDetail> updateWrapper = new UpdateWrapper<ApplyDetail>();
+ updateWrapper.lambda()
+ .setSql(" fee = " + updateFee)
+ .setSql(" current_fee = " + updateCurrentFee)
+ .set(ApplyDetail::getEndTime, delValidTime)
+ .set(ApplyDetail::getEditor, update.getEditor())
+ .set(ApplyDetail::getEditDate, update.getEditDate())
+ .eq(ApplyDetail::getId, oldModel.getId());
+
+ if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
+ && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){
+ if(delValidTime.getTime()<=oldModel.getStartTime().getTime()){
+ updateFee = BigDecimal.ZERO;
+ updateWrapper.lambda().set(ApplyDetail::getFee,updateFee)
+ .set(ApplyDetail::getChangeStatus,Constants.TWO);
+ }else{
+ //鏍囪鏁版嵁宸茶鏇挎崲
+ updateWrapper.lambda().set(ApplyDetail::getReduceMoney,solutions.getPrice().multiply(new BigDecimal(-1)))
+ .set(ApplyDetail::getChangeStatus,Constants.ONE);
+ }
+ detail.setApplyDetailId(oldModel.getId());
+ }
+
+
+ applyDetailJoinMapper.update(null, updateWrapper);
+ totalFee = totalFee.add(updateFee).subtract(oldModel.getFee());
+ currentFee = currentFee.add(updateCurrentFee);
+
+ //淇敼 鍛樺伐鎶曚繚鏄庣粏璁板綍 鍘嗗彶鏁版嵁
+ memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda()
+ .setSql(" fee = " + updateFee)
+ .set(MemberInsurance::getEndTime, delValidTime)
+ .eq(MemberInsurance::getRelationId, oldModel.getId())
+ );
+
+ //淇敼涓氬姟鏄庣粏琛屾暟鎹疄闄呮壒鍗曟棩鏈�
+ applyChangeDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
+ .set(ApplyChagneDetail::getFee,updateFee.subtract(oldModel.getFee()))
+ .set( ApplyChagneDetail::getEndTime, delValidTime)
+ .eq(ApplyChagneDetail::getId,detail.getId())
+ );
+
+ member.setApplyId(update.getApplyId());
+ member.setDuId(detail.getDuId());
+ member.setWorktypeId(detail.getWorktypeId());
+ member.setStartTime(detail.getStartTime());
+ member.setEndTime(detail.getEndTime());
+ memberMapper.updateById(member);
+ }
+
+ //鍔犱繚涓氬姟
+ for (int i = 0; i < addList.size(); i++) {
+ ApplyChagneDetail detail = addList.get(i);
+ Member member = memberMapper.selectById(detail.getMemberId());
+ if (Objects.isNull(member)) {
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鏈煡璇㈠埌鍛樺伐鏁版嵁");
+ }
+ //鏌ヨ浜哄憳淇℃伅鏄惁瀛樺湪鐩稿悓鐨勬柟妗堜笅鏄惁瀛樺湪 鍐茬獊鏁版嵁
+ InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(),
+ member.getIdcardNo(),member.getName(),detail.getStartTime(),detail.getEndTime(),
+ applyDetailJoinMapper);
+
+ //鏌ヨ鍔犱繚浜哄憳鏄惁瀛樺湪 鍐茬獊鐨� 淇濆崟鏄庣粏鏁版嵁
+ if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>()
+ .lambda()
+ .eq(ApplyDetail::getApplyId,update.getApplyId())
+ .eq(ApplyDetail::getIdcardNo,detail.getIdcardNo())
+ .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(update.getApplyStartTime(),1))
+ .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(detail.getEndTime(),2))
+ )>Constants.ZERO){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "褰撳墠淇濆崟涓嬶紝鍔犱繚浜哄憳銆�" + detail.getMemberName() + "銆戝瓨鍦ㄦ棩鏈熷啿绐佺殑鏁版嵁");
+ }
+ //鍔犱繚
+ ApplyDetail add = new ApplyDetail();
+ add.setApplyId(update.getApplyId());
+ add.setValidCode(update.getValidCode());
+ add.setFee(detail.getFee());
+ add.setIsdeleted(Constants.ZERO);
+ add.setCreator(update.getEditor());
+ add.setCreateDate(update.getEditDate());
+ add.setMemberId(detail.getMemberId());
+ add.setMemberName(detail.getMemberName());
+ add.setWorktypeId(detail.getWorktypeId());
+ add.setIsdeleted(Constants.ZERO);
+ add.setIdcardNo(detail.getIdcardNo());
+ add.setSex(Constants.getSexByIdCard(detail.getIdcardNo()));
+ add.setMemberName(detail.getMemberName());
+ add.setRemark(detail.getRemark());
+ add.setDuId(detail.getDuId());
+ add.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
+ add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
+ add.setFee(Constants.addFee(solutions,solutions.getPrice(),insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),update.getApplyStartTime(),insuranceApply.getEndTime()));
+ add.setChangeStatus(Constants.ZERO);
+ if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
+ && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){
+ add.setReduceId(reduceList.get(i).getId());
+ }
+ if(new Date().compareTo(DateUtil.getMontageDate(detail.getStartTime(), 2))>=0){
+ //2024骞�5鏈�8鏃�17:37:23 淇敼 璁$畻浜х敓璐圭敤
+ add.setCurrentFee(
+ Constants.produceFee(solutions,add.getFee(),add.getStartTime(),add.getEndTime(),add.getStartTime())
+ );
+ }else{
+ add.setCurrentFee(BigDecimal.ZERO);
+ }
+ applyDetailJoinMapper.insert(add);
+ totalFee = totalFee.add(add.getFee());
+ currentFee = currentFee.add(add.getCurrentFee());
+
+ MemberInsurance memberInsurance = new MemberInsurance(detail, update, update.getEditor(), add.getId(),solutions.getId());
+ memberInsurance.setStartTime(add.getStartTime());
+ memberInsurance.setEndTime(add.getEndTime());
+ memberInsurance.setRelationType(Constants.ONE);
+ memberInsuranceList.add(memberInsurance);
+
+ applyChangeDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
+ .set(ApplyChagneDetail::getFee,add.getFee())
+ .set(ApplyChagneDetail::getStartTime,DateUtil.getMontageDate(update.getApplyStartTime(), 1))
+ .eq(ApplyChagneDetail::getId,detail.getId())
+ );
+
+ member.setApplyId(update.getApplyId());
+ member.setDuId(detail.getDuId());
+ member.setWorktypeId(detail.getWorktypeId());
+ member.setStartTime(detail.getStartTime());
+ member.setEndTime(detail.getEndTime());
+ memberMapper.updateById(member);
+ }
+
+
+
+ /*for (ApplyChagneDetail detail : detailList) {
Member member = memberMapper.selectById(detail.getMemberId());
if(Objects.isNull(member)){
throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍛樺伐鏁版嵁");
@@ -638,9 +815,6 @@
.eq(ApplyChagneDetail::getId,detail.getId())
);
-// if(1==1){
-// throw new BusinessException(ResponseStatus.SERVER_ERROR);
-// }
} else {
//鍑忎繚鎿嶄綔
@@ -679,14 +853,30 @@
);
}
- applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
+ UpdateWrapper<ApplyDetail> updateWrapper = new UpdateWrapper<ApplyDetail>();
+ updateWrapper.lambda()
.setSql(" fee = " + updateFee)
.setSql(" current_fee = " + updateCurrentFee)
.set(ApplyDetail::getEndTime, delValidTime)
.set(ApplyDetail::getEditor, update.getEditor())
.set(ApplyDetail::getEditDate, update.getEditDate())
- .eq(ApplyDetail::getId, oldModel.getId())
- );
+ .eq(ApplyDetail::getId, oldModel.getId());
+
+ if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
+ && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){
+ if(delValidTime.getTime()<=oldModel.getStartTime().getTime()){
+ updateFee = BigDecimal.ZERO;
+ updateWrapper.lambda().set(ApplyDetail::getFee,updateFee)
+ .set(ApplyDetail::getChangeStatus,Constants.TWO);
+ }else{
+ //鏍囪鏁版嵁宸茶鏇挎崲
+ updateWrapper.lambda().set(ApplyDetail::getReduceMoney,solutions.getPrice().multiply(new BigDecimal(-1)))
+ .set(ApplyDetail::getChangeStatus,Constants.ONE);
+ }
+ }
+
+
+ applyDetailJoinMapper.update(null, updateWrapper);
totalFee = totalFee.add(updateFee).subtract(oldModel.getFee());
currentFee = currentFee.add(updateCurrentFee);
@@ -703,12 +893,6 @@
.set( ApplyChagneDetail::getEndTime, delValidTime)
.eq(ApplyChagneDetail::getId,detail.getId())
);
-
-// if(1==1){
-// throw new BusinessException(ResponseStatus.SERVER_ERROR);
-// }
-
-
}
member.setApplyId(update.getApplyId());
@@ -718,7 +902,8 @@
member.setEndTime(detail.getEndTime());
memberMapper.updateById(member);
- }
+ }*/
+
if (memberInsuranceList != null && memberInsuranceList.size() > 0) {
memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
}
@@ -915,6 +1100,12 @@
}else{
applyChange.setDelValidTime(applyChange.getValidTime());
}
+ //浠呮敮鎸佹浛鎹� 淇濊瘉鍔犲噺淇濇棩鏈熶负鍚屼竴澶�
+ if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){
+ applyChange.setApplyStartTime(
+ applyChange.getDelValidTime()
+ );
+ }
}else{
applyChange.setApplyStartTime(applyChange.getValidTime());
}
@@ -1014,9 +1205,35 @@
)>Constants.ZERO){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀛樺湪杩涜涓殑鍔犲噺淇�/鎹㈠巶鐢宠");
};
+
+ if(applyChange.getType().equals(Constants.ZERO)){
+ if(Objects.nonNull(solutions.getAddValidDays())){
+ applyChange.setApplyStartTime(
+ DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays())
+ );
+ }else{
+ applyChange.setApplyStartTime(applyChange.getValidTime());
+ }
+ if(Objects.nonNull(solutions.getDelValidDays())){
+ applyChange.setDelValidTime(
+ DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays())
+ );
+ }else{
+ applyChange.setDelValidTime(applyChange.getValidTime());
+ }
+ //浠呮敮鎸佹浛鎹� 淇濊瘉鍔犲噺淇濇棩鏈熶负鍚屼竴澶�
+ if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){
+ applyChange.setApplyStartTime(
+ applyChange.getDelValidTime()
+ );
+ }
+
+ }else{
+ applyChange.setApplyStartTime(applyChange.getValidTime());
+ }
+
applyChange.setEditDate(new Date());
applyChange.setEditor(loginUserInfo.getId());
- applyChange.setApplyStartTime(applyChange.getValidTime());
applyChange.setStatus(Constants.ZERO);
//鍒犻櫎鍘嗗彶鏁版嵁
applyChagneDetailJoinMapper.delete(new QueryWrapper<ApplyChagneDetail>().lambda().eq(ApplyChagneDetail::getApplyChangeId,applyChange.getId()));
@@ -1041,10 +1258,13 @@
}
- public BigDecimal dealApplyChangeData(ApplyChange applyChange,InsuranceApply insuranceApply,CompanySolution companySolution,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal fee){
- if(Objects.nonNull(solutions.getDelOnlyReplace())&& solutions.getDelOnlyReplace().equals(Constants.ONE)){
- if(applyChange.getDelDetailList().size() > applyChange.getAddDetailList().size()){
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ繚闄╂柟妗堜粎鏀寔鏇挎崲锛堝噺淇濅汉鏁颁笉寰楀ぇ浜庡姞淇濅汉鏁帮級");
+ public BigDecimal dealApplyChangeData(ApplyChange applyChange,InsuranceApply insuranceApply
+ ,CompanySolution companySolution,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal fee){
+ if(Constants.equalsInteger(applyChange.getType(),Constants.ZERO)){
+ if(Objects.nonNull(solutions.getDelOnlyReplace())&& solutions.getDelOnlyReplace().equals(Constants.ONE)){
+ if(applyChange.getDelDetailList().size() > applyChange.getAddDetailList().size()){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ繚闄╂柟妗堜粎鏀寔鏇挎崲锛堝噺淇濅汉鏁颁笉寰楀ぇ浜庡姞淇濅汉鏁帮級");
+ }
}
}
//鏌ヨ淇濋櫓鏂规涓嬬殑鎵�鏈夋淳閬e崟浣�
@@ -1073,7 +1293,9 @@
ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO = new ApplyChangeCyclePriceDTO();
applyChangeCyclePriceDTO.setApplyId(insuranceApply.getId());
-
+
+ //鍑忎繚鏁版嵁
+ List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList();
//鍔犱繚鏁版嵁
List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList();
@@ -1088,22 +1310,16 @@
throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝浜哄憳褰曞叆鏁版嵁瀛樺湪鐩稿悓鏁版嵁锛�");
}
- //鍔犱繚鏄庣粏鏁版嵁 璁$畻閲戦 鏍规嵁鎵瑰崟鏃堕棿 璁$畻
-// applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),1));
-// CountCyclePriceVO countCyclePriceVO = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
-// BigDecimal detailFee = countCyclePriceVO.getCyclePrice();
BigDecimal sumPrice = Objects.isNull(insuranceApply.getServerCost())?solutions.getPrice():solutions.getPrice().add(insuranceApply.getServerCost());
BigDecimal detailFee = Constants.addFee(solutions,
sumPrice
,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),
applyChange.getApplyStartTime(),insuranceApply.getEndTime());
- this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo,detailFee);
+ this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo,detailFee,delDetailList.size());
fee = addDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add);
}
- //鍑忎繚鏁版嵁
- List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList();
if (CollectionUtils.isNotEmpty(delDetailList)) {
//楠岃瘉鏄惁瀛樺湪閲嶅鏁版嵁
List<String> idcarNo = delDetailList.stream().map(m->m.getIdcardNo()).collect(Collectors.toList());
@@ -1117,6 +1333,7 @@
this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo, BigDecimal.ZERO,
DateUtil.getMontageDate(applyChange.getDelValidTime(),3));
fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
+// fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getReduceMoney).reduce(BigDecimal.ZERO,BigDecimal::add));
}
@@ -1176,7 +1393,7 @@
.lambda()
.eq(ApplyDetail::getApplyId,applyChange.getApplyId())
.eq(ApplyDetail::getIdcardNo,applyChagneDetail.getIdcardNo())
- .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),1))
+// .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),1))
.ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),3))
)<=Constants.ZERO){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "褰撳墠淇濆崟涓嬶紝鍑忎繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戞湭鏌ヨ鍒扮鍚堟壒鍗曟棩鏈熺殑鏁版嵁");
@@ -1200,7 +1417,7 @@
List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda()
.eq(ApplyDetail::getApplyId, applyChange.getApplyId())
.eq(ApplyDetail::getMemberId, applyChagneDetail.getMemberId())
- .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),1))
+// .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),1))
.ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),3))
.orderByDesc(ApplyDetail::getCreateDate));
if (applyDetailList.size() > Constants.ONE) {
@@ -1209,6 +1426,9 @@
ApplyDetail applyDetail = applyDetailList.get(Constants.ZERO);
if (applyChange.getValidTime().compareTo(applyDetail.getEndTime()) > 0) {
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍑忎繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戜繚鍗曚繚闅滄棩鏈熻嚦锛氥��" + applyDetail.getEndTime() + "銆戞棤娉曢�氳繃鏈鐢宠");
+ }
+ if(!Constants.equalsInteger(applyDetail.getChangeStatus(),Constants.ZERO)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍑忎繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戜繚鍗曚俊鎭紓甯�,鏁版嵁宸茶鍑忎繚鏃犳硶鍐嶆鍑忎繚");
}
applyChagneDetail.setPrice(applyDetail.getPrice());
applyChagneDetail.setCreateDate(new Date());
@@ -1219,6 +1439,7 @@
applyChagneDetail.setApplyDetailId(applyDetail.getId());
applyChagneDetail.setStartTime(applyDetail.getStartTime());
applyChagneDetail.setEndTime(endTime);
+ applyChagneDetail.setReduceMoney(BigDecimal.ZERO);
member.setApplyId(insuranceApply.getId());
member.setDuId(applyChagneDetail.getDuId());
@@ -1229,6 +1450,7 @@
//鏌ヨ鍑忎繚鏃ユ湡
// Integer delDays = DateUtil.daysBetweenDates(applyDetail.getEndTime(),endTime);
// ;
+
//鏌ヨ鍛ㄦ湡鏁伴噺
applyChagneDetail.setFee(
Constants.reduceFee(solutions,
@@ -1239,6 +1461,11 @@
applyDetail.getStartTime(),endTime)
.subtract(applyDetail.getFee()
));
+ //濡傛灉鏄噺淇濅笟鍔′负浠呮浛鎹� 涓� 鏂规鐨勬墸璐瑰懆鏈熷拰鎬诲懆鏈熺浉绛� 鍒欏鐞嗗噺淇濊垂鐢�
+ if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
+ && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){
+ applyChagneDetail.setReduceMoney(solutions.getPrice().multiply(new BigDecimal(-1)));
+ }
applyChagneDetailJoinMapper.insert(applyChagneDetail);
}
}
@@ -1255,14 +1482,20 @@
*/
public void addChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> addDetailList,
List<DuWorktype> duWorktypeList,List<DuSolution> duSolutionList,
- InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal detailFee){
- for (ApplyChagneDetail applyChagneDetail : addDetailList) {
+ InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal detailFee,Integer delSize){
+ for (int i = 0; i < addDetailList.size(); i++) {
+ ApplyChagneDetail applyChagneDetail = addDetailList.get(i);
if ( Objects.isNull(applyChagneDetail.getDuId())
|| Objects.isNull(applyChagneDetail.getWorktypeId())
|| StringUtils.isBlank(applyChagneDetail.getIdcardNo())
) {
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍔犱繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戝繀濉」缂哄け");
}
+ //鏌ヨ浜哄憳淇℃伅鏄惁瀛樺湪鐩稿悓鐨勬柟妗堜笅鏄惁瀛樺湪 鍐茬獊鏁版嵁
+ InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(),
+ applyChagneDetail.getMemberIdcardNo(),applyChagneDetail.getMemberName(),insuranceApply.getStartTime(),insuranceApply.getEndTime(),
+ applyDetailJoinMapper);
+
//鏌ヨ鍔犱繚浜哄憳鏄惁瀛樺湪 鍐茬獊鐨� 淇濆崟鏄庣粏鏁版嵁
if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>()
.lambda()
@@ -1377,7 +1610,13 @@
throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "銆�" + applyChagneDetail.getMemberName() + "銆戝憳宸ュ伐绉嶄俊鎭湭鏌ヨ鍒帮紒");
}
applyChagneDetail.setMemberId(member.getId());
- applyChagneDetail.setFee(detailFee);
+ //濡傛灉鏄噺淇濅笟鍔′负浠呮浛鎹� 涓� 鏂规鐨勬墸璐瑰懆鏈熷拰鎬诲懆鏈熺浉绛� 鍒欏鐞嗗噺淇濊垂鐢�
+ if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
+ && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit()) && delSize> i){
+ applyChagneDetail.setFee(BigDecimal.ZERO);
+ }else{
+ applyChagneDetail.setFee(detailFee);
+ }
applyChagneDetailJoinMapper.insert(applyChagneDetail);
}
}
--
Gitblit v1.9.3