Ejemplo n.º 1
0
 @Override
 public int save(User user) {
   int i = userMapper.insert(user);
   // 奖励积分
   integralService.encourageFromFocus(user.getId(), user.getIntegral());
   return i;
 }
  @Override
  public List<VipAccount> listVip(User user) {

    // 初始化
    int beginSellTime = configService.getInt("goods.begin.sell.time");
    int effectiveTime = configService.getInt("goods.effective.time");
    int endSellTime = configService.getInt("goods.end.sell.time");

    Calendar calendar = Calendar.getInstance();
    int curHour = calendar.get(Calendar.HOUR_OF_DAY);

    if (curHour >= beginSellTime) {
      // 获取大于等于今日开卖点买的订单
      calendar.set(Calendar.HOUR_OF_DAY, beginSellTime);
      Date startTime = calendar.getTime();

      Map<String, Object> paramMap = new HashMap<>();
      paramMap.put("userid", user.getId());
      paramMap.put("startTime", startTime);

      return vipAccountMapper.listByUserAndTime(paramMap);
    } else if (curHour < effectiveTime) {
      // 获取昨天开买点到今日结束点购买的订单
      calendar.set(Calendar.HOUR_OF_DAY, endSellTime);
      Date endTime = calendar.getTime();

      calendar.add(Calendar.DATE, -1);
      calendar.set(Calendar.HOUR_OF_DAY, beginSellTime);
      Date startTime = calendar.getTime();

      Map<String, Object> paramMap = new HashMap<>();
      paramMap.put("userid", user.getId());
      paramMap.put("startTime", startTime);
      paramMap.put("endTime", endTime);

      return vipAccountMapper.listByUserAndTime(paramMap);
    }
    return null;
  }