package cn.pluss.platform.mapper;

import cn.pluss.platform.entity.UserAccountFlow;
import cn.pluss.platform.entity.UserMakerFlow;
import cn.pluss.platform.vo.UserMakerQuotaVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author lyf
 */
@Mapper
public interface UserAccountFlowMapper extends BaseMapper<UserAccountFlow> {

    @Select("SELECT\n" +
            "\tmf.id,\n"+
            "\tbi.alias AS userName,\n" +
            "\tmf.orderNumber,\n" +
            "\tmf.create_time AS createTime,\n" +
            "\tmo.consumeFee AS lowerAmount,\n" +
            "\t(mo.consumeFee - mo.enterFee) AS amount\n" +
            "FROM\n" +
            "\ttb_pluss_user_maker_flow mf \n" +
            "\tLEFT JOIN tb_pluss_merchant_base_info bi ON bi.userId = mf.user_id\n" +
            "\tLEFT JOIN tb_pluss_merchant_order mo ON mf.orderNumber = mo.orderNumber\n" +
            "WHERE\n" +
            "\tmf.user_id = #{userId}\n" +
            "\tAND mf.biz_code = 'LD'\n" +
            "\torder by id desc  limit #{pageSize}  offset  #{offset} ")
    List<UserMakerQuotaVO> selectByUserIdType(@Param("userId") Long userId, @Param("pageSize") Integer pageSize, @Param("offset") Integer offset);

    BigDecimal selectSumByUserId(@Param("userId") Long userId,@Param("startTime") Date startTime,@Param("endTime") Date endTime);

}
