Search in sources :

Example 1 with UserAccount

use of com.heepy.model.UserAccount in project finacialpotal by f117-sercet.

the class UserAccountServiceImpl method lockAccount.

@Transactional(rollbackFor = Exception.class)
@Override
public boolean lockAccount(String userCode, String lockAmt) {
    UserAccount userAccount = this.getByUserCode(userCode);
    String amount = userAccount.getAmount();
    if (Double.parseDouble(amount) < Double.parseDouble(lockAmt)) {
        return false;
    }
    amount = BigDemicalUtil.subtract(amount, lockAmt);
    String freezeAmount = BigDemicalUtil.add(userAccount.getFreezeAmount(), lockAmt);
    userAccount.setAmount(amount);
    userAccount.setFreezeAmount(freezeAmount);
    this.updateById(userAccount);
    return true;
}
Also used : UserAccount(com.heepy.model.UserAccount) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with UserAccount

use of com.heepy.model.UserAccount in project finacialpotal by f117-sercet.

the class UserAccountServiceImpl method transferAccounts.

@Override
@Transactional(rollbackFor = Exception.class)
public boolean transferAccounts(String userCode, String unLockAmt) {
    UserAccount userAccount = this.getByUserCode(userCode);
    String amount = userAccount.getAmount();
    amount = BigDemicalUtil.add(amount, unLockAmt);
    userAccount.setAmount(amount);
    this.updateById(userAccount);
    return false;
}
Also used : UserAccount(com.heepy.model.UserAccount) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with UserAccount

use of com.heepy.model.UserAccount in project finacialpotal by f117-sercet.

the class UserAccountServiceImpl method withdraw.

@Transactional(rollbackFor = Exception.class)
@Override
public void withdraw(Map<String, Object> paramMap) {
    String bindCode = (String) paramMap.get("bindCode");
    String fetchAmt = (String) paramMap.get("fetchAmt");
    UserAccount userAccount = userAccountMapper.selectOne(new QueryWrapper<UserAccount>().eq("user_code", bindCode));
    String amount = BigDemicalUtil.subtract(userAccount.getAmount(), fetchAmt);
    userAccount.setAmount(amount);
    userAccountMapper.updateById(userAccount);
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) UserAccount(com.heepy.model.UserAccount) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with UserAccount

use of com.heepy.model.UserAccount in project finacialpotal by f117-sercet.

the class UserAccountServiceImpl method recharge.

@Transactional(rollbackFor = Exception.class)
@Override
public void recharge(Map<String, Object> paramMap) {
    String bindCode = (String) paramMap.get("bindCode");
    String chargeAmt = (String) paramMap.get("chargeAmt");
    UserAccount userAccount = userAccountMapper.selectOne(new QueryWrapper<UserAccount>().eq("user_code", bindCode));
    if (null == userAccount) {
        userAccount = new UserAccount();
        userAccount.setUserCode(bindCode);
        userAccount.setFreezeAmount("0");
        userAccountMapper.insert(userAccount);
    } else {
        String amount = BigDemicalUtil.add(userAccount.getAmount(), chargeAmt);
        userAccount.setAmount(amount);
        userAccountMapper.updateById(userAccount);
    }
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) UserAccount(com.heepy.model.UserAccount) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with UserAccount

use of com.heepy.model.UserAccount in project finacialpotal by f117-sercet.

the class UserAccountServiceImpl method unLockAccount.

@Transactional(rollbackFor = Exception.class)
@Override
public boolean unLockAccount(String userCode, String unLockAmt) {
    UserAccount userAccount = this.getByUserCode(userCode);
    String freezeAmount = userAccount.getFreezeAmount();
    if (Double.parseDouble(freezeAmount) < Double.parseDouble(unLockAmt)) {
        return false;
    }
    freezeAmount = BigDemicalUtil.subtract(userAccount.getFreezeAmount(), unLockAmt);
    userAccount.setFreezeAmount(freezeAmount);
    this.updateById(userAccount);
    return true;
}
Also used : UserAccount(com.heepy.model.UserAccount) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

UserAccount (com.heepy.model.UserAccount)7 Transactional (org.springframework.transaction.annotation.Transactional)6 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)2