ActivationDataMapper.xml 2.01 KB
<?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="cn.com.glsx.openplatform.mapper.ActivationDataMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.openplatform.model.ActivationData">
        <!--@mbg.generated-->
        <!--@Table t_activation_data-->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="month" jdbcType="VARCHAR" property="month"/>
        <result column="customer_id" jdbcType="INTEGER" property="customerId"/>
        <result column="customer" jdbcType="VARCHAR" property="customer"/>
        <result column="num" jdbcType="INTEGER" property="num"/>
        <result column="type" jdbcType="TINYINT" property="type"/>
    </resultMap>

    <select id="getActivationList" resultType="cn.com.glsx.openplatform.model.ActivationData">
        select id, month, customer_id customerId, customer, num, type
        from t_activation_data
        order by month;
    </select>

    <update id="updateDeviceActivation">
        update t_platform_device
        set customer_id = #{data.customerId,jdbcType=INTEGER},
            activat_time = from_unixtime(
                unix_timestamp(#{data.month,jdbcType=VARCHAR}) + floor(
                    rand() * (
                        unix_timestamp(#{data.endMonth,jdbcType=VARCHAR})
                        - unix_timestamp(#{data.month,jdbcType=VARCHAR}) + 1
                    )
                )
            )
        where customer_id is null
            and create_time > #{startTimeStr,jdbcType=VARCHAR}
            and create_time &lt;= #{endTimeStr,jdbcType=VARCHAR}
            and device_type = #{data.typeName,jdbcType=VARCHAR}
        order by rand()
        limit #{num,jdbcType=INTEGER}
    </update>

    <select id="getShipmentList" resultType="cn.com.glsx.openplatform.model.ShipmentData">
        select id, goods_time goodsTime, goods_num goodsNum, type
        from t_shipment_data
    </select>
</mapper>