<?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.pj.tb_order.TbOrderMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, trade_no, trade_area_id, trade_area_name, address_ids, goods_id, sale_main_id, group_id, buy_user_id, buy_user_name, buy_user_type, enterprise_id, enterprise_name, total_weight, total_price, trade_time, trade_status, pay_type, settle_time, real_price, should_price, settle_user_id, record_user_id, record_time, record, refund_reason, refund_time, receive_name, receive_phone, receive_address, out_time, goods_names, goods_img, apply, apply_time, apply_result, apply_no, apply_fail_reason, distribution, people_confirm_status, people_confirm_type, people_confirm_time, enterprise_confirm, pick, pick_time, shop_id, shop_name, send, send_time, collage_orders_id, create_time, create_by, create_name, update_time, update_by, update_name, delete_status, resale_status, finish_status, cancel_people, goods_unit, call_car_status, cooper_entrust_status, cooper_entrust_time, apply_confirm_status, apply_confirm_time, ve_no, voyage_no, pre_no, plat_seq_no, border_name, idno, border_putrec_no, settle_bill_no, buy_amount, net_wt, gross_wt, buy_qty, buy_qty1, buy_qty2, pre_ieport_no from tb_order  -->
	
	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.tb_order.TbOrder"></resultMap>
	
	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select * 
		from tb_order 
	</sql>

	
	<!-- 查集合 - 根据条件（参数为空时代表忽略指定条件） [G] -->
	<select id="getList" resultMap="model">
		<include refid="select_sql"></include>
		<where>
			<if test=' this.has("id") '> and id = #{id} </if>
			<if test=' this.has("tradeNo") '> and trade_no = #{tradeNo} </if>
			<if test=' this.has("tradeAreaId") '> and trade_area_id = #{tradeAreaId} </if>
			<if test=' this.has("tradeAreaName") '> and trade_area_name = #{tradeAreaName} </if>
			<if test=' this.has("addressIds") '> and address_ids = #{addressIds} </if>
			<if test=' this.has("goodsId") '> and goods_id = #{goodsId} </if>
			<if test=' this.has("saleMainId") '> and sale_main_id = #{saleMainId} </if>
			<if test=' this.has("groupId") '> and group_id = #{groupId} </if>
			<if test=' this.has("buyUserId") '> and buy_user_id = #{buyUserId} </if>
			<if test=' this.has("buyUserName") '> and buy_user_name = #{buyUserName} </if>
			<if test=' this.has("buyUserType") '> and buy_user_type = #{buyUserType} </if>
			<if test=' this.has("enterpriseId") '> and enterprise_id = #{enterpriseId} </if>
			<if test=' this.has("enterpriseName") '> and enterprise_name = #{enterpriseName} </if>
			<if test=' this.has("totalWeight") '> and total_weight = #{totalWeight} </if>
			<if test=' this.has("totalPrice") '> and total_price = #{totalPrice} </if>
			<if test=' this.has("tradeStatus") '> and trade_status = #{tradeStatus} </if>
			<if test=' this.has("payType") '> and pay_type = #{payType} </if>
			<if test=' this.has("settleTime") '> and settle_time = #{settleTime} </if>
			<if test=' this.has("realPrice") '> and real_price = #{realPrice} </if>
			<if test=' this.has("shouldPrice") '> and should_price = #{shouldPrice} </if>
			<if test=' this.has("settleUserId") '> and settle_user_id = #{settleUserId} </if>
			<if test=' this.has("recordUserId") '> and record_user_id = #{recordUserId} </if>
			<if test=' this.has("recordTime") '> and record_time = #{recordTime} </if>
			<if test=' this.has("record") '> and record = #{record} </if>
			<if test=' this.has("refundReason") '> and refund_reason = #{refundReason} </if>
			<if test=' this.has("refundTime") '> and refund_time = #{refundTime} </if>
			<if test=' this.has("receiveName") '> and receive_name = #{receiveName} </if>
			<if test=' this.has("receivePhone") '> and receive_phone = #{receivePhone} </if>
			<if test=' this.has("receiveAddress") '> and receive_address = #{receiveAddress} </if>
			<if test=' this.has("outTime") '> and out_time = #{outTime} </if>
			<if test=' this.has("goodsNames") '> and goods_names = #{goodsNames} </if>
			<if test=' this.has("goodsImg") '> and goods_img = #{goodsImg} </if>
			<if test=' this.has("apply") '> and apply = #{apply} </if>
			<if test=' this.has("applyTime") '> and apply_time = #{applyTime} </if>
			<if test=' this.has("applyResult") '> and apply_result = #{applyResult} </if>
			<if test=' this.has("applyNo") '> and apply_no = #{applyNo} </if>
			<if test=' this.has("applyFailReason") '> and apply_fail_reason = #{applyFailReason} </if>
			<if test=' this.has("distribution") '> and distribution = #{distribution} </if>
			<if test=' this.has("peopleConfirmStatus") '> and people_confirm_status = #{peopleConfirmStatus} </if>
			<if test=' this.has("peopleConfirmType") '> and people_confirm_type = #{peopleConfirmType} </if>
			<if test=' this.has("peopleConfirmTime") '> and people_confirm_time = #{peopleConfirmTime} </if>
			<if test=' this.has("enterpriseConfirm") '> and enterprise_confirm = #{enterpriseConfirm} </if>
			<if test=' this.has("pick") '> and pick = #{pick} </if>
			<if test=' this.has("pickTime") '> and pick_time = #{pickTime} </if>
			<if test=' this.has("shopId") '> and shop_id = #{shopId} </if>
			<if test=' this.has("shopName") '> and shop_name = #{shopName} </if>
			<if test=' this.has("send") '> and send = #{send} </if>
			<if test=' this.has("sendTime") '> and send_time = #{sendTime} </if>
			<if test=' this.has("collageOrdersId") '> and collage_orders_id = #{collageOrdersId} </if>
			<if test=' this.has("createTime") '> and create_time = #{createTime} </if>
			<if test=' this.has("createBy") '> and create_by = #{createBy} </if>
			<if test=' this.has("createName") '> and create_name = #{createName} </if>
			<if test=' this.has("updateTime") '> and update_time = #{updateTime} </if>
			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>
			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>
			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>
			<if test=' this.has("resaleStatus") '> and resale_status = #{resaleStatus} </if>
			<if test=' this.has("finishStatus") '> and finish_status = #{finishStatus} </if>
			<if test=' this.has("cancelPeople") '> and cancel_people = #{cancelPeople} </if>
			<if test=' this.has("goodsUnit") '> and goods_unit = #{goodsUnit} </if>
			<if test=' this.has("callCarStatus") '> and call_car_status = #{callCarStatus} </if>
			<if test=' this.has("cooperEntrustStatus") '> and cooper_entrust_status = #{cooperEntrustStatus} </if>
			<if test=' this.has("cooperEntrustTime") '> and cooper_entrust_time = #{cooperEntrustTime} </if>
			<if test=' this.has("applyConfirmStatus") '> and apply_confirm_status = #{applyConfirmStatus} </if>
			<if test=' this.has("applyConfirmTime") '> and apply_confirm_time = #{applyConfirmTime} </if>
			<if test=' this.has("veNo") '> and ve_no = #{veNo} </if>
			<if test=' this.has("voyageNo") '> and voyage_no = #{voyageNo} </if>
			<if test=' this.has("preNo") '> and pre_no = #{preNo} </if>
			<if test=' this.has("platSeqNo") '> and plat_seq_no = #{platSeqNo} </if>
			<if test=' this.has("borderName") '> and border_name = #{borderName} </if>
			<if test=' this.has("idno") '> and idno = #{idno} </if>
			<if test=' this.has("borderPutrecNo") '> and border_putrec_no = #{borderPutrecNo} </if>
			<if test=' this.has("settleBillNo") '> and settle_bill_no = #{settleBillNo} </if>
			<if test=' this.has("buyAmount") '> and buy_amount = #{buyAmount} </if>
			<if test=' this.has("netWt") '> and net_wt = #{netWt} </if>
			<if test=' this.has("grossWt") '> and gross_wt = #{grossWt} </if>
			<if test=' this.has("buyQty") '> and buy_qty = #{buyQty} </if>
			<if test=' this.has("buyQty1") '> and buy_qty1 = #{buyQty1} </if>
			<if test=' this.has("buyQty2") '> and buy_qty2 = #{buyQty2} </if>
			<if test=' this.has("preIeportNo") '> and pre_ieport_no = #{preIeportNo} </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> trade_no desc </when>
			<when test='sortType == 3'> trade_area_id desc </when>
			<when test='sortType == 4'> trade_area_name desc </when>
			<when test='sortType == 5'> address_ids desc </when>
			<when test='sortType == 6'> goods_id desc </when>
			<when test='sortType == 7'> sale_main_id desc </when>
			<when test='sortType == 8'> group_id desc </when>
			<when test='sortType == 9'> buy_user_id desc </when>
			<when test='sortType == 10'> buy_user_name desc </when>
			<when test='sortType == 11'> buy_user_type desc </when>
			<when test='sortType == 12'> enterprise_id desc </when>
			<when test='sortType == 13'> enterprise_name desc </when>
			<when test='sortType == 14'> total_weight desc </when>
			<when test='sortType == 15'> total_price desc </when>
			<when test='sortType == 16'> trade_time desc </when>
			<when test='sortType == 17'> trade_status desc </when>
			<when test='sortType == 18'> pay_type desc </when>
			<when test='sortType == 19'> settle_time desc </when>
			<when test='sortType == 20'> real_price desc </when>
			<when test='sortType == 21'> should_price desc </when>
			<when test='sortType == 22'> settle_user_id desc </when>
			<when test='sortType == 23'> record_user_id desc </when>
			<when test='sortType == 24'> record_time desc </when>
			<when test='sortType == 25'> record desc </when>
			<when test='sortType == 26'> refund_reason desc </when>
			<when test='sortType == 27'> refund_time desc </when>
			<when test='sortType == 28'> receive_name desc </when>
			<when test='sortType == 29'> receive_phone desc </when>
			<when test='sortType == 30'> receive_address desc </when>
			<when test='sortType == 31'> out_time desc </when>
			<when test='sortType == 32'> goods_names desc </when>
			<when test='sortType == 33'> goods_img desc </when>
			<when test='sortType == 34'> apply desc </when>
			<when test='sortType == 35'> apply_time desc </when>
			<when test='sortType == 36'> apply_result desc </when>
			<when test='sortType == 37'> apply_no desc </when>
			<when test='sortType == 38'> apply_fail_reason desc </when>
			<when test='sortType == 39'> distribution desc </when>
			<when test='sortType == 40'> people_confirm_status desc </when>
			<when test='sortType == 41'> people_confirm_type desc </when>
			<when test='sortType == 42'> people_confirm_time desc </when>
			<when test='sortType == 43'> enterprise_confirm desc </when>
			<when test='sortType == 44'> pick desc </when>
			<when test='sortType == 45'> pick_time desc </when>
			<when test='sortType == 46'> shop_id desc </when>
			<when test='sortType == 47'> shop_name desc </when>
			<when test='sortType == 48'> send desc </when>
			<when test='sortType == 49'> send_time desc </when>
			<when test='sortType == 50'> collage_orders_id desc </when>
			<when test='sortType == 51'> create_time desc </when>
			<when test='sortType == 52'> create_by desc </when>
			<when test='sortType == 53'> create_name desc </when>
			<when test='sortType == 54'> update_time desc </when>
			<when test='sortType == 55'> update_by desc </when>
			<when test='sortType == 56'> update_name desc </when>
			<when test='sortType == 57'> delete_status desc </when>
			<when test='sortType == 58'> resale_status desc </when>
			<when test='sortType == 59'> finish_status desc </when>
			<when test='sortType == 60'> cancel_people desc </when>
			<when test='sortType == 61'> goods_unit desc </when>
			<when test='sortType == 62'> call_car_status desc </when>
			<when test='sortType == 63'> cooper_entrust_status desc </when>
			<when test='sortType == 64'> cooper_entrust_time desc </when>
			<when test='sortType == 65'> apply_confirm_status desc </when>
			<when test='sortType == 66'> apply_confirm_time desc </when>
			<when test='sortType == 67'> ve_no desc </when>
			<when test='sortType == 68'> voyage_no desc </when>
			<when test='sortType == 69'> pre_no desc </when>
			<when test='sortType == 70'> plat_seq_no desc </when>
			<when test='sortType == 71'> border_name desc </when>
			<when test='sortType == 72'> idno desc </when>
			<when test='sortType == 73'> border_putrec_no desc </when>
			<when test='sortType == 74'> settle_bill_no desc </when>
			<when test='sortType == 75'> buy_amount desc </when>
			<when test='sortType == 76'> net_wt desc </when>
			<when test='sortType == 77'> gross_wt desc </when>
			<when test='sortType == 78'> buy_qty desc </when>
			<when test='sortType == 79'> buy_qty1 desc </when>
			<when test='sortType == 80'> buy_qty2 desc </when>
			<when test='sortType == 81'> pre_ieport_no desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>
	
	
	
	
	
	
	
	
	

</mapper>
