Esempio n. 1
0
 public boolean creditExchange(int creditNum, User u) {
   int toAdd = creditNum / 10;
   u.setBalance(u.getBalance() + toAdd);
   u.setCredit(u.getCredit() - toAdd * 10);
   dao.update(u);
   return true;
 }
Esempio n. 2
0
  public boolean cost(User u, int cost) {
    cost = (int) (cost * getDiscount(u));
    if (u.getBalance() >= cost) {
      System.out.println("Óà¶î×ã¹»¿Û¿î");
      u.setBalance(u.getBalance() - cost);
      u.setCredit(u.getCredit() + cost);
      dao.update(u);
      ApplicationContext appliationContext =
          new ClassPathXmlApplicationContext("applicationContext.xml");
      ConsumeRecService crs = (ConsumeRecService) appliationContext.getBean("consumeservice");
      crs.createRecord(u.getId(), cost);

      ActionContext.getContext().getSession().put("user", u);
      return true;
    } else {
      return false;
    }
  }
Esempio n. 3
0
  public void dailyCheck() {
    List<User> list = getAllUsers();

    for (User u : list) {
      if (u.getActivate() == 1) {
        if (u.getBalance() < 200) {
          Date old = new Date();
          old = u.getActivatetime();
          Date now = new Date();
          long diff = now.getTime() - old.getTime();
          long day = diff / (24 * 60 * 60 * 1000);
          if (day >= 365) {
            u.setActivate(0);
            dao.update(u);
          }
        }
      }
    }
  }
Esempio n. 4
0
  public boolean recharge(User u, int money) {
    System.out.println("OldBalance=" + u.getBalance());
    u.setBalance(u.getBalance() + money);
    u.setSum(u.getSum() + money);
    System.out.println("NewBalance=" + u.getBalance());
    checkGrade(u);
    if (u.getActivate() == 0 && money > 200) {
      u.setActivate(1);
      Timestamp d = new Timestamp(System.currentTimeMillis());
      u.setActivatetime(d);
    }
    dao.update(u);

    ApplicationContext appliationContext =
        new ClassPathXmlApplicationContext("applicationContext.xml");
    RechargeRecService rrs = (RechargeRecService) appliationContext.getBean("rechargeservice");
    rrs.createRecord(u.getId(), money);

    ActionContext.getContext().getSession().put("user", u);
    return true;
  }
Esempio n. 5
0
  public List getAllRoom() {

    return dao.getAllList(Room.class);
  }
Esempio n. 6
0
 public int getRoomId(String roomName) {
   List list = dao.find(Room.class, "name", roomName);
   System.out.println("ÕÒµ½ÁËroom");
   Room r = (Room) list.get(0);
   return r.getId();
 }
Esempio n. 7
0
 public Room getRoom(String id) {
   List list = dao.find(Room.class, "id", id);
   Room r = (Room) list.get(0);
   return r;
 }
Esempio n. 8
0
 public boolean updateInfo(User u) {
   dao.update(u);
   return true;
 }
Esempio n. 9
0
 public User getUserById(String userid) {
   List list = dao.find(User.class, "id", userid);
   User u = (User) list.get(0);
   return u;
 }
Esempio n. 10
0
 public User getUser(String username) {
   List list = dao.find(User.class, "username", username);
   User u = (User) list.get(0);
   return u;
 }
Esempio n. 11
0
 public void addCredit(String userid, int num) {
   User u = getUserById(userid);
   u.setCredit(u.getCredit() + num);
   dao.update(u);
 }
Esempio n. 12
0
 public List getAllUsers() {
   return dao.getAllList(User.class);
 }
Esempio n. 13
0
 public boolean inactivate(User u) {
   u.setActivate(0);
   dao.update(u);
   return true;
 }