PointsChangeMapper.xml 6.78 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.runsa.crmapp.points.mapper.PointsChangeMapper">
  <resultMap id="BaseResultMap" type="cn.runsa.crmapp.points.entity.PointsChange">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <result column="PNT_ID" jdbcType="BIGINT" property="pntId" />
    <result column="TYPE" jdbcType="VARCHAR" property="type" />
    <result column="PNT_VAL" jdbcType="DOUBLE" property="pntVal" />
    <result column="FACT_PNT" jdbcType="DOUBLE" property="factPnt" />
    <result column="CST_ID" jdbcType="BIGINT" property="cstId" />
    <result column="BLC_IN" jdbcType="BIGINT" property="blcIn" />
    <result column="BLC_OUT" jdbcType="BIGINT" property="blcOut" />
    <result column="S_TIME" jdbcType="TIMESTAMP" property="sTime" />
    <result column="E_TIME" jdbcType="TIMESTAMP" property="eTime" />
    <result column="CHL_ID" jdbcType="VARCHAR" property="chlId" />
    <result column="CHL_INST" jdbcType="VARCHAR" property="chlInst" />
    <result column="LOCKED" jdbcType="BIT" property="locked" />
    <result column="U_V" jdbcType="DECIMAL" property="uV" />
    <result column="REC_TIME" jdbcType="TIMESTAMP" property="recTime" />
  </resultMap>
  <insert id="insert" parameterType="cn.runsa.crmapp.points.entity.PointsChange">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into crm_points_change (`PNT_ID`, `TYPE`, `PNT_VAL`, 
      `FACT_PNT`, `CST_ID`, `BLC_IN`, 
      `BLC_OUT`, `S_TIME`, `E_TIME`, 
      `CHL_ID`, `CHL_INST`, `LOCKED`, 
      `U_V`, `REC_TIME`)
    values (#{pntId,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, #{pntVal,jdbcType=DOUBLE}, 
      #{factPnt,jdbcType=DOUBLE}, #{cstId,jdbcType=BIGINT}, #{blcIn,jdbcType=BIGINT}, 
      #{blcOut,jdbcType=BIGINT}, #{sTime,jdbcType=TIMESTAMP}, #{eTime,jdbcType=TIMESTAMP}, 
      #{chlId,jdbcType=VARCHAR}, #{chlInst,jdbcType=VARCHAR}, #{locked,jdbcType=BIT}, 
      #{uV,jdbcType=DECIMAL}, #{recTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="cn.runsa.crmapp.points.entity.PointsChange">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into crm_points_change
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="pntId != null">
        `PNT_ID`,
      </if>
      <if test="type != null">
        `TYPE`,
      </if>
      <if test="pntVal != null">
        `PNT_VAL`,
      </if>
      <if test="factPnt != null">
        `FACT_PNT`,
      </if>
      <if test="cstId != null">
        `CST_ID`,
      </if>
      <if test="blcIn != null">
        `BLC_IN`,
      </if>
      <if test="blcOut != null">
        `BLC_OUT`,
      </if>
      <if test="sTime != null">
        `S_TIME`,
      </if>
      <if test="eTime != null">
        `E_TIME`,
      </if>
      <if test="chlId != null">
        `CHL_ID`,
      </if>
      <if test="chlInst != null">
        `CHL_INST`,
      </if>
      <if test="locked != null">
        `LOCKED`,
      </if>
      <if test="uV != null">
        `U_V`,
      </if>
      <if test="recTime != null">
        `REC_TIME`,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="pntId != null">
        #{pntId,jdbcType=BIGINT},
      </if>
      <if test="type != null">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="pntVal != null">
        #{pntVal,jdbcType=DOUBLE},
      </if>
      <if test="factPnt != null">
        #{factPnt,jdbcType=DOUBLE},
      </if>
      <if test="cstId != null">
        #{cstId,jdbcType=BIGINT},
      </if>
      <if test="blcIn != null">
        #{blcIn,jdbcType=BIGINT},
      </if>
      <if test="blcOut != null">
        #{blcOut,jdbcType=BIGINT},
      </if>
      <if test="sTime != null">
        #{sTime,jdbcType=TIMESTAMP},
      </if>
      <if test="eTime != null">
        #{eTime,jdbcType=TIMESTAMP},
      </if>
      <if test="chlId != null">
        #{chlId,jdbcType=VARCHAR},
      </if>
      <if test="chlInst != null">
        #{chlInst,jdbcType=VARCHAR},
      </if>
      <if test="locked != null">
        #{locked,jdbcType=BIT},
      </if>
      <if test="uV != null">
        #{uV,jdbcType=DECIMAL},
      </if>
      <if test="recTime != null">
        #{recTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
	<insert id="insertList">
		insert into crm_points_change (`PNT_ID`, `TYPE`, `PNT_VAL`,	`CST_ID`, `BLC_IN`, `BLC_OUT`,`S_TIME`, `E_TIME`, `CHL_ID`,	`CHL_INST`, `LOCKED`,`U_V`,`REC_TIME`)
		values
		<foreach collection="list" item="it" separator=",">
			(#{it.pntId,jdbcType=BIGINT}, #{it.type,jdbcType=VARCHAR},
			#{it.pntVal,jdbcType=DOUBLE},
			#{it.cstId,jdbcType=BIGINT}, #{it.blcIn,jdbcType=BIGINT}, #{it.blcOut,jdbcType=BIGINT},
			#{it.sTime,jdbcType=TIMESTAMP}, #{it.eTime,jdbcType=TIMESTAMP}, #{it.chlId,jdbcType=VARCHAR},
			#{it.chlInst,jdbcType=VARCHAR}, #{it.locked,jdbcType=BIT},#{it.uV,jdbcType=DECIMAL},#{it.recTime,jdbcType=TIMESTAMP})
		</foreach>
	</insert>

	<select id="selectChangeList" resultType="map">
		SELECT a.PNT_VAL AS pntVal,a.REC_TIME AS recTime,a.E_TIME AS eTime,a.`TYPE` AS `type`,b.VAR_NAME AS `typeName`,a.`CHL_ID` AS chlId,r.`BIZ_NO` AS `bizNo`,m.`MKT_NAME` AS mktName,e.`EVT_NAME` AS evtName
		FROM crm_points_change a
		LEFT JOIN crm_variable b 
		ON (b.VAR_SCOPE='POINTS_CHANGE_TYPE' AND a.TYPE=b.VAR_CODE)
		LEFT JOIN crm_points_receipt r 
		ON (a.`CHL_ID` = 'INTERFACE' AND a.`CHL_INST` = r.`ID`)
		LEFT JOIN crm_market m
		ON (a.`CHL_ID` = 'ACTIVITY' AND a.`CHL_INST` = m.`MKT_ID`)
		LEFT JOIN crm_event e
		ON (a.`CHL_ID` = 'EVENT' AND a.`CHL_INST` = e.`EVT_ID`)
		WHERE
		a.CST_ID=#{cstId}
		ORDER BY a.REC_TIME desc limit #{start},#{length}
	</select>
	
	<select id="selectLockedList" resultMap="BaseResultMap" parameterType="cn.runsa.crmapp.points.entity.PointsChange">
		select `PNT_ID`, `TYPE`, `PNT_VAL`, `CST_ID`, `BLC_IN`, 
     	`BLC_OUT`, `S_TIME`, `E_TIME`, 
     	`CHL_ID`, `CHL_INST`, `LOCKED`, 
      	`U_V`, `REC_TIME`
      	from crm_points_change
      	where CHL_ID = #{chlId,jdbcType=VARCHAR} and CHL_INST = #{chlInst,jdbcType=VARCHAR} and LOCKED = true
	</select>
	
	<delete id="delete" parameterType="cn.runsa.crmapp.points.entity.PointsChange">
		delete from crm_points_change where CHL_ID = #{chlId,jdbcType=VARCHAR} and CHL_INST = #{chlInst,jdbcType=VARCHAR} and LOCKED = true
	</delete>
	
	<update id="updateLock" parameterType="cn.runsa.crmapp.points.entity.PointsChange">
		update crm_points_change set LOCKED = false where CHL_ID = #{chlId,jdbcType=VARCHAR} and CHL_INST = #{chlInst,jdbcType=VARCHAR} and LOCKED = true
	</update>
</mapper>