| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.UnionApplyMapper; |
| | | import com.doumee.dao.business.dto.SaveUnionApplyDTO; |
| | | import com.doumee.dao.business.join.InsuranceApplyJoinMapper; |
| | | import com.doumee.dao.business.model.InsuranceApply; |
| | | import com.doumee.dao.business.model.Solutions; |
| | | import com.doumee.dao.business.model.UnionApply; |
| | | import com.doumee.service.business.UnionApplyService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * åå¹¶æä¿åä¿¡æ¯è¡¨Serviceå®ç° |
| | |
| | | |
| | | @Autowired |
| | | private UnionApplyMapper unionApplyMapper; |
| | | |
| | | @Autowired |
| | | private InsuranceApplyJoinMapper insuranceApplyJoinMapper; |
| | | |
| | | @Override |
| | | public Integer create(UnionApply unionApply) { |
| | |
| | | QueryWrapper<UnionApply> wrapper = new QueryWrapper<>(unionApply); |
| | | return unionApplyMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void merge(SaveUnionApplyDTO saveUnionApplyDTO){ |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(user.getType().equals(Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"éåæ·ç¨æ·ï¼æ æ³è¿è¡è¯¥æä½"); |
| | | } |
| | | if(Objects.isNull(saveUnionApplyDTO) |
| | | || Objects.isNull(saveUnionApplyDTO.getApplyIds()) |
| | | || Objects.isNull(saveUnionApplyDTO.getStartDate()) |
| | | || Objects.isNull(saveUnionApplyDTO.getEndDate()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | List<InsuranceApply> insuranceApplyList = insuranceApplyJoinMapper.selectJoinList(InsuranceApply.class, |
| | | new MPJLambdaWrapper<InsuranceApply>() |
| | | .selectAll(InsuranceApply.class) |
| | | .selectAs(InsuranceApply::getSolutionBaseId,Solutions::getBaseId) |
| | | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) |
| | | .eq(InsuranceApply::getIsdeleted, Constants.ZERO) |
| | | .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.PLATFORM_CHECK_PASS.getKey()) |
| | | .eq(Solutions::getBaseId,saveUnionApplyDTO.getBaseSolutionId()) |
| | | .in(InsuranceApply::getId,saveUnionApplyDTO.getApplyIds()) |
| | | .isNull(InsuranceApply::getUnionApplyId) |
| | | ); |
| | | //æ¥è¯¢æ°æ®æ¯å¦å卿ªå¤äºå®¡æ¹éè¿çæ°æ® |
| | | if(insuranceApplyList.size()!=saveUnionApplyDTO.getApplyIds().size()){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"å卿°æ®å·²å¤çï¼è¯·å·æ°éè¯"); |
| | | } |
| | | |
| | | UnionApply unionApply = new UnionApply(); |
| | | unionApply.setCreateDate(new Date()); |
| | | unionApply.setCreator(user.getId()); |
| | | unionApply.setCompanyId(user.getCompanyId()); |
| | | unionApply.setStartTime(saveUnionApplyDTO.getStartDate()); |
| | | unionApply.setEndTime(saveUnionApplyDTO.getEndDate()); |
| | | unionApply.setCheckDate(new Date()); |
| | | unionApply.setStatus(Constants.UnionApplyStatus.UPLOAD.getKey()); |
| | | unionApply.setCheckUserId(user.getId()); |
| | | unionApply.setFee(insuranceApplyList.stream().map(i->i.getFee()).reduce(BigDecimal.ZERO,BigDecimal::add)); |
| | | unionApply.setCurrentFee(BigDecimal.ZERO); |
| | | unionApplyMapper.insert(unionApply); |
| | | |
| | | insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() |
| | | .set(InsuranceApply::getUnionApplyId,unionApply.getId()) |
| | | .set(InsuranceApply::getCheckDate,new Date()) |
| | | .set(InsuranceApply::getCheckUserId,user.getId()) |
| | | .in(InsuranceApply::getId,saveUnionApplyDTO.getApplyIds())); |
| | | |
| | | } |
| | | |
| | | |
| | | public void cancelMerge(Integer id){ |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(user.getType().equals(Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"éåæ·ç¨æ·ï¼æ æ³è¿è¡è¯¥æä½"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |