|  |  |  | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | 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.service.business.third.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageData; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.*; | 
|---|
|  |  |  | import com.doumee.core.wx.wxPlat.WxPlatConstants; | 
|---|
|  |  |  | import com.doumee.core.wx.wxPlat.WxPlatNotice; | 
|---|
|  |  |  | import com.doumee.dao.business.*; | 
|---|
|  |  |  | import com.doumee.dao.business.dao.MemberMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.dao.SmsConfigMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.dao.SmsEmailMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.ApproveJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.CarUseBookJoinMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.dao.business.vo.ApproveDataVO; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.DateIntervalVO; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.dao.business.model.Member; | 
|---|
|  |  |  | import com.doumee.dao.system.SystemUserMapper; | 
|---|
|  |  |  | import com.doumee.dao.system.join.NoticesJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.system.model.Notices; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemDictData; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.ApproveService; | 
|---|
|  |  |  | import com.doumee.service.business.CarUseBookService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | private ApproveJoinMapper approveJoinMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NoticesJoinMapper noticesJoinMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApproveService approveService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private EmayService emayService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WxNoticeConfigMapper wxNoticeConfigMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemUserMapper systemUserMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前登录用户无法进行该操作!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(carUseBook.getEndTime().getTime()<=System.currentTimeMillis()){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"选择日期异常[结束时间小于当前时间],请刷新重试"); | 
|---|
|  |  |  | //            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"选择日期异常[结束时间小于当前时间],请刷新重试"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!(DateUtil.getDateFromString(carUseBook.getPlanUseDate()+":00").getTime()>=carUseBook.getStartTime().getTime() | 
|---|
|  |  |  | && DateUtil.getDateFromString(carUseBook.getPlanUseDate() +":00").getTime()<= carUseBook.getEndTime().getTime()) | 
|---|
|  |  |  | 
|---|
|  |  |  | CarDriver carDriver = carDriverMapper.selectOne(new QueryWrapper<CarDriver>().lambda() | 
|---|
|  |  |  | .eq(CarDriver::getCarId,cars.getId()) | 
|---|
|  |  |  | .eq(CarDriver::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(CarDriver::getStatus,Constants.ONE) | 
|---|
|  |  |  | //                .eq(CarDriver::getStatus,Constants.ZERO) | 
|---|
|  |  |  | .last( " limit 1 ") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.nonNull(carDriver)&&Objects.nonNull(carDriver.getMemberId())){ | 
|---|
|  |  |  | 
|---|
|  |  |  | carUseBookMapper.insert(carUseBook); | 
|---|
|  |  |  | //用车申请 审批记录创建 | 
|---|
|  |  |  | approveService.createApproveFlow(carUseBook.getType()==0?3:4,carUseBook.getId(),carUseBook.getMemberId()); | 
|---|
|  |  |  | //发送微信公众号通知 | 
|---|
|  |  |  | //发送微信公众号通知 | 
|---|
|  |  |  | WxPlatNotice wxPlatNotice = new WxPlatNotice(); | 
|---|
|  |  |  | SystemUser systemUser = systemUserMapper.selectById(carUseBook.getCreator()); | 
|---|
|  |  |  | if(Objects.nonNull(systemUser) && StringUtils.isNotBlank(systemUser.getOpenid())){ | 
|---|
|  |  |  | carUseBook.setMemberName(systemUser.getRealname()); | 
|---|
|  |  |  | wxPlatNotice.sendCarUseBookTemplateNotice(systemDictDataBiz, | 
|---|
|  |  |  | wxNoticeConfigMapper,carUseBook, | 
|---|
|  |  |  | WxPlatConstants.carUseBookContent.carUseBookUpload, | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(), | 
|---|
|  |  |  | Arrays.asList(systemUser.getOpenid().split(",")),0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return carUseBook.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | approveList.add(approve); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | model.setApproveDateVO(approveDataVO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Notices notices = noticesJoinMapper.selectOne(new QueryWrapper<Notices>().lambda() | 
|---|
|  |  |  | .eq(Notices::getObjId,id) | 
|---|
|  |  |  | .eq(Notices::getType,Constants.noticesObjectType.useCar) | 
|---|
|  |  |  | .eq(Notices::getUserId,memberId) | 
|---|
|  |  |  | .eq(Notices::getSendacopy,Constants.ZERO) | 
|---|
|  |  |  | .orderByDesc(Notices::getId).last(" limit 1 ")); | 
|---|
|  |  |  | if(Objects.nonNull(notices)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(notices.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | model.setInfo("待我处理"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | model.setInfo(notices.getInfo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return  model; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //判断时间是否大于当前 | 
|---|
|  |  |  | if(Constants.equalsInteger(dateIntervalVO.getIsUse(),Constants.ZERO)  && DateUtil.getDateFromString(dateIntervalVO.getEndTime()).getTime()<=System.currentTimeMillis()){ | 
|---|
|  |  |  | dateIntervalVO.setIsUse(Constants.ONE); | 
|---|
|  |  |  | //                dateIntervalVO.setIsUse(Constants.ONE); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | .in(Approve::getObjType,Constants.approveObjectType.cityUseCar,Constants.approveObjectType.unCityUseCar) | 
|---|
|  |  |  | .eq(Approve::getObjId,id) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | Member member = memberMapper.selectById(carUseBook.getMemberId()); | 
|---|
|  |  |  | if(Objects.nonNull(member)&&StringUtils.isNotBlank(member.getPhone())){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //处理待办信息 | 
|---|
|  |  |  | noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda() | 
|---|
|  |  |  | .set(Notices::getStatus,Constants.ONE) | 
|---|
|  |  |  | .set(Notices::getInfo,"已取消") | 
|---|
|  |  |  | .eq(Notices::getType,Constants.TWO) | 
|---|
|  |  |  | .eq(Notices::getObjId,carUseBook.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SystemUser systemUser = systemUserMapper.selectById(carUseBook.getCreator()); | 
|---|
|  |  |  | if(Objects.nonNull(systemUser)&&StringUtils.isNotBlank(systemUser.getMobile())){ | 
|---|
|  |  |  | //用车申请取消 | 
|---|
|  |  |  | SmsEmailServiceImpl.sendCarUseSms(systemDictDataBiz, | 
|---|
|  |  |  | emayService,smsEmailMapper,smsConfigMapper,carUseBookMapper,carUseBook.getId(), | 
|---|
|  |  |  | SmsConstants.carUseBookContent.carUseBookCancel, | 
|---|
|  |  |  | null, Arrays.asList(member.getPhone().split(",")) | 
|---|
|  |  |  | info, Arrays.asList(systemUser.getMobile().split(",")) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(systemUser.getOpenid())){ | 
|---|
|  |  |  | carUseBook.setMemberName(systemUser.getRealname()); | 
|---|
|  |  |  | WxPlatNotice wxPlatNotice = new WxPlatNotice(); | 
|---|
|  |  |  | wxPlatNotice.sendCarUseBookTemplateNotice(systemDictDataBiz, | 
|---|
|  |  |  | wxNoticeConfigMapper, | 
|---|
|  |  |  | carUseBook, | 
|---|
|  |  |  | WxPlatConstants.carUseBookContent.carUseBookCancel, | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(), | 
|---|
|  |  |  | Arrays.asList(systemUser.getOpenid().split(",")), | 
|---|
|  |  |  | Constants.TWO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|