/**
* 获取微信绑定的手机号码
* @param encryptedData
* @param vi
* @param sessionKey
* @param mbId
* @return
* @throws Exception
* 说明:encryptedData和vi 前端调用XXX返回
* sessionKey:在getOpenId多返回一个session_key
* (https://api.weixin.qq.com/sns/jscode2session?appid="+appId+"&secret="+secret+"&js_code=" + jsCode + "&grant_type=authorization_code)
*/
@RequestMapping("/m/getWxbindPhone")
@ResponseBody
public Map<String, Object> getWxPhone(String encryptedData,String vi,String sessionKey,Integer mbId)throws Exception{
Map<String, Object> res = new HashMap<String, Object>();
String code = MConstants.SUCCESS;
String msg = MConstants.SUCCESS_TXT;
// 通过解密算法将用户的手机号解析出来。
byte[] encrypData = Base64.decodeBase64(encryptedData);
byte[] ivData = Base64.decodeBase64(vi);
byte[] session = Base64.decodeBase64(sessionKey);
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivData);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKeySpec keySpec = new SecretKeySpec(session, "AES");
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
String json = new String(cipher.doFinal(encrypData),"UTF-8");
Gson gson = new Gson();
// Map<String, Object> object = gson.fromJson(json, Map.class);
res.put("phone", object);
res.put("code", code);
res.put("msg", msg);
return res;
}