| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.vip.UserVIPPreInfoMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPPreInfoException;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
|
| | |
|
| | | @Service
|
| | | public class UserVIPPreInfoServiceImpl implements UserVIPPreInfoService {
|
| | |
|
| | | @Resource
|
| | | private UserVIPPreInfoMapper userVIPPreInfoMapper;
|
| | | |
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | | |
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | | |
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Override
|
| | | public void addUserVIPPreInfo(UserVIPPreInfo info) throws UserVIPPreInfoException {
|
| | |
| | | return infoList.get(0);
|
| | | }
|
| | |
|
| | | |
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void verifyVipCondition(Long uid) {
|
| | | if (uid == null || uid <= 0)
|
| | | return;
|
| | | |
| | | // 验证是否VIP
|
| | | boolean vip = userVIPInfoService.isVIP(uid);
|
| | | if (vip) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 邀请订单
|
| | | long countZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, HongBaoV2.TYPE_ZIGOU);
|
| | | // 邀请订单
|
| | | long countShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, HongBaoV2.TYPE_SHARE_GOODS);
|
| | | // 队员
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | |
| | | // 一阶段
|
| | | boolean process1 = oneProcess(uid, countZiGou, countShare, firstTeam, secondTeam);
|
| | | if (!process1) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 一阶段
|
| | | boolean process2 = twoProcess(uid, countZiGou, countShare, firstTeam, secondTeam);
|
| | | if (!process2) {
|
| | | return;
|
| | | }
|
| | | |
| | | vipProcess(uid, countZiGou, countShare, firstTeam, secondTeam);
|
| | | }
|
| | | |
| | | /**
|
| | | * 一阶段
|
| | | * @param uid
|
| | | * @param countZiGou
|
| | | * @param countShare
|
| | | * @param firstTeam
|
| | | * @param secondTeam
|
| | | */
|
| | | private boolean oneProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) {
|
| | | UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(uid, UserVIPPreInfo.PROCESS_1);
|
| | | if (oldInfo != null) {
|
| | | return true;
|
| | | }
|
| | | |
| | | if (countZiGou >= Constant.VIP_PROCESS_1_ZIGOU || countShare >= Constant.VIP_PROCESS_1_SHARE
|
| | | || (firstTeam >= Constant.VIP_PROCESS_1_TEAM && secondTeam >= Constant.VIP_PROCESS_1_TEAM_SECOND)) {
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | | info.setUid(uid);
|
| | | info.setProcess(UserVIPPreInfo.PROCESS_1);
|
| | | info.setCreateTime(new Date());
|
| | | info.setUpdateTime(new Date());
|
| | | userVIPPreInfoMapper.insertSelective(info);
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 一阶段
|
| | | * @param uid
|
| | | * @param countZiGou
|
| | | * @param countShare
|
| | | * @param firstTeam
|
| | | * @param secondTeam
|
| | | */
|
| | | private boolean twoProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) {
|
| | | UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(uid, UserVIPPreInfo.PROCESS_2);
|
| | | if (oldInfo != null) {
|
| | | return true;
|
| | | }
|
| | | |
| | | if (countZiGou >= Constant.VIP_PROCESS_2_ZIGOU || countShare >= Constant.VIP_PROCESS_2_SHARE
|
| | | || (firstTeam >= Constant.VIP_PROCESS_2_TEAM && secondTeam >= Constant.VIP_PROCESS_2_TEAM_SECOND)) {
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | | info.setUid(uid);
|
| | | info.setProcess(UserVIPPreInfo.PROCESS_2);
|
| | | info.setCreateTime(new Date());
|
| | | info.setUpdateTime(new Date());
|
| | | userVIPPreInfoMapper.insertSelective(info);
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 一阶段
|
| | | * @param uid
|
| | | * @param countZiGou
|
| | | * @param countShare
|
| | | * @param firstTeam
|
| | | * @param secondTeam
|
| | | */
|
| | | private boolean vipProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) {
|
| | | if (countZiGou >= Constant.VIP_PROCESS_3_ZIGOU || countShare >= Constant.VIP_PROCESS_3_SHARE
|
| | | || (firstTeam >= Constant.VIP_PROCESS_3_TEAM && secondTeam >= Constant.VIP_PROCESS_3_TEAM_SECOND)) {
|
| | | |
| | | |
| | | |
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | | |
| | | |
| | | }
|