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, "发生未知错误,导入失败!");
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations