123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?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.huiju.estateagents.mapper.TaPersonIntentionRecordMapper">
-
- <select id="selectAll" resultType="com.huiju.estateagents.entity.TaPersonIntentionRecord">
- SELECT
- *,
- tp.phone as phone,
- SUM(tpir.intention) as intentionCount
- FROM
- ta_person_intention_record tpir
- LEFT JOIN ta_person tp ON tpir.person_id = tp.person_id
- GROUP BY tpir.person_id
- </select>
-
-
- <select id="selectIntentionUser" resultType="map">
- SELECT
- tpir.person_name as personName,
- tp.phone as phone,
- tpir.building_name as buildingName,
- SUM(tpir.intention) as intention
- FROM
- ta_person_intention_record tpir
- LEFT JOIN ta_person tp on tpir.person_id = tp.person_id
- <trim prefix="where" prefixOverrides="and | or">
- <if test="buildingId != null and buildingId != ''">
- tpir.building_id = #{buildingId}
- </if>
- <if test="orgId != null">
- AND tpir.org_id = #{orgId}
- AND tp.org_id = #{orgId}
- </if>
- <if test="userId != null">
- AND tpir.building_id IN ( SELECT t3.building_id FROM ta_person_building t3 WHERE t3.user_id = #{userId} )
- </if>
- </trim>
- GROUP BY
- tpir.person_id, tpir.building_id
- ORDER BY SUM(tpir.intention) DESC
- </select>
- </mapper>
|