Search in sources :

Example 1 with ShareLog

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

the class ShareServiceImpl method activeShare.

/**
 * 受邀人激活成功后,奖励邀请人
 *
 * @Title: activeShare
 * @param receiveMem 受邀人
 * @date: 2017年10月9日 上午10:04:53
 * @author: chengxg
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void activeShare(Member receiveMem) {
    log.info("进入activeShare" + receiveMem.getUnionid());
    // Member receiveMem = memberDao.getMemberByUnionid(receiveUnionid);
    // 获得分享规则
    Share share = getShare(receiveMem.getMerchantId());
    if (share == null) {
        log.info("没有设置分享规则");
        return;
    }
    // 获得邀请记录,得到邀请人信息
    ShareLog shareLog = getShareLog(receiveMem.getUnionid());
    if (shareLog == null) {
        log.info("没有找到邀请记录");
        return;
    }
    // 判断邀请人当月已经邀请人数(激活成功为准)是否已经超过限制
    if (share.getShareCount() != null) {
        int shareCount = shareLogDao.getShareCount(shareLog.getShareUnionid(), DateUtil.getDay(shareLog.getCreateTime()));
        if (shareCount >= share.getShareCount()) {
            log.info("邀请人当月邀请人数为:" + shareCount + "超过限制的:" + share.getShareCount());
            return;
        }
    }
    // 同一IP仅限第一个注册的好友加积分
    int shareIpCount = getShareCountByIp(shareLog.getShareUnionid(), shareLog.getReceiveIp());
    if (shareIpCount >= 1) {
        log.info("邀请人已经邀请过ip:" + shareLog.getReceiveIp() + "获得奖励");
        return;
    }
    // 邀请人
    Member shareMem = memberDao.getMemberByUnionid(shareLog.getShareUnionid());
    if (shareMem == null) {
        log.info("没有找到unionid:" + shareLog.getShareUnionid() + "的邀请人");
        return;
    }
    // 赠送邀请人积分或优惠券
    Integer point = share.getPoint();
    if (point != null) {
        log.info("奖励邀请人积分:" + point);
        pointTradeService.savePointTrade(true, PointTradeType.SHARE.getCode(), point, shareMem.getId(), null, shareMem.getMerchantId(), null, "");
    }
    Long couponId = share.getCouponId();
    if (couponId != null) {
        Coupon coupon = couponMapper.selectById(couponId);
        log.info("奖励邀请人优惠券:" + coupon.getName());
        couponFetchService.saveCouponFetch(shareMem, coupon, null);
    }
    // 修改邀请记录状态为“邀请成功”
    shareLog.setReceiveStatus(true);
    shareLogMapper.updateById(shareLog);
    log.info("结束activeShare");
}
Also used : ShareLog(com.ikoori.vip.common.persistence.model.ShareLog) Coupon(com.ikoori.vip.common.persistence.model.Coupon) Share(com.ikoori.vip.common.persistence.model.Share) Member(com.ikoori.vip.common.persistence.model.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ShareLog

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

the class ShareLogController method shareLogUpdate.

/**
 * 跳转到修改分享日志
 */
@Permission
@RequestMapping("/shareLog_update/{shareLogId}")
public String shareLogUpdate(@PathVariable Long shareLogId, Model model) {
    ShareLog shareLog = shareLogService.selectById(shareLogId);
    model.addAttribute(shareLog);
    return PREFIX + "shareLog_edit.html";
}
Also used : ShareLog(com.ikoori.vip.common.persistence.model.ShareLog) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ShareLog

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

ShareLog (com.ikoori.vip.common.persistence.model.ShareLog)3 Member (com.ikoori.vip.common.persistence.model.Member)2 Transactional (org.springframework.transaction.annotation.Transactional)2 EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)1 Permission (com.ikoori.vip.common.annotion.Permission)1 Coupon (com.ikoori.vip.common.persistence.model.Coupon)1 Share (com.ikoori.vip.common.persistence.model.Share)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1