Search in sources :

Example 6 with Coupon

use of com.ikoori.vip.common.persistence.model.Coupon 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";
}
Also used : StoreCoupon(com.ikoori.vip.common.persistence.model.StoreCoupon) Coupon(com.ikoori.vip.common.persistence.model.Coupon) HashMap(java.util.HashMap) Store(com.ikoori.vip.common.persistence.model.Store) Card(com.ikoori.vip.common.persistence.model.Card) Merchant(com.ikoori.vip.common.persistence.model.Merchant) StoreCoupon(com.ikoori.vip.common.persistence.model.StoreCoupon) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with Coupon

use of com.ikoori.vip.common.persistence.model.Coupon 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 8 with Coupon

use of com.ikoori.vip.common.persistence.model.Coupon 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)

Example 9 with Coupon

use of com.ikoori.vip.common.persistence.model.Coupon 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 10 with Coupon

use of com.ikoori.vip.common.persistence.model.Coupon in project vip by guangdada.

the class CouponCodeController method index.

/**
 * 跳转到券码管理首页
 */
@Permission
@RequestMapping("")
public String index(Model model) {
    Long userId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(userId);
    Map<String, Object> couponCon = new HashMap<String, Object>();
    couponCon.put("merchantId", merchant.getId());
    couponCon.put("invalid", true);
    List<Coupon> coupons = couponService.selectByCondition(couponCon);
    // 查询优惠群
    model.addAttribute("coupons", coupons);
    model.addAttribute("codeStatus", CouponCodeStatus.values());
    return PREFIX + "couponCode.html";
}
Also used : Coupon(com.ikoori.vip.common.persistence.model.Coupon) Merchant(com.ikoori.vip.common.persistence.model.Merchant) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Coupon (com.ikoori.vip.common.persistence.model.Coupon)18 Permission (com.ikoori.vip.common.annotion.Permission)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 Merchant (com.ikoori.vip.common.persistence.model.Merchant)7 HashMap (java.util.HashMap)7 Transactional (org.springframework.transaction.annotation.Transactional)7 BussinessException (com.ikoori.vip.common.exception.BussinessException)6 StoreCoupon (com.ikoori.vip.common.persistence.model.StoreCoupon)6 Card (com.ikoori.vip.common.persistence.model.Card)4 Member (com.ikoori.vip.common.persistence.model.Member)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 JSONObject (com.alibaba.fastjson.JSONObject)2 CardRight (com.ikoori.vip.common.persistence.model.CardRight)2 CouponCode (com.ikoori.vip.common.persistence.model.CouponCode)2 Point (com.ikoori.vip.common.persistence.model.Point)2 Share (com.ikoori.vip.common.persistence.model.Share)2 Store (com.ikoori.vip.common.persistence.model.Store)2 Date (java.util.Date)2 ErrorTip (com.ikoori.vip.common.constant.tips.ErrorTip)1 CouponPayDo (com.ikoori.vip.common.dto.CouponPayDo)1