TAccountServiceImpl.java 2.6 KB
Newer Older
1 2
package com.zehong.system.service.impl;

3
import java.math.BigDecimal;
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
import java.util.List;
import com.zehong.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TAccountMapper;
import com.zehong.system.domain.TAccount;
import com.zehong.system.service.ITAccountService;

/**
 * 账户Service业务层处理
 * 
 * @author zehong
 * @date 2023-06-06
 */
@Service
public class TAccountServiceImpl implements ITAccountService 
{
    @Autowired
    private TAccountMapper tAccountMapper;

    /**
     * 查询账户
     * 
     * @param accountId 账户ID
     * @return 账户
     */
    @Override
    public TAccount selectTAccountById(Long accountId)
    {
        return tAccountMapper.selectTAccountById(accountId);
    }

    /**
     * 查询账户列表
     * 
     * @param tAccount 账户
     * @return 账户
     */
    @Override
    public List<TAccount> selectTAccountList(TAccount tAccount)
    {
        return tAccountMapper.selectTAccountList(tAccount);
    }

    /**
     * 新增账户
     * 
     * @param tAccount 账户
     * @return 结果
     */
    @Override
    public int insertTAccount(TAccount tAccount)
    {
        tAccount.setCreateTime(DateUtils.getNowDate());
        return tAccountMapper.insertTAccount(tAccount);
    }

    /**
     * 修改账户
     * 
     * @param tAccount 账户
     * @return 结果
     */
    @Override
    public int updateTAccount(TAccount tAccount)
    {
        tAccount.setUpdateTime(DateUtils.getNowDate());
        return tAccountMapper.updateTAccount(tAccount);
    }

    /**
     * 批量删除账户
     * 
     * @param accountIds 需要删除的账户ID
     * @return 结果
     */
    @Override
    public int deleteTAccountByIds(Long[] accountIds)
    {
        return tAccountMapper.deleteTAccountByIds(accountIds);
    }

    /**
     * 删除账户信息
     * 
     * @param accountId 账户ID
     * @return 结果
     */
    @Override
    public int deleteTAccountById(Long accountId)
    {
        return tAccountMapper.deleteTAccountById(accountId);
    }
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

    @Override
    public boolean checkAccountCanTrade(Long deptId, BigDecimal amount) {
        TAccount tAccount=new TAccount();
        tAccount.setDeptId(deptId);
        List<TAccount> rst=tAccountMapper.selectTAccountList(tAccount);
        if(rst!=null&&rst.size()>0){
            if(rst.get(0).getAbleAmount().compareTo(amount)>=0) {
                return true;
            }else {
                return false;
            }
        }else{
            return false;
        }
    }
113
}