Search in sources :

Example 16 with BussinessException

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

the class CardServiceImpl method saveCard.

@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveCard(Card card, String rights) {
    if (card.getGrantType().intValue() == CardGrantType.RULE.getCode() && !checkCardLevel(card.getId(), card.getCardLevel(), card.getMerchantId())) {
        throw new BussinessException(BizExceptionEnum.INVALID_cardLevel);
    }
    if (!checkCardName(card.getId(), card.getName(), card.getMerchantId())) {
        throw new BussinessException(BizExceptionEnum.INVALID_cardName);
    }
    if (card.getGrantType().intValue() == CardGrantType.SUB_WX.getCode()) {
        if (!checkSubWxCount(card.getId(), card.getMerchantId())) {
            throw new BussinessException(BizExceptionEnum.INVALID_grantType);
        }
    }
    card.setCreateUserId(Long.valueOf(ShiroKit.getUser().getId()));
    if (card.getCoverType().intValue() == 1) {
        card.setColorCode("");
    } else {
        card.setCoverPic("");
    }
    card.setCardNumberPrefix("KR");
    if (card.getId() != null) {
        Card cardDb = cardMapper.selectById(card.getId());
        String[] ignoreProperties = { "id", "createUserId", "merchantId", "colorId", "isNeedActivate", "isSyncWeixin", "isAvailable", "syncWeixinState", "weixinCardId", "cardNumberPrefix", "isAllowShare", "termToCardId", "activationCondition", "grantCondition", "displayOrder", "createTime", "updateTime", "status" };
        BeanUtils.copyProperties(card, cardDb, ignoreProperties);
        cardDb.setUpdateTime(new Date());
        Integer c = cardMapper.updateAllColumnById(cardDb);
        if (c > 0) {
            // 先删除修改前的权益值,再添加新的权益值
            cardRightMapper.delete(new EntityWrapper<CardRight>().eq("card_id", card.getId()));
            if (StringUtils.isNotBlank(rights)) {
                getRigthFromJson(rights, card.getId());
            }
        }
    } else {
        cardMapper.insert(card);
        if (StringUtils.isNotBlank(rights)) {
            getRigthFromJson(rights, card.getId());
        }
    }
}
Also used : EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) BussinessException(com.ikoori.vip.common.exception.BussinessException) Date(java.util.Date) Card(com.ikoori.vip.common.persistence.model.Card) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with BussinessException

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

the class StoreEmployeeController method add.

/**
 * 新增员工管理
 */
@RequestMapping(value = "/add")
@Permission
@ResponseBody
public Object add(StoreEmployee storeEmployee, String password, String sex) {
    // 当前登录账号
    Long createUserId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(createUserId);
    // 添加用户, 判断账号是否重复
    User theUser = managerDao.getByAccount(storeEmployee.getMobile());
    if (theUser != null) {
        throw new BussinessException(BizExceptionEnum.USER_ALREADY_REG);
    }
    storeEmployee.setMerchantId(merchant.getId());
    storeEmployee.setCreateUserId(createUserId);
    storeEmployeeService.saveEmployee(storeEmployee, password, sex);
    return super.SUCCESS_TIP;
}
Also used : User(com.ikoori.vip.common.persistence.model.User) 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 18 with BussinessException

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

the class CardController method update.

/**
 * 修改会员卡
 */
@RequestMapping(value = "/update")
@Permission
@ResponseBody
public Object update(Card card, String rights) {
    if (ToolUtil.isEmpty(card) || card.getId() == null) {
        throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
    }
    Long userId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(userId);
    card.setMerchantId(merchant.getId());
    cardService.saveCard(card, rights);
    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 19 with BussinessException

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

the class CouponController method delete.

/**
 * 删除优惠券
 */
@RequestMapping(value = "/delete")
@Permission
@ResponseBody
public Object delete(@RequestParam Long couponId) {
    Coupon coupon = couponService.selectById(couponId);
    if (coupon.isIsInvalid()) {
        throw new BussinessException(500, "优惠券已经生效,不能删除");
    }
    couponService.deleteById(couponId);
    return SUCCESS_TIP;
}
Also used : StoreCoupon(com.ikoori.vip.common.persistence.model.StoreCoupon) Coupon(com.ikoori.vip.common.persistence.model.Coupon) 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 20 with BussinessException

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

the class CouponController method valid.

/**
 * 生效优惠券
 */
@RequestMapping(value = "/valid")
@Permission
@ResponseBody
public Object valid(@RequestParam Long couponId) {
    Coupon coupon = couponService.selectById(couponId);
    if (coupon.isIsInvalid()) {
        throw new BussinessException(500, "优惠券已经生效");
    }
    coupon.setIsInvalid(true);
    couponService.updateById(coupon);
    return SUCCESS_TIP;
}
Also used : StoreCoupon(com.ikoori.vip.common.persistence.model.StoreCoupon) Coupon(com.ikoori.vip.common.persistence.model.Coupon) 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)

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