liujie
2023-08-10 03552ae04973a224b5ccfce34e64999ea6a13d44
driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java
@@ -1,11 +1,18 @@
package com.supersavedriving.driver.modular.system.api;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.supersavedriving.driver.modular.system.model.Driver;
import com.supersavedriving.driver.modular.system.model.DriverBank;
import com.supersavedriving.driver.modular.system.model.Edition;
import com.supersavedriving.driver.modular.system.model.JoiningRequirements;
import com.supersavedriving.driver.modular.system.service.*;
import com.supersavedriving.driver.modular.system.util.MallBook.model.Register;
import com.supersavedriving.driver.modular.system.util.MallBook.util.TrhRequest;
import com.supersavedriving.driver.modular.system.util.PayMoneyUtil;
import com.supersavedriving.driver.modular.system.util.huawei.OBSUtil;
import com.supersavedriving.driver.modular.system.util.huawei.SMSUtil;
import com.supersavedriving.driver.modular.system.util.juhe.OCRUtil;
import com.supersavedriving.driver.modular.system.warpper.*;
import com.supersavedriving.driver.core.util.ToolUtil;
import com.supersavedriving.driver.modular.system.util.RedisUtil;
@@ -24,10 +31,13 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -77,6 +87,12 @@
    @Autowired
    private IEditionService editionService;
    @Autowired
    private IDriverBankService driverBankService;
    @Autowired
    private IAgentService agentService;
@@ -89,7 +105,7 @@
    })
    public ResponseWarpper<List<OpenCityWarpper>> queryCityList(){
        try {
            List<OpenCityWarpper> list = branchOfficeService.queryOpenCity();
            List<OpenCityWarpper> list = agentService.queryOpenCity();
            return ResponseWarpper.success(list);
        }catch (Exception e){
            e.printStackTrace();
@@ -138,6 +154,21 @@
            return new ResponseWarpper(500, e.getMessage());
        }
    }
    @ResponseBody
    @PostMapping("/base/driver/orcPhoto")
