Search in sources :

Example 1 with SuccessTip

use of com.ikoori.vip.common.constant.tips.SuccessTip in project vip by guangdada.

the class MemberController method registerMember.

/**
 * @Title: registerMember
 * @Description: 会员激活
 * @param  request
 * @param  map
 * @param  mem
 * @param  mobileCode 手机短信验证码
 * @return Object
 * @throws
 */
@RequestMapping(value = "/registerMember", method = { RequestMethod.POST })
@ResponseBody
public Object registerMember(HttpServletRequest request, Map<String, Object> map, @Valid Member mem, String mobileCode) {
    log.info("进入registerMember");
    String unionid = WeChatAPI.getUnionid(request.getSession());
    if (unionid == null) {
        log.info("unionid == null");
        return new ErrorTip(BizExceptionEnum.SERVER_ERROR);
    }
    // 验证手机短信验证码是否正确
    String mobileCode1 = request.getSession().getAttribute(Constant.MOBILE_CODE) + "";
    if (StringUtils.isBlank(mobileCode1) || !mobileCode1.equals(mobileCode)) {
        log.info(BizExceptionEnum.ERROR_MOBILE_CODE.getMessage());
        return new ErrorTip(BizExceptionEnum.ERROR_MOBILE_CODE);
    }
    // 验证手机号是否唯一
    Object member = consumer.getMemberInfoApi().get().getMemberByMobile(mem.getMobile());
    if (member != null) {
        log.info("member != null");
        return new ErrorTip(BizExceptionEnum.EXISTED_MOBILE);
    }
    try {
        // 激活会员信息
        consumer.getMemberInfoApi().get().activeMemberByUnionid(unionid, mem.getMobile(), IpUtil.getIpAddr(request), true);
        // 移除短信码
        request.getSession().removeAttribute(Constant.MOBILE_CODE);
    } catch (Exception e) {
        log.error("会员激活失败", e);
        return new ErrorTip(BizExceptionEnum.SERVER_ERROR);
    }
    log.info("结束registerMember");
    return new SuccessTip();
}
Also used : ErrorTip(com.ikoori.vip.common.constant.tips.ErrorTip) JSONObject(com.alibaba.fastjson.JSONObject) SuccessTip(com.ikoori.vip.common.constant.tips.SuccessTip) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with SuccessTip

use of com.ikoori.vip.common.constant.tips.SuccessTip in project vip by guangdada.

the class MemberController method validateMoblie.

/**
 * @Title: validateMoblie
 * @Description: 验证手机号是否唯一
 * @param  request
 * @param  map
 * @param  mobile 手机号
 * @return Object
 * @throws
 */
@RequestMapping(value = "/validateMobile", method = { RequestMethod.GET, RequestMethod.POST })
@ResponseBody
public Object validateMoblie(HttpServletRequest request, Map<String, Object> map, String mobile) {
    log.info("进入validateMoblie");
    // 手机号是否唯一
    Object member = consumer.getMemberInfoApi().get().getMemberByMobile(mobile);
    if (member == null) {
        log.info("member == null 结束validateMoblie");
        return new SuccessTip();
    } else {
        log.info("结束validateMoblie");
        return new ErrorTip(BizExceptionEnum.SERVER_ERROR);
    }
}
Also used : ErrorTip(com.ikoori.vip.common.constant.tips.ErrorTip) JSONObject(com.alibaba.fastjson.JSONObject) SuccessTip(com.ikoori.vip.common.constant.tips.SuccessTip) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with SuccessTip

use of com.ikoori.vip.common.constant.tips.SuccessTip in project vip by guangdada.

the class MemberController method updateInfo.

/**
 * @Title: updateInfo
 * @Description: 修改会员信息
 * @param request
 * @param  map
 * @param  mem
 * @return Object
 * @throws
 */
@RequestMapping(value = "/updateMemberInfo", method = { RequestMethod.POST })
@ResponseBody
public Object updateInfo(HttpServletRequest request, Map<String, Object> map, @Valid Member mem) {
    try {
        log.info("进入updateInfo");
        String unionid = WeChatAPI.getUnionid(request.getSession());
        if (unionid == null) {
            log.info("unionid == null");
            throw new Exception("登录信息有误");
        }
        JSONObject member = consumer.getMemberInfoApi().get().getMemberInfoByUnionid(unionid);
        if (member == null || !member.getBooleanValue("isActive")) {
            throw new Exception("用户没有激活");
        }
        if (!member.getString("mobile").equals(mem.getMobile())) {
            throw new Exception("激活后手机号不能修改");
        }
        // 修改会员信息
        consumer.getMemberInfoApi().get().updateMemberInfoByUnionid(unionid, mem.getMobile(), mem.getName(), mem.getSex(), mem.getBirthday(), mem.getAddress(), mem.getArea());
    } catch (Exception e) {
        log.error("会员信息修改失败", e);
        return new ErrorTip(BizExceptionEnum.SERVER_ERROR);
    }
    log.info("结束updateInfo");
    return new SuccessTip();
}
Also used : ErrorTip(com.ikoori.vip.common.constant.tips.ErrorTip) JSONObject(com.alibaba.fastjson.JSONObject) SuccessTip(com.ikoori.vip.common.constant.tips.SuccessTip) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with SuccessTip

use of com.ikoori.vip.common.constant.tips.SuccessTip in project vip by guangdada.

the class MemberController method validateCode.

/**
 * @Title: validateCode
 * @Description: 验证码验证
 * @param  request
 * @param  map
 * @param  code   随机验证码
 * @param  mobile 手机号
 * @return Object
 * @throws
 */
@RequestMapping(value = "/validateCode", method = { RequestMethod.GET, RequestMethod.POST })
@ResponseBody
public Object validateCode(HttpServletRequest request, Map<String, Object> map, String code, String mobile) {
    log.info("进入validateCode");
    // 验证验证码是否正确,正确则发送手机短信验证码
    String imgCode = (String) request.getSession().getAttribute(Constant.IMG_CODE);
    if (mobile.equals("")) {
        log.info(BizExceptionEnum.EMPTY_MOBILE.getMessage());
        return new ErrorTip(BizExceptionEnum.EMPTY_MOBILE);
    } else if (imgCode.equals(code)) {
        request.getSession().setAttribute(Constant.MOBILE_CODE, sendMessage(mobile));
        // 移除图形验证码
        request.getSession().removeAttribute(Constant.IMG_CODE);
        log.info("结束validateCode");
        return new SuccessTip();
    } else {
        log.info("结束validateCode");
        return new ErrorTip(BizExceptionEnum.SERVER_ERROR);
    }
}
Also used : ErrorTip(com.ikoori.vip.common.constant.tips.ErrorTip) SuccessTip(com.ikoori.vip.common.constant.tips.SuccessTip) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ErrorTip (com.ikoori.vip.common.constant.tips.ErrorTip)4 SuccessTip (com.ikoori.vip.common.constant.tips.SuccessTip)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 JSONObject (com.alibaba.fastjson.JSONObject)3