Search in sources :

Example 11 with Card

use of com.ikoori.vip.common.persistence.model.Card 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);
}
Also used : Member(com.ikoori.vip.common.persistence.model.Member) BussinessException(com.ikoori.vip.common.exception.BussinessException) Card(com.ikoori.vip.common.persistence.model.Card) MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with Card

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

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

the class CouponApiImpl method checkCouponFetch.

/**
 * 验证是否符合领取条件
 *
 * @Title: checkCouponFetch
 * @param obj
 * @param coupon
 * @param member
 * @param count
 * @throws Exception
 * @date: 2017年9月18日 下午5:15:39
 * @author: chengxg
 */
private void checkCouponFetch(JSONObject obj, Coupon coupon, Member member, Integer count) throws Exception {
    log.info("进入checkCouponFetch");
    // 优惠券领取会员等级限制
    Long limitCardId = coupon.getCardId();
    if (limitCardId != null) {
        int c = getMemCardCountByCardId(member.getId(), limitCardId);
        if (c == 0) {
            Card card = cardMapper.selectById(limitCardId);
            log.error("该优惠券只能“" + card.getName() + "”才能领哦");
            obj.put("msg", "该优惠券只能“" + card.getName() + "”才能领哦");
            throw new Exception(obj.toJSONString());
        }
    }
    // 优惠券每人限领数量判断
    Integer quota = coupon.getQuota();
    if (quota != null) {
        // 获得当前会员已经领取的数量
        Integer getCount = getMemGetCount(coupon.getId(), member.getId());
        if (getCount >= quota) {
            log.error("该优惠券每人只能领" + quota + "张哦");
            obj.put("msg", "该优惠券每人只能领" + quota + "张哦");
            throw new Exception(obj.toJSONString());
        }
    }
    // 更新优惠券库存和领取次数
    if (count != 0 && couponDao.updateStock(coupon.getId(), 1) == 0) {
        log.error("该优惠券已经领完啦");
        obj.put("msg", "该优惠券已经领完啦");
        throw new Exception(obj.toJSONString());
    }
    // 领取人数更新
    couponDao.updateGetCountUser(coupon.getId(), member.getId());
    log.info("结束checkCouponFetch");
}
Also used : Card(com.ikoori.vip.common.persistence.model.Card) MemberCard(com.ikoori.vip.common.persistence.model.MemberCard)

Example 14 with Card

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

Example 15 with Card

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

the class MemberServiceImpl method saveMember.

@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveMember(UserInfo userInfo, boolean update) throws Exception {
    log.info("进去saveMember>>userInfo:" + userInfo.toString());
    if (userInfo.getUnionid() == null) {
        log.info("微信用户unionid为空");
        throw new Exception("微信用户unionid为空");
    }
    synchronized (userInfo.getUnionid().intern()) {
        Member member = memberDao.getMemberByUnionid(userInfo.getUnionid());
        if (member == null) {
            // 保存微信用户
            log.info("保存微信用户");
            WxUser wxUser = new WxUser();
            setWxUserInfo(userInfo, wxUser);
            wxUserMapper.insert(wxUser);
            // 保存会员
            log.info("保存会员信息");
            member = new Member();
            member.setUnionid(wxUser.getUnionid());
            member.setIsActive(false);
            // 需要根据appid获得商户id
            member.setMerchantId(gunsProperties.getMerchantId());
            member.setPoints(0);
            member.setSourceType(MemSourceType.wechat.getCode());
            memberMapper.insert(member);
            // 查询获取类型为“关注微信”的会员卡
            log.info("查询获取类型为“关注微信”的会员卡");
            Card card = cardDao.getCardByGrantTypeAndMerchantId(gunsProperties.getMerchantId(), CardGrantType.SUB_WX.getCode());
            if (card == null) {
                log.info("没有找到会员卡类型");
                // throw new Exception(obj.toJSONString());
                throw new Exception("没有找到会员卡类型");
            }
            log.info("保存会员卡领取记录");
            upgradeMemberCard(member, card);
            // 关注微信返回积分
            Point point = pointDao.getSubscribeWx(member.getMerchantId());
            if (point != null) {
                pointTradeService.savePointTrade(true, PointTradeType.SUBSCRIBE_WX.getCode(), point.getPoints(), member.getId(), point.getId(), member.getMerchantId(), null, "");
            }
        } else {
            // 小程序入口,不要更新openid
            if (update) {
                log.info("用户已经存在,开始更新微信账号信息");
                WxUser wxUser = new WxUser();
                wxUser.setUnionid(userInfo.getUnionid());
                wxUser = wxUserMapper.selectOne(wxUser);
                setWxUserInfo(userInfo, wxUser);
                wxUserMapper.updateById(wxUser);
            }
        }
    }
}
Also used : WxUser(com.ikoori.vip.common.persistence.model.WxUser) Point(com.ikoori.vip.common.persistence.model.Point) Member(com.ikoori.vip.common.persistence.model.Member) BussinessException(com.ikoori.vip.common.exception.BussinessException) Card(com.ikoori.vip.common.persistence.model.Card) MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Card (com.ikoori.vip.common.persistence.model.Card)16 Merchant (com.ikoori.vip.common.persistence.model.Merchant)11 Permission (com.ikoori.vip.common.annotion.Permission)9 MemberCard (com.ikoori.vip.common.persistence.model.MemberCard)9 HashMap (java.util.HashMap)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 Member (com.ikoori.vip.common.persistence.model.Member)5 Transactional (org.springframework.transaction.annotation.Transactional)5 BussinessException (com.ikoori.vip.common.exception.BussinessException)4 Coupon (com.ikoori.vip.common.persistence.model.Coupon)4 Store (com.ikoori.vip.common.persistence.model.Store)3 Point (com.ikoori.vip.common.persistence.model.Point)2 Date (java.util.Date)2 JSONObject (com.alibaba.fastjson.JSONObject)1 EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)1 CouponPayDo (com.ikoori.vip.common.dto.CouponPayDo)1 OrderItemPayDo (com.ikoori.vip.common.dto.OrderItemPayDo)1 CardRight (com.ikoori.vip.common.persistence.model.CardRight)1 CouponFetch (com.ikoori.vip.common.persistence.model.CouponFetch)1 CouponTrade (com.ikoori.vip.common.persistence.model.CouponTrade)1