Search in sources :

Example 1 with MemberCard

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

the class MemberController method memberUpdate.

/**
 * 跳转到修改会员
 */
@Permission
@RequestMapping("/member_update/{memberId}")
public String memberUpdate(@PathVariable Long memberId, Model model) {
    Member member = memberService.selectById(memberId);
    Long userId = Long.valueOf(ShiroKit.getUser().getId());
    MemberCard memberCard = new MemberCard();
    memberCard.setMemberId(member.getId());
    memberCard.setIsDefault(true);
    memberCard = memberCardMapper.selectOne(memberCard);
    model.addAttribute("memberCard", memberCard);
    // 会员卡
    Merchant merchant = merchantService.getMerchantUserId(userId);
    Map<String, Object> condition = new HashMap<String, Object>();
    condition.put("merchantId", merchant.getId());
    condition.put("inGrantType", new Object[] { CardGrantType.NO_RULE.getCode(), CardGrantType.SUB_WX.getCode() });
    List<Card> cards = cardService.selectByCondition(condition);
    model.addAttribute("cards", cards);
    model.addAttribute("member", member);
    return PREFIX + "member_edit.html";
}
Also used : MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Merchant(com.ikoori.vip.common.persistence.model.Merchant) HashMap(java.util.HashMap) Member(com.ikoori.vip.common.persistence.model.Member) Card(com.ikoori.vip.common.persistence.model.Card) MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with MemberCard

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

the class MemberCardController method memberCardUpdate.

/**
 * 跳转到修改领取记录
 */
@Permission
@RequestMapping("/memberCard_update/{memberCardId}")
public String memberCardUpdate(@PathVariable Long memberCardId, Model model) {
    MemberCard memberCard = memberCardService.selectById(memberCardId);
    model.addAttribute(memberCard);
    return PREFIX + "memberCard_edit.html";
}
Also used : MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with MemberCard

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

the class MemberServiceImpl method saveMember.

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveMember(Member member, Long cardId) {
    // 当前登录账号
    Long createUserId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(createUserId);
    /*member.setIsActive(false);*/
    this.insert(member);
    // 获得会员卡
    Card card = cardMapper.selectById(cardId);
    // 会员卡
    MemberCard mc = new MemberCard();
    mc.setMemberId(member.getId());
    mc.setMerchantId(merchant.getId());
    mc.setCardId(cardId);
    mc.setCardNumber(RandomUtil.generateCardNum(card.getCardNumberPrefix()));
    memberCardMapper.insert(mc);
}
Also used : MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Merchant(com.ikoori.vip.common.persistence.model.Merchant) Card(com.ikoori.vip.common.persistence.model.Card) MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with MemberCard

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

the class MemberServiceImpl method upgradeMemberCard.

