k94314517
2024-12-19 68a19b71ddb5775670e4cb125c29b4ee70d62da9
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformBooksServiceImpl.java
@@ -1,7 +1,5 @@
package com.doumee.service.business.impl;
import cn.emay.sdk.util.StringUtil;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
@@ -10,13 +8,21 @@
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.SmsConstants;
import com.doumee.core.utils.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.SmsConfigMapper;
import com.doumee.dao.business.dao.SmsEmailMapper;
import com.doumee.dao.business.join.ApproveJoinMapper;
import com.doumee.dao.business.model.*;
import com.doumee.dao.business.vo.ApproveDataVO;
import com.doumee.dao.system.SystemUserMapper;
import com.doumee.dao.system.join.NoticesJoinMapper;
import com.doumee.dao.web.reqeust.ConfirmTaskDTO;
import com.doumee.dao.system.model.Notices;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.dao.web.reqeust.PlatformBooksApplyDTO;
import com.doumee.dao.web.reqeust.PlatformBooksCheckNumDTO;
import com.doumee.dao.web.reqeust.RevokeDTO;
@@ -26,8 +32,8 @@
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.third.EmayService;
import org.apache.commons.lang3.StringUtils;
import org.apache.tomcat.util.bcel.Const;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -35,6 +41,7 @@
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@@ -60,7 +67,13 @@
    private PlatformReasonMapper platformReasonMapper;
    @Autowired
    private PlatformGroupMapper platformGroupMapper;
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
    private SystemUserMapper systemUserMapper;
    @Autowired
    private ApproveService approveService;
@@ -74,6 +87,17 @@
    @Autowired
    private CarsMapper carsMapper;
    @Autowired
    private SmsConfigMapper smsConfigMapper;
    @Autowired
    private SmsEmailMapper smsEmailMapper;
    @Autowired
    private EmayService emayService;
    @Autowired
    private WxNoticeConfigMapper wxNoticeConfigMapper;
    @Override
    public Integer create(PlatformBooks platformBooks) {
@@ -241,11 +265,21 @@
        if(Objects.isNull(platformReason)|| !Constants.equalsInteger(platformReason.getIsdeleted(),Constants.ZERO)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"入园原因信息异常,请刷新重试");
        }
        PlatformGroup platformGroup= platformGroupMapper.selectById(platformReason.getGroupId());
        if(Objects.isNull(platformGroup)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到绑定月台组数据");
        }
        if(!Constants.equalsInteger(platformGroup.getIsdeleted(),Constants.ZERO)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"绑定月台组数据异常,请联系管理员");
        }
        if(!Constants.checkCarNo(platformBooksApplyDTO.getCarCodeFront())){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请输入正确的车牌!");
        };
        //查询车辆是否为自有车
        if(carsMapper.selectCount(new QueryWrapper<Cars>().lambda().eq(Cars::getIsdeleted,Constants.ZERO).eq(Cars::getCode,platformBooksApplyDTO.getCarCodeFront()))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"["+platformBooksApplyDTO.getCarCodeFront()+"]属于内部车辆,无法预约");
        };
        ApproveTempl approveTempl = approveTemplMapper.selectById(platformReason.getId());
        ApproveTempl approveTempl = approveTemplMapper.selectById(platformReason.getApproveTemplId());
        if(Objects.isNull(approveTempl)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未配置审批流,请联系管理员");
        }
@@ -262,7 +296,22 @@
        platformBooksMapper.insert(platformBooks);
        //创建审批流信息
        approveService.createApproveForPlatfrom(platformReason.getApproveTemplId(),platformBooks.getId(),platformBooks.getDriverId());
        approveService.createApproveForPlatfrom(approveTempl.getId(),platformBooks.getId(),platformBooks.getDriverId());
        //发送公众号通知 给提交人
        SystemUser driver = systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda()
                .eq(SystemUser::getDeleted, Constants.ZERO)
                .eq(SystemUser::getType, Constants.ZERO)
                .eq(SystemUser::getMobile,platformBooks.getDriverPhone())
                .last(" limit 1 "));
        if(Objects.nonNull(driver)&&StringUtils.isNotBlank(driver.getOpenid())){
            WxPlatNotice wxPlatNotice = new WxPlatNotice();
            wxPlatNotice.sendPlatformBookTemplateNotice(systemDictDataBiz,
                    wxNoticeConfigMapper,platformBooks,
                    WxPlatConstants.platformBookContent.platformBookUpload,
                    systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
                    Arrays.asList(driver.getOpenid().split(",")),0);
        }
        return platformBooks.getId();
    }
@@ -344,6 +393,20 @@
            approve.setCheckDate(model.getCancelTime());
            approveList.add(approve);
        }
        Notices notices = noticesJoinMapper.selectOne(new QueryWrapper<Notices>().lambda()
                .eq(Notices::getObjId,id)
                .eq(Notices::getType,Constants.noticesObjectType.reason)
                .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;
    }
@@ -379,6 +442,15 @@
                .eq(Approve::getObjType,Constants.approveObjectType.logisticsCarUse)
                .eq(Approve::getObjId,revokeDTO.getId())
        );
        //发送短信通知
        SmsEmailServiceImpl.sendPlatformBookSms(systemDictDataBiz,
                emayService,smsEmailMapper,smsConfigMapper,platformBooksMapper,model.getId(),
                        SmsConstants.platformBookContent.platformBookCancel,
                null,null
        );
    }