Search in sources :

Example 11 with Merchant

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

the class CardController method list.

/**
 * 获取会员卡列表
 */
@RequestMapping(value = "/list")
@Permission
@ResponseBody
public Object list(String condition) {
    Long userId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(userId);
    Page<Card> page = new PageFactory<Card>().defaultPage();
    List<Map<String, Object>> result = cardService.getCardList(page, condition, page.getOrderByField(), page.isAsc(), merchant.getId());
    page.setRecords((List<Card>) new CardWarpper(result).warp());
    return super.packForBT(page);
}
Also used : Merchant(com.ikoori.vip.common.persistence.model.Merchant) CardWarpper(com.ikoori.vip.server.modular.biz.warpper.CardWarpper) HashMap(java.util.HashMap) Map(java.util.Map) Card(com.ikoori.vip.common.persistence.model.Card) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with Merchant

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

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

the class CardController method cardUpdate.

/**
 * 跳转到修改会员卡
 */
@Permission
@RequestMapping("/card_update/{cardId}")
public String cardUpdate(@PathVariable Long cardId, 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);
    couponCon.put("type", CouponType.YHQ.getCode());
    model.addAttribute("merchantName", merchant.getName());
    List<Coupon> coupons = couponService.selectByCondition(couponCon);
    // 查询优惠群
    model.addAttribute("coupons", coupons);
    // 查询颜色值
    model.addAttribute("colors", ColorType.values());
    model.addAttribute("grantType", CardGrantType.values());
    Map<String, Object> condition = new HashMap<String, Object>();
    condition.put("merchantId", merchant.getId());
    condition.put("grantType", CardGrantType.NO_RULE.getCode());
    condition.put("excludeCardId", cardId);
    List<Card> cards = cardService.selectByCondition(condition);
    // 查询会员卡
    model.addAttribute("cards", cards);
    // 查询商户Logo
    model.addAttribute("logo", merchant.getHeadImg());
    Card card = cardService.selectById(cardId);
    if (StringUtils.isNotBlank(card.getColorCode())) {
        model.addAttribute("colorType", ColorType.valueOf(card.getColorCode()));
    } else {
        model.addAttribute("colorType", ColorType.Color010);
    }
    model.addAttribute(card);
    Map<String, Object> con = new HashMap<String, Object>();
    con.put("cardId", card.getId());
    List<CardRight> cardRights = cardRightService.selectByCondition(con);
    List<CardRight> couponRights = new ArrayList<CardRight>();
    if (CollectionUtils.isNotEmpty(cardRights)) {
        for (CardRight cardRight : cardRights) {
            if (cardRight.getRightType().equals(RightType.DISCOUNT.getCode())) {
                model.addAttribute(RightType.DISCOUNT.getCode(), cardRight);
            } else if (cardRight.getRightType().equals(RightType.POINTS.getCode())) {
                model.addAttribute(RightType.POINTS.getCode(), cardRight);
            } else if (cardRight.getRightType().equals(RightType.COUPON.getCode())) {
                couponRights.add(cardRight);
            }
        }
    }
    model.addAttribute(RightType.COUPON.getCode(), couponRights);
    return PREFIX + "card_edit.html";
}
Also used : Coupon(com.ikoori.vip.common.persistence.model.Coupon) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Card(com.ikoori.vip.common.persistence.model.Card) Merchant(com.ikoori.vip.common.persistence.model.Merchant) CardRight(com.ikoori.vip.common.persistence.model.CardRight) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with Merchant

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

the class CardController method cardAdd.

/**
 * 跳转到添加会员卡
 */
@Permission
@RequestMapping("/card_add")
public String cardAdd(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);
    couponCon.put("type", CouponType.YHQ.getCode());
    model.addAttribute("merchantName", merchant.getName());
    List<Coupon> coupons = couponService.selectByCondition(couponCon);
    // 查询优惠群
    model.addAttribute("coupons", coupons);
    // 查询颜色值
    model.addAttribute("colors", ColorType.values());
    model.addAttribute("grantType", CardGrantType.values());
    Map<String, Object> condition = new HashMap<String, Object>();
    condition.put("merchantId", merchant.getId());
    condition.put("grantType", CardGrantType.NO_RULE.getCode());
    List<Card> cards = cardService.selectByCondition(condition);
    // 查询会员卡
    model.addAttribute("cards", cards);
    // model.addAttribute("grantType", GrantType.NO_RULE.getCode());
    // 查询商户Logo
    model.addAttribute("logo", merchant.getHeadImg());
    return PREFIX + "card_add.html";
}
Also used : Coupon(com.ikoori.vip.common.persistence.model.Coupon) Merchant(com.ikoori.vip.common.persistence.model.Merchant) HashMap(java.util.HashMap) Card(com.ikoori.vip.common.persistence.model.Card) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with Merchant

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

the class CouponController method list.

/**
 * 获取优惠券列表
 */
@RequestMapping(value = "/list")
@Permission
@ResponseBody
public Object list(String couponName, Long storeId, Boolean isExpired, Boolean isInvalid, Integer type) {
    Long userId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(userId);
    Page<Coupon> page = new PageFactory<Coupon>().defaultPage();
    List<Map<String, Object>> result = couponService.getCouponList(merchant.getId(), isExpired, isInvalid, type, storeId, page, couponName, page.getOrderByField(), page.isAsc());
    page.setRecords((List<Coupon>) new CouponWarpper(result).warp());
    return super.packForBT(page);
}
Also used : StoreCoupon(com.ikoori.vip.common.persistence.model.StoreCoupon) Coupon(com.ikoori.vip.common.persistence.model.Coupon) Merchant(com.ikoori.vip.common.persistence.model.Merchant) CouponWarpper(com.ikoori.vip.server.modular.biz.warpper.CouponWarpper) HashMap(java.util.HashMap) Map(java.util.Map) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Merchant (com.ikoori.vip.common.persistence.model.Merchant)66 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)59 Permission (com.ikoori.vip.common.annotion.Permission)55 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)35 HashMap (java.util.HashMap)29 Map (java.util.Map)20 Store (com.ikoori.vip.common.persistence.model.Store)12 Card (com.ikoori.vip.common.persistence.model.Card)11 BussinessException (com.ikoori.vip.common.exception.BussinessException)8 Coupon (com.ikoori.vip.common.persistence.model.Coupon)7 MemberCard (com.ikoori.vip.common.persistence.model.MemberCard)7 LinkedHashMap (java.util.LinkedHashMap)4 JSONObject (com.alibaba.fastjson.JSONObject)3 Ticket (com.ikoori.vip.common.persistence.model.Ticket)3 User (com.ikoori.vip.common.persistence.model.User)3 Transactional (org.springframework.transaction.annotation.Transactional)3 Member (com.ikoori.vip.common.persistence.model.Member)2 Picture (com.ikoori.vip.common.persistence.model.Picture)2 StoreCoupon (com.ikoori.vip.common.persistence.model.StoreCoupon)2 CouponCodeWarpper (com.ikoori.vip.server.modular.biz.warpper.CouponCodeWarpper)2