<?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.zm.order.tool.server.cymarketing.MsPointsMallLogsDao">
    <resultMap id="ResultMap" type="com.zm.order.tool.server.model.MsPointsMallLogs">
		<id column="id" jdbcType="INTEGER" property="id"/>
		<result column="store_id" jdbcType="INTEGER" property="storeId"/>
		<result column="user_id" jdbcType="BIGINT" property="userId"/>
		<result column="user_name" jdbcType="VARCHAR" property="userName"/>
		<result column="user_phone" jdbcType="CHAR" property="userPhone"/>
		<result column="points_mall_goods_id" jdbcType="INTEGER" property="pointsMallGoodsId"/>
		<result column="goods_name" jdbcType="VARCHAR" property="goodsName"/>
		<result column="goods_num" jdbcType="INTEGER" property="goodsNum"/>
		<result column="goods_id" jdbcType="BIGINT" property="goodsId"/>
		<result column="goods_type" jdbcType="TINYINT" property="goodsType"/>
		<result column="total_points_price" jdbcType="INTEGER" property="totalPointsPrice"/>
		<result column="points_mall_goods_json" jdbcType="VARCHAR" property="pointsMallGoodsJson"/>
		<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
		<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
		<result column="send_coupon_status" jdbcType="TINYINT" property="sendCouponStatus"/>
		<result column="send_entity_status" jdbcType="TINYINT" property="sendEntityStatus"/>
		<result column="send_address" jdbcType="VARCHAR" property="sendAddress"/>
		<result column="send_username" jdbcType="VARCHAR" property="sendUsername"/>
		<result column="send_mobile" jdbcType="VARCHAR" property="sendMobile"/>
		<result column="multi_store_id" jdbcType="INTEGER" property="multiStoreId"/>
		<result column="points_mall_code_json" jdbcType="VARCHAR" property="pointsMallCodeJson"/>
		<result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
		<result column="order_id" jdbcType="BIGINT" property="orderId"/>
		<result column="exchange_type" jdbcType="TINYINT" property="exchangeType"/>
		<result column="amount" jdbcType="DECIMAL" property="amount"/>
		<result column="order_status" jdbcType="TINYINT" property="orderStatus"/>
		<result column="pay_json" jdbcType="VARCHAR" property="payJson"/>
		<result column="logistics_name" jdbcType="VARCHAR" property="logisticsName"/>
		<result column="logistics_no" jdbcType="VARCHAR" property="logisticsNo"/>
		<result column="send_at" jdbcType="TIMESTAMP" property="sendAt"/>
	</resultMap>

	<sql id="tb">
        ms_points_mall_logs
    </sql>

    <sql id="cols_all">
        id,
		store_id,
		user_id,
		user_name,
		user_phone,
		points_mall_goods_id,
		goods_name,
		goods_num,
		goods_id,
		goods_type,
		total_points_price,
		points_mall_goods_json,
		created_at,
		updated_at,
		send_coupon_status,
		send_entity_status,
		send_address,
		send_username,
		send_mobile,
		multi_store_id,
		points_mall_code_json,
		order_no,
		order_id,
		exchange_type,
		amount,
		order_status,
		pay_json,
		logistics_name,
		logistics_no,
		send_at
    </sql>

    <sql id="values">
    	#{id,jdbcType=INTEGER},
		#{storeId,jdbcType=INTEGER},
		#{userId,jdbcType=BIGINT},
		#{userName,jdbcType=VARCHAR},
		#{userPhone,jdbcType=CHAR},
		#{pointsMallGoodsId,jdbcType=INTEGER},
		#{goodsName,jdbcType=VARCHAR},
		#{goodsNum,jdbcType=INTEGER},
		#{goodsId,jdbcType=BIGINT},
		#{goodsType,jdbcType=TINYINT},
		#{totalPointsPrice,jdbcType=INTEGER},
		#{pointsMallGoodsJson,jdbcType=VARCHAR},
		#{createdAt,jdbcType=TIMESTAMP},
		#{updatedAt,jdbcType=TIMESTAMP},
		#{sendCouponStatus,jdbcType=TINYINT},
		#{sendEntityStatus,jdbcType=TINYINT},
		#{sendAddress,jdbcType=VARCHAR},
		#{sendUsername,jdbcType=VARCHAR},
		#{sendMobile,jdbcType=VARCHAR},
		#{multiStoreId,jdbcType=INTEGER},
		#{pointsMallCodeJson,jdbcType=VARCHAR},
		#{orderNo,jdbcType=VARCHAR},
		#{orderId,jdbcType=BIGINT},
		#{exchangeType,jdbcType=TINYINT},
		#{amount,jdbcType=DECIMAL},
		#{orderStatus,jdbcType=TINYINT},
		#{payJson,jdbcType=VARCHAR},
		#{logisticsName,jdbcType=VARCHAR},
		#{logisticsNo,jdbcType=VARCHAR},
		#{sendAt,jdbcType=TIMESTAMP}
    </sql>

    <insert id="insert" parameterType="com.zm.order.tool.server.model.MsPointsMallLogs"
                        keyColumn="id" keyProperty="id" useGeneratedKeys="true">
        insert into
        <include refid="tb"/>
        (<include refid="cols_all"/>)
        values
        (<include refid="values"/>)
    </insert>

    <select id="selectList" resultMap="ResultMap">
        SELECT
        <include refid="cols_all"/>
        FROM
        <include refid="tb"/>
        <where>
            is_deleted = 0
        </where>
        <if test="start != null">
            limit ${start}, ${pageSize}
        </if>
    </select>

    <select id="selectOne" parameterType="map" resultMap="ResultMap">
        SELECT
        <include refid="cols_all"/>
        FROM
        <include refid="tb"/>
        <where>
			order_no =#{orderNo}
        </where>
        limit 1
    </select>


</mapper>