<?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">
<!-- 命名，每一个映射对象不一样
	namespace:必须与对应的接口全类名一致
 -->
<mapper namespace="com.iamberry.wechat.service.mapper.ProbationMapper">

	
	 <sql id="orderField">
			probation_orderid probationOrderid,
			probation_product_id probationProductId,
			probation_openid probationOpenid,
			probation_yet_amount probationYetAmount,
			probation_amount probationAmount,
			probation_create_time probationCreateTime,
			probation_post_num probationPostNum,
			probation_post_firm probationPostFirm,
			probation_status probationStatus,
			probation_send_date probationSendDate,
			probation_address_info probationAddressInfo,
			probation_receive_postnum probationReceivePostnum,
			probation_receive_tel probationReceiveTel,
			probation_receive_name probationReceiveName,
			probation_admin_remark probationAdminRemark,
			probation_user_remark probationUserRemark, 
			probation_transaction_id probationTransactionId,
			probation_transaction_time probationTransactionTime,
			probation_start_time probationStartTime,
			probation_end_time probationEndTime,
			probation_update_time probationUpdateTime,
			probation_send_name probationSendName,
			probation_send_tel probationSendTel,
			probation_color_type probationColorType,
			(SELECT product_name FROM tb_iamberry_product_info WHERE product_id = probation_product_id) probationProductName
			

				 
			
	</sql>
	 
	<!-- 添加-试用人-信息  -->
	<insert id="addProbationUser" parameterType="ProbationUserInfo">
	INSERT INTO tb_iamberry_probation_userinfo(
		puser_openid,puser_name,puser_tel,
		puser_address,puser_productid,puser_receive_name,puser_receive_tel
	)
		  VALUES ( 
		  #{puserOpenid},  
		  #{puserName}, 
		  #{puserTel},
		  #{puserAddress}, 
		  #{puserProductid},
		  #{puserReceiveName},
		  #{puserReceiveTel}
		  )
	</insert>
	<!-- 添加-试用人-订单信息  -->
	<insert id="addProbationUserOrder" parameterType="ProbationOrder">
		INSERT INTO tb_iamberry_probation_shop_order(
			probation_product_id,probation_openid,probation_amount,probation_status
		)
		  VALUES ( 
			  #{probationProductId},  
			  #{probationOpenid}, 
			  #{probationAmount},
			  #{probationStatus}
		  )
	</insert>
	
	<!-- 获取试用人，，订单 -->
	<select id="getProbationOrderDetail" resultType="ProbationOrder" parameterType="String">
		SELECT 
			
			<include refid="orderField"/>
		FROM tb_iamberry_probation_shop_order 
		WHERE probation_orderid=#{orderid}
	</select>
	
	
</mapper>
