<?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.yd.dal.mapper.commission.AgPoOrderCommissionMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.commission.AgPoOrderCommission">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="commission_no" jdbcType="VARCHAR" property="commissionNo" />
    <result column="commission_type" jdbcType="INTEGER" property="commissionType" />
    <result column="customer_id" jdbcType="BIGINT" property="customerId" />
    <result column="practitioner_id" jdbcType="BIGINT" property="practitionerId" />
    <result column="order_id" jdbcType="BIGINT" property="orderId" />
    <result column="policy_no" jdbcType="VARCHAR" property="policyNo" />
    <result column="product_name" jdbcType="VARCHAR" property="productName" />
    <result column="commission_year" jdbcType="TIMESTAMP" property="commissionYear" />
    <result column="payment_term" jdbcType="INTEGER" property="paymentTerm" />
    <result column="premium" jdbcType="DECIMAL" property="premium" />
    <result column="commission_category" jdbcType="VARCHAR" property="commissionCategory" />
    <result column="oldrate" jdbcType="DECIMAL" property="oldrate" />
    <result column="rate" jdbcType="DECIMAL" property="rate" />
    <result column="amount" jdbcType="DECIMAL" property="amount" />
    <result column="commission_status" jdbcType="VARCHAR" property="commissionStatus" />
    <result column="commission_time" jdbcType="VARCHAR" property="commissionTime" />
    <result column="commission_period" jdbcType="INTEGER" property="commissionPeriod" />
    <result column="commission_check_id" jdbcType="BIGINT" property="commissionCheckId" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
    <result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
  </resultMap>
  <sql id="Base_Column_List">
    id, commission_no, commission_type, customer_id, practitioner_id, order_id, policy_no, 
    product_name, commission_year, payment_term, premium, commission_category, oldrate, 
    rate, amount, commission_status, commission_time, commission_period, commission_check_id, 
    is_active, remark, created_at, created_by, updated_at, updated_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_po_order_commission
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_po_order_commission
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.commission.AgPoOrderCommission" useGeneratedKeys="true">
    insert into ag_po_order_commission (commission_no, commission_type, customer_id, 
      practitioner_id, order_id, policy_no, 
      product_name, commission_year, payment_term, 
      premium, commission_category, oldrate, 
      rate, amount, commission_status, 
      commission_time, commission_period, commission_check_id, 
      is_active, remark, created_at, 
      created_by, updated_at, updated_by
      )
    values (#{commissionNo,jdbcType=VARCHAR}, #{commissionType,jdbcType=INTEGER}, #{customerId,jdbcType=BIGINT}, 
      #{practitionerId,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, #{policyNo,jdbcType=VARCHAR}, 
      #{productName,jdbcType=VARCHAR}, #{commissionYear,jdbcType=TIMESTAMP}, #{paymentTerm,jdbcType=INTEGER}, 
      #{premium,jdbcType=DECIMAL}, #{commissionCategory,jdbcType=VARCHAR}, #{oldrate,jdbcType=DECIMAL}, 
      #{rate,jdbcType=DECIMAL}, #{amount,jdbcType=DECIMAL}, #{commissionStatus,jdbcType=VARCHAR}, 
      #{commissionTime,jdbcType=VARCHAR}, #{commissionPeriod,jdbcType=INTEGER}, #{commissionCheckId,jdbcType=BIGINT}, 
      #{isActive,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, 
      #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.commission.AgPoOrderCommission" useGeneratedKeys="true">
    insert into ag_po_order_commission
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="commissionNo != null">
        commission_no,
      </if>
      <if test="commissionType != null">
        commission_type,
      </if>
      <if test="customerId != null">
        customer_id,
      </if>
      <if test="practitionerId != null">
        practitioner_id,
      </if>
      <if test="orderId != null">
        order_id,
      </if>
      <if test="policyNo != null">
        policy_no,
      </if>
      <if test="productName != null">
        product_name,
      </if>
      <if test="commissionYear != null">
        commission_year,
      </if>
      <if test="paymentTerm != null">
        payment_term,
      </if>
      <if test="premium != null">
        premium,
      </if>
      <if test="commissionCategory != null">
        commission_category,
      </if>
      <if test="oldrate != null">
        oldrate,
      </if>
      <if test="rate != null">
        rate,
      </if>
      <if test="amount != null">
        amount,
      </if>
      <if test="commissionStatus != null">
        commission_status,
      </if>
      <if test="commissionTime != null">
        commission_time,
      </if>
      <if test="commissionPeriod != null">
        commission_period,
      </if>
      <if test="commissionCheckId != null">
        commission_check_id,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedAt != null">
        updated_at,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="commissionNo != null">
        #{commissionNo,jdbcType=VARCHAR},
      </if>
      <if test="commissionType != null">
        #{commissionType,jdbcType=INTEGER},
      </if>
      <if test="customerId != null">
        #{customerId,jdbcType=BIGINT},
      </if>
      <if test="practitionerId != null">
        #{practitionerId,jdbcType=BIGINT},
      </if>
      <if test="orderId != null">
        #{orderId,jdbcType=BIGINT},
      </if>
      <if test="policyNo != null">
        #{policyNo,jdbcType=VARCHAR},
      </if>
      <if test="productName != null">
        #{productName,jdbcType=VARCHAR},
      </if>
      <if test="commissionYear != null">
        #{commissionYear,jdbcType=TIMESTAMP},
      </if>
      <if test="paymentTerm != null">
        #{paymentTerm,jdbcType=INTEGER},
      </if>
      <if test="premium != null">
        #{premium,jdbcType=DECIMAL},
      </if>
      <if test="commissionCategory != null">
        #{commissionCategory,jdbcType=VARCHAR},
      </if>
      <if test="oldrate != null">
        #{oldrate,jdbcType=DECIMAL},
      </if>
      <if test="rate != null">
        #{rate,jdbcType=DECIMAL},
      </if>
      <if test="amount != null">
        #{amount,jdbcType=DECIMAL},
      </if>
      <if test="commissionStatus != null">
        #{commissionStatus,jdbcType=VARCHAR},
      </if>
      <if test="commissionTime != null">
        #{commissionTime,jdbcType=VARCHAR},
      </if>
      <if test="commissionPeriod != null">
        #{commissionPeriod,jdbcType=INTEGER},
      </if>
      <if test="commissionCheckId != null">
        #{commissionCheckId,jdbcType=BIGINT},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.commission.AgPoOrderCommission">
    update ag_po_order_commission
    <set>
      <if test="commissionNo != null">
        commission_no = #{commissionNo,jdbcType=VARCHAR},
      </if>
      <if test="commissionType != null">
        commission_type = #{commissionType,jdbcType=INTEGER},
      </if>
      <if test="customerId != null">
        customer_id = #{customerId,jdbcType=BIGINT},
      </if>
      <if test="practitionerId != null">
        practitioner_id = #{practitionerId,jdbcType=BIGINT},
      </if>
      <if test="orderId != null">
        order_id = #{orderId,jdbcType=BIGINT},
      </if>
      <if test="policyNo != null">
        policy_no = #{policyNo,jdbcType=VARCHAR},
      </if>
      <if test="productName != null">
        product_name = #{productName,jdbcType=VARCHAR},
      </if>
      <if test="commissionYear != null">
        commission_year = #{commissionYear,jdbcType=TIMESTAMP},
      </if>
      <if test="paymentTerm != null">
        payment_term = #{paymentTerm,jdbcType=INTEGER},
      </if>
      <if test="premium != null">
        premium = #{premium,jdbcType=DECIMAL},
      </if>
      <if test="commissionCategory != null">
        commission_category = #{commissionCategory,jdbcType=VARCHAR},
      </if>
      <if test="oldrate != null">
        oldrate = #{oldrate,jdbcType=DECIMAL},
      </if>
      <if test="rate != null">
        rate = #{rate,jdbcType=DECIMAL},
      </if>
      <if test="amount != null">
        amount = #{amount,jdbcType=DECIMAL},
      </if>
      <if test="commissionStatus != null">
        commission_status = #{commissionStatus,jdbcType=VARCHAR},
      </if>
      <if test="commissionTime != null">
        commission_time = #{commissionTime,jdbcType=VARCHAR},
      </if>
      <if test="commissionPeriod != null">
        commission_period = #{commissionPeriod,jdbcType=INTEGER},
      </if>
      <if test="commissionCheckId != null">
        commission_check_id = #{commissionCheckId,jdbcType=BIGINT},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.commission.AgPoOrderCommission">
    update ag_po_order_commission
    set commission_no = #{commissionNo,jdbcType=VARCHAR},
      commission_type = #{commissionType,jdbcType=INTEGER},
      customer_id = #{customerId,jdbcType=BIGINT},
      practitioner_id = #{practitionerId,jdbcType=BIGINT},
      order_id = #{orderId,jdbcType=BIGINT},
      policy_no = #{policyNo,jdbcType=VARCHAR},
      product_name = #{productName,jdbcType=VARCHAR},
      commission_year = #{commissionYear,jdbcType=TIMESTAMP},
      payment_term = #{paymentTerm,jdbcType=INTEGER},
      premium = #{premium,jdbcType=DECIMAL},
      commission_category = #{commissionCategory,jdbcType=VARCHAR},
      oldrate = #{oldrate,jdbcType=DECIMAL},
      rate = #{rate,jdbcType=DECIMAL},
      amount = #{amount,jdbcType=DECIMAL},
      commission_status = #{commissionStatus,jdbcType=VARCHAR},
      commission_time = #{commissionTime,jdbcType=VARCHAR},
      commission_period = #{commissionPeriod,jdbcType=INTEGER},
      commission_check_id = #{commissionCheckId,jdbcType=BIGINT},
      is_active = #{isActive,jdbcType=INTEGER},
      remark = #{remark,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <update id="updateBycommissionNo" parameterType="com.yd.dal.entity.commission.AgPoOrderCommission">
    update ag_po_order_commission
    <set>
      <if test="commissionStatus != null">
        commission_status = #{commissionStatus,jdbcType=BIGINT},
      </if>
      <if test="commissionTime != null">
        commission_time = #{commissionTime,jdbcType=VARCHAR},
      </if>
      <if test="commissionCheckId != null">
        commission_check_id = #{commissionCheckId,jdbcType=VARCHAR},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
    </set>
    where commission_no = #{commissionNo,jdbcType=VARCHAR}
  </update>

  <select id="selectByCommissionNo" parameterType="java.lang.String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ag_po_order_commission
    where commission_no = #{commissionNo,jdbcType=VARCHAR}
  </select>

  <select id="selectByOrderId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ag_po_order_commission
    where order_id = #{orderId,jdbcType=VARCHAR}
  </select>
</mapper>