Pu Zhibing
3 天以前 0a8d28436b2f7229ecdf40c6b003902002c8947f
ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/AppDriverRideController.java
@@ -3,14 +3,27 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.base.tips.ErrorTip;
import com.stylefeng.guns.core.beetl.ShiroExtUtil;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.shiro.ShiroUser;
import com.stylefeng.guns.modular.shunfeng.model.AppDriverRide;
import com.stylefeng.guns.modular.shunfeng.service.IAppDriverRideService;
import com.stylefeng.guns.modular.system.model.TCarBrand;
import com.stylefeng.guns.modular.system.model.TCompany;
import com.stylefeng.guns.modular.system.model.TUser;
import com.stylefeng.guns.modular.system.model.User;
import com.stylefeng.guns.modular.system.service.ITCarBrandService;
import com.stylefeng.guns.modular.system.service.ITCompanyService;
import com.stylefeng.guns.modular.system.service.ITUserService;
import com.stylefeng.guns.modular.system.service.IUserService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.EmployeeUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.UserUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.QYTUserInfo;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.SaveStaffNode;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.SaveStaffNodeRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -21,6 +34,8 @@
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
/**
 * 顺风车司机控制器
@@ -34,10 +49,21 @@
    @Autowired
    private IAppDriverRideService appDriverRideService;
    @Autowired
    private ITUserService userService;
    @Autowired
    private IUserService sysUserService;
    @Autowired
    private ShiroExtUtil shiroExtUtil;
    @Autowired
    private ITCarBrandService carBrandService;
    @Autowired
    private ITCompanyService itCompanyService;
    /**
     * 跳转到顺风车司机首页
@@ -153,6 +179,59 @@
        if(appDriverRide.getState()!=null && appDriverRide.getState()==2){//顺风车司机通过审核之后需要把id绑定到用户表中
            userInfo.setIsDriverRide(1);//是否为顺风车司机(0否,1是)
            userService.updateById(userInfo);
            TCompany tCompany = itCompanyService.selectById(appDriverRide1.getCompanyId());
            List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(userInfo.getPhone(), tCompany.getEnterCode());
            Long empId = null;
            Integer empnew = null;
            if(null == userInfoByPhone || userInfoByPhone.size() == 0){
                ShiroUser user = shiroExtUtil.getUser();
                User user2 = sysUserService.selectById(user.getId());
                SaveStaffNodeRequest request = new SaveStaffNodeRequest();
                request.setMobile(user2.getPhone());
                request.setEntercode(tCompany.getEnterCode());
                request.setEmpName(userInfo.getName());
                request.setEmpNickname(userInfo.getName());
                request.setLoginNo(userInfo.getPhone());
                request.setEmpSex(userInfo.getSex() == 1 ? "男" : "女");
                request.setMphone(userInfo.getPhone());
                request.setEmail(userInfo.getPhone() + "@qyt.com");
                request.setDeptId(0);
                request.setPositionId(1);
                request.setSuperLevel(0);
                request.setHideMobile(0);
                ResultUtil<SaveStaffNode> resultUtil = EmployeeUtil.saveStaffNode(request);
                if(200 != resultUtil.getStatus()){
                    return new ErrorTip(resultUtil.getStatus(), resultUtil.getMsg());
                }
                SaveStaffNode saveStaffNode = resultUtil.getData();
                empId = saveStaffNode.getEmpId();
                empnew = 1;
            }else{
                empId = userInfoByPhone.get(0).getEmpId();
                empnew = 0;
            }
            appDriverRide.setEmpId(empId);
            appDriverRide.setEntercode(tCompany.getEnterCode());
            appDriverRide.setEnterId(Long.valueOf(tCompany.getEnterCode()));
            appDriverRide.setEmpnew(empnew);
            //编写异步延迟处理中台账号延迟创建的问题
            if(0 == empId){
                Timer timer = new Timer();
                String finalEnterCode = tCompany.getEnterCode();
                timer.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(userInfo.getPhone(), finalEnterCode);
                        if(null != userInfoByPhone && userInfoByPhone.size() > 0){
                            Long empId1 = userInfoByPhone.get(0).getEmpId();
                            appDriverRide.setEmpId(empId1);
                            appDriverRideService.updateById(appDriverRide);
                        }
                    }
                },120*1000);
            }
        }else {
            if(certificationImg!=null){
                userInfo.setCertificationImg(certificationImg);