package com.yh.saas.plugin.yiliangyiyun.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.google.common.collect.Lists;
import com.winsea.svc.base.security.util.AuthSecurityUtils;
import com.yh.saas.common.support.util.StringUtils;
import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
import com.yh.saas.plugin.yiliangyiyun.entity.*;
import com.yh.saas.plugin.yiliangyiyun.exception.*;
import com.yh.saas.plugin.yiliangyiyun.mapper.DriverViewInfoMapper;
import com.yh.saas.plugin.yiliangyiyun.service.ICommonUserService;
import com.yh.saas.plugin.yiliangyiyun.service.IDriverCarInfoService;
import com.yh.saas.plugin.yiliangyiyun.service.IDriverPayeeInfoService;
import com.yh.saas.plugin.yiliangyiyun.service.IDriverViewInfoService;
import com.yh.saas.common.support.util.IdGenerator;
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yh.saas.plugin.yiliangyiyun.util.GeTuiUtils;
import com.yh.saas.plugin.yiliangyiyun.util.WebSocket;
import org.springframework.beans.BeanUtils;
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;
import org.springframework.util.CollectionUtils;

import java.sql.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 记录司机信息 服务实现类
 * </p>
 *
 * @author Gongdc
 * @since 2021-05-29
 */
@Service
public class DriverViewInfoServiceImpl extends ServiceImpl<DriverViewInfoMapper, DriverViewInfo> implements IDriverViewInfoService {
    @Autowired
    private IDriverCarInfoService driverCarInfoService;
    @Autowired
    private IDriverPayeeInfoService driverPayeeInfoService;
    @Value("com.mysql.jdbc.Driver")
    private String driverClassName;
    @Value("jdbc:mysql://47.100.3.209:3306/talk-core?createDatabaseIfNotExist=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true")
    private String url;
    @Value("root")
    private String username;
    @Value("Ccj841968545")
    private String password;

    Connection coon = null;
    @Autowired
    private ICommonUserService commonUserService;
    @Autowired
    private GeTuiUtils geTuiUtils;
    @Autowired
    private WebSocket webSocket;


