package cn.pluss.platform.mapper;

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

import java.util.List;

/**
 * @author lyf
 */
public interface UserMakerFlowMapper  extends BaseMapper<UserMakerFlow> {

    @Select(value = "SELECT\n" +
            "\tmf.id,\n" +
            "\tmf.biz_code AS bizCode,\n" +
            "\tmf.biz_name AS bizName,\n" +
            "\tmo.merchantName AS userName,\n" +
            "\tmf.amount AS lowerAmount,\n" +
            "\tmf.create_time AS createTime,\n" +
            "\tmo.consumeFee AS amount \n" +
            "FROM\n" +
            "\t`tb_pluss_user_maker_flow` mf\n" +
            "\tLEFT JOIN tb_pluss_merchant_base_info bi ON mf.user_id = bi.userId\n" +
            "\tLEFT JOIN tb_pluss_merchant_order mo ON mf.orderNumber = mo.orderNumber \n" +
            "WHERE\n" +
            "\tmf.user_id = #{userId} \n" +
            "\tAND mo.`status` = 1\n" +
            "ORDER BY\n" +
            "\tid DESC \n" +
            "\tLIMIT #{pageSize} OFFSET #{offset}")
    List<UserMakerQuotaVO> selectByUserId(@Param("userId") Long userId, @Param("pageSize") Integer pageSize, @Param("offset") Integer offset);
}
