| | |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.internal.util.file.IOUtils; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.model.vo.*; |
| | | 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.NCOSSUtil; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.QianYunTongConfig; |
| | | import com.stylefeng.guns.modular.system.warpper.*; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.http.*; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.security.SecureRandom; |
| | | import java.text.MessageFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.bouncycastle.cms.RecipientId.password; |
| | | |
| | | /** |
| | | * 司机控制器 |
| | |
| | | @Autowired |
| | | private ICarService carService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private RegionMapper regionMapper; |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private GunsProperties gunsProperties; |
| | | |
| | | |
| | | @Autowired |
| | | private ICompanyService companyService; |
| | | |
| | |
| | | @Autowired |
| | | private TDriverPromotionActivityService driverPromotionActivityService; |
| | | |
| | | |
| | | @Autowired |
| | | private QianYunTongConfig qianYunTongConfig; |
| | | |
| | | @Value("${wx.url}") |
| | | private String ACCESS_TOKEN_URL; |
| | | |
| | | @Value("${wx.appletsAppSecret}") |
| | | private String memberAppSecret; |
| | | |
| | | @Value("${wx.appletsAppid}") |
| | | private String wxAppId; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | /** |
| | | * 获取短信验证码 |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "个人的小程序码(分享码)/链接", tags = {"司机端-首页"}, notes = "") |
| | | @GetMapping("/api/driver/person-code") |
| | | @GetMapping("/api/driver/personCode") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<HashMap<String, String>> createQRcode(HttpServletRequest request) { |
| | | InputStream inputStream = null; |
| | | OutputStream outputStream = null; |
| | | public ResultUtil<HashMap<String, Object>> personCode(HttpServletRequest request) { |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if (null == uid) { |
| | |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | String accessToken=null; |
| | | Object img = redisTemplate.opsForValue().get("DRIVER_WX_IMG" + uid); |
| | | // 获取调用凭证accessToken |
| | | if(ToolUtil.isEmpty(driver.getShareImg())|| ToolUtil.isEmpty(driver.getShareImg())){ |
| | | if(ToolUtil.isEmpty(driver.getShareLink())|| ToolUtil.isEmpty(img)){ |
| | | accessToken = getAccessToken(); |
| | | } |
| | | String img=driver.getShareImg(); |
| | | int index=0; |
| | | |
| | | if(ToolUtil.isEmpty(driver.getShareImg())) { |
| | | index=1; |
| | | if(ToolUtil.isEmpty(img)) { |
| | | RestTemplate rest = new RestTemplate(); |
| | | String imgUrl = ""; |
| | | String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("path", "pages/home/home?driverId=" + uid); |
| | | param.put("width", 430); //二维码尺寸 |
| | | MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); |
| | | HttpEntity requestEntity = new HttpEntity(param, headers); |
| | | ResponseEntity<byte[]> entity = rest.exchange(url, HttpMethod.POST, requestEntity, byte[].class, new Object[0]); |
| | | byte[] result = entity.getBody(); |
| | | inputStream = new ByteArrayInputStream(result); |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.body(JSON.toJSONString(param)); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
| | | // 最后上传生成的文件名 |
| | | String finalFileName = System.currentTimeMillis() + "" + new SecureRandom().nextInt(0x0400) + ".jpg"; |
| | | // oss中的文件夹名 |
| | | String objectName = sdf.format(new Date()) + "/" + finalFileName; |
| | | String key = "imgs/management/" + objectName; |
| | | String object = NCOSSUtil.putObject(qianYunTongConfig.getBucketName(), key, inputStream); |
| | | System.out.println(object); |
| | | driver.setShareImg(object); |
| | | img= object; |
| | | byte[] result = post.execute().bodyBytes(); |
| | | // base64 |
| | | img = Base64.getEncoder().encodeToString(result); |
| | | redisTemplate.opsForValue().set("DRIVER_WX_IMG" + uid, img,30, TimeUnit.DAYS); |
| | | } |
| | | |
| | | String urlLink = driver.getShareLink(); |
| | |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | HashMap<String, String> stringStringHashMap = new HashMap<>(); |
| | | HashMap<String, Object> stringStringHashMap = new HashMap<>(); |
| | | stringStringHashMap.put("url_link",urlLink); |
| | | stringStringHashMap.put("img",img); |
| | | |
| | | |
| | | // inputStream = new ByteArrayInputStream(result); |
| | | // |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
| | | // // 最后上传生成的文件名 |
| | | // String finalFileName = System.currentTimeMillis() + "" + new SecureRandom().nextInt(0x0400) + ".jpg"; |
| | | // // oss中的文件夹名 |
| | | // String objectName = sdf.format(new Date()) + "/" + finalFileName; |
| | | // // 上传oss |
| | | //// ossUtil.uploadFile2OSS(inputStream, objectName); |
| | | //// //获取文件的URl地址 |
| | | //// imgUrl = ossUtil.getImgUrl(objectName); |
| | | // log.info("imgUrl: "+imgUrl); |
| | | return ResultUtil.success(stringStringHashMap); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("调用小程序生成微信永久小程序码URL接口异常", e); |
| | | }finally { |
| | | if(inputStream != null){ |
| | | try { |
| | | inputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | if(outputStream != null){ |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return ResultUtil.error("获取二维码失败"); |
| | | } |
| | | |
| | | @Value("${wx.url}") |
| | | private String ACCESS_TOKEN_URL; |
| | | |
| | | @Value("${wx.appletsAppSecret}") |
| | | private String memberAppSecret; |
| | | |
| | | @Value("${wx.appletsAppid}") |
| | | private String wxAppId; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | |
| | | |
| | | public String getAccessToken() { |
| | |
| | | @PostMapping("/base/savePosition") |
| | | public String savePosition(OrderPosition orderPosition){ |
| | | try { |
| | | //将最新定位存储mongodb中 |
| | | GeoJsonPoint point = new GeoJsonPoint(new Point(Double.parseDouble(orderPosition.getLon()), |
| | | Double.parseDouble(orderPosition.getLat()))); |
| | | DriverPosition position = mongoTemplate.findOne(Query.query(Criteria.where("driverId") |
| | | .is(orderPosition.getDriverId())), DriverPosition.class); |
| | | if(null == position){ |
| | | position = new DriverPosition(); |
| | | } |
| | | position.setPoint(point); |
| | | mongoTemplate.save(position); |
| | | //处理业务上的功能 |
| | | orderPositionService.saveData(orderPosition); |
| | | return JSON.toJSONString(ResultUtil.success()); |
| | | }catch (Exception e){ |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryPhone") |
| | | @ApiOperation(value = "获取客服电话", tags = {"司机端-个人中心"}, notes = "车队=franchisee,分公司=branch,平台=platform") |
| | | @ApiOperation(value = "获取客服电话(黔云通)", tags = {"司机端-个人中心"}, notes = "车队=franchisee,分公司=branch,平台=platform") |
| | | @ApiImplicitParams({ |
| | | @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 queryPhone(HttpServletRequest request){ |
| | | public ResultUtil queryPhone(String code, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Map<String, Object> map = driverService.queryPhone(uid); |
| | | Map<String, Object> map = driverService.queryPhone(uid, code); |
| | | return ResultUtil.success(map); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | if(companyCities.isEmpty()){ |
| | | return ResultUtil.success(companyVos); |
| | | } |
| | | Wrapper<Company> in = new EntityWrapper<Company>().ne("type", 1).ne("flag", 3).in("id", companyCities.stream().map(CompanyCity::getCompanyId).collect(Collectors.toList())); |
| | | Wrapper<Company> in = new EntityWrapper<Company>().eq("type", 2).ne("flag", 3).in("id", companyCities.stream().map(CompanyCity::getCompanyId).collect(Collectors.toList())); |
| | | |
| | | if(ToolUtil.isNotEmpty( name)){ |
| | | in.like("name", name); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @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(); |
| | | } |
| | | } |
| | | |
| | | |
| | | // @ResponseBody |