Search in sources :

Example 21 with BussinessException

use of com.ikoori.vip.common.exception.BussinessException 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 22 with BussinessException

use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.

the class MemberController method add.

/**
 * 新增会员
 */
@RequestMapping(value = "/add")
@Permission
@ResponseBody
public Object add(Member member, Long cardId) {
    // 添加会员, 判断账号是否重复
    Member memberRe = memberService.selectByMobile(member.getMobile());
    if (memberRe != null) {
        throw new BussinessException(BizExceptionEnum.USER_ALREADY_REG);
    }
    memberService.saveMember(member, cardId);
    return super.SUCCESS_TIP;
}
Also used : Member(com.ikoori.vip.common.persistence.model.Member) BussinessException(com.ikoori.vip.common.exception.BussinessException) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 23 with BussinessException

use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.

the class CouponCodeController method update.

/**
 * 根据批次号修改券号状态为“已制卡”
 */
@RequestMapping(value = "/update")
@Permission
@ResponseBody
public Object update(@RequestParam String ids) {
    if (ToolUtil.isEmpty(ids)) {
        throw new BussinessException(500, "请选择数据");
    }
    String[] as = ids.split(",");
    Long[] codeIds = new Long[as.length];
    for (int i = 0; i < as.length; i++) {
        codeIds[i] = Long.valueOf(as[i]);
    }
    Long userId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(userId);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("ids", codeIds);
    params.put("merchantId", merchant.getId());
    params.put("useStatus", CouponCodeStatus.madecard.getCode());
    couponCodeService.updateUseStatus(params);
    return super.SUCCESS_TIP;
}
Also used : Merchant(com.ikoori.vip.common.persistence.model.Merchant) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BussinessException(com.ikoori.vip.common.exception.BussinessException) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 24 with BussinessException

use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.

the class ShareController method update.

/**
 * 修改分享规则
 */
@RequestMapping(value = "/update")
@Permission
@ResponseBody
public Object update(Share share) {
    if (ToolUtil.isEmpty(share) || share.getId() == null) {
        throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
    }
    Long userId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(userId);
    share.setMerchantId(merchant.getId());
    shareService.saveShare(share);
    return super.SUCCESS_TIP;
}
Also used : Merchant(com.ikoori.vip.common.persistence.model.Merchant) BussinessException(com.ikoori.vip.common.exception.BussinessException) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 25 with BussinessException

use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.

the class MemberServiceImpl method updateMember.

/**
 * <p>Title: updateMember</p>
 * <p>Description: 修改会员</p>
 * @param member
 * @param cardId 会员卡号
 * @param point  交易积分
 * @see com.ikoori.vip.server.modular.biz.service.IMemberService#updateMember(com.ikoori.vip.common.persistence.model.Member, java.lang.Long, int)
 */
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void updateMember(Member member, Long cardId, int point) {
    Member dbMember = selectById(member.getId());
    // 会员没激活,填手机号码,判断手机号码是否唯一
    if (!dbMember.isIsActive()) {
        // 修改会员, 判断账号是否重复
        Member memberRe = selectByMobile(member.getMobile());
        if (memberRe != null) {
            throw new BussinessException(BizExceptionEnum.USER_ALREADY_REG);
        }
    }
    // 更新交易积分
    if (point != 0) {
        Boolean inOut = point > 0 ? true : false;
        pointTradeService.savePointTrade(inOut, PointTradeType.GIVE.getCode(), point, dbMember.getId(), null, dbMember.getMerchantId(), null, "");
    }
    // 更新会员信息
    member.setPoints(member.getPoints() + point);
    member.setIsActive(true);
    memberMapper.updateById(member);
    // 更新会员卡
    Card card = cardMapper.selectById(cardId);
    upgradeMemberCard(dbMember, card);
}
Also used : Member(com.ikoori.vip.common.persistence.model.Member) BussinessException(com.ikoori.vip.common.exception.BussinessException) Card(com.ikoori.vip.common.persistence.model.Card) MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

BussinessException (com.ikoori.vip.common.exception.BussinessException)41 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)25 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)19 Permission (com.ikoori.vip.common.annotion.Permission)17 Transactional (org.springframework.transaction.annotation.Transactional)9 User (com.ikoori.vip.common.persistence.model.User)8 Merchant (com.ikoori.vip.common.persistence.model.Merchant)7 Date (java.util.Date)7 Coupon (com.ikoori.vip.common.persistence.model.Coupon)6 ShiroUser (com.ikoori.vip.server.core.shiro.ShiroUser)6 BussinessLog (com.ikoori.vip.common.annotion.log.BussinessLog)5 File (java.io.File)4 HashMap (java.util.HashMap)4 EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)3 OrderItemPayDo (com.ikoori.vip.common.dto.OrderItemPayDo)3 Card (com.ikoori.vip.common.persistence.model.Card)3 Member (com.ikoori.vip.common.persistence.model.Member)3 Menu (com.ikoori.vip.common.persistence.model.Menu)3 StoreCoupon (com.ikoori.vip.common.persistence.model.StoreCoupon)3 ApiOperation (io.swagger.annotations.ApiOperation)3