|
@@ -16,16 +16,12 @@ package vip.xiaonuo.biz.modular.rechargerecord.service.impl;
|
|
|
import cn.hutool.core.collection.CollStreamUtil;
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
-import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
-import cn.hutool.http.HttpRequest;
|
|
|
-import cn.hutool.http.HttpResponse;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.google.common.collect.Maps;
|
|
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
|
|
import com.wechat.pay.java.core.exception.HttpException;
|
|
|
import com.wechat.pay.java.core.exception.MalformedMessageException;
|
|
@@ -42,6 +38,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import vip.xiaonuo.auth.api.SaBaseLoginUserApi;
|
|
|
import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
+import vip.xiaonuo.biz.core.utils.WxUtil;
|
|
|
import vip.xiaonuo.biz.modular.rechargeplanconfig.entity.BizRechargePlanConfig;
|
|
|
import vip.xiaonuo.biz.modular.rechargeplanconfig.mapper.BizRechargePlanConfigMapper;
|
|
|
import vip.xiaonuo.biz.modular.rechargerecord.param.*;
|
|
@@ -63,7 +60,6 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
-import java.util.Base64;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -377,30 +373,31 @@ public class BizRechargeRecordServiceImpl extends ServiceImpl<BizRechargeRecordM
|
|
|
try {
|
|
|
String accessToken = util.getAccessToken();
|
|
|
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+accessToken;
|
|
|
- Map<String,Object> map = Maps.newHashMap();
|
|
|
- map.put("page","pages/register/index");
|
|
|
- map.put("scene","a=1");
|
|
|
- map.put("check_path","true");
|
|
|
- map.put("env_version","release");
|
|
|
- //HttpResponse execute = HttpUtil.createPost(url).body(JSONObject.toJSONString(map)).execute();
|
|
|
- HttpResponse response = HttpRequest.post(url)
|
|
|
- .header("Content-Type", "application/json")
|
|
|
- .body(JSONObject.toJSONString(map))
|
|
|
- .execute();
|
|
|
- if (response.isOk()) {
|
|
|
- // 获取响应的字节流
|
|
|
- byte[] bytes = response.bodyBytes();
|
|
|
- if (bytes.length > 0) {
|
|
|
- // 转换为 Base64 字符串
|
|
|
- System.out.printf("base:"+Base64.getEncoder().encodeToString(bytes));
|
|
|
- saveImageToFile(bytes,"D://1.png");
|
|
|
- } else {
|
|
|
- System.out.printf("返回的字节流为空");
|
|
|
+ JSONObject paramJson = new JSONObject();
|
|
|
+ paramJson.put("page", "pages/register/index");
|
|
|
+ paramJson.put("check_path", false);
|
|
|
+ paramJson.put("width", 280);
|
|
|
+ paramJson.put("scene", "a=1");
|
|
|
+
|
|
|
+ try {
|
|
|
+ File localFile = new File("/Users/xuchao/document/其他");
|
|
|
+ if(!localFile.exists()) {
|
|
|
+ localFile.mkdir();
|
|
|
+ }
|
|
|
+
|
|
|
+ String localPath = "/Users/xuchao/document/其他/" + 1 + ".png";
|
|
|
+ InputStream inputStream = WxUtil.postInputStream(url, paramJson);
|
|
|
+ int index;
|
|
|
+ byte[] bytes = new byte[1024];
|
|
|
+ FileOutputStream downloadFile = new FileOutputStream(localPath);
|
|
|
+ while ((index = inputStream.read(bytes)) != -1) {
|
|
|
+ downloadFile.write(bytes, 0, index);
|
|
|
+ downloadFile.flush();
|
|
|
}
|
|
|
- } else {
|
|
|
- // 如果返回状态码不是 200,解析错误信息
|
|
|
- String errorResponse = response.body();
|
|
|
- System.out.printf("获取小程序码失败,错误信息:" + errorResponse);
|
|
|
+ downloadFile.close();
|
|
|
+ inputStream.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|