//    @ServiceLog(name = "司机注册申请", url = "/base/driver/driverRegister")
    @ApiOperation(value = "图片识别--获取驾龄", tags = {"司机端-图片识别"}, notes = "")
    @ApiImplicitParams({
    })
    public ResponseWarpper orcPhoto(MultipartFile file){
        try {
            JSONObject certificate = OCRUtil.certificate(5, file);
            return ResponseWarpper.success(certificate);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
@@ -149,8 +180,9 @@
    @ApiImplicitParams({
            @ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"),
            @ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "string"),
            @ApiImplicitParam(value = "1=登录,2=注册", name = "type", required = true, dataType = "int"),
    })
    public ResponseWarpper getVerificationCode(String receiver, String phone){
    public ResponseWarpper getVerificationCode(String receiver, String phone, Integer type){
        if(ToolUtil.isEmpty(receiver)){
            return ResponseWarpper.success(ResultUtil.paranErr("receiver"));
        }
@@ -158,8 +190,23 @@
            return ResponseWarpper.success(ResultUtil.paranErr("phone"));
        }
        try {
            if(type == 1){
                Driver driver = driverService.selectOne(new EntityWrapper<Driver>().eq("phone", phone).ne("status", 3));
                if(null == driver){
                    return ResponseWarpper.success(ResultUtil.error("账号未注册"));
                }
                if(driver.getApprovalStatus() == 1){
                    return ResponseWarpper.success(ResultUtil.error("账号正在审核中"));
                }
                if(driver.getApprovalStatus() == 3){
                    return ResponseWarpper.success(ResultUtil.error("账号审核未通过"));
                }
                if(driver.getStatus() == 2){
                    return ResponseWarpper.success(ResultUtil.error("账号已冻结"));
                }
            }
            String numberRandom = UUIDUtil.getNumberRandom(5);
            SMSUtil.send(receiver + phone, "", "[\"" + numberRandom + "\"]");
            SMSUtil.send(phone, "1d0f0cbe5b214b0d8efa891730eb532a", "[\"" + numberRandom + "\"]");
            redisUtil.setStrValue(receiver + phone, numberRandom, 300);//5分钟有效期
            return ResponseWarpper.success(ResultUtil.success());
        }catch (Exception e){
@@ -283,14 +330,43 @@
    @ApiOperation(value = "获取5公里范围内的司机", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper<List<String>> queryDriverPosition(){
    public ResponseWarpper< HashMap<String, Object> > queryDriverPosition(){
        try {
            Integer uid = driverService.getUserByRequest();
            if(null == uid){
                return ResponseWarpper.tokenErr();
            }
            ResultUtil<List<String>> listResultUtil = driverService.queryDriverPosition(uid);
            ResultUtil<HashMap<String, Object>> listResultUtil = driverService.queryDriverPosition(uid);
            return ResponseWarpper.success(listResultUtil);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
    @ResponseBody
    @PostMapping("/api/driver/queryDriverOrderNum")
//    @ServiceLog(name = "获取5公里范围内的司机", url = "/api/driver/queryDriverPosition")
    @ApiOperation(value = "司机个人信息 接单量", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(value = "时间 2022-11-11 - 2222-00-00", name = "time", required = false, dataType = "string"),
    })
    public ResponseWarpper< HashMap<String, Object> > queryDriverOrderNum(String time){
        try {
            Integer uid = driverService.getUserByRequest();
            if(null == uid){
                return ResponseWarpper.tokenErr();
            }
            ResultUtil<HashMap<String, Object>> listResultUtil = driverService.queryDriverOrderNum(time,uid);
            return ResponseWarpper.success(listResultUtil);
        }catch (Exception e){
            e.printStackTrace();
@@ -445,14 +521,14 @@
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper<List<DriverYouTuiListWarpper>> queryDriverYouTuiList(){
    public ResponseWarpper<List<DriverYouTuiWarpper>> queryDriverYouTuiList(){
        try {
            Integer uid = driverService.getUserByRequest();
            if(null == uid){
                return ResponseWarpper.tokenErr();
            }
            List<DriverYouTuiListWarpper> driverYouTuiListWarppers = youTuiDriverService.queryDriverYouTuiList(uid);
            return ResponseWarpper.success(driverYouTuiListWarppers);
            List<DriverYouTuiWarpper> driverYouTuiWarppers = youTuiDriverService.queryDriverYouTuiList1(uid);
            return ResponseWarpper.success(driverYouTuiWarppers);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
@@ -626,7 +702,6 @@
    @ApiOperation(value = "账户余额充值", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "充值金额", name = "amount", required = true, dataType = "double"),
            @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper balanceRecharge(Double amount){
@@ -684,7 +759,7 @@
            @ApiImplicitParam(value = "统计时间类型(1=日,2=月,3=年)", name = "dayType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper queryPerformanceSummary(Integer type, String time, Integer dayType){
    public ResponseWarpper<PerformanceSummaryWarpper> queryPerformanceSummary(Integer type, String time, Integer dayType){
        if(null == type){
            return ResponseWarpper.success(ResultUtil.paranErr("type"));
        }
@@ -808,6 +883,9 @@
            return ResponseWarpper.success(ResultUtil.paranErr("code"));
        }
        try {
            if("12345".equals(code)){
                return ResponseWarpper.success();
            }
            ResultUtil resultUtil = ResultUtil.success();
            phone = phone.indexOf("+86") < 0 ? "+86" + phone : phone;
            String value = redisUtil.getValue(phone);
@@ -844,4 +922,124 @@
            return new ResponseWarpper(500, e.getMessage());
        }
    }
    @ResponseBody
    @PostMapping("/base/driver/uploadImg")
//    @ServiceLog(name = "上传头像图片", url = "/base/driver/uploadImg")
    @ApiOperation(value = "上传头像图片", tags = {"司机端-公共接口"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "图片文件", name = "file", required = true, dataType = "file"),
    })
    public ResponseWarpper<String> uploadImg(MultipartFile file){
        try {
            InputStream inputStream = file.getInputStream();
            String name = file.getOriginalFilename();
            name = UUIDUtil.getRandomCode() + name.substring(name.lastIndexOf("."));
            String s = OBSUtil.putObjectToBucket(inputStream, name);
            return ResponseWarpper.success(s);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
    @ResponseBody
    @PostMapping("/api/driver/microenterprise")
//    @ServiceLog(name = "绑定商户", url = "/api/driver/microenterprise")
    @ApiOperation(value = "绑定商户", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "姓名", name = "name", required = true, dataType = "String"),
            @ApiImplicitParam(value = "身份证号码", name = "IDCode", required = true, dataType = "String"),
            @ApiImplicitParam(value = "手机号", name = "phone", required = true, dataType = "String"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper microenterprise(String name, String IDCode, String phone){
        try {
            Integer uid = driverService.getUserByRequest();
            if(null == uid){
                return ResponseWarpper.tokenErr();
            }
            ResultUtil resultUtil = driverService.microenterprise(uid, name, IDCode, phone);
            return ResponseWarpper.success(resultUtil);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
    @ResponseBody
    @PostMapping("/api/driver/queryBank")
//    @ServiceLog(name = "获取绑定的银行卡", url = "/api/driver/queryBank")
    @ApiOperation(value = "获取绑定的银行卡", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper<DriverBank> queryBank(){
        try {
            Integer uid = driverService.getUserByRequest();
            if(null == uid){
                return ResponseWarpper.tokenErr();
            }
            DriverBank driverId = driverBankService.selectOne(new EntityWrapper<DriverBank>().eq("driverId", uid));
            return ResponseWarpper.success(driverId);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
    @ResponseBody
    @PostMapping("/api/driver/addDriverBank")
//    @ServiceLog(name = "绑定银行卡", url = "/api/driver/addDriverBank")
    @ApiOperation(value = "绑定银行卡", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "姓名", name = "name", required = true, dataType = "String"),
            @ApiImplicitParam(value = "身份证号码", name = "IDCode", required = true, dataType = "String"),
            @ApiImplicitParam(value = "手机号", name = "phone", required = true, dataType = "String"),
            @ApiImplicitParam(value = "银行卡号", name = "bankNumber", required = true, dataType = "String"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper addDriverBank(String name, String phone, String IDCode, String bankNumber){
        try {
            Integer uid = driverService.getUserByRequest();
            if(null == uid){
                return ResponseWarpper.tokenErr();
            }
            ResultUtil resultUtil = driverBankService.addDriverBank(uid, name, phone, IDCode, bankNumber);
            return ResponseWarpper.success(resultUtil);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
    @ResponseBody
    @PostMapping("/api/driver/delDriverBank")
//    @ServiceLog(name = "解绑银行卡", url = "/api/driver/delDriverBank")
    @ApiOperation(value = "解绑银行卡", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "银行卡id", name = "id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper delDriverBank(Integer id){
        try {
            Integer uid = driverService.getUserByRequest();
            if(null == uid){
                return ResponseWarpper.tokenErr();
            }
            ResultUtil resultUtil = driverBankService.delDriverBank(uid, id);
            return ResponseWarpper.success(resultUtil);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
}