<?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.accounting.unified.customer.AccountingUnifiedCustomerOrderGoodsMapper">
  <resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.accounting.unified.customer.AccountingUnifiedCustomerOrderGoods">

    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="dz_order_id" jdbcType="BIGINT" property="dzOrderId" />
    <result column="good_id" jdbcType="BIGINT" property="goodId" />
    <result column="goodno" jdbcType="VARCHAR" property="goodno" />
    <result column="price" jdbcType="DECIMAL" property="price" />
    <result column="total" jdbcType="INTEGER" property="total" />
    <result column="unit_price" jdbcType="DECIMAL" property="unitPrice" />
    <result column="optionname" jdbcType="VARCHAR" property="optionname" />
    <result column="unit" jdbcType="VARCHAR" property="unit" />
    <result column="other_field1" jdbcType="VARCHAR" property="otherField1" />
    <result column="other_field2" jdbcType="VARCHAR" property="otherField2" />
    <result column="dispatch_price" jdbcType="DECIMAL" property="dispatchPrice" />
    <result column="total_price" jdbcType="DECIMAL" property="totalPrice" />
    <result column="tax_code" jdbcType="VARCHAR" property="taxCode" />
    <result column="fiscal_code" jdbcType="VARCHAR" property="fiscalCode" />
  </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, dz_order_id, good_id, goodno, price, total, unit_price, optionname, unit, other_field1, 
    other_field2, dispatch_price, total_price, tax_code, fiscal_code
  </sql>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.accounting.unified.customer.AccountingUnifiedCustomerOrderGoodsExample" resultMap="BaseResultMap">

    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from accounting_unified_customer_order_goods
    <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 accounting_unified_customer_order_goods
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">

    delete from accounting_unified_customer_order_goods
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.superdesk.uniorder.dao.entity.accounting.unified.customer.AccountingUnifiedCustomerOrderGoodsExample">

    delete from accounting_unified_customer_order_goods
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.accounting.unified.customer.AccountingUnifiedCustomerOrderGoods">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into accounting_unified_customer_order_goods (dz_order_id, good_id, goodno, 
      price, total, unit_price, 
      optionname, unit, other_field1, 
      other_field2, dispatch_price, total_price, 
      tax_code, fiscal_code)
    values (#{dzOrderId,jdbcType=BIGINT}, #{goodId,jdbcType=BIGINT}, #{goodno,jdbcType=VARCHAR}, 
      #{price,jdbcType=DECIMAL}, #{total,jdbcType=INTEGER}, #{unitPrice,jdbcType=DECIMAL}, 
      #{optionname,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR}, #{otherField1,jdbcType=VARCHAR}, 
      #{otherField2,jdbcType=VARCHAR}, #{dispatchPrice,jdbcType=DECIMAL}, #{totalPrice,jdbcType=DECIMAL}, 
      #{taxCode,jdbcType=VARCHAR}, #{fiscalCode,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.accounting.unified.customer.AccountingUnifiedCustomerOrderGoods">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into accounting_unified_customer_order_goods
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="dzOrderId != null">
        dz_order_id,
      </if>
      <if test="goodId != null">
        good_id,
      </if>
      <if test="goodno != null">
        goodno,
      </if>
      <if test="price != null">
        price,
      </if>
      <if test="total != null">
        total,
      </if>
      <if test="unitPrice != null">
        unit_price,
      </if>
      <if test="optionname != null">
        optionname,
      </if>
      <if test="unit != null">
        unit,
      </if>
      <if test="otherField1 != null">
        other_field1,
      </if>
      <if test="otherField2 != null">
        other_field2,
      </if>
      <if test="dispatchPrice != null">
        dispatch_price,
      </if>
      <if test="totalPrice != null">
        total_price,
      </if>
      <if test="taxCode != null">
        tax_code,
      </if>
      <if test="fiscalCode != null">
        fiscal_code,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="dzOrderId != null">
        #{dzOrderId,jdbcType=BIGINT},
      </if>
      <if test="goodId != null">
        #{goodId,jdbcType=BIGINT},
      </if>
      <if test="goodno != null">
        #{goodno,jdbcType=VARCHAR},
      </if>
      <if test="price != null">
        #{price,jdbcType=DECIMAL},
      </if>
      <if test="total != null">
        #{total,jdbcType=INTEGER},
      </if>
      <if test="unitPrice != null">
        #{unitPrice,jdbcType=DECIMAL},
      </if>
      <if test="optionname != null">
        #{optionname,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        #{unit,jdbcType=VARCHAR},
      </if>
      <if test="otherField1 != null">
        #{otherField1,jdbcType=VARCHAR},
      </if>
      <if test="otherField2 != null">
        #{otherField2,jdbcType=VARCHAR},
      </if>
      <if test="dispatchPrice != null">
        #{dispatchPrice,jdbcType=DECIMAL},
      </if>
      <if test="totalPrice != null">
        #{totalPrice,jdbcType=DECIMAL},
      </if>
      <if test="taxCode != null">
        #{taxCode,jdbcType=VARCHAR},
      </if>
      <if test="fiscalCode != null">
        #{fiscalCode,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.accounting.unified.customer.AccountingUnifiedCustomerOrderGoodsExample" resultType="java.lang.Long">

    select count(*) from accounting_unified_customer_order_goods
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">

    update accounting_unified_customer_order_goods
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.dzOrderId != null">
        dz_order_id = #{record.dzOrderId,jdbcType=BIGINT},
      </if>
      <if test="record.goodId != null">
        good_id = #{record.goodId,jdbcType=BIGINT},
      </if>
      <if test="record.goodno != null">
        goodno = #{record.goodno,jdbcType=VARCHAR},
      </if>
      <if test="record.price != null">
        price = #{record.price,jdbcType=DECIMAL},
      </if>
      <if test="record.total != null">
        total = #{record.total,jdbcType=INTEGER},
      </if>
      <if test="record.unitPrice != null">
        unit_price = #{record.unitPrice,jdbcType=DECIMAL},
      </if>
      <if test="record.optionname != null">
        optionname = #{record.optionname,jdbcType=VARCHAR},
      </if>
      <if test="record.unit != null">
        unit = #{record.unit,jdbcType=VARCHAR},
      </if>
      <if test="record.otherField1 != null">
        other_field1 = #{record.otherField1,jdbcType=VARCHAR},
      </if>
      <if test="record.otherField2 != null">
        other_field2 = #{record.otherField2,jdbcType=VARCHAR},
      </if>
      <if test="record.dispatchPrice != null">
        dispatch_price = #{record.dispatchPrice,jdbcType=DECIMAL},
      </if>
      <if test="record.totalPrice != null">
        total_price = #{record.totalPrice,jdbcType=DECIMAL},
      </if>
      <if test="record.taxCode != null">
        tax_code = #{record.taxCode,jdbcType=VARCHAR},
      </if>
      <if test="record.fiscalCode != null">
        fiscal_code = #{record.fiscalCode,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">

    update accounting_unified_customer_order_goods
    set id = #{record.id,jdbcType=BIGINT},
      dz_order_id = #{record.dzOrderId,jdbcType=BIGINT},
      good_id = #{record.goodId,jdbcType=BIGINT},
      goodno = #{record.goodno,jdbcType=VARCHAR},
      price = #{record.price,jdbcType=DECIMAL},
      total = #{record.total,jdbcType=INTEGER},
      unit_price = #{record.unitPrice,jdbcType=DECIMAL},
      optionname = #{record.optionname,jdbcType=VARCHAR},
      unit = #{record.unit,jdbcType=VARCHAR},
      other_field1 = #{record.otherField1,jdbcType=VARCHAR},
      other_field2 = #{record.otherField2,jdbcType=VARCHAR},
      dispatch_price = #{record.dispatchPrice,jdbcType=DECIMAL},
      total_price = #{record.totalPrice,jdbcType=DECIMAL},
      tax_code = #{record.taxCode,jdbcType=VARCHAR},
      fiscal_code = #{record.fiscalCode,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.accounting.unified.customer.AccountingUnifiedCustomerOrderGoods">

    update accounting_unified_customer_order_goods
    <set>
      <if test="dzOrderId != null">
        dz_order_id = #{dzOrderId,jdbcType=BIGINT},
      </if>
      <if test="goodId != null">
        good_id = #{goodId,jdbcType=BIGINT},
      </if>
      <if test="goodno != null">
        goodno = #{goodno,jdbcType=VARCHAR},
      </if>
      <if test="price != null">
        price = #{price,jdbcType=DECIMAL},
      </if>
      <if test="total != null">
        total = #{total,jdbcType=INTEGER},
      </if>
      <if test="unitPrice != null">
        unit_price = #{unitPrice,jdbcType=DECIMAL},
      </if>
      <if test="optionname != null">
        optionname = #{optionname,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        unit = #{unit,jdbcType=VARCHAR},
      </if>
      <if test="otherField1 != null">
        other_field1 = #{otherField1,jdbcType=VARCHAR},
      </if>
      <if test="otherField2 != null">
        other_field2 = #{otherField2,jdbcType=VARCHAR},
      </if>
      <if test="dispatchPrice != null">
        dispatch_price = #{dispatchPrice,jdbcType=DECIMAL},
      </if>
      <if test="totalPrice != null">
        total_price = #{totalPrice,jdbcType=DECIMAL},
      </if>
      <if test="taxCode != null">
        tax_code = #{taxCode,jdbcType=VARCHAR},
      </if>
      <if test="fiscalCode != null">
        fiscal_code = #{fiscalCode,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.accounting.unified.customer.AccountingUnifiedCustomerOrderGoods">

    update accounting_unified_customer_order_goods
    set dz_order_id = #{dzOrderId,jdbcType=BIGINT},
      good_id = #{goodId,jdbcType=BIGINT},
      goodno = #{goodno,jdbcType=VARCHAR},
      price = #{price,jdbcType=DECIMAL},
      total = #{total,jdbcType=INTEGER},
      unit_price = #{unitPrice,jdbcType=DECIMAL},
      optionname = #{optionname,jdbcType=VARCHAR},
      unit = #{unit,jdbcType=VARCHAR},
      other_field1 = #{otherField1,jdbcType=VARCHAR},
      other_field2 = #{otherField2,jdbcType=VARCHAR},
      dispatch_price = #{dispatchPrice,jdbcType=DECIMAL},
      total_price = #{totalPrice,jdbcType=DECIMAL},
      tax_code = #{taxCode,jdbcType=VARCHAR},
      fiscal_code = #{fiscalCode,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>