Search in sources :

Example 1 with ClubCharge

use of com.code.server.db.model.ClubCharge in project summer by foxsugar.

the class GameClubService method charge.

/**
 * 充值
 *
 * @param msgKey
 * @param userId
 * @param clubId
 * @param money
 * @return
 */
public int charge(KafkaMsgKey msgKey, long userId, String clubId, int money) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    if (club.getPresident() != userId) {
        return ErrorCode.CLUB_NOT_PRESIDENT;
    }
    if (money <= 0) {
        return ErrorCode.REQUEST_PARAM_ERROR;
    }
    if (RedisManager.getUserRedisService().getUserMoney(userId) < money) {
        return ErrorCode.NOT_HAVE_MORE_MONEY;
    }
    // 加钱
    club.setMoney(club.getMoney() + money);
    RedisManager.getUserRedisService().addUserMoney(userId, -money);
    sendMsg(msgKey, new ResponseVo("clubService", "charge", "ok"));
    // 记录
    ClubCharge clubCharge = new ClubCharge();
    clubCharge.setClubId(clubId);
    clubCharge.setNum(money);
    clubCharge.setNowMoney(club.getMoney());
    clubCharge.setChargeTime(LocalDateTime.now().toString());
    clubChargeService.getClubChargeDao().save(clubCharge);
    return 0;
}
Also used : ClubCharge(com.code.server.db.model.ClubCharge) Club(com.code.server.db.model.Club) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 2 with ClubCharge

use of com.code.server.db.model.ClubCharge in project summer by foxsugar.

the class GameClubService method getChargeRecord.

public int getChargeRecord(KafkaMsgKey msgKey, long userId, String clubId) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    if (club.getPresident() != userId) {
        return ErrorCode.CLUB_NOT_PRESIDENT;
    }
    List<ClubCharge> list = clubChargeService.getClubChargeDao().getClubChargesByClubId(clubId);
    sendMsg(msgKey, new ResponseVo("clubService", "getChargeRecord", list));
    return 0;
}
Also used : ClubCharge(com.code.server.db.model.ClubCharge) Club(com.code.server.db.model.Club) ResponseVo(com.code.server.constant.response.ResponseVo)

Aggregations

ResponseVo (com.code.server.constant.response.ResponseVo)2 Club (com.code.server.db.model.Club)2 ClubCharge (com.code.server.db.model.ClubCharge)2