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

    List<User> list = new ArrayList<>();

    User user = null;
    // id1:status#id2:status
    String[] datas = user.getSpreadRecord().split("#");
    StringBuffer ids = new StringBuffer();
    boolean isFirst = true;
    for (String str : datas) {
      String[] values = str.split(":");
      if ("1".equals(values[1])) {
        if (isFirst) {
          ids.append(values[0]);
          isFirst = false;
          continue;
        }
        ids.append(",").append(values[0]);
      }
    }

    if (StringUtils.isEmpty(ids.toString())) return list;

    // todo
    list = null;

    return list;
  }
  @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;
  }