package com.it.rattan.monisuo.mapper;

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

/**
 * 交易账户Mapper
 */
@Mapper
public interface AccountTradeMapper extends BaseMapper<AccountTrade> {

    @Select("SELECT IFNULL(SUM(at.quantity * c.price), 0) FROM account_trade at " +
            "LEFT JOIN coin c ON at.coin_code = c.code " +
            "WHERE at.quantity > 0")
    BigDecimal sumAllTradeValue();
}
