<?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.SysOrderMapper">
	<resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.sys.SysOrder">
		<id column="id" property="id" jdbcType="BIGINT"/>
		<result column="my_order_id" property="myOrderId" jdbcType="VARCHAR"/>
		<result column="order_id" property="orderId" jdbcType="BIGINT"/>
		<result column="my_ordersn" property="myOrdersn" jdbcType="VARCHAR"/>
		<result column="ordersn" property="ordersn" jdbcType="VARCHAR"/>
		<result column="parent_order_id" property="parentOrderId" jdbcType="INTEGER"/>
		<result column="parent_ordersn" property="parentOrdersn" jdbcType="VARCHAR"/>
		<result column="detail_url" property="detailUrl" jdbcType="VARCHAR"/>
		<result column="dispatchprice" property="dispatchprice" jdbcType="DECIMAL"/>
		<result column="price" property="price" jdbcType="DECIMAL"/>
		<result column="organization_id" property="organizationId" jdbcType="BIGINT"/>
		<result column="enterprise_id" property="enterpriseId" jdbcType="BIGINT"/>
		<result column="invoiceType" property="invoicetype" jdbcType="TINYINT"/>
		<result column="dispatchname" property="dispatchname" jdbcType="VARCHAR"/>
		<result column="createtime" property="createtime" jdbcType="TIMESTAMP"/>
		<result column="sync_time" property="syncTime" jdbcType="TIMESTAMP"/>
		<result column="paytime" property="paytime" jdbcType="TIMESTAMP"/>
		<result column="realname_id" property="realnameId" jdbcType="INTEGER"/>
		<result column="examine_id" property="examineId" jdbcType="INTEGER"/>
		<result column="address_realname" property="addressRealname" jdbcType="VARCHAR"/>
		<result column="address_mobile" property="addressMobile" jdbcType="VARCHAR"/>
		<result column="address_address" property="addressAddress" jdbcType="VARCHAR"/>
		<result column="companyName" property="companyname" jdbcType="VARCHAR"/>
		<result column="taxpayersIDcode" property="taxpayersidcode" jdbcType="VARCHAR"/>
		<result column="sendtime" property="sendtime" jdbcType="TIMESTAMP"/>
		<result column="finishtime" property="finishtime" jdbcType="TIMESTAMP"/>
		<result column="status" property="status" jdbcType="TINYINT"/>
		<result column="merch_name" property="merchName" jdbcType="VARCHAR"/>
		<result column="service_name" property="serviceName" jdbcType="TINYINT"/>
		<result column="paytype" property="paytype" jdbcType="TINYINT"/>
		<result column="search_field1" property="searchField1" jdbcType="VARCHAR"/>
		<result column="search_field2" property="searchField2" jdbcType="VARCHAR"/>
		<result column="search_field3" property="searchField3" jdbcType="VARCHAR"/>
		<result column="other_field1" property="otherField1" jdbcType="VARCHAR"/>
		<result column="other_field2" property="otherField2" jdbcType="VARCHAR"/>
		<result column="other_field3" property="otherField3" jdbcType="VARCHAR"/>
		<result column="remark" property="remark" jdbcType="VARCHAR"/>
		<result column="invoiceAccount" property="invoiceaccount" jdbcType="VARCHAR"/>
		<result column="is_gen_bill" property="isGenBill" jdbcType="TINYINT"/>
		<result column="invoiceBank" property="invoicebank" jdbcType="VARCHAR"/>
	</resultMap>
	<sql id="Base_Column_List">
    id, my_order_id, order_id, my_ordersn, ordersn, parent_order_id, parent_ordersn, 
    detail_url, dispatchprice, price, organization_id, enterprise_id, invoiceType, dispatchname, 
    createtime, sync_time, paytime, realname_id, examine_id, address_realname, address_mobile, 
    address_address, companyName, taxpayersIDcode, sendtime, finishtime, status, merch_name, 
    service_name, paytype, search_field1, search_field2, search_field3, other_field1, other_field2,
    other_field3, remark, invoiceAccount, is_gen_bill, invoiceBank
  </sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
		select
		<include refid="Base_Column_List"/>
		from sys_order
		where id = #{id,jdbcType=BIGINT}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from sys_order
    where id = #{id,jdbcType=BIGINT}
  </delete>
	<insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysOrder">
		<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
			SELECT LAST_INSERT_ID()
		</selectKey>
		insert into sys_order (my_order_id, order_id, my_ordersn,
		ordersn, parent_order_id, parent_ordersn,
		detail_url, dispatchprice, price,
		organization_id, enterprise_id, invoiceType,
		dispatchname, createtime, sync_time,
		paytime, realname_id, examine_id,
		address_realname, address_mobile, address_address,
		companyName, taxpayersIDcode, sendtime,
		finishtime, status, merch_name,
		service_name, paytype, search_field1,
		search_field2, search_field3, other_field1,
		other_field2, other_field3, remark,
		invoiceAccount, is_gen_bill, invoiceBank
		)
		values (#{myOrderId,jdbcType=VARCHAR}, #{orderId,jdbcType=BIGINT}, #{myOrdersn,jdbcType=VARCHAR},
		#{ordersn,jdbcType=VARCHAR}, #{parentOrderId,jdbcType=INTEGER}, #{parentOrdersn,jdbcType=VARCHAR},
		#{detailUrl,jdbcType=VARCHAR}, #{dispatchprice,jdbcType=DECIMAL}, #{price,jdbcType=DECIMAL},
		#{organizationId,jdbcType=BIGINT}, #{enterpriseId,jdbcType=BIGINT}, #{invoicetype,jdbcType=TINYINT},
		#{dispatchname,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}, #{syncTime,jdbcType=TIMESTAMP},
		#{paytime,jdbcType=TIMESTAMP}, #{realnameId,jdbcType=INTEGER}, #{examineId,jdbcType=INTEGER},
		#{addressRealname,jdbcType=VARCHAR}, #{addressMobile,jdbcType=VARCHAR}, #{addressAddress,jdbcType=VARCHAR},
		#{companyname,jdbcType=VARCHAR}, #{taxpayersidcode,jdbcType=VARCHAR}, #{sendtime,jdbcType=TIMESTAMP},
		#{finishtime,jdbcType=TIMESTAMP}, #{status,jdbcType=TINYINT}, #{merchName,jdbcType=VARCHAR},
		#{serviceName,jdbcType=TINYINT}, #{paytype,jdbcType=TINYINT}, #{searchField1,jdbcType=VARCHAR},
		#{searchField2,jdbcType=VARCHAR}, #{searchField3,jdbcType=VARCHAR}, #{otherField1,jdbcType=VARCHAR},
		#{otherField2,jdbcType=VARCHAR}, #{otherField3,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
		#{invoiceaccount,jdbcType=VARCHAR}, #{isGenBill,jdbcType=TINYINT}, #{invoicebank,jdbcType=VARCHAR}
		)
	</insert>
	<insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysOrder">
		<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
			SELECT LAST_INSERT_ID()
		</selectKey>
		insert into sys_order
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="myOrderId != null">
				my_order_id,
			</if>
			<if test="orderId != null">
				order_id,
			</if>
			<if test="myOrdersn != null">
				my_ordersn,
			</if>
			<if test="ordersn != null">
				ordersn,
			</if>
			<if test="parentOrderId != null">
				parent_order_id,
			</if>
			<if test="parentOrdersn != null">
				parent_ordersn,
			</if>
			<if test="detailUrl != null">
				detail_url,
			</if>
			<if test="dispatchprice != null">
				dispatchprice,
			</if>
			<if test="price != null">
				price,
			</if>
			<if test="organizationId != null">
				organization_id,
			</if>
			<if test="enterpriseId != null">
				enterprise_id,
			</if>
			<if test="invoicetype != null">
				invoiceType,
			</if>
			<if test="dispatchname != null">
				dispatchname,
			</if>
			<if test="createtime != null">
				createtime,
			</if>
			<if test="syncTime != null">
				sync_time,
			</if>
			<if test="paytime != null">
				paytime,
			</if>
			<if test="realnameId != null">
				realname_id,
			</if>
			<if test="examineId != null">
				examine_id,
			</if>
			<if test="addressRealname != null">
				address_realname,
			</if>
			<if test="addressMobile != null">
				address_mobile,
			</if>
			<if test="addressAddress != null">
				address_address,
			</if>
			<if test="companyname != null">
				companyName,
			</if>
			<if test="taxpayersidcode != null">
				taxpayersIDcode,
			</if>
			<if test="sendtime != null">
				sendtime,
			</if>
			<if test="finishtime != null">
				finishtime,
			</if>
			<if test="status != null">
				status,
			</if>
			<if test="merchName != null">
				merch_name,
			</if>
			<if test="serviceName != null">
				service_name,
			</if>
			<if test="paytype != null">
				paytype,
			</if>
			<if test="searchField1 != null">
				search_field1,
			</if>
			<if test="searchField2 != null">
				search_field2,
			</if>
			<if test="searchField3 != null">
				search_field3,
			</if>
			<if test="otherField1 != null">
				other_field1,
			</if>
			<if test="otherField2 != null">
				other_field2,
			</if>
			<if test="otherField3 != null">
				other_field3,
			</if>
			<if test="remark != null">
				remark,
			</if>
			<if test="invoiceaccount != null">
				invoiceAccount,
			</if>
			<if test="isGenBill != null">
				is_gen_bill,
			</if>
			<if test="invoicebank != null">
				invoiceBank,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="myOrderId != null">
				#{myOrderId,jdbcType=VARCHAR},
			</if>
			<if test="orderId != null">
				#{orderId,jdbcType=BIGINT},
			</if>
			<if test="myOrdersn != null">
				#{myOrdersn,jdbcType=VARCHAR},
			</if>
			<if test="ordersn != null">
				#{ordersn,jdbcType=VARCHAR},
			</if>
			<if test="parentOrderId != null">
				#{parentOrderId,jdbcType=INTEGER},
			</if>
			<if test="parentOrdersn != null">
				#{parentOrdersn,jdbcType=VARCHAR},
			</if>
			<if test="detailUrl != null">
				#{detailUrl,jdbcType=VARCHAR},
			</if>
			<if test="dispatchprice != null">
				#{dispatchprice,jdbcType=DECIMAL},
			</if>
			<if test="price != null">
				#{price,jdbcType=DECIMAL},
			</if>
			<if test="organizationId != null">
				#{organizationId,jdbcType=BIGINT},
			</if>
			<if test="enterpriseId != null">
				#{enterpriseId,jdbcType=BIGINT},
			</if>
			<if test="invoicetype != null">
				#{invoicetype,jdbcType=TINYINT},
			</if>
			<if test="dispatchname != null">
				#{dispatchname,jdbcType=VARCHAR},
			</if>
			<if test="createtime != null">
				#{createtime,jdbcType=TIMESTAMP},
			</if>
			<if test="syncTime != null">
				#{syncTime,jdbcType=TIMESTAMP},
			</if>
			<if test="paytime != null">
				#{paytime,jdbcType=TIMESTAMP},
			</if>
			<if test="realnameId != null">
				#{realnameId,jdbcType=INTEGER},
			</if>
			<if test="examineId != null">
				#{examineId,jdbcType=INTEGER},
			</if>
			<if test="addressRealname != null">
				#{addressRealname,jdbcType=VARCHAR},
			</if>
			<if test="addressMobile != null">
				#{addressMobile,jdbcType=VARCHAR},
			</if>
			<if test="addressAddress != null">
				#{addressAddress,jdbcType=VARCHAR},
			</if>
			<if test="companyname != null">
				#{companyname,jdbcType=VARCHAR},
			</if>
			<if test="taxpayersidcode != null">
				#{taxpayersidcode,jdbcType=VARCHAR},
			</if>
			<if test="sendtime != null">
				#{sendtime,jdbcType=TIMESTAMP},
			</if>
			<if test="finishtime != null">
				#{finishtime,jdbcType=TIMESTAMP},
			</if>
			<if test="status != null">
				#{status,jdbcType=TINYINT},
			</if>
			<if test="merchName != null">
				#{merchName,jdbcType=VARCHAR},
			</if>
			<if test="serviceName != null">
				#{serviceName,jdbcType=TINYINT},
			</if>
			<if test="paytype != null">
				#{paytype,jdbcType=TINYINT},
			</if>
			<if test="searchField1 != null">
				#{searchField1,jdbcType=VARCHAR},
			</if>
			<if test="searchField2 != null">
				#{searchField2,jdbcType=VARCHAR},
			</if>
			<if test="searchField3 != null">
				#{searchField3,jdbcType=VARCHAR},
			</if>
			<if test="otherField1 != null">
				#{otherField1,jdbcType=VARCHAR},
			</if>
			<if test="otherField2 != null">
				#{otherField2,jdbcType=VARCHAR},
			</if>
			<if test="otherField3 != null">
				#{otherField3,jdbcType=VARCHAR},
			</if>
			<if test="remark != null">
				#{remark,jdbcType=VARCHAR},
			</if>
			<if test="invoiceaccount != null">
				#{invoiceaccount,jdbcType=VARCHAR},
			</if>
			<if test="isGenBill != null">
				#{isGenBill,jdbcType=TINYINT},
			</if>
			<if test="invoicebank != null">
				#{invoicebank,jdbcType=VARCHAR},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysOrder">
		update sys_order
		<set>
			<if test="myOrderId != null">
				my_order_id = #{myOrderId,jdbcType=VARCHAR},
			</if>
			<if test="orderId != null">
				order_id = #{orderId,jdbcType=BIGINT},
			</if>
			<if test="myOrdersn != null">
				my_ordersn = #{myOrdersn,jdbcType=VARCHAR},
			</if>
			<if test="ordersn != null">
				ordersn = #{ordersn,jdbcType=VARCHAR},
			</if>
			<if test="parentOrderId != null">
				parent_order_id = #{parentOrderId,jdbcType=INTEGER},
			</if>
			<if test="parentOrdersn != null">
				parent_ordersn = #{parentOrdersn,jdbcType=VARCHAR},
			</if>
			<if test="detailUrl != null">
				detail_url = #{detailUrl,jdbcType=VARCHAR},
			</if>
			<if test="dispatchprice != null">
				dispatchprice = #{dispatchprice,jdbcType=DECIMAL},
			</if>
			<if test="price != null">
				price = #{price,jdbcType=DECIMAL},
			</if>
			<if test="organizationId != null">
				organization_id = #{organizationId,jdbcType=BIGINT},
			</if>
			<if test="enterpriseId != null">
				enterprise_id = #{enterpriseId,jdbcType=BIGINT},
			</if>
			<if test="invoicetype != null">
				invoiceType = #{invoicetype,jdbcType=TINYINT},
			</if>
			<if test="dispatchname != null">
				dispatchname = #{dispatchname,jdbcType=VARCHAR},
			</if>
			<if test="createtime != null">
				createtime = #{createtime,jdbcType=TIMESTAMP},
			</if>
			<if test="syncTime != null">
				sync_time = #{syncTime,jdbcType=TIMESTAMP},
			</if>
			<if test="paytime != null">
				paytime = #{paytime,jdbcType=TIMESTAMP},
			</if>
			<if test="realnameId != null">
				realname_id = #{realnameId,jdbcType=INTEGER},
			</if>
			<if test="examineId != null">
				examine_id = #{examineId,jdbcType=INTEGER},
			</if>
			<if test="addressRealname != null">
				address_realname = #{addressRealname,jdbcType=VARCHAR},
			</if>
			<if test="addressMobile != null">
				address_mobile = #{addressMobile,jdbcType=VARCHAR},
			</if>
			<if test="addressAddress != null">
				address_address = #{addressAddress,jdbcType=VARCHAR},
			</if>
			<if test="companyname != null">
				companyName = #{companyname,jdbcType=VARCHAR},
			</if>
			<if test="taxpayersidcode != null">
				taxpayersIDcode = #{taxpayersidcode,jdbcType=VARCHAR},
			</if>
			<if test="sendtime != null">
				sendtime = #{sendtime,jdbcType=TIMESTAMP},
			</if>
			<if test="finishtime != null">
				finishtime = #{finishtime,jdbcType=TIMESTAMP},
			</if>
			<if test="status != null">
				status = #{status,jdbcType=TINYINT},
			</if>
			<if test="merchName != null">
				merch_name = #{merchName,jdbcType=VARCHAR},
			</if>
			<if test="serviceName != null">
				service_name = #{serviceName,jdbcType=TINYINT},
			</if>
			<if test="paytype != null">
				paytype = #{paytype,jdbcType=TINYINT},
			</if>
			<if test="searchField1 != null">
				search_field1 = #{searchField1,jdbcType=VARCHAR},
			</if>
			<if test="searchField2 != null">
				search_field2 = #{searchField2,jdbcType=VARCHAR},
			</if>
			<if test="searchField3 != null">
				search_field3 = #{searchField3,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="otherField3 != null">
				other_field3 = #{otherField3,jdbcType=VARCHAR},
			</if>
			<if test="remark != null">
				remark = #{remark,jdbcType=VARCHAR},
			</if>
			<if test="invoiceaccount != null">
				invoiceAccount = #{invoiceaccount,jdbcType=VARCHAR},
			</if>
			<if test="isGenBill != null">
				is_gen_bill = #{isGenBill,jdbcType=TINYINT},
			</if>
			<if test="invoicebank != null">
				invoiceBank = #{invoicebank,jdbcType=VARCHAR},
			</if>
		</set>
		where id = #{id,jdbcType=BIGINT}
	</update>
	<update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysOrder">
    update sys_order
    set my_order_id = #{myOrderId,jdbcType=VARCHAR},
      order_id = #{orderId,jdbcType=BIGINT},
      my_ordersn = #{myOrdersn,jdbcType=VARCHAR},
      ordersn = #{ordersn,jdbcType=VARCHAR},
      parent_order_id = #{parentOrderId,jdbcType=INTEGER},
      parent_ordersn = #{parentOrdersn,jdbcType=VARCHAR},
      detail_url = #{detailUrl,jdbcType=VARCHAR},
      dispatchprice = #{dispatchprice,jdbcType=DECIMAL},
      price = #{price,jdbcType=DECIMAL},
      organization_id = #{organizationId,jdbcType=BIGINT},
      enterprise_id = #{enterpriseId,jdbcType=BIGINT},
      invoiceType = #{invoicetype,jdbcType=TINYINT},
      dispatchname = #{dispatchname,jdbcType=VARCHAR},
      createtime = #{createtime,jdbcType=TIMESTAMP},
      sync_time = #{syncTime,jdbcType=TIMESTAMP},
      paytime = #{paytime,jdbcType=TIMESTAMP},
      realname_id = #{realnameId,jdbcType=INTEGER},
      examine_id = #{examineId,jdbcType=INTEGER},
      address_realname = #{addressRealname,jdbcType=VARCHAR},
      address_mobile = #{addressMobile,jdbcType=VARCHAR},
      address_address = #{addressAddress,jdbcType=VARCHAR},
      companyName = #{companyname,jdbcType=VARCHAR},
      taxpayersIDcode = #{taxpayersidcode,jdbcType=VARCHAR},
      sendtime = #{sendtime,jdbcType=TIMESTAMP},
      finishtime = #{finishtime,jdbcType=TIMESTAMP},
      status = #{status,jdbcType=TINYINT},
      merch_name = #{merchName,jdbcType=VARCHAR},
      service_name = #{serviceName,jdbcType=TINYINT},
      paytype = #{paytype,jdbcType=TINYINT},
      search_field1 = #{searchField1,jdbcType=VARCHAR},
      search_field2 = #{searchField2,jdbcType=VARCHAR},
      search_field3 = #{searchField3,jdbcType=VARCHAR},
      other_field1 = #{otherField1,jdbcType=VARCHAR},
      other_field2 = #{otherField2,jdbcType=VARCHAR},
      other_field3 = #{otherField3,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      invoiceAccount = #{invoiceaccount,jdbcType=VARCHAR},
      is_gen_bill = #{isGenBill,jdbcType=TINYINT},
      invoiceBank = #{invoicebank,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>


	<!--自定义查询 覆盖前要备份好-->
	<select id="findByOrderId" resultMap="BaseResultMap" parameterType="java.lang.String">
		select
		<include refid="Base_Column_List"/>
		from sys_order
		where my_order_id = #{myOrderId,jdbcType=VARCHAR}
	</select>


	<!--自定义查询 覆盖前要备份好-->
	<select id="findByParentOrderId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
		select
		<include refid="Base_Column_List"/>
		from sys_order
		where parent_order_id = #{parentOrderId,jdbcType=INTEGER}
	</select>

</mapper>