<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.ExpenseMappingMapper">

    <!-- 根据网商交易流水号查询 -->
    <select id="getByTradeNo" resultType="com.cool.store.entity.ExpenseMappingDO">
        select *
        from zxjp_expense_mapping
        where trade_no = #{tradeNo}
    </select>

    <!-- 根据费用单号查询 -->
    <select id="getByRelatedAdjustmentNo" resultType="com.cool.store.entity.ExpenseMappingDO">
        select *
        from zxjp_expense_mapping
        where related_adjustment_no = #{relatedAdjustmentNo}
    </select>

    <!-- 根据交易流水号列表批量查询 -->
    <select id="listByTradeNos" resultType="com.cool.store.entity.ExpenseMappingDO">
        select *
        from zxjp_expense_mapping
        where trade_no in
        <foreach collection="tradeNos" item="tradeNo" open="(" separator="," close=")">
            #{tradeNo}
        </foreach>
    </select>

    <!-- 根据费用单号查询列表 -->
    <select id="listByRelatedAdjustmentNo" resultType="com.cool.store.entity.ExpenseMappingDO">
        select *
        from zxjp_expense_mapping
        where related_adjustment_no = #{relatedAdjustmentNo}
    </select>

    <!-- 根据费用单号列表批量查询 -->
    <select id="listByRelatedAdjustmentNoList" resultType="com.cool.store.entity.ExpenseMappingDO">
        select *
        from zxjp_expense_mapping
        where related_adjustment_no in
        <foreach collection="relatedAdjustmentNos" item="relatedAdjustmentNo" open="(" separator="," close=")">
            #{relatedAdjustmentNo}
        </foreach>
    </select>

    <!-- 批量插入 -->
    <insert id="batchInsert" parameterType="java.util.List">
        insert into zxjp_expense_mapping (related_adjustment_no, trade_no)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.relatedAdjustmentNo}, #{item.tradeNo})
        </foreach>
    </insert>

</mapper>
