Pu Zhibing
3 天以前 25cf266e99714ac5d428e66b40ce272325c91dd8
ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
@@ -7,42 +7,34 @@
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.ShiroKit;
import com.stylefeng.guns.core.util.*;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.core.util.WoUtil;
import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample;
import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq;
import com.stylefeng.guns.modular.system.controller.util.Base64Util;
import com.stylefeng.guns.modular.system.dao.DriverPunishMapper;
import com.stylefeng.guns.modular.system.dao.DriverTrainMapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.system.util.ExcelExportUtil;
import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.resp.AllocationResp;
import org.apache.commons.lang.time.DateUtils;
import org.apache.poi.hdf.extractor.TC;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.Model;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -129,7 +121,7 @@
            endTime = timeArray[1];
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(tComplaintService.getComplaintList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,userName,userPhone,driverPhone,isHandle,driverId));
        page.setRecords(tComplaintService.getComplaintList(page, ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, userName, userPhone, driverPhone, isHandle, driverId));
        return super.packForBT(page);
    }
    /**
@@ -154,22 +146,22 @@
    @RequestMapping("/tDriver_add")
    public String tDriverAdd(Model model) {
        List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2));
        model.addAttribute("companyList",companyList);
        Integer roleType = ShiroKit.getUser().getRoleType();
        model.addAttribute("roleType",roleType);
        if (2 == roleType){
        model.addAttribute("companyList", companyList);
        Integer roleType = ShiroExtUtil.getUser().getRoleType();
        model.addAttribute("roleType", roleType);
        if (2 == roleType) {
            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>()
                    .eq("type", 3)
                    .eq("superiorId",ShiroKit.getUser().getObjectId())
                    .notIn("state",1)
                    .notIn("flag",3));
            model.addAttribute("franchiseeList",franchiseeList);
        }else{
            model.addAttribute("franchiseeList",null);
                    .eq("superiorId", ShiroExtUtil.getUser().getObjectId())
                    .notIn("state", 1)
                    .notIn("flag", 3));
            model.addAttribute("franchiseeList", franchiseeList);
        } else {
            model.addAttribute("franchiseeList", null);
        }
        //查询当前用户所属分公司/加盟商
        model.addAttribute("objectName",tCompanyService.selectById(ShiroKit.getUser().getObjectId()).getName());
        model.addAttribute("objectName", tCompanyService.selectById(ShiroExtUtil.getUser().getObjectId()).getName());
        //查询线路列表
        List<TLine> lineList = itLineService.selectList(new EntityWrapper<TLine>().eq("state", 1));
@@ -232,21 +224,21 @@
    @RequestMapping("/tDriver_update/{tDriverId}")
    public String tDriverUpdate(@PathVariable Integer tDriverId, Model model) {
        TDriver tDriver = tDriverService.selectById(tDriverId);
        model.addAttribute("item",tDriver);
        model.addAttribute("item", tDriver);
        LogObjectHolder.me().set(tDriver);
        Integer roleType = ShiroKit.getUser().getRoleType();
        model.addAttribute("roleType",roleType);
        model.addAttribute("objectName",tCompanyService.selectById(ShiroKit.getUser().getObjectId()).getName());
        if (1 == roleType){
            List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2).ne("flag",3));
            model.addAttribute("companyList",companyList);
            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3).eq("superiorId",tDriver.getCompanyId()));
            model.addAttribute("franchiseeList",franchiseeList);
        }else if (2 == roleType){
            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3).eq("superiorId",ShiroKit.getUser().getObjectId()));
            model.addAttribute("franchiseeList",franchiseeList);
        Integer roleType = ShiroExtUtil.getUser().getRoleType();
        model.addAttribute("roleType", roleType);
        model.addAttribute("objectName", tCompanyService.selectById(ShiroExtUtil.getUser().getObjectId()).getName());
        if (1 == roleType) {
            List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2).ne("flag", 3));
            model.addAttribute("companyList", companyList);
            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3).eq("superiorId", tDriver.getCompanyId()));
            model.addAttribute("franchiseeList", franchiseeList);
        } else if (2 == roleType) {
            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3).eq("superiorId", ShiroExtUtil.getUser().getObjectId()));
            model.addAttribute("franchiseeList", franchiseeList);
        }
        //查询平台ID
@@ -572,10 +564,10 @@
            endTime = timeArray[1];
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        if (ShiroKit.getUser().getRoleType() != 1){
        if (ShiroExtUtil.getUser().getRoleType() != 1) {
            page.setRecords(null);
        }else{
            page.setRecords(tDriverService.getAuthDriverList(page,beginTime,endTime,companyName,phone,account,addType,authState));
        } else {
            page.setRecords(tDriverService.getAuthDriverList(page, beginTime, endTime, companyName, phone, account, addType, authState));
        }
        return super.packForBT(page);
    }
@@ -599,7 +591,7 @@
            endTime = timeArray[1];
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(tDriverService.getDriverList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,companyName,phone,name,addType,authState));
        page.setRecords(tDriverService.getDriverList(page, ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, companyName, phone, name, addType, authState));
        return super.packForBT(page);
    }
@@ -624,7 +616,7 @@
        }*/
        //2020-08-21:新需求,已被绑定的车辆可以被继续绑定
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(tDriverService.getCanSelectCarList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),null,carLicensePlate,brandName,modelName,color,serverStr));
        page.setRecords(tDriverService.getCanSelectCarList(page, ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), null, carLicensePlate, brandName, modelName, color, serverStr));
        return super.packForBT(page);
    }
