Search in sources :

Example 1 with ErrorTip

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

the class CouponController method importCode.

/**
 * 现金券导入券码
 */
@RequestMapping(value = "/importCode/{couponId}")
@Permission
@ResponseBody
public Object importCode(@RequestParam(value = "codeFile") MultipartFile codeFile, @PathVariable Long couponId, HttpServletRequest request) {
    // 判断文件是否为空
    if (codeFile == null) {
        return new ErrorTip(500, "文件不能为空!");
    }
    // 获取文件名
    String fileName = codeFile.getOriginalFilename();
    // 验证文件名是否合格
    if (!ExcelImportUtils.validateExcel(fileName)) {
        return new ErrorTip(500, "文件必须是excel格式!");
    }
    // 进一步判断文件内容是否为空(即判断其大小是否为0或其名称是否为null)
    long size = codeFile.getSize();
    if (StringUtils.isEmpty(fileName) || size == 0) {
        return new ErrorTip(500, "文件不能为空!");
    }
    Coupon coupon = couponService.selectById(couponId);
    if (coupon == null) {
        return new ErrorTip(500, "优惠券没有找到!");
    } else if (coupon.getType().intValue() != CouponType.XJQ.getCode()) {
        return new ErrorTip(500, "现金券才能导入券号!");
    }
    // 执行导入
    try {
        String message = batchImport(fileName, codeFile, coupon);
        return new ErrorTip(200, message);
    } catch (BussinessException e) {
        log.error("", e);
        return new ErrorTip(500, e.getMessage());
    } catch (Exception e) {
        log.error("", e);
        return new ErrorTip(500, "发生未知错误,导入失败!");
    }
}
Also used : StoreCoupon(com.ikoori.vip.common.persistence.model.StoreCoupon) Coupon(com.ikoori.vip.common.persistence.model.Coupon) ErrorTip(com.ikoori.vip.common.constant.tips.ErrorTip) BussinessException(com.ikoori.vip.common.exception.BussinessException) BussinessException(com.ikoori.vip.common.exception.BussinessException) IOException(java.io.IOException) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with ErrorTip

use of com.ikoori.vip.common.constant.tips.ErrorTip 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 3 with ErrorTip

use of com.ikoori.vip.common.constant.tips.ErrorTip 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 4 with ErrorTip

use of com.ikoori.vip.common.constant.tips.ErrorTip 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 5 with ErrorTip

use of com.ikoori.vip.common.constant.tips.ErrorTip 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)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 SuccessTip (com.ikoori.vip.common.constant.tips.SuccessTip)4 JSONObject (com.alibaba.fastjson.JSONObject)3 Permission (com.ikoori.vip.common.annotion.Permission)1 BussinessException (com.ikoori.vip.common.exception.BussinessException)1 Coupon (com.ikoori.vip.common.persistence.model.Coupon)1 StoreCoupon (com.ikoori.vip.common.persistence.model.StoreCoupon)1 IOException (java.io.IOException)1