<?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.fuzamei.mapperInterface.OrderMapper">
	
	<select id="queryOrderById" resultType="int">
		select count(*) from orders where order_id=#{orderId}
	</select>
	
	<select id="queryFullOrderByOrderId" resultType="Orders">
		select 
			temp.order_id,
			temp.part_no,
			temp.box_no,
			b.box_name,
			temp.box_qty,
			temp.inbox_qty,
			temp.require_time,
			temp.send_time,
			temp.planner_id,
			up.person_name as planner_name,
			temp.supplier_id,
			us.person_name as supplier_name,
			temp.carrier_id,
			uc.person_name as carrier_name,
			temp.receiver_id,
			ur.person_name as receiver_name,
			temp.transport_time,
			temp.tally_time,
			temp.car_no,
			temp.status_id,
			s.status_name,
			temp.create_time,
			temp.update_time
		from
			(select * from orders where order_id=#{orderId})temp
		left join 
			status s
		on 
			temp.status_id=s.status_id
		left join 
			box b
		on 
			temp.box_no=b.box_no
		left join
			users up
		on 
			temp.planner_id=up.user_id
		left join 
			users us
		on 
			temp.supplier_id=us.user_id
		left join 
			users uc
		on 
			temp.carrier_id=uc.user_id
		left join 
			users ur
		on 
			temp.receiver_id=ur.user_id
	</select>
</mapper>