package com.stylefeng.guns.modular.api; import com.alibaba.fastjson.JSON; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; import com.stylefeng.guns.modular.system.model.Driver; import com.stylefeng.guns.modular.system.model.Income; import com.stylefeng.guns.modular.system.model.OrderPosition; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.util.ResultUtil; import com.stylefeng.guns.modular.system.util.qiniuyun.QNYAuth; import com.stylefeng.guns.modular.system.warpper.*; import com.stylefeng.guns.modular.taxi.model.OrderTaxi; import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.text.SimpleDateFormat; import java.util.*; /** * 司机控制器 */ @Api @CrossOrigin @RestController @RequestMapping("") public class DriverController { @Autowired private IDriverService driverService; @Autowired private IOrderPositionService orderPositionService; @Autowired private ISmsrecordService smsrecordService; @Autowired private IDriverOrdersService driverOrdersService; @Autowired private ICarService carService; @Autowired private IOrderTaxiService orderTaxiService; @Autowired private IIncomeService incomeService; @Autowired private IOrderPrivateCarService orderPrivateCarService; @Autowired private IOrderCrossCityService orderCrossCityService; @Autowired private IOrderLogisticsService orderLogisticsService; @Autowired private IDriverOnlineService driverOnlineService; /** * 获取所有车辆品牌 * @return */ @ResponseBody @PostMapping("/base/car/queryAllBrand") @ApiOperation(value = "获取所有车辆品牌", tags = {"司机端-个人中心"}, notes = "") public ResultUtil queryAllBrand(){ try { List> list = carService.queryAllBrand(); return ResultUtil.success(list); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 查询车辆品牌型号 * @param brandId * @return */ @ResponseBody @PostMapping("/base/car/queryCarModel") @ApiOperation(value = "查询车辆品牌型号", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "车辆品牌id", name = "brandId", required = true, dataType = "int"), }) public ResultUtil queryCarModel(Integer brandId){ try { List> list = carService.queryCarModel(brandId); return ResultUtil.success(list); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取短信验证码 * @param phone * @return */ @ResponseBody @PostMapping("/base/driver/queryCaptcha") @ApiOperation(value = "获取短信验证码", tags = {"司机端-注册"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "场景类型(1=身份验证,2=登录确认,3=用户注册,4=修改密码)", name = "type", required = true, dataType = "String") }) public ResultUtil queryCaptcha(String phone, Integer type){ if(ToolUtil.isNotEmpty(phone)){ try { return driverService.queryCaptcha(phone, type); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } }else{ return ResultUtil.paranErr(); } } /** * 验证短信验证码 * @param phone * @param code * @return */ @ResponseBody @PostMapping("/base/driver/checkCaptcha") @ApiOperation(value = "验证短信验证码", tags = {"司机端-注册"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String") }) public ResultUtil checkCaptcha(String phone, String code){ try { boolean b = driverService.checkCaptcha(phone, code); if(b){ Driver driver = driverService.queryByPhone(phone); smsrecordService.saveData(null == driver ? 5 : 8, phone, code, "短信验证码【" + code + "】已发到您的手机,验证码将在5分钟后失效,请及时登录!"); } return b ? ResultUtil.success() : ResultUtil.error("验证码无效"); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 司机提交注册申请 * @return */ @ResponseBody @PostMapping("/base/driver/registeredDriver") @ApiOperation(value = "司机提交注册申请", tags = {"分享专用"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String"), @ApiImplicitParam(value = "密码", name = "password", required = true, dataType = "String"), @ApiImplicitParam(value = "分享的用户id", name = "uid", required = true, dataType = "int"), @ApiImplicitParam(value = "用户类型(1=用户,2=司机)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "注册类型(1=司机注册,2=用户注册)", name = "userType", required = true, dataType = "int") }) public ResultUtil registeredDriver(String phone, String code, String password, Integer uid, Integer type, Integer userType){ try { return driverService.registeredDriver(phone, code, password, uid, type, userType); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 司机注册 * @param phone * @param code * @param password * @return */ @ResponseBody @PostMapping("/base/driver/registeredDriver_") @ApiOperation(value = "司机提交注册申请", tags = {"司机端-注册"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String"), @ApiImplicitParam(value = "密码", name = "password", required = true, dataType = "String"), @ApiImplicitParam(value = "分享的用户id", name = "uid", required = true, dataType = "int"), @ApiImplicitParam(value = "用户类型(1=用户,2=司机)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "注册类型(1=司机注册,2=用户注册)", name = "userType", required = true, dataType = "int") }) public ResultUtil registeredDriver_(String phone, String code, String password, Integer uid, Integer type, Integer userType){ try { return driverService.registeredDriver(phone, code, password, uid, type, userType); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/driver/queryNeedCertificate") @ApiOperation(value = "注册完善个人信息根据选择的从业地判断是否需要网约车资格证", tags = {"司机端-注册"}, notes = "0=城市未开通,1=是,2=否") @ApiImplicitParams({ @ApiImplicitParam(value = "城市行政编号", name = "code", required = true, dataType = "String") }) public ResultUtil queryNeedCertificate(String code){ try { Integer integer = driverService.queryNeedCertificate(code); return ResultUtil.success(integer == null ? 0 : integer); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 司机注册后完善个人信息 * @param registeredWarpper * @return */ @ResponseBody @PostMapping("/base/driver/updateDriver") @ApiOperation(value = "司机注册后完善个人信息", tags = {"司机端-注册"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "司机id", name = "uid", required = true, dataType = "int") }) public ResultUtil updateDriver(RegisteredWarpper registeredWarpper, Integer uid){ try { return driverService.updateDriver(registeredWarpper, uid); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 司机注册后完善车辆信息 * @param * @return */ @ResponseBody @PostMapping("/base/driver/addDriverCar") @ApiOperation(value = "司机注册后完善车辆信息", tags = {"司机端-注册"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "车辆型号id", name = "modelId", required = true, dataType = "int"), @ApiImplicitParam(value = "车辆颜色", name = "color", required = true, dataType = "string"), @ApiImplicitParam(value = "车牌号", name = "licensePlate", required = true, dataType = "string"), @ApiImplicitParam(value = "年审日期(需要格式化)", name = "time", required = false, dataType = "string"), @ApiImplicitParam(value = "行驶证照片", name = "drivingLicensePhoto", required = true, dataType = "string"), @ApiImplicitParam(value = "车辆照片", name = "carPhoto", required = true, dataType = "string"), @ApiImplicitParam(value = "保险照片", name = "insurancePhoto", required = false, dataType = "string"), @ApiImplicitParam(value = "司机id", name = "uid", required = true, dataType = "int"), @ApiImplicitParam(value = "车辆id", name = "carId", required = false, dataType = "int") }) public ResultUtil addDriverCar(Integer modelId, String color, String licensePlate, Date time, String drivingLicensePhoto, String carPhoto, String insurancePhoto, Integer uid, Integer carId){ try { return carService.addCar(modelId, color, licensePlate, time, drivingLicensePhoto, carPhoto, insurancePhoto, uid,carId); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 司机注册审核后的短信 * @param uid * @param type * @return */ @ResponseBody @PostMapping("/base/driver/sendsms") public ResultUtil sendsms(Integer uid, Integer type){ try { Driver driver = driverService.selectById(uid); String templateCode = null; switch (type){ case 1: templateCode = "SMS_154775435";//身份验证 break; case 2: templateCode = "SMS_154775434";//登录确认 break; case 3: templateCode = "SMS_154775432";//用户注册 break; case 4: templateCode = "SMS_154775431";//修改密码 break; case 5: templateCode = "SMS_194650202";//司机注册成功 break; case 6: templateCode = "SMS_194610237";//司机注册失败 break; } // String s = aLiSendSms.sendSms(driver.getPhone(), templateCode, "{}"); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 忘记密码操作 * @param phone * @param code * @param password * @return */ @ResponseBody @PostMapping("/base/driver/resetPassword") @ApiOperation(value = "忘记密码操作", tags = {"司机端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String"), @ApiImplicitParam(value = "新密码", name = "password", required = true, dataType = "String") }) public ResultUtil resetPassword(String phone, String code, String password){ try { return driverService.resetPassword(phone, code, password); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取忘记密码页面的电话 * @return */ @ResponseBody @PostMapping("/base/driver/queryPhone") @ApiOperation(value = "获取忘记密码页面的电话", tags = {"司机端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "当前定位城市行政编号(510100)", name = "code", required = true, dataType = "String") }) public ResultUtil queryPhone(String code){ try { Map map = driverService.queryPhone(code); return ResultUtil.success(map); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 司机登录操作 * @param phone * @param password * @return */ @ResponseBody @PostMapping("/base/driver/driverLogin") @ApiOperation(value = "登录操作", tags = {"司机端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "密码", name = "password", required = true, dataType = "String") }) public ResultUtil driverLogin(String phone, String password){ try { return driverService.driverLogin(phone, password); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取首页统计数据 * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryHomeData") @ApiOperation(value = "获取首页统计数据", tags = {"司机端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryHomeData(HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Map map = driverService.queryHomeData(uid); return ResultUtil.success(HomeWarpper.getHomeWarpper(map)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 司机上下班操作 * @param type * @param request * @return */ @ResponseBody @PostMapping("/api/driver/work") @ApiOperation(value = "司机上下班操作", tags = {"司机端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "上班的业务类型(1=专车,2=快车,3=城际,4=小件物流-同城,5=小件物流-跨城)多个已逗号分隔", name = "type", required = false, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil work(String type, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return driverService.work(uid, type); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/api/driver/getDriverOnlineTime") @ApiOperation(value = "获取司机在线时长", tags = {"司机端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), }) public ResultUtil getDriverOnlineTime(HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Map map = new HashMap<>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); Date now = new Date(); Integer today = driverOnlineService.querySumTime(uid, 0, sdf.parse(sdf1.format(now) + " 00:00:00"), sdf.parse(sdf1.format(now) + " 23:59:59")); map.put("today", today); Calendar s = Calendar.getInstance(); s.setTime(now); s.set(Calendar.DAY_OF_WEEK, 2); Calendar e = Calendar.getInstance(); e.setTime(now); int day_of_week = e.get(Calendar.DAY_OF_WEEK); int day_of_month = e.get(Calendar.DAY_OF_MONTH); e.set(Calendar.DAY_OF_MONTH, day_of_month + (8 - day_of_week)); Integer thisWeek = driverOnlineService.querySumTime(uid, 0, sdf.parse(sdf1.format(s.getTime()) + " 00:00:00"), sdf.parse(sdf1.format(e.getTime()) + " 23:59:59")); map.put("thisWeek", thisWeek); s = Calendar.getInstance(); s.setTime(now); s.set(Calendar.DAY_OF_MONTH, 1); e = Calendar.getInstance(); e.setTime(now); e.set(Calendar.DAY_OF_MONTH, e.getActualMaximum(Calendar.DAY_OF_MONTH)); Integer thisMonth = driverOnlineService.querySumTime(uid, 0, sdf.parse(sdf1.format(s.getTime()) + " 00:00:00"), sdf.parse(sdf1.format(e.getTime()) + " 23:59:59")); map.put("thisMonth", thisMonth); Integer attendance = driverOnlineService.querySumTime(uid, 1, sdf.parse(sdf1.format(now) + " 00:00:00"), sdf.parse(sdf1.format(now) + " 23:59:59")); map.put("attendance", attendance); return ResultUtil.success(map); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/api/driver/work2") @ApiOperation(value = "司机上下班操作,同时设置接单类型", tags = {"司机端-车载端"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "上班的业务类型(1=专车,2=快车,3=城际,4=小件物流-同城,5=小件物流-跨城)多个已逗号分隔", name = "type", required = false, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil work2(String type, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return driverService.work2(uid, type); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/api/driver/queryHomeNum") @ApiOperation(value = "获取首页统计数据", tags = {"司机端-车载端"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryHomeNum(HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Map map = driverService.queryHomeNum(uid); return ResultUtil.success(map); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 上班时选择的业务类型 * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryMyBusiness") @ApiOperation(value = "上班时选择的业务类型", tags = {"司机端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryMyBusiness(HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } // TODO: 2020/7/21 修改为个人中心中设置的接单业务类型。 List list = driverService.queryMyBusiness(uid); List integers = driverOrdersService.queryOrders(uid); List data = new ArrayList<>(); for(BaseWarpper baseWarpper : list){ if(integers.contains(baseWarpper.getId())){ data.add(baseWarpper); } } return ResultUtil.success(data); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 存储订单服务中的司机位置 * @param orderPosition * @return */ @ResponseBody @PostMapping("/base/savePosition") public String savePosition(OrderPosition orderPosition){ try { orderPositionService.saveData(orderPosition); return JSON.toJSONString(ResultUtil.success()); }catch (Exception e){ e.printStackTrace(); return JSON.toJSONString(ResultUtil.runErr()); } } @ResponseBody @PostMapping("/base/driver/queryInfo_") @ApiOperation(value = "根据用户id获取数据", tags = {"司机端-注册"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "司机id", name = "uid", required = true, dataType = "int"), }) public ResultUtil queryInfo_(Integer uid){ try { Map map = driverService.queryInfo(uid); return ResultUtil.success(DriverInfoWarpper.getDriverInfoWarpper(map)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取个人中心详情 * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryInfo") @ApiOperation(value = "获取个人中心详情", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryInfo(HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Map map = driverService.queryInfo(uid); map.put("qrCodeIsOpen",driverService.getAppOpenInfo(1)==1); DriverInfoWarpper driverInfoWarpper = DriverInfoWarpper.getDriverInfoWarpper(map); Double money = driverService.getThisWeekMoney(uid); driverInfoWarpper.setLaveBusinessMoney(driverInfoWarpper.getLaveBusinessMoney()-(money==null?0d:money)); driverInfoWarpper.setLaveBusinessNextWeekMoney(money==null?0d:money); return ResultUtil.success(driverInfoWarpper); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 修改手机号码 * @param phone * @param code * @param request * @return */ @ResponseBody @PostMapping("/api/driver/updatePhone") @ApiOperation(value = "修改手机号码", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "新电话号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil updatePhone(String phone, String code, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return driverService.updatePhone(phone, code, uid); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 修改密码 * @param password * @param request * @return */ @ResponseBody @PostMapping("/api/driver/updatePassword") @ApiOperation(value = "修改密码", tags = {"司机端-个人中心"}, notes = "修改前需要验证短信验证码") @ApiImplicitParams({ @ApiImplicitParam(value = "新密码", name = "password", required = true, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil updatePassword(String password, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } driverService.updatePassword(password, uid); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取设置接单的业务类型列表 * @param request * @return */ @ResponseBody @PostMapping("/api/driver/querySetOrders") @ApiOperation(value = "获取设置接单的业务类型列表", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> querySetOrders(HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List list = driverService.queryMyBusiness(uid); List integers = driverOrdersService.queryOrders(uid); List data = new ArrayList<>(); for(BaseWarpper b : list){ OrdersWarpper ordersWarpper = new OrdersWarpper(); ordersWarpper.setType(b.getId()); ordersWarpper.setName(b.getName()); ordersWarpper.setState(integers.contains(b.getId()) ? 2 : 1); data.add(ordersWarpper); } return ResultUtil.success(data); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 设置接单规则 * @param type * @param request * @return */ @ResponseBody @PostMapping("/api/driver/updateOrders") @ApiOperation(value = "设置接单规则", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单类型(1=专车,2=快车,3=城际,4=小件物流-同城,5=小件物流-跨城)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil updateOrders(Integer type, HttpServletRequest request){ try{ Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return driverOrdersService.updateOrders(uid, type); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取当前车辆及空闲车辆 * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryMyCar") @ApiOperation(value = "获取当前车辆及空闲车辆", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryMyCar(HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Map map = carService.queryCars(uid); return ResultUtil.success(map); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 更换车辆 * @param carId * @param request * @return */ @ResponseBody @PostMapping("/api/driver/replaceCar") @ApiOperation(value = "更换车辆", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "车辆id", name = "carId", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil replaceCar(Integer carId, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return driverService.replaceCar(carId, uid); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取客服电话 * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryPhone") @ApiOperation(value = "获取客服电话", tags = {"司机端-个人中心"}, notes = "车队=franchisee,分公司=branch,平台=platform") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryPhone(HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Map map = driverService.queryPhone(uid); return ResultUtil.success(map); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取扣款明细 * @param pageNum * @param size * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryPenalties") @ApiOperation(value = "获取扣款明细", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryPenalties(Integer pageNum, Integer size, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List> list = driverService.queryPenalties(pageNum, size, uid); List data = new ArrayList<>(); for(Map map : list){ BaseWarpper baseWarpper = new BaseWarpper(); baseWarpper.setAmount(Double.valueOf(String.valueOf(map.get("amount")))); baseWarpper.setName(String.valueOf(map.get("name"))); baseWarpper.setDay(String.valueOf(map.get("day"))); data.add(baseWarpper); } return ResultUtil.success(data); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取收益明细 * @param pageNum * @param size * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryActivityIncome") @ApiOperation(value = "获取收益明细", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryActivityIncome(Integer pageNum, Integer size, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List> list = driverService.queryActivityIncome(uid, pageNum, size); List data = new ArrayList<>(); for(Map map : list){ BaseWarpper baseWarpper = new BaseWarpper(); baseWarpper.setDay(String.valueOf(null != map.get("time") ? map.get("time") : "")); baseWarpper.setAmount(Double.valueOf(String.valueOf(null != map.get("money") ? map.get("money") : 0))); baseWarpper.setName("活动奖励"); data.add(baseWarpper); } return ResultUtil.success(data); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取收入明细 * @param pageNum * @param size * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryTotalRevenue") @ApiOperation(value = "获取收入明细", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryTotalRevenue(Integer pageNum, Integer size, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List> list = driverService.queryTotalRevenue(uid, pageNum, size); List data = new ArrayList<>(); for(Map map : list){ BaseWarpper baseWarpper = new BaseWarpper(); baseWarpper.setDay(String.valueOf(null != map.get("time") ? map.get("time") : "")); baseWarpper.setAmount(Double.valueOf(String.valueOf(null != map.get("money") ? map.get("money") : 0))); switch (Integer.valueOf(String.valueOf(null != map.get("orderType") ? map.get("orderType") : 0))){ case 1: baseWarpper.setName("快车"); break; case 2: baseWarpper.setName("快车"); break; case 3: baseWarpper.setName("城际出行"); break; case 4: baseWarpper.setName("同城小件物流"); break; case 5: baseWarpper.setName("跨城小件物流"); break; } Map map1 = new HashMap<>(); switch (Integer.valueOf(map.get("orderType").toString())){ case 1: OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(map.get("incomeId").toString()); List incomes = incomeService.queryData(1, null, 2, orderPrivateCar.getId(), 1); map1.put("travelMoney", orderPrivateCar != null ? orderPrivateCar.getOrderMoney() : 0);//行程费 map1.put("parkMoney", orderPrivateCar != null ? orderPrivateCar.getParkMoney() : 0);//停车费 map1.put("tipMoney", 0);//小费 map1.put("roadTollMoney", orderPrivateCar != null ? orderPrivateCar.getRoadTollMoney() : 0);//过路费 map1.put("rakeMoney", incomes.size() > 0 ? incomes.get(0).getMoney() : 0);//抽成 break; case 2: OrderTaxi orderTaxi = orderTaxiService.selectById(map.get("incomeId").toString()); List incomes1 = incomeService.queryData(1, null, 2, orderTaxi.getId(), 2); map1.put("travelMoney", orderTaxi != null ? orderTaxi.getTravelMoney() : 0);//行程费 map1.put("parkMoney", orderTaxi != null ? orderTaxi.getParkMoney() : 0);//停车费 map1.put("tipMoney", orderTaxi != null ? orderTaxi.getTipMoney() : 0);//小费 map1.put("roadTollMoney", orderTaxi != null ? orderTaxi.getRoadTollMoney() : 0);//过路费 map1.put("rakeMoney", incomes1.size() > 0 ? incomes1.get(0).getMoney() : 0);//抽成 break; case 3: OrderCrossCity orderCrossCity = orderCrossCityService.selectById(map.get("incomeId").toString()); List incomes2 = incomeService.queryData(1, null, 2, orderCrossCity.getId(), 3); map1.put("travelMoney", orderCrossCity != null ? orderCrossCity.getOrderMoney() : 0);//行程费 map1.put("parkMoney", 0);//停车费 map1.put("tipMoney", 0);//小费 map1.put("roadTollMoney", 0);//过路费 map1.put("rakeMoney", incomes2.size() > 0 ? incomes2.get(0).getMoney() : 0);//抽成 break; case 4: OrderLogistics orderLogistics = orderLogisticsService.selectById(map.get("incomeId").toString()); List incomes3 = incomeService.queryData(1, null, 2, orderLogistics.getId(), 4); map1.put("travelMoney", orderLogistics != null ? orderLogistics.getTravelMoney() : 0);//行程费 map1.put("parkMoney", 0);//停车费 map1.put("tipMoney", orderLogistics != null ? orderLogistics.getTipMoney() : 0);//小费 map1.put("roadTollMoney", 0);//过路费 map1.put("rakeMoney", incomes3.size() > 0 ? incomes3.get(0).getMoney() : 0);//抽成 break; case 5: OrderLogistics orderLogistics1 = orderLogisticsService.selectById(map.get("incomeId").toString()); List incomes4 = incomeService.queryData(1, null, 2, orderLogistics1.getId(), 5); map1.put("travelMoney", orderLogistics1 != null ? orderLogistics1.getTravelMoney() : 0);//行程费 map1.put("parkMoney", 0);//停车费 map1.put("tipMoney", orderLogistics1 != null ? orderLogistics1.getTipMoney() : 0);//小费 map1.put("roadTollMoney", 0);//过路费 map1.put("rakeMoney", incomes4.size() > 0 ? incomes4.get(0).getMoney() : 0);//抽成 break; } baseWarpper.setData(map1); data.add(baseWarpper); } return ResultUtil.success(data); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取当前有效的活动列表 * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryMyActivity") @ApiOperation(value = "获取当前有效的活动列表", tags = {"司机端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryMyActivity(HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return ResultUtil.success(driverService.queryMyActivity(uid, new Date())); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取历史活动列表 * @param pageNum * @param size * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryHistoryActivity") @ApiOperation(value = "获取历史活动列表", tags = {"司机端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryHistoryActivity(Integer pageNum, Integer size, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List> list = driverService.queryHistory(uid, pageNum, size); return ResultUtil.success(list); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取历史日期中的活动内容 * @param time * @param request * @return */ @ResponseBody @PostMapping("/api/driver/queryHistoryActivityInfo") @ApiOperation(value = "获取历史日期中的活动内容", tags = {"司机端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "查询的给定日期", name = "time", required = true, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryHistoryActivityInfo(String time, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); List activityWarppers = driverService.queryMyActivity(uid, sdf.parse(time)); return ResultUtil.success(activityWarppers); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 工号登录(仅快车) * @param jobNum * @return */ @ResponseBody @PostMapping("/base/driver/loginByJobNumber") @ApiOperation(value = "工号登录", tags = {"司机端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "工号", name = "jobNum", required = true, dataType = "String"), }) public ResultUtil loginByJobNumber(String jobNum){ try { return driverService.loginByJobNumber(jobNum); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 身份证号码登录 * @param identification * @return */ @ResponseBody @PostMapping("/base/driver/loginByIdentification") @ApiOperation(value = "身份证号码登录", tags = {"司机端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "身份证号码", name = "identification", required = true, dataType = "String"), }) public ResultUtil loginByIdentification(String identification){ try { return driverService.loginByIdentification(identification); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 快车资格证号码登录 * @param taxiAptitudeCard * @return */ @ResponseBody @PostMapping("/base/driver/loginByTaxiAptitudeCard") @ApiOperation(value = "快车资格证号登录", tags = {"司机端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "快车资格证号", name = "taxiAptitudeCard", required = true, dataType = "String"), }) public ResultUtil loginByTaxiAptitudeCard(String taxiAptitudeCard){ try { return driverService.loginByTaxiAptitudeCard(taxiAptitudeCard); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 验证登录密码是否有效 * @param password * @param request * @return */ @ResponseBody @PostMapping("/api/driver/verificationPassword") @ApiOperation(value = "验证登录密码是否有效", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "登录密码", name = "password", required = true, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil verificationPassword(String password, HttpServletRequest request){ try { Integer driverId = driverService.getUserIdFormRedis(request); if(null == driverId){ return ResultUtil.tokenErr(); } return driverService.verificationPassword(password, driverId); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 设置提现密码 * @param withdrawPassword * @param request * @return */ @ResponseBody @PostMapping("/api/driver/setWithdrawPassword") @ApiOperation(value = "设置提现密码", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "提现密码", name = "withdrawPassword", required = true, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil setWithdrawPassword(String withdrawPassword, HttpServletRequest request){ try { Integer driverId = driverService.getUserIdFormRedis(request); if(null == driverId){ return ResultUtil.tokenErr(); } return driverService.setWithdrawPassword(withdrawPassword, driverId); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 验证提现密码是否有效 * @param withdrawPassword * @param request * @return */ @ResponseBody @PostMapping("/api/driver/verificationWithdrawPassword") @ApiOperation(value = "验证提现密码是否有效", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "提现密码", name = "withdrawPassword", required = true, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil verificationWithdrawPassword(String withdrawPassword, HttpServletRequest request){ try { Integer driverId = driverService.getUserIdFormRedis(request); if(null == driverId){ return ResultUtil.tokenErr(); } return driverService.verificationWithdrawPassword(withdrawPassword, driverId); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 退出登录 * @param request * @return */ @ResponseBody @PostMapping("/api/driver/loginOut") @ApiOperation(value = "退出登录", tags = {"司机端-车载端"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil loginOut(HttpServletRequest request){ try { Integer driverId = driverService.getUserIdFormRedis(request); if(null == driverId){ return ResultUtil.tokenErr(); } return driverService.loginOut(driverId); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/api/driver/getInviteList") @ApiOperation(value = "获取邀请司机/乘客列表", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "类型[1:乘客,2:司机]", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil getInviteList(Integer type,Integer pageNum, Integer size, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List> list = driverService.queryMyInviteList(type,uid, pageNum, size); return ResultUtil.success(DriverInviteInfoWarpper.getDriverInviteInfoWarpper(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/driver/getQnyToken") @ApiOperation(value = "获取七牛云token", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "上传key", name = "key", required = true, dataType = "string"), }) public ResultUtil getQnyToken(String key){ try { String s = QNYAuth.create("6DqM0CEdAVON3mL3C6E23Vuj--635Q1hdjOwnpXw", "q35tZkQjvBCRkDsfWksY3PCr3wqUuJlodE7EF5qg") .uploadToken("rbkj-zycx", key); return ResultUtil.success(s); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } }