<?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.ContractConfigMapper">
  <resultMap id="BaseResultMap" type="com.cool.store.entity.ContractConfigDO">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="brand" jdbcType="VARCHAR" property="brand" />
    <result column="contract_name" jdbcType="VARCHAR" property="contractName" />
    <result column="party_a" jdbcType="VARCHAR" property="partyA" />
    <result column="party_b" jdbcType="VARCHAR" property="partyB" />
    <result column="party_c" jdbcType="VARCHAR" property="partyC" />
    <result column="franchise_mode" jdbcType="VARCHAR" property="franchiseMode" />
    <result column="fadada_template_id" jdbcType="VARCHAR" property="fadadaTemplateId" />
    <result column="serial_number" jdbcType="INTEGER" property="serialNumber" />
    <result column="payee_name" jdbcType="VARCHAR" property="payeeName"/>
    <result column="deleted" jdbcType="TINYINT" property="deleted" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>

  <select id="queryContractConfigByBrand" resultMap="BaseResultMap">
    select * from xfsg_contract_config where brand = #{brand} and serial_number = #{serialNumber} and deleted = 0
  </select>

  <select id="queryContractConfigList" resultMap="BaseResultMap">
    select * from xfsg_contract_config
    where deleted = 0
    <if test="brand!=null and brand !=''">
      and brand = #{brand}
    </if>
  </select>

  <select id="queryContractConfigListByBrandAndMode" resultMap="BaseResultMap">
    select * from xfsg_contract_config
    where deleted = 0
    <if test="brand!=null and brand !=''">
      and brand = #{brand}
    </if>
    <if test="mode!=null and mode !=''">
      and franchise_mode like concat('%,',#{mode},',%')
    </if>
  </select>
</mapper>