CustomerWxgzhMapper.xml 11.9 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.customer.mapper.CustomerWxgzhMapper">
  <resultMap id="BaseResultMap" type="cn.runsa.crmapp.customer.entity.CustomerWxgzh">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="GZH_ID" jdbcType="VARCHAR" property="gzhId" />
    <id column="OPEN_ID" jdbcType="VARCHAR" property="openId" />
    <result column="CST_ID" jdbcType="BIGINT" property="cstId" />
    <result column="UNION_ID" jdbcType="VARCHAR" property="unionId" />
    <result column="SUBSCRIBE" jdbcType="BIT" property="subscribe" />
    <result column="NICK_NAME" jdbcType="VARCHAR" property="nickName" />
    <result column="SEX" jdbcType="TINYINT" property="sex" />
    <result column="CITY" jdbcType="VARCHAR" property="city" />
    <result column="PROVINCE" jdbcType="VARCHAR" property="province" />
    <result column="COUNTRY" jdbcType="VARCHAR" property="country" />
    <result column="HEAD_IMG" jdbcType="VARCHAR" property="headImg" />
    <result column="SUBS_TIME" jdbcType="TIMESTAMP" property="subsTime" />
    <result column="LAST_SUBS" jdbcType="TIMESTAMP" property="lastSubs" />
    <result column="LAST_ACTION" jdbcType="BIGINT" property="lastAction" />
    <result column="REC_TIME" jdbcType="TIMESTAMP" property="recTime" />
  </resultMap>
  
  <resultMap id="CustomerBaseResultMap" type="cn.runsa.crmapp.customer.entity.Customer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="CST_ID" jdbcType="BIGINT" property="cstId" />
    <result column="CST_TYPE" jdbcType="TINYINT" property="cstType" />
    <result column="CST_CHL" jdbcType="VARCHAR" property="cstChl" />
    <result column="CST_SRC" jdbcType="VARCHAR" property="cstSrc" />
    <result column="SRC_VAL" jdbcType="VARCHAR" property="srcVal" />
    <result column="REFERRER" jdbcType="BIGINT" property="referrer" />
    <result column="CST_SITE" jdbcType="BIGINT" property="cstSite" />
    <result column="REG_TIME" jdbcType="TIMESTAMP" property="regTime" />
    <result column="CST_NAME" jdbcType="VARCHAR" property="cstName" />
    <result column="FIRST_NAME" jdbcType="VARCHAR" property="firstName" />
    <result column="LAST_NAME" jdbcType="VARCHAR" property="lastName" />
    <result column="SEX" jdbcType="TINYINT" property="sex" />
    <result column="PHONE" jdbcType="VARCHAR" property="phone" />
    <result column="EMAIL" jdbcType="VARCHAR" property="email" />
    <result column="CRED_TYPE" jdbcType="VARCHAR" property="credType" />
    <result column="CRED_NUM" jdbcType="VARCHAR" property="credNum" />
    <result column="BIRTHDAY" jdbcType="DATE" property="birthday" />
    <result column="BIRTH_TYPE" jdbcType="TINYINT" property="birthType" />
    <result column="VERIFY" jdbcType="TINYINT" property="verify" />
    <result column="MARRIAGE" jdbcType="TINYINT" property="marriage" />
    <result column="JOB" jdbcType="VARCHAR" property="job" />
    <result column="DEGREE" jdbcType="VARCHAR" property="degree" />
    <result column="ACTIVATE" jdbcType="BIT" property="activate" />
    <result column="FREEZE" jdbcType="BIT" property="freeze" />
    <result column="MERGED" jdbcType="BIT" property="merged" />
    <result column="FRZ_ID" jdbcType="BIGINT" property="frzId" />
    <result column="LAST_LOGIN" jdbcType="TIMESTAMP" property="lastLogin" />
    <result column="PREPAID" jdbcType="BIT" property="prepaid" />
    <result column="RCV_MSG" jdbcType="BIT" property="rcvMsg" />
    <result column="PAY_PASS" jdbcType="VARCHAR" property="payPass" />
    <result column="TOTAL_PROFIT" jdbcType="DOUBLE" property="totalProfit" />
    <result column="TOTAL_AMOUNT" jdbcType="DOUBLE" property="totalAmount" />
    <result column="FILE_TIME" jdbcType="TIMESTAMP" property="fileTime" />
    <result column="PROVINCE" jdbcType="VARCHAR" property="province" />
    <result column="CITY" jdbcType="VARCHAR" property="city" />
    <result column="COUNTY" jdbcType="VARCHAR" property="county" />
    <result column="ADDRESS" jdbcType="VARCHAR" property="address" />
    <result column="REC_TIME" jdbcType="TIMESTAMP" property="recTime" />
    <result column="REC_USER" jdbcType="BIGINT" property="recUser" />
    <result column="HEAD_IMG" jdbcType="VARCHAR" property="headImg" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    `GZH_ID`, `OPEN_ID`, `CST_ID`, `UNION_ID`, `SUBSCRIBE`, `NICK_NAME`, `SEX`, `CITY`, 
    `PROVINCE`, `COUNTRY`, `HEAD_IMG`, `SUBS_TIME`, `LAST_SUBS`, `LAST_ACTION`, `REC_TIME`
  </sql>
  <select id="selectByPrimaryKey" parameterType="map" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select 
    <include refid="Base_Column_List" />
    from crm_customer_weixin
    where `GZH_ID` = #{gzhId,jdbcType=VARCHAR}
      and `OPEN_ID` = #{openId,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="map">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from crm_customer_weixin
    where `GZH_ID` = #{gzhId,jdbcType=VARCHAR}
      and `OPEN_ID` = #{openId,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="cn.runsa.crmapp.customer.entity.CustomerWxgzh">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into crm_customer_weixin (`GZH_ID`, `OPEN_ID`, `CST_ID`, 
      `UNION_ID`, `SUBSCRIBE`, `NICK_NAME`, 
      `SEX`, `CITY`, `PROVINCE`, 
      `COUNTRY`, `HEAD_IMG`, `SUBS_TIME`, 
      `LAST_SUBS`, `LAST_ACTION`, `REC_TIME`
      )
    values (#{gzhId,jdbcType=VARCHAR}, #{openId,jdbcType=VARCHAR}, #{cstId,jdbcType=BIGINT}, 
      #{unionId,jdbcType=VARCHAR}, #{subscribe,jdbcType=BIT}, #{nickName,jdbcType=VARCHAR}, 
      #{sex,jdbcType=TINYINT}, #{city,jdbcType=VARCHAR}, #{province,jdbcType=VARCHAR}, 
      #{country,jdbcType=VARCHAR}, #{headImg,jdbcType=VARCHAR}, #{subsTime,jdbcType=TIMESTAMP}, 
      #{lastSubs,jdbcType=TIMESTAMP}, #{lastAction,jdbcType=BIGINT}, #{recTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="cn.runsa.crmapp.customer.entity.CustomerWxgzh">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into crm_customer_weixin
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="gzhId != null">
        `GZH_ID`,
      </if>
      <if test="openId != null">
        `OPEN_ID`,
      </if>
      <if test="cstId != null">
        `CST_ID`,
      </if>
      <if test="unionId != null">
        `UNION_ID`,
      </if>
      <if test="subscribe != null">
        `SUBSCRIBE`,
      </if>
      <if test="nickName != null">
        `NICK_NAME`,
      </if>
      <if test="sex != null">
        `SEX`,
      </if>
      <if test="city != null">
        `CITY`,
      </if>
      <if test="province != null">
        `PROVINCE`,
      </if>
      <if test="country != null">
        `COUNTRY`,
      </if>
      <if test="headImg != null">
        `HEAD_IMG`,
      </if>
      <if test="subsTime != null">
        `SUBS_TIME`,
      </if>
      <if test="lastSubs != null">
        `LAST_SUBS`,
      </if>
      <if test="lastAction != null">
        `LAST_ACTION`,
      </if>
      <if test="recTime != null">
        `REC_TIME`,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="gzhId != null">
        #{gzhId,jdbcType=VARCHAR},
      </if>
      <if test="openId != null">
        #{openId,jdbcType=VARCHAR},
      </if>
      <if test="cstId != null">
        #{cstId,jdbcType=BIGINT},
      </if>
      <if test="unionId != null">
        #{unionId,jdbcType=VARCHAR},
      </if>
      <if test="subscribe != null">
        #{subscribe,jdbcType=BIT},
      </if>
      <if test="nickName != null">
        #{nickName,jdbcType=VARCHAR},
      </if>
      <if test="sex != null">
        #{sex,jdbcType=TINYINT},
      </if>
      <if test="city != null">
        #{city,jdbcType=VARCHAR},
      </if>
      <if test="province != null">
        #{province,jdbcType=VARCHAR},
      </if>
      <if test="country != null">
        #{country,jdbcType=VARCHAR},
      </if>
      <if test="headImg != null">
        #{headImg,jdbcType=VARCHAR},
      </if>
      <if test="subsTime != null">
        #{subsTime,jdbcType=TIMESTAMP},
      </if>
      <if test="lastSubs != null">
        #{lastSubs,jdbcType=TIMESTAMP},
      </if>
      <if test="lastAction != null">
        #{lastAction,jdbcType=BIGINT},
      </if>
      <if test="recTime != null">
        #{recTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.runsa.crmapp.customer.entity.CustomerWxgzh">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update crm_customer_weixin
    <set>
      <if test="cstId != null">
        `CST_ID` = #{cstId,jdbcType=BIGINT},
      </if>
      <if test="unionId != null">
        `UNION_ID` = #{unionId,jdbcType=VARCHAR},
      </if>
      <if test="subscribe != null">
        `SUBSCRIBE` = #{subscribe,jdbcType=BIT},
      </if>
      <if test="nickName != null">
        `NICK_NAME` = #{nickName,jdbcType=VARCHAR},
      </if>
      <if test="sex != null">
        `SEX` = #{sex,jdbcType=TINYINT},
      </if>
      <if test="city != null">
        `CITY` = #{city,jdbcType=VARCHAR},
      </if>
      <if test="province != null">
        `PROVINCE` = #{province,jdbcType=VARCHAR},
      </if>
      <if test="country != null">
        `COUNTRY` = #{country,jdbcType=VARCHAR},
      </if>
      <if test="headImg != null">
        `HEAD_IMG` = #{headImg,jdbcType=VARCHAR},
      </if>
      <if test="subsTime != null">
        `SUBS_TIME` = IF(`SUBS_TIME` IS NULL ,#{subsTime,jdbcType=TIMESTAMP},`SUBS_TIME`),
      </if>
      <if test="lastSubs != null">
        `LAST_SUBS` = #{lastSubs,jdbcType=TIMESTAMP},
      </if>
      <if test="lastAction != null">
        `LAST_ACTION` = #{lastAction,jdbcType=BIGINT},
      </if>
      <if test="recTime != null">
        `REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
      </if>
	  <if test="recTime == null">
        `REC_TIME` = now(),
      </if>
    </set>
    where `GZH_ID` = #{gzhId,jdbcType=VARCHAR}
      and `OPEN_ID` = #{openId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.runsa.crmapp.customer.entity.CustomerWxgzh">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update crm_customer_weixin
    set `CST_ID` = #{cstId,jdbcType=BIGINT},
      `UNION_ID` = #{unionId,jdbcType=VARCHAR},
      `SUBSCRIBE` = #{subscribe,jdbcType=BIT},
      `NICK_NAME` = #{nickName,jdbcType=VARCHAR},
      `SEX` = #{sex,jdbcType=TINYINT},
      `CITY` = #{city,jdbcType=VARCHAR},
      `PROVINCE` = #{province,jdbcType=VARCHAR},
      `COUNTRY` = #{country,jdbcType=VARCHAR},
      `HEAD_IMG` = #{headImg,jdbcType=VARCHAR},
      `SUBS_TIME` = #{subsTime,jdbcType=TIMESTAMP},
      `LAST_SUBS` = #{lastSubs,jdbcType=TIMESTAMP},
      `LAST_ACTION` = #{lastAction,jdbcType=BIGINT},
      `REC_TIME` = #{recTime,jdbcType=TIMESTAMP}
      where `GZH_ID` = #{gzhId,jdbcType=VARCHAR}
      and `OPEN_ID` = #{openId,jdbcType=VARCHAR}
  </update>
  
  <select id="selectCustomerByPrimaryKey" resultMap="CustomerBaseResultMap">
  	SELECT c.`CST_ID`,c.`CST_TYPE` 
  	FROM crm_customer c 
  	INNER JOIN crm_customer_weixin w 
  	ON c.`CST_ID` = w.`CST_ID` 
  	WHERE w.`GZH_ID` = #{gzhId,jdbcType=VARCHAR}
  	AND w.`OPEN_ID` = #{openId,jdbcType=VARCHAR};
  </select>
</mapper>