@@ -709,32 +701,32 @@
            tDriver.setAddType(2);
            tDriver.setIsPlatCar(1);
            tDriver.setAuthState(2);
        }else if (2 == roleType){  //分公司
            if (SinataUtil.isNotEmpty(ShiroKit.getUser().getObjectId())){
                tDriver.setCompanyId(ShiroKit.getUser().getObjectId());
        }else if (2 == roleType) {  //分公司
            if (SinataUtil.isNotEmpty(ShiroExtUtil.getUser().getObjectId())) {
                tDriver.setCompanyId(ShiroExtUtil.getUser().getObjectId());
            }
            if (SinataUtil.isNotEmpty(franchiseeId)){
            if (SinataUtil.isNotEmpty(franchiseeId)) {
                tDriver.setFranchiseeId(franchiseeId);
            }
            tDriver.setAddType(3);
            tDriver.setIsPlatCar(2);
            tDriver.setAuthState(1);
            tDriver.setAddObjectId(ShiroKit.getUser().getObjectId());
        }else if (3 == roleType){  //加盟商
            TCompany tCompany = tCompanyService.selectById(ShiroKit.getUser().getObjectId());
            if (SinataUtil.isNotEmpty(tCompany)){
            tDriver.setAddObjectId(ShiroExtUtil.getUser().getObjectId());
        }else if (3 == roleType) {  //加盟商
            TCompany tCompany = tCompanyService.selectById(ShiroExtUtil.getUser().getObjectId());
            if (SinataUtil.isNotEmpty(tCompany)) {
                tDriver.setCompanyId(tCompany.getSuperiorId());
            }
            if (SinataUtil.isNotEmpty(ShiroKit.getUser().getObjectId())){
                tDriver.setFranchiseeId(ShiroKit.getUser().getObjectId());
            if (SinataUtil.isNotEmpty(ShiroExtUtil.getUser().getObjectId())) {
                tDriver.setFranchiseeId(ShiroExtUtil.getUser().getObjectId());
            }
            tDriver.setAddType(4);
            tDriver.setIsPlatCar(2);
            tDriver.setAuthState(1);
            tDriver.setAddObjectId(ShiroKit.getUser().getObjectId());
            tDriver.setAddObjectId(ShiroExtUtil.getUser().getObjectId());
        }
        tDriver.setInsertTime(new Date());
        tDriver.setInsertUser(ShiroKit.getUser().getId());
        tDriver.setInsertUser(ShiroExtUtil.getUser().getId());
//        tDriver.setPassword(MD5Util.encrypt(tDriver.getPassword()));
        tDriver.setPassword(ShiroKit.md5(tDriver.getPassword(), "SA;d5#"));
@@ -864,24 +856,24 @@
                tDriver.setCompanyId(company.getId());
                tDriver.setFranchiseeId(franchiseeId);
            }
        }else if (2 == roleType){  //分公司
            if (SinataUtil.isNotEmpty(ShiroKit.getUser().getObjectId())){
                tDriver.setCompanyId(ShiroKit.getUser().getObjectId());
        }else if (2 == roleType) {  //分公司
            if (SinataUtil.isNotEmpty(ShiroExtUtil.getUser().getObjectId())) {
                tDriver.setCompanyId(ShiroExtUtil.getUser().getObjectId());
            }
            if (SinataUtil.isNotEmpty(franchiseeId)){
            if (SinataUtil.isNotEmpty(franchiseeId)) {
                tDriver.setFranchiseeId(franchiseeId);
            }
        }else if (3 == roleType){  //加盟商
            TCompany tCompany = tCompanyService.selectById(ShiroKit.getUser().getObjectId());
            if (SinataUtil.isNotEmpty(tCompany)){
        }else if (3 == roleType) {  //加盟商
            TCompany tCompany = tCompanyService.selectById(ShiroExtUtil.getUser().getObjectId());
            if (SinataUtil.isNotEmpty(tCompany)) {
                tDriver.setCompanyId(tCompany.getSuperiorId());
            }
            if (SinataUtil.isNotEmpty(ShiroKit.getUser().getObjectId())){
                tDriver.setFranchiseeId(ShiroKit.getUser().getObjectId());
            if (SinataUtil.isNotEmpty(ShiroExtUtil.getUser().getObjectId())) {
                tDriver.setFranchiseeId(ShiroExtUtil.getUser().getObjectId());
            }
        }
        tDriver.setUpdateTime(new Date());
        tDriver.setUpdateUser(ShiroKit.getUser().getId());
        tDriver.setUpdateUser(ShiroExtUtil.getUser().getId());
//        tDriver.setPassword(MD5Util.encrypt(tDriver.getPassword()));
        if(ToolUtil.isEmpty(tDriver.getPassword())){
            tDriver.setPassword(obj.getPassword());
@@ -933,7 +925,7 @@
        obj.setEmergencyContactPhone(tDriver.getEmergencyContactPhone());
        obj.setEmergencyContactAddress(tDriver.getEmergencyContactAddress());
        obj.setUpdateTime(new Date());
        obj.setUpdateUser(ShiroKit.getUser().getId());
        obj.setUpdateUser(ShiroExtUtil.getUser().getId());
        tDriverService.updateAllColumnById(obj);
        //删除业务
@@ -984,9 +976,9 @@
        // 首行【封装】
        List<String> shellList = new ArrayList<String>();
        if (ShiroKit.getUser().getRoleType() == 1){
        if (ShiroExtUtil.getUser().getRoleType() == 1) {
            title = "平台导入司机模板";
            shellList.add("司机名称");
            shellList.add("所属机构[平台司机/加盟司机]");
            shellList.add("所属分公司[提示:加盟司机选填]");
@@ -1006,9 +998,9 @@
            shellList.add("经营业务:包车[是/否]");
            shellList.add("登录账号[手机号]");
            shellList.add("登录密码[密码长度为6-18]");
        }else if (ShiroKit.getUser().getRoleType() == 2){
        } else if (ShiroExtUtil.getUser().getRoleType() == 2) {
            title = "分公司导入司机模板";
            shellList.add("司机名称");
            shellList.add("所属加盟商[选填]");
            shellList.add("性别[男/女]");
@@ -1026,9 +1018,9 @@
            shellList.add("经营业务:包车[是/否]");
            shellList.add("登录账号[手机号]");
            shellList.add("登录密码[密码长度为6-18]");
        }else if (ShiroKit.getUser().getRoleType() == 3){
        } else if (ShiroExtUtil.getUser().getRoleType() == 3) {
            title = "加盟商导入司机模板";
            shellList.add("司机名称");
            shellList.add("性别[男/女]");
            shellList.add("驾驶证号码");
@@ -1067,15 +1059,15 @@
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        MultipartFile file = (MultipartFile) multipartRequest.getFile("myfile");
        try {
            if (ShiroKit.getUser().getRoleType() == 1){
            if (ShiroExtUtil.getUser().getRoleType() == 1) {
                Workbook book = WoUtil.ImportFile(file);
                Sheet sh = book.getSheetAt(0);   //获取到第一个表
                for (int i = 1; i <= sh.getLastRowNum(); i++) {
                    Row row = sh.getRow(i);
                    Cell cell0 = row.getCell(0);  //司机名称
                    String zero = null;
                    if (SinataUtil.isNotEmpty(cell0)){
                    if (SinataUtil.isNotEmpty(cell0)) {
                        zero = String.valueOf(cell0.getStringCellValue()).trim();
                    }
@@ -1290,10 +1282,10 @@
                        driver.setState(2);
                        driver.setAuthState(2);
                        driver.setFlag("1");
                        driver.setInsertUser(ShiroKit.getUser().getId());
                        driver.setInsertUser(ShiroExtUtil.getUser().getId());
                        driver.setInsertTime(new Date());
                        driver.setAddType(2);
                        driver.setAddObjectId(ShiroKit.getUser().getObjectId());
                        driver.setAddObjectId(ShiroExtUtil.getUser().getObjectId());
                        if(SinataUtil.isNotEmpty(eight)){
                            driver.setDriverAddress(eight);
                        }
@@ -1336,7 +1328,7 @@
                            itDriverServiceService.insert(service);
                        }
                        //添加包车服务模式
                        if ("是".equals(sixteen)){
                        if ("是".equals(sixteen)) {
                            TDriverService service = new TDriverService();
                            service.setDriverId(driver.getId());
                            service.setType(6);
@@ -1344,15 +1336,15 @@
                        }
                    }
                }
            }else if (ShiroKit.getUser().getRoleType() == 2){
            } else if (ShiroExtUtil.getUser().getRoleType() == 2) {
                Workbook book = WoUtil.ImportFile(file);
                Sheet sh = book.getSheetAt(0);   //获取到第一个表
                for (int i = 1; i <= sh.getLastRowNum(); i++) {
                    Row row = sh.getRow(i);
                    Cell cell0 = row.getCell(0);  //司机名称
                    String zero = null;
                    if (SinataUtil.isNotEmpty(cell0)){
                    if (SinataUtil.isNotEmpty(cell0)) {
                        zero = String.valueOf(cell0.getStringCellValue()).trim();
                    }
@@ -1504,7 +1496,7 @@
                            return new ErrorTip(500, "登录密码格式不正确");
                        }
                        //查找平台公司
                        Integer companyId = ShiroKit.getUser().getObjectId();
                        Integer companyId = ShiroExtUtil.getUser().getObjectId();
                        Integer franchiseeId = 0;
                        //判断所属分公司是否存在
                        if (SinataUtil.isNotEmpty(one)){
@@ -1535,10 +1527,10 @@
                        driver.setState(1);
                        driver.setAuthState(1);
                        driver.setFlag("1");
                        driver.setInsertUser(ShiroKit.getUser().getId());
                        driver.setInsertUser(ShiroExtUtil.getUser().getId());
                        driver.setInsertTime(new Date());
                        driver.setAddType(3);
                        driver.setAddObjectId(ShiroKit.getUser().getObjectId());
                        driver.setAddObjectId(ShiroExtUtil.getUser().getObjectId());
                        if (SinataUtil.isNotEmpty(six)){
                            driver.setDriverAddress(six);
                        }
@@ -1580,24 +1572,24 @@
                            itDriverServiceService.insert(service);
                        }
                        //添加包车服务模式
                        if ("是".equals(fourteen)){
                        if ("是".equals(fourteen)) {
                            TDriverService service = new TDriverService();
                            service.setDriverId(driver.getId());
                            service.setType(6);
                            itDriverServiceService.insert(service);
                        }
                    }
                }
            }else if (ShiroKit.getUser().getRoleType() == 3){
            } else if (ShiroExtUtil.getUser().getRoleType() == 3) {
                Workbook book = WoUtil.ImportFile(file);
                Sheet sh = book.getSheetAt(0);   //获取到第一个表
                for (int i = 1; i <= sh.getLastRowNum(); i++) {
                    Row row = sh.getRow(i);
                    Cell cell0 = row.getCell(0);  //司机名称
                    String zero = null;
                    if (SinataUtil.isNotEmpty(cell0)){
                    if (SinataUtil.isNotEmpty(cell0)) {
                        zero = String.valueOf(cell0.getStringCellValue()).trim();
                    }
@@ -1745,7 +1737,7 @@
                        //查找平台公司
                        Integer companyId = 0;
                        Integer franchiseeId = 0;
                        TCompany franchisee = itCompanyService.selectById(ShiroKit.getUser().getObjectId());
                        TCompany franchisee = itCompanyService.selectById(ShiroExtUtil.getUser().getObjectId());
                        if (SinataUtil.isNotEmpty(franchisee)){
                            companyId = franchisee.getSuperiorId();
                            franchiseeId = franchisee.getId();
@@ -1775,10 +1767,10 @@
                        driver.setState(1);
                        driver.setAuthState(1);
                        driver.setFlag("1");
                        driver.setInsertUser(ShiroKit.getUser().getId());
                        driver.setInsertUser(ShiroExtUtil.getUser().getId());
                        driver.setInsertTime(new Date());
                        driver.setAddType(4);
                        driver.setAddObjectId(ShiroKit.getUser().getObjectId());
                        driver.setAddObjectId(ShiroExtUtil.getUser().getObjectId());
                        if (SinataUtil.isNotEmpty(five)){
                            driver.setDriverAddress(five);
                        }
@@ -1895,7 +1887,7 @@
     */
    @RequestMapping(value = "/outDriver")
    public void outDriver(HttpServletRequest request, HttpServletResponse response) {
        List<Map<String,Object>> listMap = tDriverService.getDriverListNoPage(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId());
        List<Map<String, Object>> listMap = tDriverService.getDriverListNoPage(ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId());
        // 表格数据【封装】
        List<List<String>> dataList = new ArrayList<>();
@@ -2053,14 +2045,6 @@
            income.setInsertTime(new Date());
            incomeService.insert(income);
            String allocationReq = createAllocationReq(1, tDriver.getId(), 2, complaintDeductmoney.getMoney().doubleValue());
            if("error".equals(allocationReq)){
                return ResultUtil.error("该司机未进件");
            }
            if(!"ok".equals(allocationReq)){
                return ResultUtil.error(allocationReq);
            }
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
@@ -2068,47 +2052,4 @@
        return ResultUtil.success();
    }
    @Autowired
    private ITEnterpriseWithdrawalService tEnterpriseWithdrawalService;
    @Autowired
    private IUserWithdrawalService userWithdrawalService;
    public String createAllocationReq(Integer companyId,Integer userId,int type,double money){
        List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId));
        TDriver tUser = tDriverService.selectById(userId);
        List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone()));
        if(userWithdrawals.size()==0){
            return "error";
        }
        AllocationReq allocationReq= new AllocationReq();
        allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        if(type==1){
            allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
        }else {
            allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
        }
        money=money*100;
        allocationReq.setAmount((int)money);
        allocationReq.setProductName("分账");
        allocationReq.setProductCount(1);
        allocationReq.setOrderNo(ToolUtil.getRandomString(32));
        allocationReq.setOrderAmount(1l);
        try {
            AllocationResp allocationResp = AllocationExample.create(allocationReq);
            System.out.println(allocationResp);
            return "ok";
        } catch (UpyztException e) {
            e.printStackTrace();
            return e.getMessage();
        }
    }
}