<?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.sys.SysGoodMapper">
	<resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.sys.SysGood">
		<id column="id" property="id" jdbcType="BIGINT"/>
		<result column="sys_order_id" property="sysOrderId" jdbcType="VARCHAR"/>
		<result column="goodno" property="goodno" jdbcType="VARCHAR"/>
		<result column="total" property="total" jdbcType="INTEGER"/>
		<result column="unit_price" property="unitPrice" jdbcType="DECIMAL"/>
		<result column="price" property="price" jdbcType="DECIMAL"/>
		<result column="dispatch_price" property="dispatchPrice" jdbcType="DECIMAL"/>
		<result column="total_price" property="totalPrice" jdbcType="DECIMAL"/>
		<result column="optionname" property="optionname" jdbcType="VARCHAR"/>
		<result column="unit" property="unit" jdbcType="VARCHAR"/>
		<result column="other_field1" property="otherField1" jdbcType="VARCHAR"/>
		<result column="other_field2" property="otherField2" jdbcType="VARCHAR"/>
		<result column="tax_code" property="taxCode" jdbcType="VARCHAR"/>
		<result column="fiscal_code" property="fiscalCode" jdbcType="VARCHAR"/>
	</resultMap>
	<sql id="Base_Column_List">
    id, sys_order_id, goodno, total, unit_price, price, dispatch_price, total_price, 
    optionname, unit, other_field1, other_field2, tax_code, fiscal_code
  </sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
		select
		<include refid="Base_Column_List"/>
		from sys_good
		where id = #{id,jdbcType=BIGINT}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from sys_good
    where id = #{id,jdbcType=BIGINT}
  </delete>

	<delete id="deleteGoodBySysOrderId" parameterType="java.lang.String">
    delete from sys_good
    where sys_order_id = #{sysOrderId,jdbcType=BIGINT}
  </delete>


	<insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysGood">
		<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
			SELECT LAST_INSERT_ID()
		</selectKey>
		insert into sys_good (sys_order_id, goodno, total,
		unit_price, price, dispatch_price,
		total_price, optionname, unit,
		other_field1, other_field2, tax_code,
		fiscal_code)
		values (#{sysOrderId,jdbcType=VARCHAR}, #{goodno,jdbcType=VARCHAR}, #{total,jdbcType=INTEGER},
		#{unitPrice,jdbcType=DECIMAL}, #{price,jdbcType=DECIMAL}, #{dispatchPrice,jdbcType=DECIMAL},
		#{totalPrice,jdbcType=DECIMAL}, #{optionname,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR},
		#{otherField1,jdbcType=VARCHAR}, #{otherField2,jdbcType=VARCHAR}, #{taxCode,jdbcType=VARCHAR},
		#{fiscalCode,jdbcType=VARCHAR})
	</insert>
	<insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysGood">
		<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
			SELECT LAST_INSERT_ID()
		</selectKey>
		insert into sys_good
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="sysOrderId != null">
				sys_order_id,
			</if>
			<if test="goodno != null">
				goodno,
			</if>
			<if test="total != null">
				total,
			</if>
			<if test="unitPrice != null">
				unit_price,
			</if>
			<if test="price != null">
				price,
			</if>
			<if test="dispatchPrice != null">
				dispatch_price,
			</if>
			<if test="totalPrice != null">
				total_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="taxCode != null">
				tax_code,
			</if>
			<if test="fiscalCode != null">
				fiscal_code,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="sysOrderId != null">
				#{sysOrderId,jdbcType=VARCHAR},
			</if>
			<if test="goodno != null">
				#{goodno,jdbcType=VARCHAR},
			</if>
			<if test="total != null">
				#{total,jdbcType=INTEGER},
			</if>
			<if test="unitPrice != null">
				#{unitPrice,jdbcType=DECIMAL},
			</if>
			<if test="price != null">
				#{price,jdbcType=DECIMAL},
			</if>
			<if test="dispatchPrice != null">
				#{dispatchPrice,jdbcType=DECIMAL},
			</if>
			<if test="totalPrice != null">
				#{totalPrice,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="taxCode != null">
				#{taxCode,jdbcType=VARCHAR},
			</if>
			<if test="fiscalCode != null">
				#{fiscalCode,jdbcType=VARCHAR},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysGood">
		update sys_good
		<set>
			<if test="sysOrderId != null">
				sys_order_id = #{sysOrderId,jdbcType=VARCHAR},
			</if>
			<if test="goodno != null">
				goodno = #{goodno,jdbcType=VARCHAR},
			</if>
			<if test="total != null">
				total = #{total,jdbcType=INTEGER},
			</if>
			<if test="unitPrice != null">
				unit_price = #{unitPrice,jdbcType=DECIMAL},
			</if>
			<if test="price != null">
				price = #{price,jdbcType=DECIMAL},
			</if>
			<if test="dispatchPrice != null">
				dispatch_price = #{dispatchPrice,jdbcType=DECIMAL},
			</if>
			<if test="totalPrice != null">
				total_price = #{totalPrice,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="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.sys.SysGood">
    update sys_good
    set sys_order_id = #{sysOrderId,jdbcType=VARCHAR},
      goodno = #{goodno,jdbcType=VARCHAR},
      total = #{total,jdbcType=INTEGER},
      unit_price = #{unitPrice,jdbcType=DECIMAL},
      price = #{price,jdbcType=DECIMAL},
      dispatch_price = #{dispatchPrice,jdbcType=DECIMAL},
      total_price = #{totalPrice,jdbcType=DECIMAL},
      optionname = #{optionname,jdbcType=VARCHAR},
      unit = #{unit,jdbcType=VARCHAR},
      other_field1 = #{otherField1,jdbcType=VARCHAR},
      other_field2 = #{otherField2,jdbcType=VARCHAR},
      tax_code = #{taxCode,jdbcType=VARCHAR},
      fiscal_code = #{fiscalCode,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>