示例#1
0
 /**
  * 购买套餐
  *
  * @param id
  */
 public void buy(long id) {
   VipPackage one = vipPackageDao.findOne(id);
   User user = UserUtils.getUser();
   if (one != null) {
     if (one.getValidMouth() == 0) {
       user.setVipTimes(user.getVipTimes() + 1);
     } else if (one.getValidMouth() > 0) {
       user.setUserType(User.VIP_USER);
       user.setVipStartDate(DateUtils.now());
       Date dateEnd =
           DateUtils.getDateEnd(DateUtils.addDays(DateUtils.now(), one.getValidMouth() * 30));
       user.setVipEndDate(dateEnd);
     }
   } else {
     throw new ServiceException("系统不存在此套餐");
   }
   userDao.save(user);
 }
示例#2
0
  public List<VipPackage> getAllVipPackage() {

    return (List<VipPackage>) vipPackageDao.findAll();
  }