From 3a5fbcae78f6d395468826ce5dbcf6b4643aec7e Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期三, 03 四月 2024 18:02:58 +0800
Subject: [PATCH] 提交一把
---
server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 160 insertions(+), 19 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
index 8126ff7..19467b3 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
@@ -1,5 +1,6 @@
package com.doumee.service.business.impl;
+import com.alibaba.fastjson.JSONObject;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.annotation.excel.ExcelExporter;
import com.doumee.core.constants.ResponseStatus;
@@ -11,12 +12,12 @@
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.*;
-import com.doumee.dao.business.dto.SaveUnionApplyDTO;
-import com.doumee.dao.business.dto.SaveUnionChangeDTO;
-import com.doumee.dao.business.dto.UnionChangeBXDDTO;
+import com.doumee.dao.business.dto.*;
import com.doumee.dao.business.join.*;
import com.doumee.dao.business.model.*;
import com.doumee.dao.business.vo.CountCyclePriceVO;
+import com.doumee.dao.system.model.SystemUser;
+import com.doumee.service.business.SmsEmailService;
import com.doumee.service.business.UnionChangeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -28,6 +29,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -82,6 +84,18 @@
@Autowired
private InsuranceApplyMapper insuranceApplyMapper;
+ @Value("${debug_model}")
+ private boolean debugModel;
+ @Autowired
+ private SmsEmailService smsEmailService;
+ @Autowired
+ private MultifileMapper multifileMapper;
+
+ @Autowired
+ private ApplyLogMapper applyLogMapper;
+
+ @Autowired
+ private ApplyLogJoinMapper applyLogJoinMapper;
@Override
public Integer create(UnionChange unionChange) {
unionChangeMapper.insert(unionChange);
@@ -127,6 +141,48 @@
return unionChangeMapper.selectById(id);
}
+
+ @Override
+ public UnionChange getDetail(Integer id){
+ UnionChange unionChange = unionChangeJoinMapper.selectJoinOne(UnionChange.class,
+ new MPJLambdaWrapper<UnionChange>()
+ .selectAll(UnionChange.class)
+ .selectAs(UnionApply::getCode,UnionChange::getApplyCode)
+ .selectAs(Solutions::getName,UnionChange::getSolutionsName)
+ .selectAs(UnionApply::getStartTime,UnionChange::getStartTime)
+ .selectAs(UnionApply::getEndTime,UnionChange::getEndTime)
+ .selectAs(Company::getName,UnionChange::getShopName)
+ .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 0 )",UnionChange::getAddNum)
+ .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 1 )",UnionChange::getDelNum)
+ .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 2 )",UnionChange::getChangeNum)
+ .leftJoin(UnionApply.class,UnionApply::getId,UnionChange::getUnionApplyId)
+ .leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId)
+ .leftJoin(Company.class,Company::getId,UnionChange::getShopId)
+ .eq(UnionChange::getId,id)
+ .last(" limit 1 ")
+ );
+
+ if(!Objects.isNull(unionChange)){
+ //鏌ヨ鎿嶄綔璁板綍
+ List<ApplyLog> applyLogList = applyLogJoinMapper.selectJoinList(ApplyLog.class,
+ new MPJLambdaWrapper<ApplyLog>()
+ .selectAll(ApplyLog.class)
+ .selectAs(SystemUser::getRealname,ApplyLog::getCreatorName)
+ .selectAs(Company::getName,ApplyLog::getCompanyName)
+ .selectAs(SystemUser::getType,ApplyLog::getCreatorType)
+ .leftJoin(SystemUser.class,SystemUser::getId,ApplyLog::getCreator)
+ .leftJoin(Company.class,Company::getId,SystemUser::getCompanyId)
+ .in(ApplyLog::getObjType,Constants.ApplyLogType.getTypeList(Constants.THREE))
+ .eq(ApplyLog::getApplyId,unionChange.getId())
+ .orderByAsc(ApplyLog::getCreateDate)
+ );
+ unionChange.setApplyLogList(applyLogList);
+ }
+ return unionChange;
+ }
+
+
+
@Override
public UnionChange findOne(UnionChange unionChange) {
QueryWrapper<UnionChange> wrapper = new QueryWrapper<>(unionChange);
@@ -144,15 +200,17 @@
IPage<UnionChange> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
MPJLambdaWrapper<UnionChange> queryWrapper = new MPJLambdaWrapper<>();
queryWrapper.selectAll(UnionChange.class);
- queryWrapper.selectAs(UnionApply::getCode,UnionChange::getApplyCode)
+ pageWrap.getModel().setIsdeleted(Constants.ZERO);
+ queryWrapper.selectAs(UnionApply::getCode,UnionChange::getApplyCode);
+ queryWrapper.selectAs(Solutions::getName,UnionChange::getSolutionsName)
.select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 0 )",UnionChange::getAddNum)
.select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 1 )",UnionChange::getDelNum)
.select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 2 )",UnionChange::getChangeNum);
queryWrapper.leftJoin(UnionApply.class,UnionApply::getId,UnionChange::getUnionApplyId);
queryWrapper.leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId);
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
- if(user.getType().equals(Constants.TWO)){
- queryWrapper.eq(UnionChange::getShopId, pageWrap.getModel().getShopId());
+ if(Constants.equalsInteger(user.getType(),Constants.TWO)){
+ queryWrapper.eq(UnionChange::getShopId, user.getCompanyId());
}
Utils.MP.blankToNull(pageWrap.getModel());
if (pageWrap.getModel().getId() != null) {
@@ -235,9 +293,10 @@
@Override
+ @Transactional(rollbackFor = {BusinessException.class,Exception.class})
public Integer merge(SaveUnionChangeDTO saveUnionChangeDTO){
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
- if(user.getType().equals(Constants.TWO)){
+ if(!user.getType().equals(Constants.TWO)){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣�");
}
if(Objects.isNull(saveUnionChangeDTO)
@@ -254,8 +313,8 @@
.leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
.eq(ApplyChange::getIsdeleted, Constants.ZERO)
.eq(InsuranceApply::getUnionApplyId,saveUnionChangeDTO.getUnionApplyId())
- .eq(ApplyChange::getStatus,Constants.ApplyChangeStatus.PALTFORM_CHECK_PASS.getKey())
- .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())
+ .eq(ApplyChange::getStatus,Constants.ApplyChangeStatus.CHECHED_PASSED.getKey())
+ .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_DONE.getKey())
.eq(ApplyChange::getType,saveUnionChangeDTO.getBusinessType())
.in(ApplyChange::getId,saveUnionChangeDTO.getApplyIds())
.isNull(ApplyChange::getUnionChangeId)
@@ -269,6 +328,7 @@
unionChange.setCreateDate(new Date());
unionChange.setCreator(user.getId());
unionChange.setShopId(user.getCompanyId());
+ unionChange.setIsdeleted(Constants.ZERO);
unionChange.setUnionApplyId(saveUnionChangeDTO.getUnionApplyId());
unionChange.setApplyStartTime(saveUnionChangeDTO.getApplyDate());
unionChange.setType(saveUnionChangeDTO.getBusinessType());
@@ -279,12 +339,20 @@
.set(ApplyChange::getUnionChangeId,unionChange.getId())
.set(ApplyChange::getCheckDate,new Date())
.set(ApplyChange::getCheckUserId,user.getId())
+ .set(ApplyChange::getStatus,Constants.ApplyChangeStatus.WTB_TOUBAOING.getKey())
.in(ApplyChange::getId,saveUnionChangeDTO.getApplyIds())
);
applyChagneDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
.set(ApplyChagneDetail::getUnionChangeId,unionChange.getId())
- .in(ApplyChagneDetail::getApplyId,saveUnionChangeDTO.getApplyIds()));
+ .in(ApplyChagneDetail::getApplyChangeId,saveUnionChangeDTO.getApplyIds()));
+
+
+ Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_UPLOAD;
+ ApplyLog log = new ApplyLog(unionChange,applyLogType.getName(), null
+ ,unionChange.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionChange));
+ applyLogMapper.insert(log);
+
return unionChange.getId();
}
@@ -295,16 +363,21 @@
/**
* 鍙栨秷淇濆崟鍚堝苟
- * @param id
+ * @param closeDTO
*/
@Override
@Transactional(rollbackFor = {Exception.class,BusinessException.class})
- public void cancelMerge(Integer id){
+ public void cancelMerge(CloseDTO closeDTO){
+ if(Objects.isNull(closeDTO)
+ ||Objects.isNull(closeDTO.getId())
+ ||StringUtils.isBlank(closeDTO.getReason())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
if(user.getType().equals(Constants.TWO)){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣滐紒");
}
- UnionChange unionChange = unionChangeMapper.selectById(id);
+ UnionChange unionChange = unionChangeMapper.selectById(closeDTO.getId());
if(Objects.isNull(unionChange)||!Constants.equalsInteger(unionChange.getIsdeleted(),Constants.ZERO)){
throw new BusinessException(ResponseStatus.DATA_EMPTY);
}
@@ -322,6 +395,7 @@
.set(ApplyChange::getUnionChangeId,null)
.set(ApplyChange::getCheckDate,new Date())
.set(ApplyChange::getCheckUserId,user.getId())
+ .set(ApplyChange::getStatus,Constants.ApplyChangeStatus.CHECHED_PASSED.getKey())
.in(ApplyChange::getUnionChangeId,unionChange.getId())
);
@@ -333,6 +407,14 @@
.set(UnionChange::getStatus,Constants.UnionApplyStatus.CLOSE.getKey())
.eq(UnionChange::getId,unionChange.getId())
);
+
+ Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_UPLOAD;
+ String info =applyLogType.getInfo();
+ info = info.replace("${param}", closeDTO.getReason());
+ ApplyLog log = new ApplyLog(unionChange,applyLogType.getName(), info
+ ,unionChange.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionChange));
+ applyLogMapper.insert(log);
+
}
@@ -389,17 +471,24 @@
/**
* 鍚堝苟鍗曪紙鍔犲噺淇�/鎹㈠巶锛� - 鎶曚繚鐢宠绛剧讲
- * @param id
+ * @param smsCheckDTO
* @return
*/
@Override
@Transactional(rollbackFor = {Exception.class,BusinessException.class})
- public String getSignLink(Integer id) {
- if(id == null ){
+ public String getSignLink(SmsCheckDTO smsCheckDTO) {
+ if(Objects.isNull(smsCheckDTO)
+ || Objects.isNull(smsCheckDTO.getBusinessId())
+ || StringUtils.isBlank(smsCheckDTO.getCode())
+ ){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
+ //楠岃瘉 楠岃瘉鐮�
+ if(!debugModel){
+ smsEmailService.validateCode(smsCheckDTO.getCode());
+ }
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
- UnionChange unionChange = this.unionChangeDetail(id);
+ UnionChange unionChange = this.unionChangeDetail(smsCheckDTO.getBusinessId());
if(Objects.isNull(unionChange)||!Constants.equalsInteger(unionChange.getIsdeleted(),Constants.ZERO)){
throw new BusinessException(ResponseStatus.DATA_EMPTY);
}
@@ -454,8 +543,8 @@
if(Objects.isNull(unionChangeBXDDTO)
|| Objects.isNull(unionChangeBXDDTO.getId())
|| Objects.isNull(unionChangeBXDDTO.getApplyDate())
- || StringUtils.isBlank(unionChangeBXDDTO.getFileName())
- || StringUtils.isBlank(unionChangeBXDDTO.getFileUrl())
+ || StringUtils.isBlank(unionChangeBXDDTO.getName())
+ || StringUtils.isBlank(unionChangeBXDDTO.getFileurl())
|| StringUtils.isBlank(unionChangeBXDDTO.getCode())
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
@@ -485,14 +574,60 @@
.selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode)
.leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
.eq(ApplyChange::getUnionChangeId,unionChange.getId()));
+
+ //瀛樺偍鍚堝苟鍗曚繚闄╁崟
+ Multifile multifile = new Multifile();
+ multifile.setIsdeleted(Constants.ZERO);
+ multifile.setCreator(user.getId());
+ multifile.setCreateDate(new Date());
+ multifile.setObjId(unionChangeBXDDTO.getId());
+ multifile.setCreateDate(new Date());
+ multifile.setObjType(Constants.MultiFile.WTB_CA_DONE_PDF.getKey());
+ multifile.setType(Constants.TWO);
+ multifile.setFileurl(unionChangeBXDDTO.getFileurl());
+ multifile.setName(unionChangeBXDDTO.getName());
+ multifileMapper.insert(multifile);
+
+ if(CollectionUtils.isNotEmpty(unionChangeBXDDTO.getApplyChangeBXDList())){
+ //鏌ヨ鏄惁涓嶅瓨鍦ㄥ綋鍓嶅悎骞跺崟鐨勬暟鎹�
+ if(applyChangeJoinMapper.selectCount(new QueryWrapper<ApplyChange>()
+ .lambda().ne(ApplyChange::getUnionChangeId,unionChangeBXDDTO.getId())
+ .in(ApplyChange::getId,
+ unionChangeBXDDTO.getApplyChangeBXDList().stream().map(m->m.getObjId()).collect(Collectors.toList())
+ )
+ )>Constants.ZERO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鎵瑰崟鏄庣粏璁板綍瀛樺湪闈炴湰鍚堝苟鍗曟暟鎹�");
+ };
+ for (Multifile m:unionChangeBXDDTO.getApplyChangeBXDList()) {
+ if(Objects.isNull(m.getObjId())
+ ||StringUtils.isBlank(m.getFileurl())
+ ||StringUtils.isBlank(m.getName())
+ ){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍔犲噺淇�/鎹㈠巶涓氬姟鎵瑰崟鏂囦欢淇℃伅缂哄け");
+ }
+ multifile.setIsdeleted(Constants.ZERO);
+ multifile.setCreator(user.getId());
+ multifile.setCreateDate(new Date());
+ multifile.setCreateDate(new Date());
+ multifile.setObjType(Constants.MultiFile.CA_PD_PDF.getKey());
+ multifile.setType(Constants.TWO);
+ multifileMapper.insert(multifile);
+ }
+ }
+
+
if(CollectionUtils.isNotEmpty(applyChangeList)){
for (ApplyChange applyChange:applyChangeList) {
applyChange.setApplyStartTime(unionChangeBXDDTO.getApplyDate());
applyChange.setValidTime(unionChangeBXDDTO.getApplyDate());
applyChange.setEditDate(new Date());
applyChange.setEditor(user.getId());
+ applyChange.setStatus(Constants.ApplyChangeStatus.APPROVE.getKey());
List<ApplyChagneDetail> allList = applyChagneDetailJoinMapper.selectList(new QueryWrapper<ApplyChagneDetail>().lambda().eq(ApplyChagneDetail::getApplyChangeId,applyChange.getId()));
this.dealApplyChangeDetail(applyChange,allList);
+ applyChange.setCode(unionChangeBXDDTO.getCode());
+ applyChange.setCheckUserId(user.getId());
+ applyChangeJoinMapper.updateById(applyChange);
}
}
unionChangeMapper.update(null,new UpdateWrapper<UnionChange>().lambda()
@@ -501,6 +636,12 @@
.set(UnionChange::getEditor,user.getId())
.eq(UnionChange::getId,unionChangeBXDDTO.getId())
);
+
+
+ Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_UPLOAD_INSURANCE;
+ ApplyLog log = new ApplyLog(unionChange,applyLogType.getName(), null
+ ,unionChange.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionChange));
+ applyLogMapper.insert(log);
}
--
Gitblit v1.9.3