TsCustomerStatisticMonthlyMapper.xml 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.huiju.estateagents.statistic.mapper.TsCustomerStatisticMonthlyMapper">
  4. <select id="getNewCustomerStatisticMonthly"
  5. resultType="com.huiju.estateagents.statistic.entity.TsCustomerStatisticMonthly">
  6. SELECT
  7. org_id,
  8. count( customer_id ) as customer_num
  9. FROM
  10. ta_recommend_customer
  11. WHERE
  12. `STATUS` = #{status}
  13. AND date_format( create_date, '%Y-%m' ) = date_format( #{nowDate}, '%Y-%m' )
  14. GROUP BY
  15. org_id
  16. </select>
  17. <select id="getFollowUpStatisticMonthly"
  18. resultType="com.huiju.estateagents.statistic.entity.TsCustomerStatisticMonthly">
  19. SELECT
  20. org_id,
  21. count( DISTINCT ( customer_id ) ) as customer_num
  22. FROM
  23. ta_customer_follow_up_record
  24. WHERE
  25. date_format( create_date, '%Y-%m' ) = date_format( #{nowDate}, '%Y-%m' )
  26. GROUP BY
  27. org_id
  28. </select>
  29. <select id="getVisiteStatisticMonthly"
  30. resultType="com.huiju.estateagents.statistic.entity.TsCustomerStatisticMonthly">
  31. SELECT
  32. count( DISTINCT ( c.customer_id ) ) as customer_num,
  33. c.org_id
  34. FROM
  35. ta_activity_dynamic_enlist t
  36. LEFT JOIN ta_recommend_customer c ON t.person_id = c.person_id
  37. AND t.building_id = c.building_id
  38. AND t.org_id = c.org_id
  39. WHERE
  40. t.is_checkin = #{checkin}
  41. AND date_format( t.create_date, '%Y-%m' ) = date_format( #{nowDate}, '%Y-%m' )
  42. GROUP BY
  43. c.org_id
  44. </select>
  45. <select id="getMonthlyList" resultType="com.huiju.estateagents.statistic.entity.TsCustomerStatisticMonthly">
  46. SELECT
  47. *
  48. FROM
  49. ts_customer_statistic_monthly
  50. WHERE
  51. org_id = #{orgId}
  52. AND customer_type = #{customerType}
  53. AND date_format( create_date, '%Y-%m-%d' ) >= date_format( #{beforeDate}, '%Y-%m-%d' )
  54. AND date_format( create_date, '%Y-%m-%d' ) &lt;= date_format( #{nowDate}, '%Y-%m-%d' )
  55. order by `month`
  56. </select>
  57. </mapper>