use of com.code.server.redis.service.UserRedisService in project summer by foxsugar.
the class GameRpcHandler method exchange.
@Override
public void exchange(Order order, AsyncMethodCallback<Integer> resultHandler) throws TException {
long userId = order.getUserId();
UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
if (userBean == null) {
UserService userService = SpringUtil.getBean(UserService.class);
User user = userService.getUserByUserId(userId);
user.setMoney(user.getMoney() - order.getNum());
user.setGold(user.getGold() + order.getNum());
userService.save(user);
} else {
UserRedisService userRedisService = RedisManager.getUserRedisService();
userRedisService.addUserMoney(userId, -order.getNum());
RedisManager.addGold(userId, order.getNum());
}
resultHandler.onComplete(0);
}
use of com.code.server.redis.service.UserRedisService in project summer by foxsugar.
the class GameRpcNewHandler method exchange.
@Override
public void exchange(Order order, AsyncMethodCallback<Integer> resultHandler) throws TException {
long userId = order.getUserId();
UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
if (userBean == null) {
UserService userService = SpringUtil.getBean(UserService.class);
User user = userService.getUserByUserId(userId);
user.setMoney(user.getMoney() - order.getNum());
user.setGold(user.getGold() + order.getNum());
userService.save(user);
} else {
UserRedisService userRedisService = RedisManager.getUserRedisService();
userRedisService.addUserMoney(userId, -order.getNum());
RedisManager.addGold(userId, order.getNum());
}
resultHandler.onComplete(0);
}
Aggregations