|
@@ -13,9 +13,11 @@
|
|
|
package vip.xiaonuo.biz.modular.rechargerecord.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.codec.Base64;
|
|
|
import cn.hutool.core.collection.CollStreamUtil;
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.img.ImgUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -368,6 +370,48 @@ public class BizRechargeRecordServiceImpl extends ServiceImpl<BizRechargeRecordM
|
|
|
this.updateById(bizRechargeRecord);
|
|
|
}
|
|
|
|
|
|
+ public String returnBase(){
|
|
|
+ CommonWxUtil util = new CommonWxUtil();
|
|
|
+ try {
|
|
|
+ String accessToken = util.getAccessToken();
|
|
|
+ String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+accessToken;
|
|
|
+ JSONObject paramJson = new JSONObject();
|
|
|
+ paramJson.put("page", "pages/register/index");
|
|
|
+ paramJson.put("scene", "8JFFG95PD0");
|
|
|
+ paramJson.put("check_path", false);
|
|
|
+ paramJson.put("env_version","trial");
|
|
|
+ paramJson.put("width", 280);
|
|
|
+
|
|
|
+ try {
|
|
|
+ File localFile = new File("D:/defaultUploadFolder/recommend");
|
|
|
+ if(!localFile.exists()) {
|
|
|
+ localFile.mkdir();
|
|
|
+ }
|
|
|
+
|
|
|
+ String localPath = "D:/defaultUploadFolder/recommend/" + 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();
|
|
|
+ }
|
|
|
+ File file = new File(localPath);
|
|
|
+ String base = "data:image/png;base64,"+Base64.encode(file);
|
|
|
+ System.out.printf("base:"+base);
|
|
|
+ downloadFile.close();
|
|
|
+ inputStream.close();
|
|
|
+ return base;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
CommonWxUtil util = new CommonWxUtil();
|
|
|
try {
|
|
@@ -375,17 +419,18 @@ public class BizRechargeRecordServiceImpl extends ServiceImpl<BizRechargeRecordM
|
|
|
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+accessToken;
|
|
|
JSONObject paramJson = new JSONObject();
|
|
|
paramJson.put("page", "pages/register/index");
|
|
|
+ paramJson.put("scene", "8JFFG95PD0");
|
|
|
paramJson.put("check_path", false);
|
|
|
+ paramJson.put("env_version","trial");
|
|
|
paramJson.put("width", 280);
|
|
|
- paramJson.put("scene", "a=1");
|
|
|
|
|
|
try {
|
|
|
- File localFile = new File("/Users/xuchao/document/其他");
|
|
|
+ File localFile = new File("D:/defaultUploadFolder/recommend");
|
|
|
if(!localFile.exists()) {
|
|
|
localFile.mkdir();
|
|
|
}
|
|
|
|
|
|
- String localPath = "/Users/xuchao/document/其他/" + 1 + ".png";
|
|
|
+ String localPath = "D:/defaultUploadFolder/recommend/" + 1 + ".png";
|
|
|
InputStream inputStream = WxUtil.postInputStream(url, paramJson);
|
|
|
int index;
|
|
|
byte[] bytes = new byte[1024];
|
|
@@ -394,6 +439,9 @@ public class BizRechargeRecordServiceImpl extends ServiceImpl<BizRechargeRecordM
|
|
|
downloadFile.write(bytes, 0, index);
|
|
|
downloadFile.flush();
|
|
|
}
|
|
|
+ File file = new File(localPath);
|
|
|
+ String base = "data:image/png;base64,"+Base64.encode(file);
|
|
|
+ System.out.printf("base:"+base);
|
|
|
downloadFile.close();
|
|
|
inputStream.close();
|
|
|
} catch (Exception e) {
|