| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | |
| | | |
| | | import com.stylefeng.guns.config.properties.GunsProperties; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.system.warpper.ActivityWarpper; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.ALiSendSms; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.WeChatUtil; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.SMSUtil; |
| | | 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.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class DriverController { |
| | | |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | private RedisTemplate redisTemplate; |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderPositionService orderPositionService; |
| | | |
| | | |
| | | @Autowired |
| | | private ISmsrecordService smsrecordService; |
| | | |
| | | |
| | | @Autowired |
| | | private IDriverOrdersService driverOrdersService; |
| | | |
| | | |
| | | @Autowired |
| | | private ICarService carService; |
| | | |
| | | |
| | | @Autowired |
| | | private ALiSendSms aLiSendSms; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderTaxiService orderTaxiService; |
| | | |
| | | |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderPrivateCarService orderPrivateCarService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderCrossCityService orderCrossCityService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderLogisticsService orderLogisticsService; |
| | | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private GunsProperties gunsProperties; |
| | | |
| | | |
| | | /** |
| | | * 获取短信验证码 |
| | | * |
| | | * @param phone |
| | | * @return |
| | | */ |
| | |
| | | @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)){ |
| | | public ResultUtil queryCaptcha(String phone, Integer type) { |
| | | if (ToolUtil.isNotEmpty(phone)) { |
| | | try { |
| | | return driverService.queryCaptcha(phone, type); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | }else{ |
| | | } else { |
| | | return ResultUtil.paranErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 验证短信验证码 |
| | | * |
| | | * @param phone |
| | | * @param code |
| | | * @return |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 司机注册审核后的短信 |
| | | * |
| | | * @param uid |
| | | * @param type |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/sendsms") |
| | | public ResultUtil sendsms(Integer uid, Integer type){ |
| | | public ResultUtil sendsms(Integer uid, Integer type) { |
| | | try { |
| | | Driver driver = driverService.selectById(uid); |
| | | String templateCode = null; |
| | | switch (type){ |
| | | switch (type) { |
| | | case 1: |
| | | templateCode = "SMS_229648175";//身份验证 |
| | | break; |
| | |
| | | templateCode = "SMS_229613326";//司机注册失败 |
| | | break; |
| | | } |
| | | String s = aLiSendSms.sendSms(driver.getPhone(), templateCode, "{}"); |
| | | // String s = aLiSendSms.sendSms(driver.getPhone(), templateCode, "{}"); |
| | | SMSUtil.sendVerifyCode(driver.getPhone()); |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/getDriverCode") |
| | | @ApiOperation(value = "获取司机端的二维码", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil getDriverCode(HttpServletRequest request){ |
| | | public ResultUtil getDriverCode(HttpServletRequest request) { |
| | | try { |
| | | Integer driverId = driverService.getUserIdFormRedis(request); |
| | | if(null == driverId){ |
| | | if (null == driverId) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Driver driver = driverService.selectById(driverId); |
| | | if(driver!=null){ |
| | | if (driver != null) { |
| | | String fileName = driver.getQrCode(); |
| | | if(fileName==null || "".equals(fileName) ){ |
| | | if (fileName == null || "".equals(fileName)) { |
| | | String appletPath = "pages/home/scanPage/scanPage"; |
| | | //HttpURLConnection httpURLConnection = weChatUtil.getwxacodeunlimit(appletPath, "d=" + driverId + "&k=" + 0, "release",driverId); |
| | | InputStream inputStream = weChatUtil.getwxacodeunlimit(appletPath, "driverId=" + driverId , "release"); |
| | | if(inputStream!=null){ |
| | | fileName = OssUploadUtil.ossUploadByStream(driverId,inputStream); |
| | | System.out.println(fileName); |
| | | driver.setQrCode(fileName); |
| | | InputStream inputStream = weChatUtil.getwxacodeunlimit(appletPath, "driverId=" + driverId, "release"); |
| | | if (inputStream != null) { |
| | | // 上传文件目录 |
| | | fileName = UUID.randomUUID().toString() + ".png"; |
| | | String fileSavePath = gunsProperties.getFileUploadPath() + "img\\"; |
| | | FileUtil.writeFromStream(inputStream, fileName); |
| | | String pictureName = gunsProperties.getPictureServerAddress() + "img/" + fileName; |
| | | // fileName = OssUploadUtil.ossUploadByStream(driverId, inputStream); |
| | | System.out.println(pictureName); |
| | | driver.setQrCode(pictureName); |
| | | driverService.updateById(driver); |
| | | } |
| | | } |
| | |
| | | public ResultUtil cancellation(HttpServletRequest request){ |
| | | try { |
| | | Integer driverId = driverService.getUserIdFormRedis(request); |
| | | if(null == driverId){ |
| | | if (null == driverId) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Driver driver = driverService.selectById(driverId); |
| | | driver.setAuthState(3); |
| | | driverService.updateById(driver); |
| | | //开始验证当前账号是否在别处登录 |
| | | String value = redisUtil.getValue("DRIVER_" + driverId); |
| | | if(ToolUtil.isNotEmpty(value)){//将另外设备上的强迫下线 |
| | | String value = (String) redisTemplate.opsForValue().get("DRIVER_" + driverId); |
| | | if (ToolUtil.isNotEmpty(value)) {//将另外设备上的强迫下线 |
| | | //开始清除redis中无效的数据 |
| | | String key = redisUtil.getValue("DRIVER_" + driver.getPhone()); |
| | | redisUtil.remove(key);//删除个人信息数据 |
| | | redisUtil.remove("DRIVER_" + driver.getPhone());//删除后台冻结相关缓存 |
| | | redisUtil.remove("DRIVER_" + driverId);//清除存储的token |
| | | String key = (String) redisTemplate.opsForValue().get("DRIVER_" + driver.getPhone()); |
| | | redisTemplate.delete(key);//删除个人信息数据 |
| | | redisTemplate.delete("DRIVER_" + driver.getPhone());//删除后台冻结相关缓存 |
| | | redisTemplate.delete("DRIVER_" + driverId);//清除存储的token |
| | | } |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/base/driver/getDriverInfo") |
| | | public void getDriverInfo(String lsu, String ssologinid, String ticket, HttpSession session) { |
| | | try { |
| | | String onconParam = edu.yale.its.tp.cas.client.Util.getOnconParam(session); |
| | | onconParam = new String(Base64.getDecoder().decode(onconParam), "UTF-8"); |
| | | System.err.println("lsu: " + lsu + ",ticket: " + ticket + ",ssologinid: " + ssologinid); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |