PointsEventMapper.xml 4.53 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.PointsEventMapper" >
  <resultMap id="BaseResultMap" type="cn.runsa.crmapp.common.entity.Event" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="EVT_ID" property="evtId" jdbcType="INTEGER" />
    <result column="EVT_CODE" property="evtCode" jdbcType="VARCHAR" />
    <result column="EVT_NAME" property="evtName" jdbcType="VARCHAR" />
    <result column="EVT_DESC" property="evtDesc" jdbcType="VARCHAR" />
    <result column="GLOBAL" property="global" jdbcType="BIT" />
    <result column="INTERNAL" property="internal" jdbcType="BIT" />
    <result column="REC_TIME" property="recTime" jdbcType="TIMESTAMP" />
    <result column="REC_USER" property="recUser" jdbcType="BIGINT" />
  </resultMap>
  
  <select id="getOrgPointsEventByPntId" resultMap="BaseResultMap" parameterType="Integer" >
    select t1.* from crm_event t1 
    where t1.EVT_ID not in 
    (select t2.EVT_ID from crm_points_event t2 where t2.PNT_ID = #{pntId})
    and t1.EVT_ID not in (5,6)
    <!-- 根据需求先隐藏掉评价商品和升级(重新设计) -->
  </select>
  
  <select id="getGrpIdByEvt" parameterType="cn.runsa.crmapp.points.vo.CreatePointsEventVo" resultType="java.util.Map">
  	select grp_id from crm_points_event where pnt_id = #{pnt_id} and evt_id = #{evt_id} LIMIT 0,1
  </select>
  
  <insert id="createGrpId" parameterType="cn.runsa.crmapp.points.vo.CreatePointsEventVo" useGeneratedKeys="true" keyProperty="grp_id">
  	insert into crm_event_group (S_TIME,E_TIME,STRATEGY,REC_TIME) 
  	values 
  	(Now(),#{time,jdbcType=TIMESTAMP},'0',Now())
  	<!-- DATE_ADD(Now(),INTERVAL 99 YEAR) -->
  	<!-- STR_TO_DATE(CONCAT('2099-',DATE_FORMAT(Now(),'%m-%d %T')) -->
  </insert>
  
  <update id="updateEventListener" parameterType="cn.runsa.crmapp.points.vo.CreatePointsEventVo">
  	update crm_event_listener 
  	set union_id = #{union_id},front_data = #{front_data}
  	where act_id = #{act_id},evt_id = #{evt_id}
  </update>
  
  <insert id="createEventListener" parameterType="cn.runsa.crmapp.points.vo.CreatePointsEventVo">
  	insert into crm_event_listener(grp_id,act_id,evt_id,union_id,front_data,inner_data)
  	values
  	(#{grp_id},#{act_id},#{evt_id},#{union_id},#{front_data},#{inner_data})
  </insert>
  
  <insert id="createPointsEvent" parameterType="cn.runsa.crmapp.points.vo.CreatePointsEventVo">
  	insert into crm_points_event(pnt_id,evt_id,grp_id,rec_time)
  	values
  	(#{pnt_id},#{evt_id},#{grp_id},Now())
  </insert>
  
  <delete id="delPointsEvent" parameterType="cn.runsa.crmapp.points.vo.CreatePointsEventVo">
  	delete from crm_points_event where pnt_id = #{pnt_id} and evt_id = #{evt_id} and grp_id = #{grp_id}
  </delete>
  
  <delete id="delEventListener" parameterType="cn.runsa.crmapp.points.vo.CreatePointsEventVo">
  	delete from crm_event_listener where grp_id = #{grp_id} and act_id = #{act_id} and evt_id = #{evt_id}
  </delete>
  
  <delete id="delEventGroup" parameterType="cn.runsa.crmapp.points.vo.CreatePointsEventVo">
  	delete from crm_event_group where grp_id = #{grp_id}
  </delete>
  
  <select id="getTemplateByEvtId" parameterType="Integer" resultType="java.util.Map">
  	select t2.UNION_ID,t3.TPL_ID,t3.TPL_NAME from crm_event_action t1 
	left join crm_event_action_process t2 on t1.ACTION = t2.ACTION 
	left join crm_event_template t3 on t2.TEMPLATE = t3.TPL_ID
	where t1.EVT_ID = #{evt_id}
  </select>
  
  <update id="updatePointsEventGrpId" parameterType="cn.runsa.crmapp.points.vo.CreatePointsEventVo">
  	update crm_points_event set grp_id = #{grp_id}, rec_time = Now() where pnt_id = #{pnt_id} and evt_id = #{evt_id}
  </update>
  
  <select id="getCustomerRank" parameterType="Integer" resultType="java.util.Map">
  	select rak_id,rak_name from crm_customer_rank
	where act_id = #{act_id} order by rak_index
  </select>
  
  <select id="getPntSettlementBody" parameterType="Integer" resultType="java.util.Map">
  	select t1.bebId as BEBID,t1.bebName as BEBNAME,t1.beId as BEID,t1.bebCode as BEBCODE 
  	from mtBizSetOfBook t1 
	where t1.ptValid=1 and case when 
	#{beId} is null then 1 = 1 
	else t1.beId = #{beId} end
  </select>
  
  <select id="getBeIdByPntId" parameterType="Long" resultType="Integer">
  	select t3.beId from crm_points_set t1
	left join crm_account_set t2 on t1.ACT_ID = t2.ACT_ID
	left join smplatform t3 on t2.PTF_ID = t3.plId
	where t1.PNT_ID = #{pnt_id}
  </select>
</mapper>