Java Code Examples for cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo#getPhoneNumber()

The following examples show how to use cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo#getPhoneNumber() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WxAuthController.java    From BigDataPlatform with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 微信手机号码绑定
 *
 * @param userId
 * @param body
 * @return
 */
@PostMapping("bindPhone")
public Object bindPhone(@LoginUser Integer userId, @RequestBody String body) {
	if (userId == null) {
        return ResponseUtil.unlogin();
    }
	LitemallUser user = userService.findById(userId);
    String encryptedData = JacksonUtil.parseString(body, "encryptedData");
    String iv = JacksonUtil.parseString(body, "iv");
    WxMaPhoneNumberInfo phoneNumberInfo = this.wxService.getUserService().getPhoneNoInfo(user.getSessionKey(), encryptedData, iv);
    String phone = phoneNumberInfo.getPhoneNumber();
    user.setMobile(phone);
    if (userService.updateById(user) == 0) {
        return ResponseUtil.updatedDataFailed();
    }
    return ResponseUtil.ok();
}
 
Example 2
Source File: WxAuthController.java    From litemall with MIT License 6 votes vote down vote up
/**
 * 微信手机号码绑定
 *
 * @param userId
 * @param body
 * @return
 */
@PostMapping("bindPhone")
public Object bindPhone(@LoginUser Integer userId, @RequestBody String body) {
	if (userId == null) {
        return ResponseUtil.unlogin();
    }
	LitemallUser user = userService.findById(userId);
    String encryptedData = JacksonUtil.parseString(body, "encryptedData");
    String iv = JacksonUtil.parseString(body, "iv");
    WxMaPhoneNumberInfo phoneNumberInfo = this.wxService.getUserService().getPhoneNoInfo(user.getSessionKey(), encryptedData, iv);
    String phone = phoneNumberInfo.getPhoneNumber();
    user.setMobile(phone);
    if (userService.updateById(user) == 0) {
        return ResponseUtil.updatedDataFailed();
    }
    return ResponseUtil.ok();
}
 
Example 3
Source File: WxAuthController.java    From dts-shop with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 绑定手机号码
 * 
 * @param userId
 * @param body
 * @return
 */
@PostMapping("bindPhone")
public Object bindPhone(@LoginUser Integer userId, @RequestBody String body) {
	logger.info("【请求开始】绑定手机号码,请求参数,body:{}", body);

	String sessionKey = UserTokenManager.getSessionKey(userId);
	String encryptedData = JacksonUtil.parseString(body, "encryptedData");
	String iv = JacksonUtil.parseString(body, "iv");
	WxMaPhoneNumberInfo phoneNumberInfo = null;
	try {
		phoneNumberInfo = this.wxService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, iv);
	} catch (Exception e) {
		logger.error("绑定手机号码失败,获取微信绑定的手机号码出错:{}", body);
		e.printStackTrace();
		return ResponseUtil.fail();
	}
	String phone = phoneNumberInfo.getPhoneNumber();
	DtsUser user = userService.findById(userId);
	user.setMobile(phone);
	if (userService.updateById(user) == 0) {
		logger.error("绑定手机号码,更新用户信息出错,id:{}", user.getId());
		return ResponseUtil.updatedDataFailed();
	}
	Map<Object, Object> data = new HashMap<Object, Object>();
	data.put("phone", phone);

	logger.info("【请求结束】绑定手机号码,响应结果:{}", JSONObject.toJSONString(data));
	return ResponseUtil.ok(data);
}
 
Example 4
Source File: WxAuthController.java    From mall with MIT License 5 votes vote down vote up
@PostMapping("bindPhone")
public Object bindPhone(@LoginUser Integer userId, @RequestBody String body) {
    String sessionKey = UserTokenManager.getSessionKey(userId);
    String encryptedData = JacksonUtil.parseString(body, "encryptedData");
    String iv = JacksonUtil.parseString(body, "iv");
    WxMaPhoneNumberInfo phoneNumberInfo = this.wxService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, iv);
    String phone = phoneNumberInfo.getPhoneNumber();
    LitemallUser user = userService.findById(userId);
    user.setMobile(phone);
    if (userService.updateById(user) == 0) {
        return ResponseUtil.updatedDataFailed();
    }
    return ResponseUtil.ok();
}