<?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="cn.superdesk.uniorder.dao.mapper.operationCenter.OperationCenterPaymentBizMapper">
  <resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterPaymentBiz">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="payment_id" jdbcType="BIGINT" property="paymentId" />
    <result column="biz_platform_code" jdbcType="VARCHAR" property="bizPlatformCode" />
    <result column="biz_platform_name" jdbcType="VARCHAR" property="bizPlatformName" />
    <result column="biz_pay_type_id" jdbcType="VARCHAR" property="bizPayTypeId" />
    <result column="biz_pay_type_name" jdbcType="VARCHAR" property="bizPayTypeName" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_user" jdbcType="BIGINT" property="createUser" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, payment_id, biz_platform_code, biz_platform_name, biz_pay_type_id, biz_pay_type_name, 
    create_time, create_user
  </sql>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterPaymentBizExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from tb_operation_center_payment_biz
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tb_operation_center_payment_biz
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from tb_operation_center_payment_biz
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterPaymentBizExample">
    delete from tb_operation_center_payment_biz
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterPaymentBiz">
    insert into tb_operation_center_payment_biz (id, payment_id, biz_platform_code, 
      biz_platform_name, biz_pay_type_id, biz_pay_type_name, 
      create_time, create_user)
    values (#{id,jdbcType=BIGINT}, #{paymentId,jdbcType=BIGINT}, #{bizPlatformCode,jdbcType=VARCHAR}, 
      #{bizPlatformName,jdbcType=VARCHAR}, #{bizPayTypeId,jdbcType=VARCHAR}, #{bizPayTypeName,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=TIMESTAMP}, #{createUser,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterPaymentBiz">
    insert into tb_operation_center_payment_biz
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="paymentId != null">
        payment_id,
      </if>
      <if test="bizPlatformCode != null">
        biz_platform_code,
      </if>
      <if test="bizPlatformName != null">
        biz_platform_name,
      </if>
      <if test="bizPayTypeId != null">
        biz_pay_type_id,
      </if>
      <if test="bizPayTypeName != null">
        biz_pay_type_name,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="paymentId != null">
        #{paymentId,jdbcType=BIGINT},
      </if>
      <if test="bizPlatformCode != null">
        #{bizPlatformCode,jdbcType=VARCHAR},
      </if>
      <if test="bizPlatformName != null">
        #{bizPlatformName,jdbcType=VARCHAR},
      </if>
      <if test="bizPayTypeId != null">
        #{bizPayTypeId,jdbcType=VARCHAR},
      </if>
      <if test="bizPayTypeName != null">
        #{bizPayTypeName,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterPaymentBizExample" resultType="java.lang.Long">
    select count(*) from tb_operation_center_payment_biz
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update tb_operation_center_payment_biz
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.paymentId != null">
        payment_id = #{record.paymentId,jdbcType=BIGINT},
      </if>
      <if test="record.bizPlatformCode != null">
        biz_platform_code = #{record.bizPlatformCode,jdbcType=VARCHAR},
      </if>
      <if test="record.bizPlatformName != null">
        biz_platform_name = #{record.bizPlatformName,jdbcType=VARCHAR},
      </if>
      <if test="record.bizPayTypeId != null">
        biz_pay_type_id = #{record.bizPayTypeId,jdbcType=VARCHAR},
      </if>
      <if test="record.bizPayTypeName != null">
        biz_pay_type_name = #{record.bizPayTypeName,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createUser != null">
        create_user = #{record.createUser,jdbcType=BIGINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update tb_operation_center_payment_biz
    set id = #{record.id,jdbcType=BIGINT},
      payment_id = #{record.paymentId,jdbcType=BIGINT},
      biz_platform_code = #{record.bizPlatformCode,jdbcType=VARCHAR},
      biz_platform_name = #{record.bizPlatformName,jdbcType=VARCHAR},
      biz_pay_type_id = #{record.bizPayTypeId,jdbcType=VARCHAR},
      biz_pay_type_name = #{record.bizPayTypeName,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      create_user = #{record.createUser,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterPaymentBiz">
    update tb_operation_center_payment_biz
    <set>
      <if test="paymentId != null">
        payment_id = #{paymentId,jdbcType=BIGINT},
      </if>
      <if test="bizPlatformCode != null">
        biz_platform_code = #{bizPlatformCode,jdbcType=VARCHAR},
      </if>
      <if test="bizPlatformName != null">
        biz_platform_name = #{bizPlatformName,jdbcType=VARCHAR},
      </if>
      <if test="bizPayTypeId != null">
        biz_pay_type_id = #{bizPayTypeId,jdbcType=VARCHAR},
      </if>
      <if test="bizPayTypeName != null">
        biz_pay_type_name = #{bizPayTypeName,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        create_user = #{createUser,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterPaymentBiz">
    update tb_operation_center_payment_biz
    set payment_id = #{paymentId,jdbcType=BIGINT},
      biz_platform_code = #{bizPlatformCode,jdbcType=VARCHAR},
      biz_platform_name = #{bizPlatformName,jdbcType=VARCHAR},
      biz_pay_type_id = #{bizPayTypeId,jdbcType=VARCHAR},
      biz_pay_type_name = #{bizPayTypeName,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_user = #{createUser,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <select id="getPaymentBizListByPayment"
          resultMap="BaseResultMap">
    select *
    from tb_operation_center_payment_biz
    where 1=1
    and
    <foreach collection="operationCenterPaymentBizParamList" separator="or" open="(" close=")" item="param" index="index">
      (biz_platform_code =#{param.bizPlatformCode}  and biz_pay_type_id=#{param.bizPayTypeId})
    </foreach>

    <if test="payId != null and payId !=''">
      and payment_id !=#{payId}
    </if>


  </select>
  <select id="selectPlatformPayTypeByPlatformCodeAndBizType" resultType="java.lang.Long">
    SELECT t1.id
    FROM tb_operation_center_payment t1
           LEFT JOIN tb_operation_center_payment_biz t2 ON t1.id = t2.payment_id
    WHERE t2.biz_platform_code = #{platformCode}
      AND t2.biz_pay_type_id = #{bizPayTypeId}
  </select>

</mapper>