/**
 * 升级会员卡和权益
 * @Title: upgradeMemCard
 * @param member
 * @param card
 * @date:   2017年9月18日 下午1:51:33
 * @author: chengxg
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void upgradeMemberCard(Member member, Card card) {
    MemberCard mc = getMemberCard(member.getId(), card.getId());
    if (mc != null) {
        log.info("已经有该级别会员卡");
        // 已经有该级别会员卡
        mc.setIsDefault(true);
        memberCardMapper.updateById(mc);
    } else {
        log.info("没有该级别会员卡,发送一张");
        // 没有该级别会员卡
        MemberCard memCard = new MemberCard();
        memCard.setCardId(card.getId());
        memCard.setCardNumber(RandomUtil.generateCardNum(card.getCardNumberPrefix()));
        memCard.setMemberId(member.getId());
        memCard.setMerchantId(member.getMerchantId());
        memCard.setState(MemCardState.USED.getCode());
        memCard.setIsDefault(true);
        memberCardMapper.insert(memCard);
        // 获取会员卡权益
        log.info("获取会员卡权益");
        List<CardRight> cardRights = cardRightDao.selectByCardId(card.getId());
        if (CollectionUtils.isNotEmpty(cardRights)) {
            for (CardRight cardRight : cardRights) {
                if (RightType.COUPON.getCode().equals(cardRight.getRightType())) {
                    log.info("赠送id=" + cardRight.getCouponId() + "的优惠券");
                    Coupon coupon = couponMapper.selectById(cardRight.getCouponId());
                    Integer number = cardRight.getNumber();
                    log.info("赠送数量为:" + number);
                    log.info("剩余数量为:" + coupon.getStock());
                    if (number != null) {
                        // 更新库存数
                        int us = couponDao.updateStock(coupon.getId(), number);
                        if (us == 0) {
                            log.info("修改库存失败");
                            continue;
                        }
                        // 跟新领取人数
                        int uu = couponDao.updateGetCountUser(coupon.getId(), member.getId());
                        if (uu == 0) {
                            log.info("修改领取人数失败:" + uu);
                        }
                        log.info("保存优惠券领取记录");
                        for (int i = 0; i < number.intValue(); i++) {
                            // 保存领取记录
                            couponFetchService.saveCouponFetch(member, coupon, null);
                        }
                    }
                } else if (RightType.POINTS.getCode().equals(cardRight.getRightType())) {
                    log.info("赠送积分:" + cardRight.getPoints());
                    pointTradeService.savePointTrade(true, PointTradeType.CARD.getCode(), cardRight.getPoints(), member.getId(), null, member.getMerchantId(), null, "");
                }
            }
        }
    // 获得关注微信的积分规则
    }
    // 修改会员的默认会员卡
    log.info("修改会员的默认会员卡");
    updateDefaultCard(card.getId(), member.getId());
}
Also used : Coupon(com.ikoori.vip.common.persistence.model.Coupon) MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) CardRight(com.ikoori.vip.common.persistence.model.CardRight) Point(com.ikoori.vip.common.persistence.model.Point) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with MemberCard

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

the class MemberCardApiImpl method getMemberCardByUnionid.

@Override
public JSONObject getMemberCardByUnionid(String unionid) {
    log.info("进入getMemberCardByUnionid>>unionid=" + unionid);
    Member member = memberDao.getMemberByUnionid(unionid);
    if (member == null) {
        log.info("member == null");
        return null;
    }
    MemberCard memberCard = memberCardDao.getMemberCard(member.getId());
    if (memberCard == null) {
        log.info("memberCard == null");
        return null;
    }
    Merchant merchant = memberCard.getMerchant();
    Card card = memberCard.getCard();
    if (merchant == null || card == null) {
        log.info("merchant == null || card == null");
        return null;
    }
    JSONObject obj = new JSONObject();
    obj.put("coverType", card.getCoverType());
    obj.put("coverPic", card.getCoverPic());
    obj.put("colorCode", ColorType.valOf(card.getColorCode()));
    obj.put("merchantName", merchant.getName());
    obj.put("merchantLogo", merchant.getHeadImg());
    obj.put("cardName", card.getName());
    obj.put("cardNum", memberCard.getCardNumber());
    log.info("结束getMemberCardByUnionid");
    return obj;
}
Also used : MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Merchant(com.ikoori.vip.common.persistence.model.Merchant) JSONObject(com.alibaba.fastjson.JSONObject) Member(com.ikoori.vip.common.persistence.model.Member) Card(com.ikoori.vip.common.persistence.model.Card) MemberCard(com.ikoori.vip.common.persistence.model.MemberCard)

Aggregations

MemberCard (com.ikoori.vip.common.persistence.model.MemberCard)7 Merchant (com.ikoori.vip.common.persistence.model.Merchant)4 Permission (com.ikoori.vip.common.annotion.Permission)3 Card (com.ikoori.vip.common.persistence.model.Card)3 Member (com.ikoori.vip.common.persistence.model.Member)3 Transactional (org.springframework.transaction.annotation.Transactional)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 HashMap (java.util.HashMap)2 JSONObject (com.alibaba.fastjson.JSONObject)1 CardRight (com.ikoori.vip.common.persistence.model.CardRight)1 Coupon (com.ikoori.vip.common.persistence.model.Coupon)1 Point (com.ikoori.vip.common.persistence.model.Point)1 MemberCardWarpper (com.ikoori.vip.server.modular.biz.warpper.MemberCardWarpper)1 Map (java.util.Map)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1