<?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.iamberry.wechat.service.mapper.ReserveMapper">
	<!-- 增加用户访问记录 -->
	<insert id="addAccess" parameterType="ChannelAccess">
		INSERT INTO tb_channel_access(user_openid, access_browser, access_device_type, access_device_model, access_is_mobile, channel_id, access_create_time)
		VALUES (#{userOpenid}, #{accessBrowser}, #{accessDeviceType}, #{accessDeviceModel}, #{accessIsMobile}, #{channelId}, NOW())
	</insert>

    <!-- 修改渠道商的销售数量 -->
    <update id="updateChannelNum" parameterType="Integer">
        UPDATE tb_channel_info SET channel_salve_num = (channel_salve_num + 1) WHERE channel_id = #{id}
    </update>

    <!-- 录入订单 -->
    <insert id="addOrder" parameterType="ReserveOrder" useGeneratedKeys="true" keyProperty="reserveOrderid">
        INSERT INTO tb_iamberry_reserve_order
        (reserve_openid, reserve_package, reserve_pay_money, reserve_address_info, reserve_address_tel, reserve_address_name, reserve_transaction_id,
         reserve_transaction_date, reserve_create_date, reserve_user_remark, reserve_status, reserve_color)
        VALUES (#{reserveOpenid}, #{reservePackage}, #{reservePayMoney}, #{reserveAddressInfo}, #{reserveAddressTel}, #{reserveAddressName}, #{reserveTransactionId},
          #{reserveTransactionDate}, NOW(), #{reserveUserRemark}, #{reserveStatus}, #{reserveColor})
    </insert>

    <!--修改订单状态-->
    <update id="updateOrder" parameterType="Integer">
        UPDATE tb_iamberry_reserve_order SET reserve_status = #{reserveStatus} WHERE reserve_orderid = #{reserveOrderid}
    </update>

    <!-- 获取订单信息 -->
    <select id="getOrder" parameterType="Integer" resultType="ReserveOrder">
        SELECT * FROM tb_iamberry_reserve_order WHERE reserve_orderid = #{reserveOrderid}
    </select>
</mapper>