Exemplo n.º 1
0
 /**
  * 领取声望奖励
  *
  * @param userId
  * @param id
  * @return
  */
 public CommonGoodsBeanBO rewardPrestige(String userId, int id) {
   User user = userService.getByUserId(userId);
   SystemPrestigeRewards rewards = systemPrestigeRewardsDaoCache.getPrestigeRewardsById(id);
   if (rewards == null) {
     throw new ServiceException(SystemConstant.FAIL_CODE, "id=" + id + ",不存在该id的配置");
   }
   // 判断是否达到领取等级
   if (user.getPrestigeLevel() < rewards.getLevel()) {
     throw new ServiceException(LEVEL_LIMIT, "声望等级不足");
   }
   // 判断是否已经领取过了
   if (userPrestigeRewardLogDao.isReward(userId, id)) {
     throw new ServiceException(HAS_REWARD, "已经领取过了");
   }
   UserPrestigeRewardLog log = new UserPrestigeRewardLog();
   log.setUserId(userId);
   log.setId(id);
   log.setCreatedTime(new Date());
   // 给奖励
   if (userPrestigeRewardLogDao.addUserPrestigeRewardLog(log)) {
     return goodsDealService.sendGoods(
         userId,
         GoodsType.Hero.intValue + "," + rewards.getRewards() + ",1",
         GoodsUseType.ADD_PRESTIGE_REWARDS);
   } else {
     ServiceException e = new ServiceException(SystemConstant.FAIL_CODE, "添加日志异常!!");
     LogSystem.error(e, "");
     throw e;
   }
 }
Exemplo n.º 2
0
 /**
  * 获取用户已领取的声望奖励id列表 用户登录总推送
  *
  * @param userId
  * @return
  */
 public List<Integer> getUserHaveGetRewardsIds(String userId) {
   List<Integer> result = Lists.newArrayList();
   List<UserPrestigeRewardLog> list =
       userPrestigeRewardLogDao.getUserPrestigeRewardLogList(userId);
   if (list != null && list.size() > 0) {
     for (UserPrestigeRewardLog rewardLog : list) {
       result.add(rewardLog.getId());
     }
   }
   return result;
 }