package com.it.rattan.monisuo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.it.rattan.monisuo.entity.AccountFund;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;

/**
 * 资金账户Mapper
 */
@Mapper
public interface AccountFundMapper extends BaseMapper<AccountFund> {

    @Select("SELECT IFNULL(SUM(balance), 0) FROM account_fund")
    BigDecimal sumAllBalance();

    @Select("SELECT IFNULL(SUM(total_deposit), 0) FROM account_fund")
    BigDecimal sumTotalDeposit();

    @Select("SELECT IFNULL(SUM(total_withdraw), 0) FROM account_fund")
    BigDecimal sumTotalWithdraw();

    @Select("SELECT IFNULL(SUM(quantity * avg_price), 0) FROM account_trade")
    BigDecimal sumAllTradeValue();
}
