| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void addExpireTime(Long uid, long time) { |
| | | UserVIPInfo userVIPInfo = userVIPInfoDao.selectByPrimaryKeyForUpdate(uid); |
| | | if (userVIPInfo == null) { |
| | | //新增 |
| | | UserVIPInfo vip = new UserVIPInfo(); |
| | | vip.setUid(uid); |
| | | vip.setCreateTime(new Date()); |
| | | vip.setExpireDate(new Date(System.currentTimeMillis() + time)); |
| | | userVIPInfoDao.insertSelective(vip); |
| | | } else { |
| | | //修改 |
| | | UserVIPInfo update = new UserVIPInfo(); |
| | | update.setUid(uid); |
| | | if (userVIPInfo.getExpireDate() != null) { |
| | | |
| | | //预计到期时间比现在的时间大 |
| | | if (userVIPInfo.getExpireDate().getTime() > System.currentTimeMillis()) { |
| | | update.setExpireDate(new Date(userVIPInfo.getExpireDate().getTime() + time)); |
| | | } else { |
| | | update.setExpireDate(new Date(System.currentTimeMillis() + time)); |
| | | } |
| | | } else { |
| | | update.setExpireDate(new Date(System.currentTimeMillis() + time)); |
| | | } |
| | | update.setUpdateTime(new Date()); |
| | | userVIPInfoDao.updateByPrimaryKeySelective(update); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<UserVIPInfo> listVIPUser(Date minVIPExpireDate, Date maxVIPExpireDate, int page, int pageSize) { |
| | | UserVIPInfoDao.DaoQuery daoQuery = new UserVIPInfoDao.DaoQuery(); |