| | |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.OrderStatusEnum; |
| | | import cc.mrbird.febs.common.utils.HttpCurlUtil; |
| | | import cc.mrbird.febs.common.utils.MallUtils; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.mall.dto.AdminLeaderAddFenceDto; |
| | | import cc.mrbird.febs.mall.dto.ApiLeaderRefundOrderDto; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | } |
| | | @Autowired |
| | | private IXcxPayService iXcxPayService; |
| | | @Autowired |
| | | private MallGoodsMapper mallGoodsMapper; |
| | | @Autowired |
| | | private IAdminMallTeamLeaderService iAdminMallTeamLeaderService; |
| | | |
| | | @Test |
| | | public void qrcodeBase64(){ |
| | | WxGenerateQrCodeDto wxGenerateQrCodeDto = new WxGenerateQrCodeDto(); |
| | | wxGenerateQrCodeDto.setPage("pages/index/index"); |
| | | wxGenerateQrCodeDto.setScene("15"); |
| | | FebsResponse febsResponse = iXcxPayService.generateQrCode(wxGenerateQrCodeDto); |
| | | String data = febsResponse.get("data").toString(); |
| | | System.out.println(data); |
| | | |
| | | // Integer integer = mallGoodsMapper.upDateStockAndVolumeByGoodsId(35L, 3); |
| | | // System.out.println(integer); |
| | | // WxGenerateQrCodeDto wxGenerateQrCodeDto = new WxGenerateQrCodeDto(); |
| | | // wxGenerateQrCodeDto.setPage("pages/product/details"); |
| | | // wxGenerateQrCodeDto.setScene("35"); |
| | | // FebsResponse febsResponse = iXcxPayService.generateQrCode(wxGenerateQrCodeDto); |
| | | // String data = febsResponse.get("data").toString(); |
| | | // System.out.println(data); |
| | | trackServiceInfo("e024c63342930addc57189c8608cdb01",null); |
| | | } |
| | | public String trackServiceInfo(String gaodeKey, String serviceName) { |
| | | String url = "https://tsapi.amap.com/v1/track/service/list"; |
| | | HttpPost httpPost = new HttpPost(url); |
| | | Map<String,String> map = new HashMap<>(); |
| | | //高德Key |
| | | //用户在高德地图官网申请Web服务API类型Key |
| | | map.put("key",gaodeKey); |
| | | System.out.println("==高德返回"+map); |
| | | String result = null; |
| | | try { |
| | | result = HttpCurlUtil.sendGetHttp(url, map); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | System.out.println("==高德返回"+result); |
| | | cn.hutool.json.JSONObject maps = JSONUtil.parseObj(result); |
| | | String errCode = maps.get("errcode").toString(); |
| | | if("10000".equals(errCode)){ |
| | | String dataStr = maps.get("data").toString(); |
| | | cn.hutool.json.JSONObject dataResults = JSONUtil.parseObj(dataStr); |
| | | String resultsStr = dataResults.get("results").toString(); |
| | | return resultsStr; |
| | | }else{ |
| | | return "fail"; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | String json = JSON.toJSONString(param); |
| | | ByteArrayInputStream inputStream = sendPost(url, json); |
| | | |
| | | System.out.println(inputStream); |
| | | //这里判断的是返回的图片还是错误信息,一般错误信息不会大于200 |
| | | if (inputStream.available() <= 200){ |
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| | |
| | | byteArrayOutputStream.write(buffer,0,i); |
| | | } |
| | | String str = new String(byteArrayOutputStream.toByteArray()); |
| | | System.out.println(str); |
| | | //错误信息的格式在官方文档里有 |
| | | JSONObject jsonObject = JSONObject.parseObject(str); |
| | | if ("41030".equals(jsonObject.getString("errcode"))){ |
| | |
| | | //输出到本地的代码 |
| | | FileOutputStream fileOutputStream = new FileOutputStream("D:/123.png"); |
| | | int i; |
| | | byte[] buffer = new byte[200]; |
| | | byte[] buffer = new byte[10240000]; |
| | | while ((i = inputStream.read(buffer)) != -1){ |
| | | fileOutputStream.write(buffer,0,i); |
| | | } |
| | | |
| | | fileOutputStream.flush(); |
| | | fileOutputStream.close(); |
| | | |
| | | inputStream.close(); |
| | | }catch (Exception e){ |
| | | } |
| | |
| | | inputStream.close(); |
| | | // 把outStream里的数据写入内存 |
| | | byteArrayInputStream = new ByteArrayInputStream(outStream.toByteArray()); |
| | | byte[] data = outStream.toByteArray(); |
| | | String result = new String(Base64.getEncoder().encode(data)); |
| | | result = "data:image/jpeg;base64," + result; |
| | | System.out.println(result); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |