| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.dg.core.annotation.Authorization; |
| | | import com.dg.core.db.gen.entity.GuideEvolveEntity; |
| | | import com.dg.core.db.gen.entity.GuideRepairOrder; |
| | | import com.dg.core.db.gen.entity.SysUser; |
| | |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.DefaultHttpClient; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | |
| | | |
| | | private static String miniprogramState="trial";//trial 为测试版 formal 为正式版 切记发布版本时候改为正式版 |
| | | |
| | | @Resource(name = "stringRedisTemplate") |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| | | private static WxUtil wxUtil; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | wxUtil = this; |
| | | wxUtil.stringRedisTemplate = this.stringRedisTemplate; |
| | | } |
| | | |
| | | /** |
| | | * 获取花城token,(ps:0=token获取失败) |
| | | * |
| | |
| | | */ |
| | | public String getBatteryCarAccessToken() throws Exception { |
| | | String accessToken = "0"; |
| | | try { |
| | | // 此处APP_ID APP_SECRET 在微信小程序后端可见 |
| | | // String accessTokenUrl = String.format(TEMP_URL, APP_ID, APP_SECRET); |
| | | String accessTokenUrl = ACCESS_TOKEN_URL + "&appid=" + ConstantPropertiesUtil.WX_OPEN_APP_ID |
| | | + "&secret=" +ConstantPropertiesUtil.WX_OPEN_APP_SECRET; |
| | | String result = httpGet(accessTokenUrl, null, null); |
| | | Map<String, Object> resultMap = JSON.parseObject(result, Map.class); |
| | | if (resultMap.containsKey("access_token")) { |
| | | accessToken = resultMap.get("access_token").toString(); |
| | | } |
| | | } catch (IOException ioe) { |
| | | ioe.printStackTrace(); |
| | | } |
| | | // try { |
| | | // // 此处APP_ID APP_SECRET 在微信小程序后端可见 |
| | | // // String accessTokenUrl = String.format(TEMP_URL, APP_ID, APP_SECRET); |
| | | // String accessTokenUrl = ACCESS_TOKEN_URL + "&appid=" + ConstantPropertiesUtil.WX_OPEN_APP_ID |
| | | // + "&secret=" +ConstantPropertiesUtil.WX_OPEN_APP_SECRET; |
| | | // String result = httpGet(accessTokenUrl, null, null); |
| | | // Map<String, Object> resultMap = JSON.parseObject(result, Map.class); |
| | | // if (resultMap.containsKey("access_token")) { |
| | | // accessToken = resultMap.get("access_token").toString(); |
| | | // } |
| | | // } catch (IOException ioe) { |
| | | // ioe.printStackTrace(); |
| | | // } |
| | | accessToken =wxUtil.stringRedisTemplate.boundValueOps("access_token:access_token:" + ConstantPropertiesUtil.WX_OPEN_APP_ID).get(); |
| | | return accessToken; |
| | | } |
| | | |