Commit c4bece98 by zhengxj

finish 生成服务商二维码上传到fastdfs on 20191015 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@24262 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 585001db
...@@ -36,6 +36,7 @@ import org.apache.http.message.BasicHeader; ...@@ -36,6 +36,7 @@ import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HTTP;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -47,6 +48,8 @@ import org.springframework.web.client.RestTemplate; ...@@ -47,6 +48,8 @@ import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.Constants; import com.glsx.common.constants.Constants;
import com.glsx.common.feign.client.CommonClient;
import com.glsx.common.feign.client.UserClient;
import com.glsx.common.utils.HttpUtils; import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil; import com.glsx.common.utils.PropertiesUtil;
import com.glsx.common.utils.RedisCacheUtil; import com.glsx.common.utils.RedisCacheUtil;
...@@ -80,6 +83,8 @@ public class WechatUtils { ...@@ -80,6 +83,8 @@ public class WechatUtils {
@Resource @Resource
RedisCacheUtil redisCacheUtil; RedisCacheUtil redisCacheUtil;
@Autowired
private CommonClient commonClient;
/** /**
* 获取微信token和ticket * 获取微信token和ticket
* *
...@@ -329,11 +334,11 @@ public class WechatUtils { ...@@ -329,11 +334,11 @@ public class WechatUtils {
Map<String, String> returnMap = new HashMap<>(4); Map<String, String> returnMap = new HashMap<>(4);
returnMap.put("code", "500"); returnMap.put("code", "500");
String prefix = "data:image/png;base64,";
String appid = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_APPID); String appid = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_APPID);
String secret = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_SECRET); String secret = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_SECRET);
// TODO 待前端开发技工注册的跳转页面 // TODO 待前端开发技工注册的跳转页面
String page = "pages/index"; // String page = "pages/index";
String accessToken = null; String accessToken = null;
try { try {
accessToken = this.getWechatToken(appid, secret); accessToken = this.getWechatToken(appid, secret);
...@@ -351,7 +356,7 @@ public class WechatUtils { ...@@ -351,7 +356,7 @@ public class WechatUtils {
String url = this.GET_WXACODE_UNLIMIT.replace("$ACCESS_TOKEN$", accessToken); String url = this.GET_WXACODE_UNLIMIT.replace("$ACCESS_TOKEN$", accessToken);
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("scene", sceneStr); param.put("scene", sceneStr);
param.put("page", page); // param.put("page", page);
param.put("width", 430); param.put("width", 430);
param.put("auto_color", false); param.put("auto_color", false);
Map<String, Object> line_color = new HashMap<>(); Map<String, Object> line_color = new HashMap<>();
...@@ -371,9 +376,13 @@ public class WechatUtils { ...@@ -371,9 +376,13 @@ public class WechatUtils {
if (img.startsWith("/9j/")) { if (img.startsWith("/9j/")) {
// 二维码生成成功 // 二维码生成成功
logger.info(Base64.encodeBase64String(result)); logger.info(Base64.encodeBase64String(result));
returnMap.put("img", prefix + img); JSONObject jb = commonClient.uploadQRImage(result);
returnMap.put("code", "200"); if (jb != null && jb.containsKey("data")) {
return returnMap; returnMap.put("code", "200");
returnMap.put("img", jb.getString("data"));
return returnMap;
}
} }
// inputStream = new ByteArrayInputStream(result); // inputStream = new ByteArrayInputStream(result);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!