use of com.ikoori.vip.common.annotion.Permission in project vip by guangdada.
the class CouponController method couponUpdate.
/**
* 跳转到修改优惠券
*/
@Permission
@RequestMapping("/coupon_update/{couponId}")
public String couponUpdate(@PathVariable Long couponId, Model model) {
Long userId = Long.valueOf(ShiroKit.getUser().getId());
Merchant merchant = merchantService.getMerchantUserId(userId);
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("merchantId", merchant.getId());
// 查询可用店铺
List<StoreCoupon> storeCoupons = storeCouponService.getByCouponId(couponId);
model.addAttribute("storeCoupons", storeCoupons);
// 查询店铺
List<Store> stores = storeService.selectByCondition(condition);
model.addAttribute("stores", stores);
// 查询会员卡
List<Card> cards = cardService.selectByCondition(condition);
model.addAttribute("cards", cards);
Coupon coupon = couponService.selectById(couponId);
model.addAttribute(coupon);
return PREFIX + "coupon_edit.html";
}
use of com.ikoori.vip.common.annotion.Permission 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.annotion.Permission in project vip by guangdada.
the class CouponController method index.
/**
* 跳转到优惠券首页
*/
@Permission
@RequestMapping("")
public String index(Model model) {
model.addAttribute("couponType", CouponType.values());
Long userId = Long.valueOf(ShiroKit.getUser().getId());
Merchant merchant = merchantService.getMerchantUserId(userId);
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("merchantId", merchant.getId());
List<Store> stores = storeService.selectByCondition(condition);
model.addAttribute("stores", stores);
return PREFIX + "coupon.html";
}
use of com.ikoori.vip.common.annotion.Permission 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;
}
use of com.ikoori.vip.common.annotion.Permission 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, "发生未知错误,导入失败!");
}
}
Aggregations