123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845 |
- <?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.yunzhi.marketing.mapper.TaBuildingMapper">
- <select id="buildingList" resultType="com.yunzhi.marketing.entity.TaBuilding">
- SELECT * FROM ta_building
- <where>
- status > -1
- <if test="Name != null and Name != ''">
- and (ta_building.name like concat('%',#{Name,jdbcType=VARCHAR},'%') or ta_building.building_name like concat('%',#{Name,jdbcType=VARCHAR},'%'))
- </if>
- <if test="Code != null and Code != ''">
- and ta_building.code like concat('%',#{Code,jdbcType=VARCHAR},'%')
- </if>
- <if test="startDate != null">
- and TO_DAYS(ta_building.opening_date ) = TO_DAYS(#{startDate})
- </if>
- <if test="buildingStatus != null and buildingStatus != ''">
- and ta_building.status = #{buildingStatus}
- </if>
- <if test="marketStatus != null and marketStatus != ''">
- and ta_building.market_status =#{marketStatus}
- </if>
- <if test="cityId != null and cityId != ''">
- and ta_building.city_id =#{cityId}
- </if>
- <if test="isMain != null">
- and ta_building.is_main = #{isMain}
- </if>
- <if test="orgId != null">
- and ta_building.org_id = #{orgId}
- </if>
- <if test="institutionIds != null and institutionIds.size > 0">
- AND ta_building.institution_id in
- <foreach collection="institutionIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="personBuildingList != null and personBuildingList.size > 0">
- AND ta_building.building_id in
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
- #{personBuilding.buildingId}
- </foreach>
- </if>
- </where>
- ORDER BY status ASC, create_date DESC, building_id ASC
- </select>
-
- <select id="buildingListSelect" resultType="com.yunzhi.marketing.entity.TaBuilding">
- SELECT * FROM ta_building
- <where>
- 1 =1
- and status != -1
- <if test="Name != null and Name != ''">
- and (ta_building.name like concat('%',#{Name,jdbcType=VARCHAR},'%') or ta_building.building_name like concat('%',#{Name,jdbcType=VARCHAR},'%'))
- </if>
- <if test="Code != null and Code != ''">
- and ta_building.code like concat('%',#{Code,jdbcType=VARCHAR},'%')
- </if>
- <if test="startDate != null">
- and TO_DAYS(ta_building.opening_date ) = TO_DAYS(#{startDate})
- </if>
- <if test="marketStatus != null and marketStatus != ''">
- and ta_building.market_status =#{marketStatus}
- </if>
- <if test="cityId != null and cityId != ''">
- and ta_building.city_id =#{cityId}
- </if>
- <if test="isMain != null and isMain != ''">
- and ta_building.is_main = #{isMain}
- </if>
- <if test="orgId != null and orgId != ''">
- and ta_building.org_id = #{orgId}
- </if>
- <if test="personBuildingList != null and personBuildingList.size > 0">
- AND ta_building.building_id in
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
- #{personBuilding.buildingId}
- </foreach>
- </if>
- </where>
- ORDER BY create_date DESC,status asc
- </select>
-
- <select id="buildingAll" resultType="com.yunzhi.marketing.entity.TaBuilding">
- SELECT * FROM ta_building
- where status > -1
- and org_id = #{orgId}
- </select>
-
- <select id="selectBuilding" resultType="com.yunzhi.marketing.entity.TaBuilding">
- SELECT * FROM ta_building
- where building_id = #{buildingId}
- </select>
-
- <select id="selectBuildingStatistical" resultType="map">
- select
- IFNULL(sum(pv_num), 0) as pvNum,
- <if test="saveOrShare == 'save'">
- IFNULL(sum(save_num),0) as saveNum
- </if>
- <if test="saveOrShare == 'share'">
- IFNULL(sum(share_num),0) as shareNum
- </if>
- from ta_building
- where org_id = ${orgId}
- </select>
-
- <select id="selectBuildingPage" resultType="com.yunzhi.marketing.entity.TaBuilding">
- SELECT
- tb.*
- FROM
- (
- select * from ta_building
- WHERE
- `status` = 1
- and org_id = #{orgId}
- <if test="cityId != null">
- AND city_id = #{cityId}
- </if>
- <if test="buildingArea != null">
- AND building_area in
- <foreach collection="buildingAreaLisr" item="buildingList" open="(" close=")" separator=" , ">
- #{buildingList}
- </foreach>
- </if>
- <if test="brandId != null">
- AND brand_id = #{brandId}
- </if>
- <if test="isCommerce != null and isCommerce">
- AND is_commerce = 1
- </if>
- <if test="isRecentOpening != null and isRecentOpening">
- AND is_recent_opening = 1
- </if>
- <if test="marketStatus != null and marketStatus != ''">
- AND market_status = #{marketStatus}
- </if>
- <if test="targets != null and targets.size > 0">
- AND building_id IN
- <foreach collection="targets" item="buildingId" open="(" close=")" separator=",">
- #{buildingId}
- </foreach>
- </if>
- <if test="name != null and name !=''">
- AND (`name` LIKE CONCAT('%',#{name},'%')
- OR `building_name` LIKE CONCAT('%',#{name},'%'))
- </if>
- ) as tb
-
- left JOIN
- (
- SELECT * FROM ta_building_project_type
- <trim prefix="where" prefixOverrides="and | or">
- <if test="priceList != null and priceList.size > 0">
- <foreach collection="priceList" item="priceArr" open="(" close=")" separator=" OR ">
- (
- <if test='priceArr[0] != null and priceArr[0] != ""'>
- <![CDATA[ start_price > ${priceArr[0]} ]]>
- </if>
- <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
- AND
- </if>
- <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
- <![CDATA[ start_price <= ${priceArr[1]} ]]>
- </if>
- ) or
- (
- <if test='priceArr[0] != null and priceArr[0] != ""'>
- <![CDATA[ end_price > ${priceArr[0]} ]]>
- </if>
- <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
- AND
- </if>
- <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
- <![CDATA[ end_price <= ${priceArr[1]} ]]>
- </if>
- )
- </foreach>
- <if test="priceType != null and priceType != ''">
- and price_type = #{priceType}
- </if>
- </if>
-
- <if test="buildingTypeList != null and buildingTypeList.length > 0">
- AND building_type_id in
- <foreach collection="buildingTypeList" item="buildingType" open="(" close=")" separator=",">
- #{buildingType}
- </foreach>
- </if>
- </trim>
- GROUP BY building_id
- )
- AS tbpt ON tb.building_id = tbpt.building_id
-
- <if test="(areaList != null and areaList.size > 0) or (houseTypeList != null and houseTypeList.length > 0)">
- INNER JOIN
- (
- SELECT * FROM ta_building_apartment
- <trim prefix="where" prefixOverrides="and | or">
- <if test="areaList != null and areaList.size > 0">
- <foreach collection="areaList" item="areaArr" open="(" close=")" separator=" OR ">
- (
- <if test='areaArr[0] != null and areaArr[0] != ""'>
- <![CDATA[ building_area >= ${areaArr[0]} ]]>
- </if>
- <if test='areaArr.length > 1 and areaArr[0] != null and areaArr[0] != ""'>
- AND
- </if>
- <if test='areaArr.length > 1 and areaArr[1] != null and areaArr[1] != ""'>
- <![CDATA[ building_area <= ${areaArr[1]} ]]>
- </if>
- )
- </foreach>
- </if>
-
- <if test="houseTypeList != null and houseTypeList.length > 0">
- AND house_type in
- <foreach collection="houseTypeList" item="houseType" open="(" close=")" separator=",">
- #{houseType}
- </foreach>
- </if>
- </trim>
- GROUP BY building_id
- ) as tba ON tb.building_id = tba.building_id
- </if>
- <trim prefix="where" prefixOverrides="and | or">
- <if test="priceList != null and priceList.size > 0">
- <foreach collection="priceList" item="priceArr" open="(" close=")" separator=" OR ">
- (
- <if test='priceArr[0] != null and priceArr[0] != ""'>
- <![CDATA[ tbpt.start_price > ${priceArr[0]} ]]>
- </if>
- <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
- AND
- </if>
- <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
- <![CDATA[ tbpt.start_price <= ${priceArr[1]} ]]>
- </if>
- ) or
- (
- <if test='priceArr[0] != null and priceArr[0] != ""'>
- <![CDATA[ tbpt.end_price > ${priceArr[0]} ]]>
- </if>
- <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
- AND
- </if>
- <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
- <![CDATA[ tbpt.end_price <= ${priceArr[1]} ]]>
- </if>
- )
- </foreach>
- <if test="priceType != null and priceType != ''">
- and tbpt.price_type = #{priceType}
- </if>
- </if>
-
- and tb.org_id = #{orgId}
- <if test="buildingTypeList != null and buildingTypeList.length > 0">
- AND tbpt.building_type_id in
- <foreach collection="buildingTypeList" item="buildingType" open="(" close=")" separator=",">
- #{buildingType}
- </foreach>
- </if>
- </trim>
- ORDER BY ${orderBy}
- </select>
-
- <select id="selectBuildingByBuildingTypeId" resultType="com.yunzhi.marketing.entity.TaBuilding">
-
- SELECT
- tab.*
- FROM
- ta_building_project_type tbpt
- LEFT JOIN td_building_type tbt ON tbpt.building_type_id = tbt.building_type_id
- LEFT JOIN ta_building tab ON tbpt.building_id = tab.building_id
- WHERE
- tab.status <![CDATA[ > ]]> -1
- and
- tbpt.building_type_id = #{buildingTypeId}
-
- </select>
-
- <select id="getBuildingListById" resultType="com.yunzhi.marketing.entity.TaBuilding">
- select * from ta_building t where t.building_id in (
- select t.building_id from ta_goods t where t.org_id = #{orgId} and t.city_id = #{cityId} and `status`=1 group by t.building_id
- )
- </select>
-
- <select id="countNumByHeavy" resultType="java.lang.Integer">
- select COUNT(1) from ta_building_dynamic t where t.heavy = #{heavy}
- <if test="dynamicId != null and dynamicId != ''">
- and t.dynamic_id != #{dynamicId}
- </if>
- </select>
-
- <select id="selectMainBuildings" resultType="com.yunzhi.marketing.entity.TaBuilding">
- SELECT
- CONCAT( c.`name`, t.building_area ) AS building_area,
- t.*,
- s.url AS list_poster,
- GROUP_CONCAT( m.tag_name ) AS tags
- FROM
- ta_building t
- LEFT JOIN ta_building_img s ON t.building_id = s.building_id
- AND s.img_type = 'list'
- LEFT JOIN ta_building_tag m ON t.building_id = m.building_id
- LEFT JOIN td_city c ON t.city_id = c.id
- WHERE
- t.org_id = #{orgId}
- <if test="cityId != null and cityId != ''">
- AND t.city_id = #{cityId}
- </if>
- AND t.status = 1
- AND t.is_main = 1
- GROUP BY
- t.building_id
- ORDER BY t.order_no desc
- </select>
-
- <select id="getGkBarData" resultType="java.util.Map">
- SELECT
- count( * ) AS gk_num,
- bb.building_id,
- bb.create_date,
- bb.building_name
- FROM
- (
- SELECT
- b.*,
- d.building_name
- FROM
- ta_recommend_customer b
- LEFT JOIN ta_building d ON b.building_id = d.building_id
- WHERE
- b.STATUS > 0
- AND b.org_id = #{orgId}
- AND b.verify_status = 1
- AND ( b.realty_consultant IS NULL OR b.realty_consultant = '' )
- <if test="personBuildingList != null and personBuildingList.size > 0">
- AND b.building_id in
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
- #{personBuilding.buildingId}
- </foreach>
- </if>
- <if test="startDate != null">
- and TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(b.create_date) <= TO_DAYS(#{endDate})
- </if>
- and b.building_id is not null
- GROUP BY
- b.person_id
- ) bb
- GROUP BY
- bb.building_id
- order by gk_num desc
- limit 6
- </select>
-
- <select id="getSkBarData" resultType="java.util.Map">
- SELECT
- count( * ) AS sk_num,
- a.building_id,
- d.building_name
- FROM
- ta_recommend_customer a
- LEFT JOIN ta_building d ON a.building_id = d.building_id
- WHERE
- a.STATUS > 0
- AND a.verify_status = 1
- AND a.realty_consultant IS NOT NULL
- AND a.realty_consultant != ''
- AND a.org_id = #{orgId}
- <if test="personBuildingList != null and personBuildingList.size > 0">
- AND a.building_id in
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
- #{personBuilding.buildingId}
- </foreach>
- </if>
- <if test="startDate != null">
- and TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(a.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- a.building_id
- ORDER BY
- sk_num DESC
- LIMIT 6
- </select>
-
- <select id="getWgBarData" resultType="java.util.Map">
- SELECT
- count( * ) AS wg_num,
- a.be_uv AS building_id,
- a.create_date,
- d.building_name
- FROM
- ta_uv a
- LEFT JOIN ta_building d ON a.be_uv = d.building_id
- LEFT JOIN ta_person p ON a.person_id = p.person_id
- WHERE
- a.tagert_type = 'project'
- and p.org_id = #{orgId}
- and a.be_uv != "undefined"
- <if test="personBuildingList != null and personBuildingList.size > 0">
- AND a.be_uv in
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
- #{personBuilding.buildingId}
- </foreach>
- </if>
- <if test="startDate != null">
- and TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(a.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- a.be_uv
- ORDER BY
- wg_num DESC
- LIMIT 6
- </select>
-
- <select id="getFwBarData" resultType="java.util.Map">
- SELECT
- t.pv_num,
- t.building_id,
- t.building_name
- FROM
- ta_building t
- WHERE
- t.org_id = #{orgId}
- <if test="personBuildingList != null and personBuildingList.size > 0">
- AND t.building_id in
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
- #{personBuilding.buildingId}
- </foreach>
- </if>
- ORDER BY
- pv_num DESC
- LIMIT 6
- </select>
-
- <select id="getStatsTableList" resultType="com.yunzhi.marketing.excel.StatsBuilding">
- SELECT
- t.building_id,
- t.building_name,
- IFNULL( t.pv_num, 0 ) AS pv_num,
- IFNULL( uu.uv_num, 0 ) AS uv_num,
- IFNULL( aa.sk_num, 0 ) AS sk_num,
- IFNULL( bbb.gk_num, 0 ) AS gk_num,
- IFNULL( aa.sk_num, 0 ) + IFNULL( bbb.gk_num, 0 ) AS kh_num
- FROM
- ta_building t
- LEFT JOIN (
- SELECT
- count( * ) AS sk_num,
- a.building_id
- FROM
- ta_recommend_customer a
- WHERE
- a.STATUS > 0
- AND a.verify_status = 1
- AND a.realty_consultant IS NOT NULL
- AND a.realty_consultant != ''
- AND a.org_id = #{orgId}
- <if test="startDate != null">
- and TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(a.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- a.building_id
- ) aa ON aa.building_id = t.building_id
- LEFT JOIN (
- SELECT
- count( * ) AS gk_num,
- bb.building_id
- FROM
- (
- SELECT
- b.*
- FROM
- ta_recommend_customer b
- WHERE
- b.STATUS > 0
- AND b.org_id = #{orgId}
- AND b.verify_status = 1
- AND ( b.realty_consultant IS NULL OR b.realty_consultant = '' )
- <if test="startDate != null">
- and TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(b.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- b.person_id
- ) bb
- GROUP BY
- bb.building_id
- ) bbb ON bbb.building_id = t.building_id
- LEFT JOIN (
- SELECT
- count( * ) AS uv_num,
- u.be_uv AS building_id
- FROM
- ta_uv u
- LEFT JOIN ta_person p ON u.person_id = p.person_id
- WHERE
- u.tagert_type = 'project'
- AND p.org_id = #{orgId}
- <if test="startDate != null">
- and TO_DAYS(u.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(u.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- u.be_uv
- ) uu ON uu.building_id = t.building_id
- WHERE
- t.org_id = #{orgId}
- <if test="personBuildingList != null and personBuildingList.size > 0">
- AND t.building_id in
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
- #{personBuilding.buildingId}
- </foreach>
- </if>
- <if test="buildingId != null and buildingId != '' ">
- AND t.building_id = #{buildingId}
- </if>
- <if test="sortField != null and sortField != ''">
- ORDER BY ${sortField} ${orderType}
- </if>
- </select>
- <select id="getExportTableList" resultType="com.yunzhi.marketing.excel.StatsBuilding">
- SELECT
- t.building_id,
- t.building_name,
- IFNULL( t.pv_num, 0 ) AS pv_num,
- IFNULL( uu.uv_num, 0 ) AS uv_num,
- IFNULL( aa.sk_num, 0 ) AS sk_num,
- IFNULL( bbb.gk_num, 0 ) AS gk_num,
- IFNULL( aa.sk_num, 0 ) + IFNULL( bbb.gk_num, 0 ) AS kh_num
- FROM
- ta_building t
- LEFT JOIN (
- SELECT
- count( * ) AS sk_num,
- a.building_id
- FROM
- ta_recommend_customer a
- WHERE
- a.STATUS > 0
- AND a.verify_status = 1
- AND a.realty_consultant IS NOT NULL
- AND a.realty_consultant != ''
- AND a.org_id = #{orgId}
- <if test="startDate != null">
- and TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(a.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- a.building_id
- ) aa ON aa.building_id = t.building_id
- LEFT JOIN (
- SELECT
- count( * ) AS gk_num,
- bb.building_id
- FROM
- (
- SELECT
- b.*
- FROM
- ta_recommend_customer b
- WHERE
- b.STATUS > 0
- AND b.org_id = #{orgId}
- AND b.verify_status = 1
- AND ( b.realty_consultant IS NULL OR b.realty_consultant = '' )
- <if test="startDate != null">
- and TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(b.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- b.person_id
- ) bb
- GROUP BY
- bb.building_id
- ) bbb ON bbb.building_id = t.building_id
- LEFT JOIN (
- SELECT
- count( * ) AS uv_num,
- u.be_uv AS building_id
- FROM
- ta_uv u
- LEFT JOIN ta_person p ON u.person_id = p.person_id
- WHERE
- u.tagert_type = 'project'
- AND p.org_id = #{orgId}
- <if test="startDate != null">
- and TO_DAYS(u.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(u.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- u.be_uv
- ) uu ON uu.building_id = t.building_id
- WHERE
- t.org_id = #{orgId}
- <if test="personBuildingList != null and personBuildingList.size > 0">
- AND t.building_id in
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
- #{personBuilding.buildingId}
- </foreach>
- </if>
- <if test="buildingId != null and buildingId != '' ">
- AND t.building_id = #{buildingId}
- </if>
- </select>
- <select id="getStatsTimeBarList" resultType="com.yunzhi.marketing.excel.StatsTimeBuilding">
- SELECT
- #{buildingName} as building_name,
- t.date as create_date,
- IFNULL( s.sk_num, 0 ) AS sk_num,
- IFNULL( g.gk_num, 0 ) AS gk_num,
- IFNULL( u.uv_num, 0 ) AS uv_num,
- IFNULL( s.sk_num, 0 ) + IFNULL( g.gk_num, 0 ) AS kh_num
- FROM
- (
- SELECT
- DATE_FORMAT( DATE_SUB( #{endDate}, INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
- FROM
- sequence a
- WHERE
- a.rownum <= datediff( #{endDate}, #{startDate} )
- ) t
- LEFT JOIN (
- SELECT
- count( * ) AS sk_num,
- a.building_id,
- DATE_FORMAT( a.create_date, '%Y-%m-%d' ) AS create_date
- FROM
- ta_recommend_customer a
- WHERE
- a.STATUS > 0
- AND a.verify_status = 1
- AND a.realty_consultant IS NOT NULL
- AND a.realty_consultant != ''
- AND a.org_id = #{orgId}
- AND a.building_id = #{buildingId}
- <if test="startDate != null">
- and TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(a.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- DATE_FORMAT( a.create_date, '%Y-%m-%d' )
- ) s ON t.date = s.create_date
- LEFT JOIN (
- SELECT
- count( * ) AS gk_num,
- b.building_id,
- DATE_FORMAT( b.create_date, '%Y-%m-%d' ) AS create_date
- FROM
- ta_person b
- WHERE
- b.STATUS > 0
- AND b.org_id = #{orgId}
- AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
- AND b.person_id NOT IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = 84 AND person_id IS NOT NULL AND person_id != '' )
- AND b.building_id = #{buildingId}
- <if test="startDate != null">
- and TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(b.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- DATE_FORMAT( b.create_date, '%Y-%m-%d' )
- ) g ON t.date = g.create_date
- LEFT JOIN (
- SELECT
- count( * ) AS uv_num,
- u.be_uv AS building_id,
- DATE_FORMAT( u.create_date, '%Y-%m-%d' ) AS create_date
- FROM
- ta_uv u
- LEFT JOIN ta_person p ON u.person_id = p.person_id
- WHERE
- tagert_type = 'project'
- AND p.org_id = #{orgId}
- AND u.be_uv = #{buildingId}
- <if test="startDate != null">
- and TO_DAYS(u.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(u.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- DATE_FORMAT( u.create_date, '%Y-%m-%d' )
- ) u ON t.date = u.create_date
- ORDER BY create_date
- </select>
- <select id="getStatsTimeTableList" resultType="com.yunzhi.marketing.excel.StatsTimeBuilding">
- SELECT
- t.date as create_date,
- IFNULL( s.sk_num, 0 ) AS sk_num,
- IFNULL( g.gk_num, 0 ) AS gk_num,
- IFNULL( u.uv_num, 0 ) AS uv_num,
- IFNULL( s.sk_num, 0 ) + IFNULL( g.gk_num, 0 ) AS kh_num
- FROM
- (
- SELECT
- DATE_FORMAT( DATE_SUB( #{endDate}, INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
- FROM
- sequence a
- WHERE
- a.rownum <= datediff( #{endDate}, #{startDate} )
- ) t
- LEFT JOIN (
- SELECT
- count( * ) AS sk_num,
- a.building_id,
- DATE_FORMAT( a.create_date, '%Y-%m-%d' ) AS create_date
- FROM
- ta_recommend_customer a
- WHERE
- a.STATUS > 0
- AND a.verify_status = 1
- AND a.realty_consultant IS NOT NULL
- AND a.realty_consultant != ''
- AND a.org_id = #{orgId}
- AND a.building_id = #{buildingId}
- <if test="startDate != null">
- and TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(a.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- DATE_FORMAT( a.create_date, '%Y-%m-%d' )
- ) s ON t.date = s.create_date
- LEFT JOIN (
- SELECT
- count( * ) AS gk_num,
- b.building_id,
- DATE_FORMAT( b.create_date, '%Y-%m-%d' ) AS create_date
- FROM
- ta_person b
- WHERE
- b.STATUS > 0
- AND b.org_id = #{orgId}
- AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
- AND b.person_id NOT IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = 84 AND person_id IS NOT NULL AND person_id != '' )
- AND b.building_id = #{buildingId}
- <if test="startDate != null">
- and TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(b.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- DATE_FORMAT( b.create_date, '%Y-%m-%d' )
- ) g ON t.date = g.create_date
- LEFT JOIN (
- SELECT
- count( * ) AS uv_num,
- u.be_uv AS building_id,
- DATE_FORMAT( u.create_date, '%Y-%m-%d' ) AS create_date
- FROM
- ta_uv u
- LEFT JOIN ta_person p ON u.person_id = p.person_id
- WHERE
- u.tagert_type = 'project'
- AND p.org_id = #{orgId}
- AND u.be_uv = #{buildingId}
- <if test="startDate != null">
- and TO_DAYS(u.create_date) >= TO_DAYS(#{startDate})
- </if>
- <if test="endDate != null">
- and TO_DAYS(u.create_date) <= TO_DAYS(#{endDate})
- </if>
- GROUP BY
- DATE_FORMAT( u.create_date, '%Y-%m-%d' )
- ) u ON t.date = u.create_date
- ORDER BY
- <if test="sortField != null and sortField != ''">
- ${sortField} ${orderType},
- </if>
- create_date desc
- </select>
- <select id="selectByUserId" resultType="com.yunzhi.marketing.entity.TaBuilding">
- SELECT
- *
- FROM
- ta_building b
- WHERE b.institution_id in (SELECT
- i.institution_id
- FROM
- xlk_institution i
- INNER JOIN ( SELECT x.institution_code FROM xlk_user_institution t LEFT JOIN xlk_institution x ON t.institution_id = x.institution_id WHERE t.user_id = #{userId}) g ON i.institution_code LIKE CONCAT(g.institution_code ,"%")
- )
- </select>
- <select id="getBuilidngsOfPerson" resultType="com.yunzhi.marketing.entity.TaBuilding">
- SELECT
- *
- FROM
- ta_building t
- INNER JOIN ta_person_building s ON t.building_id = s.building_id
- AND s.person_id = #{personId}
- WHERE
- t.org_id = #{orgId}
- AND t.`status` = 1
- ORDER BY
- t.create_date DESC
- </select>
- <select id="getSpecial" resultType="com.yunzhi.marketing.entity.TaBuilding">
- SELECT
- DISTINCT t.*
- FROM
- ta_building t
- INNER JOIN xlk_building_special_room s ON t.org_id = s.org_id
- AND t.building_id = s.building_id
- AND s.start_time <= now( )
- AND s.end_time >= now( )
- WHERE
- t.org_id = #{orgId}
- AND t.city_id = #{cityId}
- AND t.`status` = 1
- ORDER BY
- t.create_date DESC
- </select>
-
- </mapper>
|