<?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.xxfc.platform.vehicle.mapper.BranchCompanyStockInfoMapper">

    <update id="updateBalance">
        update branch_company_stock_info
        set balance = #{balance}
        where id = #{companyId} and balance = #{lastBalance}
    </update>
    <select id="selectVoAll" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyStockInfoVo">
        select *
        from branch_company_stock_info
    </select>
    <select id="search" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyStockInfoVo">
        select *
        from branch_company_stock_info
        <trim prefix="where" suffixOverrides="and">
            <if test="companyName != null">
                company_name  like  CONCAT('%',#{companyName},'%')
            </if>
            <if test="addrProvince != null">
                addr_province = #{addrProvince} and
            </if>
            <if test="addrCity != null">
                addr_city = #{addrCity} and
            </if>
            <if test="priceStart">
                price >= #{priceStart} and
            </if>
            <if test="priceEnd">
                price &lt;= #{priceEnd} and
            </if>
        </trim>

    </select>
    <select id="selectAllPrice" resultType="int">
        select distinct price from branch_company_stock_info order by price
    </select>
    <select id="selectInfoById" resultType="String">
        select info from branch_company_stock_info where id = #{id}
    </select>

    <insert id="addCompamyList" parameterType="java.util.List">
        insert into branch_company_stock_info (
        balance,total,price,company_name,addr_province,addr_city,state,company_pic
        ) VALUES
        <foreach collection ="list" item="item" index="index" separator =",">
            (#{item.balance},#{item.total},#{item.price},#{item.companyName},#{item.addrProvince},#{item.addrCity},#{item.state},#{item.companyPic})
        </foreach>
    </insert>
</mapper>