package com.hfkj.dao;

import com.hfkj.entity.BsOrderSettle;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;
import java.util.Map;

/**
 * mapper扩展类
 */
public interface BsOrderSettleMapperExt {

    @Select(" <script>" +
            " SELECT a.* " +
            " FROM `bs_order_settle` a " +
            " LEFT JOIN bs_order b on b.order_no = a.order_no " +
            " where 1 = 1 " +
            " <if test='param.ledgerFlag != null'> and a.ledger_flag = #{param.ledgerFlag} </if>" +
            " <if test='param.ledgerStatus != null'> and a.ledger_status = #{param.ledgerStatus} </if>" +
            " <if test='param.orderStatus != null'> and b.order_status = #{param.orderStatus} </if>" +
            " <if test='param.createTimeS != null'> <![CDATA[ and a.create_time >= #{param.createTimeS} ]]></if>" +
            " <if test='param.createTimeE != null'> <![CDATA[ and a.create_time <= #{param.createTimeE} ]]></if>" +
            "ORDER BY a.create_time desc" +
            " </script>")
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="mer_no", property="merNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="settle_mer_no", property="settleMerNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="settle_mer_key", property="settleMerKey", jdbcType=JdbcType.VARCHAR),
            @Result(column="settle_amount", property="settleAmount", jdbcType=JdbcType.DECIMAL),
            @Result(column="ledger_flag", property="ledgerFlag", jdbcType=JdbcType.BIT),
            @Result(column="ledger_order_no", property="ledgerOrderNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="ledger_amount", property="ledgerAmount", jdbcType=JdbcType.DECIMAL),
            @Result(column="ledger_status", property="ledgerStatus", jdbcType=JdbcType.INTEGER),
            @Result(column="revoke_order_no", property="revokeOrderNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
    })
    List<BsOrderSettle> queryList(@Param("param") Map<String,Object> param);
}