    /**
     * 添加信息
     *
     * @param
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String addInfo(DriverViewInfo driverViewInfo) {
        //新增主键id
        driverViewInfo.setId(IdGenerator.generateUUID());
        //APP添加的司机需要审核
        if ("0".equals(driverViewInfo.getPcFlag())) {
            //判断司机电话是否唯一
            List<DriverViewInfo> driverViewInfos =
                    this.selectList(new EntityWrapper<DriverViewInfo>()
                            .eq(DriverViewInfo.QueryFiles.DRIVER_PHONE, driverViewInfo.getDriverPhone())
                            .eq(DriverViewInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
            if (driverViewInfos.size() > 0) {
                for (DriverViewInfo driverViewInfo1 : driverViewInfos) {
                    driverViewInfo1.setCover("1");
                    this.updateById(driverViewInfo1);
                }
            }
            driverViewInfo.setAuthenticationStatus(StatusEnum.IDENTITY_REVIEWED.getName());
            driverViewInfo.setAuthenticationStatusKey(StatusEnum.IDENTITY_REVIEWED.getFlag());
        } else {
            //判断司机电话是否唯一
            List<DriverViewInfo> driverViewInfos =
                    this.selectList(new EntityWrapper<DriverViewInfo>()
                            .eq(DriverViewInfo.QueryFiles.DRIVER_PHONE, driverViewInfo.getDriverPhone())
                            .eq(DriverViewInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
            if (driverViewInfos.size() > 0) {
                throw new YException(YExceptionEnum.DRIVER_PHONE_ERROR);
            }
            driverViewInfo.setAuthenticationStatus(StatusEnum.IDENTITY_COMPLETED.getName());
            driverViewInfo.setAuthenticationStatusKey(StatusEnum.IDENTITY_COMPLETED.getFlag());
        }
        //判断司机身份证号是否唯一
        List<DriverViewInfo> driverViewInfoList =
                this.selectList(new EntityWrapper<DriverViewInfo>()
                        .eq(DriverViewInfo.QueryFiles.NUMBER_CARD, driverViewInfo.getNumberCard())
                        .eq(DriverViewInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
        if (driverViewInfoList.size() > 0) {
            throw new YException(YExceptionEnum.DRIVER_NUMBER_ERROR);
        }
        //货车信息新增
        List<DriverCarInfo> driverCarInfoList = driverViewInfo.getDriverCarInfoList();
        if (!CollectionUtils.isEmpty(driverCarInfoList)) {
            for (DriverCarInfo driverCarInfo : driverCarInfoList) {
                driverCarInfo.setId(IdGenerator.generateUUID());
                driverCarInfo.setDriverId(driverViewInfo.getId());
            }
        }
        //收款人账户信息新增
        List<DriverPayeeInfo> driverPayeeInfoList = driverViewInfo.getDriverPayeeInfoList();
        if (!CollectionUtils.isEmpty(driverPayeeInfoList)) {
            for (DriverPayeeInfo driverPayeeInfo : driverPayeeInfoList) {
                driverPayeeInfo.setId(IdGenerator.generateUUID());
                driverPayeeInfo.setDriverId(driverViewInfo.getId());
                //判断收款人身份证号是否唯一
//                List<DriverPayeeInfo> driverPayeeInfos =
//                        driverPayeeInfoService.selectList(new EntityWrapper<DriverPayeeInfo>()
//                                .eq(DriverPayeeInfo.QueryFiles.PAYEE_NUMBER_CARD, driverPayeeInfo.getPayeeNumberCard())
//                                .eq(DriverPayeeInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
//                if (driverPayeeInfos.size() > 0) {
//                    throw new YException(YExceptionEnum.PAYEE_NUMBER_ERROR);
//                }
            }
        }
        boolean one = this.insert(driverViewInfo);
        boolean two = driverCarInfoService.insertBatch(driverCarInfoList);
        boolean three = driverPayeeInfoService.insertBatch(driverPayeeInfoList);
        //将粮信用户表的物流字段更新为1
        if (driverViewInfo.getDriverPhone() != null) {
            DBConnection();
            String sUserId = excSelect("select * from s_user s where s.user_name = '" + driverViewInfo.getDriverPhone() + "'", this.coon);
            if (sUserId != null && !sUserId.isEmpty()) {
                excUpdate("update s_user s set s.driver_flag = 1 where s.user_name = '" + driverViewInfo.getDriverPhone() + "'", this.coon);
            }
            close();
        }
        // 假如 都成功返回ok
        if (one && two && three) {
            return "OK";
        } else {
            return "NG";
        }
    }

    /**
     * 编辑信息
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String editInfo(DriverViewInfo driverViewInfo) {
//        //覆盖
//        if ("1".equals(driverViewInfo.getCover())){
//            DriverViewInfo driverViewInfo1=this.selectOne(new EntityWrapper<DriverViewInfo>()
//                    .eq("driver_phone",driverViewInfo.getDriverPhone())
//                    .eq("delete_flag","0"));
//            driverViewInfo.setId(driverViewInfo1.getId());
//        }
        //主表信息编辑
        this.updateById(driverViewInfo);
        //货车信息编辑
        List<DriverCarInfo> driverCarInfoList = driverViewInfo.getDriverCarInfoList();
        if (!CollectionUtils.isEmpty(driverCarInfoList)) {
            for (DriverCarInfo driverCarInfo : driverCarInfoList) {
//                //覆盖
//                if ("1".equals(driverViewInfo.getCover())){
//                    DriverCarInfo driverCarInfo1=driverCarInfoService.selectOne(new EntityWrapper<DriverCarInfo>()
//                            .eq("driver_id",driverViewInfo.getId())
//                            .eq("delete_flag","0"));
//                    if (StringUtils.isEmpty(driverCarInfo1.getId())) {
//                        driverCarInfo.setId(IdGenerator.generateUUID());
//                        driverCarInfo.setDriverId(driverViewInfo.getId());
//                        driverCarInfoService.insert(driverCarInfo);
//                    }
//                    else {
//                        driverCarInfo.setId(driverCarInfo1.getId());
//                        driverCarInfoService.updateById(driverCarInfo);
//                    }
//                }
//                //编辑
//                else {
                if (StringUtils.isEmpty(driverCarInfo.getId())) {
                    driverCarInfo.setId(IdGenerator.generateUUID());
                    driverCarInfo.setDriverId(driverViewInfo.getId());
                    driverCarInfoService.insert(driverCarInfo);
                } else {
                    driverCarInfoService.updateById(driverCarInfo);
                }
//                }
            }
        }
        //收款人账户信息编辑
        List<DriverPayeeInfo> driverPayeeInfoList = driverViewInfo.getDriverPayeeInfoList();
        if (!CollectionUtils.isEmpty(driverPayeeInfoList)) {
            for (DriverPayeeInfo driverPayeeInfo : driverPayeeInfoList) {
                //覆盖
//                if ("1".equals(driverViewInfo.getCover())){
//                    DriverPayeeInfo driverPayeeInfo1=driverPayeeInfoService.selectOne(new EntityWrapper<DriverPayeeInfo>()
//                            .eq("driver_id",driverViewInfo.getId())
//                            .eq("delete_flag","0"));
//                    if (StringUtils.isEmpty(driverPayeeInfo1.getId())) {
//                        driverPayeeInfo.setId(IdGenerator.generateUUID());
//                        driverPayeeInfo.setDriverId(driverViewInfo.getId());
//                        driverPayeeInfoService.insert(driverPayeeInfo);
//                    }
//                    else {
//                        driverPayeeInfo.setId(driverPayeeInfo1.getId());
//                        driverPayeeInfoService.updateById(driverPayeeInfo);
//                    }
//                }
//                //编辑
//                else {
                if (StringUtils.isEmpty(driverPayeeInfo.getId())) {
                    driverPayeeInfo.setId(IdGenerator.generateUUID());
                    driverPayeeInfo.setDriverId(driverViewInfo.getId());
                    driverPayeeInfoService.insert(driverPayeeInfo);
                } else {
                    driverPayeeInfoService.updateById(driverPayeeInfo);
                }
//                }
            }
        }
        return "OK";
    }


    /**
     * 司机管理页面列表
     *
     * @param driverViewInfo
     * @return
     */
    @Override
    public Page<DriverViewInfo> selectDriverInfoPage(DriverViewInfo driverViewInfo) {
        Map<String, Object> pageView = new HashMap<>();
        pageView.put("startRecord", (driverViewInfo.getCurrentPage() - 1)
                * driverViewInfo.getPageSize());
        //公司id
        pageView.put("compId", driverViewInfo.getCompId());
        pageView.put("commonId", driverViewInfo.getCommonId());
        pageView.put("pcFlag", driverViewInfo.getPcFlag());
        pageView.put("searchType", driverViewInfo.getSearchType());
        pageView.put("residentCityProvincial", driverViewInfo.getResidentCityProvincial());
        pageView.put("residentCityMunicipal", driverViewInfo.getResidentCityMunicipal());
        pageView.put("searchKeyWord", driverViewInfo.getSearchKeyWord());
        pageView.put("pageSize", driverViewInfo.getPageSize());
        pageView.put("currentPage", driverViewInfo.getCurrentPage());
        // 查询司机总数
        Integer dataCount = baseMapper.getCountByCondition(pageView);
        List<DriverViewInfo> dataList = baseMapper.getListByCondition(pageView);
        dataList.forEach(driverViewInfo1 -> {
            driverViewInfo1.setDriverCarInfoList(driverCarInfoService.selectList(new EntityWrapper<DriverCarInfo>()
                    .eq(DriverCarInfo.QueryFiles.DRIVER_ID, driverViewInfo1.getId())
                    .eq(DriverCarInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0)));
            driverViewInfo1.setDriverPayeeInfoList(driverPayeeInfoService.selectList(new EntityWrapper<DriverPayeeInfo>()
                    .eq(DriverPayeeInfo.QueryFiles.DRIVER_ID, driverViewInfo1.getId())
                    .eq(DriverPayeeInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0)));
        });
        Page<DriverViewInfo> page = new Page<>();
        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
        page.setTotal(dataCount == null ? 0 : dataCount);
        page.setCurrent(driverViewInfo.getCurrentPage());
        page.setSize(driverViewInfo.getPageSize());
        return page;
    }

