Search in sources :

Example 16 with Member

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

Example 17 with Member

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

the class MemberServiceImpl method deleteMember.

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void deleteMember(Long memberId) {
    Member member = this.selectById(memberId);
    MemberCard mc = new MemberCard();
    mc.setMemberId(member.getId());
    mc = memberCardMapper.selectOne(mc);
    memberCardMapper.deleteById(mc.getId());
    this.deleteById(memberId);
}
Also used : MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Member(com.ikoori.vip.common.persistence.model.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with Member

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

the class MemberCardApiImpl method selectByMemberId.

/**
 * @Title: selectByMemberId
 * @Description: 会员卡详情
 * @date:   2017年9月20日 下午5:06:48
 * @author: huanglin
 * @throws
 */
@Override
public JSONObject selectByMemberId(String unionid) {
    log.info("进入selectByMemberId>>unionid" + unionid);
    Member member = memberDao.getMemberByUnionid(unionid);
    if (member == null) {
        log.info("member == null");
        return null;
    }
    Map<String, Object> cardDetail = memberCardService.selectByMemberId(member.getId());
    if (cardDetail == null) {
        log.info("cardDetail == null");
        return null;
    }
    JSONObject obj = new JSONObject();
    obj.put("description", cardDetail.get("description"));
    obj.put("servicePhone", cardDetail.get("servicePhone"));
    obj.put("termType", cardDetail.get("termType"));
    obj.put("termDays", cardDetail.get("termDays"));
    obj.put("termStartAt", cardDetail.get("termStartAt"));
    obj.put("termEndAt", cardDetail.get("termEndAt"));
    log.info("结束selectByMemberId");
    return obj;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONObject(com.alibaba.fastjson.JSONObject) Member(com.ikoori.vip.common.persistence.model.Member)

Example 19 with Member

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

the class MemberOrderApiImpl method getMemberOrderByUnionid.

/**
 * <p>Title: getMemberOrderByUnionid</p>
 * <p>Description: 获取会员订单</p>
 * @param unionid
 * @return
 */
@Override
public List<Map<String, Object>> getMemberOrderByUnionid(String unionid, int start, int pageSize) {
    log.info("进入getMemberOrderByUnionid>>unionid=" + unionid);
    Member member = memberDao.getMemberByUnionid(unionid);
    if (member == null) {
        log.info("member == null");
        return null;
    }
    List<Map<String, Object>> orders = orderDao.selectOrderListByMemberId(member.getId(), start, pageSize);
    if (orders == null) {
        log.info("orders==null");
        return null;
    }
    log.info("结束getMemberOrderByUnionid");
    return orders;
}
Also used : Member(com.ikoori.vip.common.persistence.model.Member) Map(java.util.Map)

Example 20 with Member

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

the class ShareApiImpl method saveShareLog.

/**
 * 保存邀请记录
 *
 * @Title: saveShareLog
 * @param shareUnionid
 *            邀请人unionid
 * @param receiveUnionid
 *            受邀人unionid
 * @param receiveIp
 *            受邀人ip
 * @throws Exception
 * @date: 2017年10月9日 上午9:28:15
 * @author: chengxg
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
@Override
public void saveShareLog(String shareUnionid, String receiveUnionid, String receiveIp) throws Exception {
    log.info("进入saveShareLog>>shareUnionid=" + shareUnionid);
    log.info("进入saveShareLog>>receiveUnionid=" + receiveUnionid);
    log.info("进入saveShareLog>>receiveIp=" + receiveIp);
    // 邀请人不存在, 不处理
    Member shareMem = memberDao.getMemberByUnionid(shareUnionid);
    if (shareMem == null) {
        log.info("邀请人不存在");
        return;
    }
    // 受邀人不是会员 或者已激活不处理
    Member receiveMem = memberDao.getMemberByUnionid(receiveUnionid);
    if (receiveMem == null || receiveMem.isIsActive()) {
        log.info("受邀人不存在");
        return;
    }
    Wrapper<ShareLog> w = new EntityWrapper<ShareLog>();
    w.eq("share_unionid", shareUnionid);
    w.eq("receive_unionid", receiveUnionid);
    int count = shareLogMapper.selectCount(w);
    if (count > 0) {
        log.info("已有邀请记录");
        return;
    }
    ShareLog shareLog = new ShareLog();
    shareLog.setShareUnionid(shareUnionid);
    shareLog.setReceiveUnionid(receiveUnionid);
    shareLog.setReceiveIp(receiveIp);
    shareLog.setReceiveStatus(false);
    shareLogMapper.insert(shareLog);
    log.info("结束saveShareLog");
}
Also used : ShareLog(com.ikoori.vip.common.persistence.model.ShareLog) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Member(com.ikoori.vip.common.persistence.model.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Member (com.ikoori.vip.common.persistence.model.Member)23 JSONObject (com.alibaba.fastjson.JSONObject)12 Transactional (org.springframework.transaction.annotation.Transactional)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 Card (com.ikoori.vip.common.persistence.model.Card)5 MemberCard (com.ikoori.vip.common.persistence.model.MemberCard)5 HashMap (java.util.HashMap)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 BussinessException (com.ikoori.vip.common.exception.BussinessException)4 Coupon (com.ikoori.vip.common.persistence.model.Coupon)4 ApiOperation (io.swagger.annotations.ApiOperation)4 JSONArray (com.alibaba.fastjson.JSONArray)3 Date (java.util.Date)3 EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)2 Permission (com.ikoori.vip.common.annotion.Permission)2 Merchant (com.ikoori.vip.common.persistence.model.Merchant)2 Point (com.ikoori.vip.common.persistence.model.Point)2 ShareLog (com.ikoori.vip.common.persistence.model.ShareLog)2 WxUser (com.ikoori.vip.common.persistence.model.WxUser)2 BigDecimal (java.math.BigDecimal)2