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());
}
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations