后台服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WxCUserCarMapper.xml 4.7 KiB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.iformall.mapper.WxCUserCarMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserCar">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  8. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  9. <result column="phone" jdbcType="VARCHAR" property="userPhone" />
  10. <result column="car_number" jdbcType="VARCHAR" property="carNumber" />
  11. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  12. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  13. <result column="vendor_type" jdbcType="INTEGER" property="vendorType" />
  14. <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams" />
  15. <result column="vendor_person_id" jdbcType="VARCHAR" property="vendorPersonId" />
  16. </resultMap>
  17. <sql id="allColumns">
  18. wcuc.`id`,wcuc.`tenant_id`,wcuc.`parent_tenant_id`,wcuc.`c_user_id`,wcuc.`car_number`,wcuc.`create_date`,wcuc.`update_date`,wcuc.`vendor_type`,wcuc.`vendor_params`,wcuc.`vendor_person_id`
  19. </sql>
  20. <sql id="dynamicWhereConditions">
  21. where 1=1
  22. <if test=" null != id ">
  23. and wcuc.`id` = #{id}
  24. </if>
  25. <if test=" null != tenantId and '' != tenantId">
  26. and wcuc.`tenant_id` = #{tenantId}
  27. </if>
  28. <if test=" null != parentTenantId and '' != parentTenantId">
  29. and wcuc.`parent_tenant_id` = #{parentTenantId}
  30. </if>
  31. <if test=" null != cUserId ">
  32. and wcuc.`c_user_id` = #{cUserId}
  33. </if>
  34. <if test=" null != carNumber ">
  35. and wcuc.`car_number` like concat('%', #{carNumber},'%')
  36. </if>
  37. <!-- <if test=" null != carNumber ">
  38. and `car_number` like concat('%', #{carNumber},'%')
  39. </if> -->
  40. <if test=" null != createDate ">
  41. and wcuc.`create_date` = #{createDate}
  42. </if>
  43. <if test=" null != vendorType ">
  44. and wcuc.`vendor_type` = #{vendorType}
  45. </if>
  46. <!--<if test=" null != vendorParams ">
  47. and `vendor_params` like concat('%', #{vendorParams},'%')
  48. </if>-->
  49. <if test=" null != vendorPersonId ">
  50. and wcuc.`vendor_person_id` = #{vendorPersonId}
  51. </if>
  52. <if test=" null != ids ">
  53. and wcuc.id in
  54. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  55. #{idItem}
  56. </foreach>
  57. </if>
  58. <if test=" null != userIds ">
  59. and wcuc.c_user_id in
  60. <foreach collection="userIds" index="index" item="idItem" open="(" separator="," close=")">
  61. #{idItem}
  62. </foreach>
  63. </if>
  64. <!-- <if test=" null != sortColumns"> order by ${sortColumns} </if>-->
  65. order by wcuc.create_date
  66. </sql>
  67. <select id="findList" parameterType="com.iformall.domain.po.WxCUserCar" resultMap="BaseResultMap">
  68. select
  69. <include refid="allColumns"/>
  70. from wx_c_user_car wcuc
  71. <include refid="dynamicWhereConditions" />
  72. </select>
  73. <select id="countList" parameterType="com.iformall.domain.po.WxCUserCar" resultType="java.lang.Integer">
  74. select count(1) from wx_c_user_car wcuc
  75. <include refid="dynamicWhereConditions" />
  76. </select>
  77. <select id="countUser" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Integer">
  78. select count(DISTINCT ubi.id)
  79. from wx_c_user_car uc
  80. left join wx_c_user_basic_info ubi on uc.c_user_id = ubi.id
  81. where uc.tenant_id = #{tenantId}
  82. <if test=" null != parentTenantId and '' != parentTenantId">
  83. and uc.parent_tenant_id = #{parentTenantId}
  84. </if>
  85. <if test=" null != startTime ">
  86. and ubi.create_date &gt;= #{startTime}
  87. </if>
  88. <if test=" null != endTime">
  89. and ubi.create_date &lt; #{endTime}
  90. </if>
  91. </select>
  92. <select id="queryCarCount" parameterType="hashmap" resultType="long">
  93. select count(id) from wx_c_user_car
  94. where `tenant_id` = #{tenantId}
  95. <if test=" null != parentTenantId and '' != parentTenantId">
  96. and `parent_tenant_id` = #{parentTenantId}
  97. </if>
  98. and create_date between #{startdate} and #{enddate}
  99. </select>
  100. <select id="queryCarCountHistory" resultType="hashmap" parameterType="hashmap">
  101. SELECT count(DISTINCT c.id) count, c.create_time FROM
  102. (SELECT ubi.id as id, DATE_FORMAT(uc.create_date, '%m/%d') create_time
  103. FROM wx_c_user_car uc, wx_c_user_basic_info ubi
  104. WHERE uc.c_user_id = ubi.id
  105. <if test=" null != tenantId and '' != tenantId">
  106. and uc.tenant_id = #{tenantId}
  107. </if>
  108. <if test=" null != parentTenantId and '' != parentTenantId">
  109. and uc.parent_tenant_id = #{parentTenantId}
  110. </if>
  111. AND ubi.create_date BETWEEN #{startdate} AND #{enddate}) c
  112. GROUP BY c.create_time ORDER BY c.create_time
  113. </select>
  114. </mapper>