    /**
     * 查看司机信息
     *
     * @param id
     * @return
     */
    @Override
    public DriverViewInfo getDriver(String id) {
        //查看司机信息
        DriverViewInfo driverViewInfo = this.selectById(id);
        //查看货车信息
        List<DriverCarInfo> driverCarInfoList = driverCarInfoService.selectList(new EntityWrapper<DriverCarInfo>()
                .eq(DriverCarInfo.QueryFiles.DRIVER_ID, id));
        driverViewInfo.setDriverCarInfoList(driverCarInfoList);
        //查看收款账户信息
        List<DriverPayeeInfo> driverPayeeInfoList = driverPayeeInfoService.selectList(new EntityWrapper<DriverPayeeInfo>()
                .eq(DriverPayeeInfo.QueryFiles.DRIVER_ID, id));
        driverViewInfo.setDriverPayeeInfoList(driverPayeeInfoList);
        return driverViewInfo;
    }

    /**
     * 删除司机信息
     *
     * @param id
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteDriver(String id) {
        //删除司机信息
        DriverViewInfo driverViewInfo = this.selectById(id);
        this.deleteById(driverViewInfo.getId());
        //删除货车信息
        List<DriverCarInfo> driverCarInfoList = driverCarInfoService.selectList(new EntityWrapper<DriverCarInfo>()
                .eq(DriverCarInfo.QueryFiles.DRIVER_ID, id));
        if (!CollectionUtils.isEmpty(driverCarInfoList)) {
            for (DriverCarInfo driverCarInfo : driverCarInfoList) {
                driverCarInfoService.deleteById(driverCarInfo.getId());
            }
        }
        //删除收款账户信息
        List<DriverPayeeInfo> driverPayeeInfoList = driverPayeeInfoService.selectList(new EntityWrapper<DriverPayeeInfo>()
                .eq(DriverPayeeInfo.QueryFiles.DRIVER_ID, id));
        if (!CollectionUtils.isEmpty(driverPayeeInfoList)) {
            for (DriverPayeeInfo driverPayeeInfo : driverPayeeInfoList) {
                driverPayeeInfoService.deleteById(driverPayeeInfo.getId());
            }
        }
    }

    /**
     * 更改状态
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String editDisableInfo(DriverViewInfo driverViewInfo) {
        DriverViewInfo driverViewInfos = this.selectById(driverViewInfo.getId());
        //查询司机信息
        if (driverViewInfos != null) {
            //已禁用状态
            if (StatusEnum.DISABLED.getFlag().equals(driverViewInfo.getDisableStatusFlag())) {
                driverViewInfos.setDisableStatusFlag(StatusEnum.NOT_DISABLE.getFlag());
            }
            //未禁用状态
            else {
                driverViewInfos.setDisableStatusFlag(StatusEnum.DISABLED.getFlag());
                driverViewInfos.setDisableReasons(driverViewInfo.getDisableReasons());
            }
            //更改司机信息
            this.updateById(driverViewInfos);
            return "OK";
        }
        return "NG";
    }

    /**
     * 司机姓名电话下拉列表
     *
     * @param compId
     * @return
     */
    @Override
    public List<DriverViewInfo> selectDriverName(String compId) {
        List<DriverViewInfo> driverViewInfoList = this.selectList(new EntityWrapper<DriverViewInfo>()
                .eq(DriverViewInfo.QueryFiles.COMP_ID, compId).eq(DriverViewInfo.QueryFiles.DISABLE_STATUS_FLAG, NumberConstant.CONSTANT0).eq(DriverViewInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
        return driverViewInfoList;
    }

    /**
     * 根据姓名查电话、根据电话查姓名
     *
     * @param id
     * @return
     */
    @Override
    public DriverCarInfo selectDriverDetail(String id) {
        DriverCarInfo driverCarInfo = driverCarInfoService.selectOne(new EntityWrapper<DriverCarInfo>()
                .eq(DriverCarInfo.QueryFiles.DRIVER_ID, id).eq(DriverViewInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
        return driverCarInfo;
    }

    /**
     * 审核
     *
     * @param driverViewInfo
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String examine(DriverViewInfo driverViewInfo) {
        //查询司机列表
        DriverViewInfo driverViewInfo1 = this.selectById(driverViewInfo.getId());
        CommonUser commonUser = commonUserService.selectOne(new EntityWrapper<CommonUser>().eq("phone", driverViewInfo1.getDriverPhone()));

        if (driverViewInfo1 != null) {
            //通过
            if (driverViewInfo.getFlag() == 1) {
                driverViewInfo1.setAuthenticationStatusKey(StatusEnum.IDENTITY_COMPLETED.getFlag());
                driverViewInfo1.setAuthenticationStatus(StatusEnum.IDENTITY_COMPLETED.getName());
                geTuiUtils.pushByCid("审核通知", "您的司机认证申请已审核通过", commonUser.getId());
                UnimallMessage messageDO = new UnimallMessage();
                messageDO.setAdminId(commonUser.getId());
                messageDO.setCustomer(commonUser.getUserName());
                messageDO.setOperation("审核通知");
                messageDO.setResult("您的司机认证申请已审核通过");
                messageDO.setGmtUpdate(new java.util.Date());
                messageDO.setGmtCreate(new Date());
                messageDO.setTaskId(IdGenerator.generateUUID());
                messageDO.setCompanyId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
                messageDO.setPath("XXXXX");
                webSocket.sendOneMessage(messageDO);
            }
            //驳回
            else {
                driverViewInfo1.setAuthenticationStatusKey(StatusEnum.IDENTITY_FAILED.getFlag());
                driverViewInfo1.setAuthenticationStatus(StatusEnum.IDENTITY_FAILED.getName());
                geTuiUtils.pushByCid("驳回通知", "您的司机认证申请已被驳回", commonUser.getId());
                UnimallMessage messageDO = new UnimallMessage();
                messageDO.setAdminId(commonUser.getId());
                messageDO.setCustomer(commonUser.getUserName());
                messageDO.setOperation("驳回通知");
                messageDO.setResult("您的司机认证申请已被驳回");
                messageDO.setGmtUpdate(new java.util.Date());
                messageDO.setGmtCreate(new Date());
                messageDO.setTaskId(IdGenerator.generateUUID());
                messageDO.setCompanyId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
                messageDO.setPath("XXXXX");
                webSocket.sendOneMessage(messageDO);
            }
            //更改司机信息
            this.updateById(driverViewInfo1);
            return "OK";
        }
        return "NG";
    }


    /**
     * 查手机号是否存在
     *
     * @param driverViewInfo
     */
    @Override
    public DriverViewInfo selectPhone(DriverViewInfo driverViewInfo) throws AppServiceException {
        //未覆盖的手机号
        DriverViewInfo driverViewInfo1 = this.selectOne(new EntityWrapper<DriverViewInfo>()
                .eq("driver_phone", driverViewInfo.getDriverPhone())
                .eq("cover", "0")
                .eq(DriverViewInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
        if (driverViewInfo1 != null) {
            throw new AppServiceException(ExceptionDefinition.PHONE_NUMBER_ALREADY_EXISTS);
        }
        return driverViewInfo1;
    }

    /**
     * 更改手机号
     *
     * @param driverViewInfo
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String modifyPhone(DriverViewInfo driverViewInfo) {
        DriverViewInfo driverViewInfo1 = this.selectOne(new EntityWrapper<DriverViewInfo>()
                .eq("driver_phone", driverViewInfo.getDriverPhone())
                .eq("delete_flag", "0"));
        //查询手机号存在，将其覆盖
        if (driverViewInfo1 != null) {
            driverViewInfo1.setCover("1");
            this.updateById(driverViewInfo1);
        }
        //修改身份认证信息
        this.updateById(driverViewInfo);
        return "OK";
    }

    public void DBConnection() {
        try {
            //加载驱动程序
            Class.forName(driverClassName);
            coon = (Connection) DriverManager.getConnection(url, username, password);
            if (!coon.isClosed()) {
                System.out.println("成功连接数据库！");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void close() {
        try {
            this.coon.close();
            System.out.println("成功关闭数据库连接！");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("关闭数据库连接异常！");
        }
    }

    //    查询s_user表
    public String excSelect(String sql, Connection coon) {
        try {
            Statement stmt = (Statement) coon.createStatement();
            ResultSet rs = (ResultSet) stmt.executeQuery(sql);//得到的是结果的集合

            while (rs.next()) {
                String id = rs.getString("id");
                if (id != null && !id.isEmpty()) {
                    return id;
                }
            }
            stmt.close();
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    //    更改数据
    public void excUpdate(String sql, Connection coon) {
        try {
            PreparedStatement prestmt = (PreparedStatement) coon.prepareStatement(sql);
            prestmt.executeUpdate();
            System.out.println("更改数据成功！");
            prestmt.close();
        } catch (Exception e) {
            System.out.println("粮信更改数据异常！");
            e.printStackTrace();
        }
    }

    /**
     * 根据用户id查看司机
     * @param
     */
    @Override
    public DriverViewInfo getInfo(String commonId) throws ServiceException{
        //判断司机是否存在
        DriverViewInfo driverViewInfo =
                this.selectOne(new EntityWrapper<DriverViewInfo>()
                        .eq(DriverViewInfo.QueryFiles.COMMON_ID, commonId)
                        .eq("cover", NumberConstant.CONSTANT0)
                        .eq(DriverViewInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
        if (driverViewInfo != null) {
            //判断司机是否存在
            DriverViewInfo driverViewInfo1 =
                    this.selectOne(new EntityWrapper<DriverViewInfo>()
                            .eq(DriverViewInfo.QueryFiles.COMMON_ID, commonId)
                            .eq("authentication_status_key", "7")
                            .eq("cover", NumberConstant.CONSTANT0)
                            .eq(DriverViewInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
            //身份审核中
            if (driverViewInfo1 == null) {
                throw new AppServiceException(ExceptionDefinition.DRIVER_IS_BEING_AUDITED);
            }
            DriverViewInfo driverViewInfo2 =
                    this.selectOne(new EntityWrapper<DriverViewInfo>()
                            .eq(DriverViewInfo.QueryFiles.COMMON_ID, commonId)
                            .eq("authentication_status_key", "7")
                            .eq("cover", NumberConstant.CONSTANT0)
                            .eq("default_flag", "1")
                            .eq(DriverViewInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
            //有默认
            if (driverViewInfo2 != null) {
                return driverViewInfo2;
            } else {
                return driverViewInfo1;
            }

        }
        //司机不存在
        else {
            throw new AppServiceException(ExceptionDefinition.UNAUTHENTICATED_GRAIN_MERCHANT_DRIVER);
        }
    }
}
