From 4be10170bc9a1546537762e03f2c963d61d2f6ea Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 22 二月 2024 09:16:24 +0800
Subject: [PATCH] mrshi
---
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java | 192 ++++++++++++++++++++++++++++++-----------------
1 files changed, 122 insertions(+), 70 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 e2cfd75..8aba30d 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
@@ -171,6 +171,7 @@
update.setStatus(Constants.ApplyChangeStatus.APPROVE.getKey());
update.setCheckDate(update.getEditDate());
update.setCheckInfo(param.getCheckInfo());
+ update.setApplyId(model.getApplyId());
update.setCheckUserId(user.getId());
update.setId(model.getId());
update.setValidCode(param.getValidCode());
@@ -194,6 +195,9 @@
dealDetailsDUdata(update);
}
+// if(1==1){
+// throw new BusinessException(ResponseStatus.DATA_EMPTY);
+// }
Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_PLATFORM_APPROVE;
String info = "";
@@ -344,6 +348,17 @@
MemberInsurance memberInsurance = new MemberInsurance(applyDetail,update.getId());
memberInsuranceJoinMapper.insert(memberInsurance);
+
+ Member member = memberMapper.selectById(detail.getMemberId());
+ if(Objects.isNull(member)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍛樺伐鏁版嵁");
+ }
+ member.setApplyId(update.getApplyId());
+ member.setDuId(detail.getDuId());
+ member.setWorktypeId(detail.getWorktypeId());
+ member.setStartTime(detail.getStartTime());
+ member.setEndTime(detail.getEndTime());
+ memberMapper.updateById(member);
}
}
/**
@@ -361,7 +376,6 @@
.leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId)
.leftJoin(InsuranceApply.class, InsuranceApply::getId, ApplyChange::getApplyId)
.leftJoin(Solutions.class, Solutions::getId, InsuranceApply::getSolutionId)
- .leftJoin(Solutions.class, Solutions::getId, ApplyChange::getSolutionsId)
.leftJoin(Worktype.class, Worktype::getId, ApplyChagneDetail::getWorktypeId)
.leftJoin(DispatchUnit.class, DispatchUnit::getId, ApplyChagneDetail::getDuId)
.eq(ApplyChagneDetail::getApplyChangeId, update.getId())
@@ -380,20 +394,17 @@
//鍔犱繚涓氬姟 浣跨敤鐨勫姞淇濋噾棰�
ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO_add = new ApplyChangeCyclePriceDTO();
applyChangeCyclePriceDTO_add.setApplyId(update.getApplyId());
- applyChangeCyclePriceDTO_add.setValidTime(DateUtil.getMontageDate(update.getStartTime(), 1));
+ applyChangeCyclePriceDTO_add.setValidTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
//鍔犱繚 娣诲姞鐨勯噾棰�
CountCyclePriceVO countCyclePriceVO_add = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_add);
- //鍑忎繚涓氬姟 浣跨敤鐨勫噺淇濋噾棰�
- ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO_reduce = new ApplyChangeCyclePriceDTO();
- applyChangeCyclePriceDTO_reduce.setApplyId(update.getApplyId());
- applyChangeCyclePriceDTO_reduce.setValidTime(DateUtil.getMontageDate(update.getStartTime(), 3));
- //鍑忎繚 闇�瑕佸噺灏戠殑閲戦
- CountCyclePriceVO countCyclePriceVO_reduce = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_reduce);
-
for (ApplyChagneDetail detail : detailList) {
+ Member member = memberMapper.selectById(detail.getMemberId());
+ if(Objects.isNull(member)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍛樺伐鏁版嵁");
+ }
if (Constants.equalsInteger(detail.getType(), Constants.ZERO)) {
//鍔犱繚
ApplyDetail add = new ApplyDetail();
@@ -409,26 +420,24 @@
add.setDuId(detail.getDuId());
add.setStartTime(update.getApplyStartTime());
add.setEndTime(detail.getEndTime());
- add.setFee(new BigDecimal(0));
-// add.setFee(Constants.countDetailFee(detail.getSolutionTimeUnit(),detail.getSolutionPrice(), add.getStartTime(),add.getEndTime()));
- if (DateUtil.daysBetweenDates(add.getStartTime(), new Date()) >= 0) {
- add.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
- add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
+ add.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
+ add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
+ add.setFee(countCyclePriceVO_add.getCyclePrice());
- add.setFee(countCyclePriceVO_add.getCyclePrice());
- if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(add.getStartTime(), 2), new Date()) >= 0) {
- Integer days = DateUtil.daysBetweenDates(new Date(), DateUtil.getMontageDate(add.getStartTime(), 2)) + 1;
- //濡傛灉宸蹭骇鐢熻垂鐢紝璁$畻宸蹭骇鐢熻垂鐢�
- add.setCurrentFee(this.getApplyPrice(update.getApplyId(), days));
- }
-// addList.add(add);
- applyDetailJoinMapper.insert(add);
- totalFee.add(add.getFee());
- currentFee.add(add.getCurrentFee());
+ if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(detail.getStartTime(), 2), new Date()) >= 0) {
+ Integer days = DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2), detail.getStartTime()) + 1;
+ //濡傛灉宸蹭骇鐢熻垂鐢紝璁$畻宸蹭骇鐢熻垂鐢�
+ add.setCurrentFee(this.getApplyPrice(update.getApplyId(), days));
+ }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());
- memberInsuranceList.add(memberInsurance);
- } else {
+ MemberInsurance memberInsurance = new MemberInsurance(detail, update, update.getEditor(), add.getId());
+ memberInsuranceList.add(memberInsurance);
+ } else {
//鍑忎繚鎿嶄綔
//鏌ヨ鍛樺伐鏄湪涓诲崟涓� 鏄惁瀛樺湪鐢熸晥涓殑鏁版嵁
ApplyDetail oldModel = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda()
@@ -439,32 +448,31 @@
if (oldModel == null || oldModel.getStartTime() == null || oldModel.getStartTime().getTime() > update.getApplyStartTime().getTime()) {
throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝鐢ㄦ埛銆�" + detail.getMemberName() + "銆戝師淇濆崟淇℃伅鏈夎锛屽綋鍓嶇敵璇蜂笉鏀寔鍑忎繚澶勭悊锛�");
}
- //閫�淇濋渶瑕侀��鍥炵殑璐圭敤
+ //鍑忎繚涓氬姟 浣跨敤鐨勫噺淇濋噾棰�
+ ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO_reduce = new ApplyChangeCyclePriceDTO();
+ applyChangeCyclePriceDTO_reduce.setApplyId(update.getApplyId());
+ applyChangeCyclePriceDTO_reduce.setValidTime(DateUtil.getMontageDate(update.getApplyStartTime(), 2));
+ //鍑忎繚 闇�瑕佸噺灏戠殑閲戦 鍗� 閫�淇濋渶瑕侀��鍥炵殑璐圭敤
+ CountCyclePriceVO countCyclePriceVO_reduce = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_reduce);
BigDecimal updateFee = countCyclePriceVO_reduce.getCyclePrice().multiply(new BigDecimal(-1));
- BigDecimal updateCurrentFee = oldModel.getFee().subtract(updateFee);
-
-// BigDecimal updateCurrentFee = new BigDecimal(0);
-// if(DateUtil.daysBetweenDates(update.getApplyStartTime(),new Date() )>0){
-// //濡傛灉鐢熸晥鏃堕棿 鏄粖澶╀箣鍓嶏紝閫�鍥炲凡浜х敓璐圭敤锛岃绠楀凡浜х敓璐圭敤(鎬昏垂鐢�-宸蹭骇鐢熻垂鐢�)
-// updateCurrentFee = updateFee.subtract(oldModel.getCurrentFee());
-// }
-
-// BigDecimal updateFee = (Constants.countDetailFee(detail.getSolutionTimeUnit(), detail.getSolutionPrice(), oldModel.getStartTime(), update.getApplyStartTime()));
-// BigDecimal updateCurrentFee = new BigDecimal(0);
- if (DateUtil.daysBetweenDates(update.getApplyStartTime(), new Date()) > 0) {
- //濡傛灉鐢熸晥鏃堕棿 鏄粖澶╀箣鍓嶏紝閫�鍥炲凡浜х敓璐圭敤锛岃绠楀凡浜х敓璐圭敤(鎬昏垂鐢�-宸蹭骇鐢熻垂鐢�)
- updateCurrentFee = updateFee.subtract(Constants.formatBigdecimal(oldModel.getCurrentFee()));
+ //褰撳鎵规椂闂� 澶т簬 鐢宠鐨勬椂闂存椂 璁$畻瀹為檯鍑忓皯閲戦 鍥犱负宸叉墸閲戦浼氬ぇ浜� 搴旀墸閲戦
+ BigDecimal updateCurrentFee = BigDecimal.ZERO;
+ if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2),update.getApplyStartTime()) > 0) {
+ applyChangeCyclePriceDTO_reduce.setValidTime(DateUtil.getMontageDate(new Date(), 2));
+ //鑾峰彇 澶т簬瀹℃壒鏃ユ湡瀵艰嚧 澶氬噺鐨勯噾棰�
+ CountCyclePriceVO timeoutCountCyclePriceVOReduce = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_reduce);
+ updateCurrentFee = timeoutCountCyclePriceVOReduce.getCyclePrice().subtract(countCyclePriceVO_reduce.getCyclePrice());
}
applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
.setSql(" fee = ifnull(fee,0)+" + updateFee)
.setSql(" current_fee = " + updateCurrentFee)
- .set(ApplyDetail::getEndTime, update.getApplyStartTime())
+ .set(ApplyDetail::getEndTime, DateUtil.getMontageDate(update.getApplyStartTime(), 3))
.set(ApplyDetail::getEditor, update.getEditor())
.set(ApplyDetail::getEditDate, update.getEditDate())
- .eq(ApplyDetail::getId, oldModel.getApplyId())
+ .eq(ApplyDetail::getId, oldModel.getId())
);
- totalFee.add(updateFee);
- currentFee.add(updateCurrentFee);
+ totalFee = totalFee.add(updateFee);
+ currentFee = currentFee.add(updateCurrentFee);
//淇敼 鍛樺伐鎶曚繚鏄庣粏璁板綍 鍘嗗彶鏁版嵁
memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda()
@@ -472,26 +480,28 @@
.set(MemberInsurance::getEndTime, update.getApplyStartTime())
.eq(MemberInsurance::getRelationId, oldModel.getId())
);
-
- }
}
+
+ member.setApplyId(update.getApplyId());
+ member.setDuId(detail.getDuId());
+ member.setWorktypeId(detail.getWorktypeId());
+ member.setStartTime(detail.getStartTime());
+ member.setEndTime(detail.getEndTime());
+ memberMapper.updateById(member);
if (memberInsuranceList != null && memberInsuranceList.size() > 0) {
-// applyDetailJoinMapper.insertBatchSomeColumn(addList);
memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
}
- if (totalFee.compareTo(new BigDecimal(0)) != 0) {
- //濡傛灉淇濆崟閲戦鍙戠敓缂栫爜锛屾洿鏂版�讳繚鍗曢噾棰�
- insuranceApplyMapper.update(null, new UpdateWrapper<InsuranceApply>().lambda()
- .setSql(" fee = ifnull(fee,0)+" + totalFee)
- .setSql(" current_fee = ifnull(current_fee,0)+" + currentFee)
- .set(InsuranceApply::getEditor, update.getEditor())
- .set(InsuranceApply::getEditDate, update.getEditDate())
- .eq(InsuranceApply::getId, update.getApplyId())
- );
-
- }
-
+ }
+ if (totalFee.compareTo(new BigDecimal(0)) != 0) {
+ //濡傛灉淇濆崟閲戦鍙戠敓缂栫爜锛屾洿鏂版�讳繚鍗曢噾棰�
+ insuranceApplyMapper.update(null, new UpdateWrapper<InsuranceApply>().lambda()
+ .setSql(" fee = ifnull(fee,0)+" + totalFee)
+ .setSql(" current_fee = ifnull(current_fee,0)+" + currentFee)
+ .set(InsuranceApply::getEditor, update.getEditor())
+ .set(InsuranceApply::getEditDate, update.getEditDate())
+ .eq(InsuranceApply::getId, update.getApplyId())
+ );
}
}
@@ -624,6 +634,8 @@
}
applyChange.setCreateDate(new Date());
applyChange.setCreator(loginUserInfo.getId());
+ applyChange.setEditor(loginUserInfo.getId());
+ applyChange.setEditDate(new Date());
applyChange.setIsdeleted(Constants.ZERO);
applyChange.setApplyStartTime(applyChange.getValidTime());
applyChange.setStatus(Constants.ZERO);
@@ -635,6 +647,10 @@
applyChangeFee.setId(applyChange.getId());
applyChangeFee.setFee(fee);
applyChangeMapper.updateById(applyChangeFee);
+
+// if(1==1){
+// throw new BusinessException(ResponseStatus.DATA_EMPTY);
+// }
@@ -782,7 +798,7 @@
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽噺淇�");
}
//鍑忎繚鏄庣粏鏁版嵁 璁$畻閲戦 鏍规嵁鎵瑰崟鏃堕棿 鍓嶄竴澶� 璁$畻
- applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),3));
+ applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),2));
CountCyclePriceVO countCyclePriceVO = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
BigDecimal detailFee = countCyclePriceVO.getCyclePrice();
this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo,detailFee);
@@ -822,7 +838,8 @@
* @param delDetailList
* @param loginUserInfo
*/
- public void delChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> delDetailList,InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal detailFee){
+ public void delChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> delDetailList,InsuranceApply insuranceApply,Solutions solutions,
+ LoginUserInfo loginUserInfo,BigDecimal detailFee){
for (ApplyChagneDetail applyChagneDetail : delDetailList) {
if (Objects.isNull(applyChagneDetail.getMemberId())) {
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍑忎繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戝繀濉」缂哄け");
@@ -859,8 +876,15 @@
applyChagneDetail.setApplyChangeId(applyChange.getId());
applyChagneDetail.setType(Constants.ONE);
- applyChagneDetail.setStartTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1));
+ applyChagneDetail.setStartTime(applyDetail.getStartTime());
applyChagneDetail.setEndTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),3));
+
+ member.setApplyId(insuranceApply.getId());
+ member.setDuId(applyChagneDetail.getDuId());
+ member.setWorktypeId(applyChagneDetail.getWorktypeId());
+ member.setStartTime(applyChagneDetail.getStartTime());
+ member.setEndTime(applyChagneDetail.getEndTime());
+ memberMapper.updateById(member);
applyChagneDetail.setFee( detailFee.multiply(new BigDecimal(-1)));
applyChagneDetailJoinMapper.insert(applyChagneDetail);
@@ -886,6 +910,13 @@
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍔犱繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戝繀濉」缂哄け");
}
+ applyChagneDetail.setCreateDate(new Date());
+ applyChagneDetail.setCreator(loginUserInfo.getId());
+ applyChagneDetail.setIsdeleted(Constants.ZERO);
+ applyChagneDetail.setApplyChangeId(applyChange.getId());
+ applyChagneDetail.setStartTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1));
+ applyChagneDetail.setEndTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2));
+ applyChagneDetail.setType(Constants.ZERO);
Member member = new Member();
if(Objects.isNull(applyChagneDetail.getMemberId())){
//鏌ヨ鏄惁瀛樺湪璇ョ敤鎴�
@@ -907,11 +938,15 @@
member.setApplyId(insuranceApply.getId());
member.setDuId(applyChagneDetail.getDuId());
member.setWorktypeId(applyChagneDetail.getWorktypeId());
+ member.setStartTime(applyChagneDetail.getStartTime());
+ member.setEndTime(applyChagneDetail.getEndTime());
memberMapper.insert(member);
}else{
member.setApplyId(insuranceApply.getId());
member.setDuId(applyChagneDetail.getDuId());
member.setWorktypeId(applyChagneDetail.getWorktypeId());
+ member.setStartTime(applyChagneDetail.getStartTime());
+ member.setEndTime(applyChagneDetail.getEndTime());
memberMapper.updateById(member);
}
}else{
@@ -922,8 +957,19 @@
member.setApplyId(insuranceApply.getId());
member.setDuId(applyChagneDetail.getDuId());
member.setWorktypeId(applyChagneDetail.getWorktypeId());
+ member.setStartTime(applyChagneDetail.getStartTime());
+ member.setEndTime(applyChagneDetail.getEndTime());
memberMapper.updateById(member);
}
+
+ //鏍规嵁鍛樺伐韬唤璇佽繘琛屽垽鏂勾榫�
+ long age = Constants.getAgeByIdCard(member.getIdcardNo());
+ if(Objects.isNull(age)
+ || age > solutions.getMaxAge()
+ || age < solutions.getMinAge()){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆�"+applyChagneDetail.getMemberName()+"銆戝憳宸ュ勾榫勮秴鍑烘柟妗堥厤缃� 鏂规閰嶇疆銆�"+solutions.getMinAge()+" - "+solutions.getMaxAge()+"銆戝瓨鍦ㄥ紓甯告暟鎹紒");
+ }
+
//鏌ヨ鍛樺伐鏄惁瀛樺湪 0寰呯缃� 1宸茬绔� 鐨勬绫讳笟鍔′繚鏁版嵁 鍚屼竴涓诲崟涓�
if (applyChagneDetailJoinMapper.selectJoinCount(
new MPJLambdaWrapper<ApplyChagneDetail>()
@@ -934,6 +980,8 @@
) > Constants.ZERO) {
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍔犱繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戝瓨鍦ㄧ敵璇蜂腑鐨勫姞鍑忎繚/鎹㈠巶鍗曟嵁");
}
+
+
//鏌ヨ鍛樺伐鏄湪涓诲崟涓� 鏄惁瀛樺湪鐢熸晥涓殑鏁版嵁
if(!Objects.isNull(applyChagneDetail.getMemberId())){
if (applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>().lambda()
@@ -954,13 +1002,6 @@
throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "銆�" + applyChagneDetail.getMemberName() + "銆戝憳宸ュ伐绉嶄俊鎭湭鏌ヨ鍒帮紒");
}
applyChagneDetail.setMemberId(member.getId());
- applyChagneDetail.setCreateDate(new Date());
- applyChagneDetail.setCreator(loginUserInfo.getId());
- applyChagneDetail.setIsdeleted(Constants.ZERO);
- applyChagneDetail.setApplyChangeId(applyChange.getId());
- applyChagneDetail.setStartTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1));
- applyChagneDetail.setEndTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2));
- applyChagneDetail.setType(Constants.ZERO);
applyChagneDetail.setFee(detailFee);
applyChagneDetailJoinMapper.insert(applyChagneDetail);
}
@@ -1025,7 +1066,18 @@
applyChagneDetail.setIsdeleted(Constants.ZERO);
applyChagneDetail.setApplyChangeId(applyChange.getId());
applyChagneDetail.setType(Constants.TWO);
+ applyChagneDetail.setStartTime(applyDetail.getStartTime());
+ applyChagneDetail.setEndTime(applyDetail.getEndTime());
+
applyChagneDetailJoinMapper.insert(applyChagneDetail);
+
+ member.setApplyId(applyChange.getApplyId());
+ member.setDuId(applyChagneDetail.getDuId());
+ member.setWorktypeId(applyChagneDetail.getWorktypeId());
+ member.setStartTime(applyChagneDetail.getStartTime());
+ member.setEndTime(applyChagneDetail.getEndTime());
+ memberMapper.updateById(member);
+
}
}
--
Gitblit v1.9.3