Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

436 строки
15 KiB

  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.WxCUserBasicInfoMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserBasicInfo">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  7. <result column="birthdate" jdbcType="TIMESTAMP" property="birthdate"/>
  8. <result column="education" jdbcType="VARCHAR" property="education"/>
  9. <result column="sex" jdbcType="INTEGER" property="sex"/>
  10. <result column="email" jdbcType="VARCHAR" property="email"/>
  11. <result column="address" jdbcType="VARCHAR" property="address"/>
  12. <result column="poins" jdbcType="INTEGER" property="poins"/>
  13. <result column="tag_id" jdbcType="BIGINT" property="tagId"/>
  14. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  15. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  16. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  17. <result column="name" jdbcType="VARCHAR" property="name"/>
  18. <result column="level" jdbcType="VARCHAR" property="level"/>
  19. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  20. <result column="credit" jdbcType="INTEGER" property="credit"/>
  21. <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/>
  22. </resultMap>
  23. <sql id="allColumns">
  24. `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,
  25. `create_date`,`update_date`,`tenant_id`,`name`,`level`,`nick_name`,`credit`,`active_time`
  26. </sql>
  27. <sql id="dynamicWhereConditions">
  28. where 1 = 1
  29. <if test=" null != id ">
  30. and `id` = #{id}
  31. </if>
  32. <if test=" null != tenantId ">
  33. and `tenant_id` = #{tenantId}
  34. </if>
  35. <if test=" null != phone ">
  36. and `phone` like concat('%', #{phone},'%')
  37. </if>
  38. <if test=" null != birthdate ">
  39. and `birthdate` = #{birthdate}
  40. </if>
  41. <if test=" null != education ">
  42. and `education` like concat('%', #{education},'%')
  43. </if>
  44. <if test=" null != sex ">
  45. and `sex` = #{sex}
  46. </if>
  47. <if test=" null != email ">
  48. and `email` like concat('%', #{email},'%')
  49. </if>
  50. <if test=" null != address ">
  51. and `address` like concat('%', #{address},'%')
  52. </if>
  53. <if test=" null != poins ">
  54. and `poins` = #{poins}
  55. </if>
  56. <if test=" null != credit ">
  57. and `credit` = #{credit}
  58. </if>
  59. <if test=" null != tagId ">
  60. and `tag_id` = #{tagId}
  61. </if>
  62. <if test=" null != createDate ">
  63. and `create_date` = #{createDate}
  64. </if>
  65. <if test=" null != updateDate ">
  66. and `update_date` = #{updateDate}
  67. </if>
  68. <if test=" null != name ">
  69. and `name` like concat('%', #{name},'%')
  70. </if>
  71. <if test=" null != level ">
  72. <if test=" '' != level ">
  73. and `level` like concat('%', #{level},'%')
  74. </if>
  75. </if>
  76. <if test=" null != startTime and null!=endTime">
  77. and `create_date` between #{startTime} and #{endTime}
  78. </if>
  79. <if test=" null != ids ">
  80. and id in
  81. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  82. #{idItem}
  83. </foreach>
  84. </if>
  85. <if test=" null != sortColumns">order by ${sortColumns}</if>
  86. </sql>
  87. <select id="findList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap">
  88. select
  89. <include refid="allColumns"/>
  90. from wx_c_user_basic_info
  91. <include refid="dynamicWhereConditions"/>
  92. </select>
  93. <sql id="allUserColumns">
  94. c.`id`,c.`phone`,cb.`birthdate`,cb.`education`,cb.`sex`,cb.`email`,cb.`address`,cb.`poins`,cb.`tag_id`,
  95. cb.`create_date`,cb.`update_date`,c.`tenant_id`,cb.`name`,cb.level,cb.nick_name
  96. </sql>
  97. <update id="updateScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo">
  98. update wx_c_user_basic_info set poins=#{poins} where phone=#{phone} and tenant_id=#{tenantId}
  99. and id=#{id}
  100. </update>
  101. <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserBaseVo">
  102. update wx_c_user_basic_info set id=#{newId} where tenant_id=#{tenantId}
  103. and id = #{id}
  104. </update>
  105. <select id="findCountBySex" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  106. select count(id) from wx_c_user_basic_info
  107. where sex =#{sex}
  108. <if test=" null != startTime ">
  109. and create_date &gt;= #{startTime}
  110. </if>
  111. <if test=" null != endTime">
  112. and create_date &lt;= #{endTime}
  113. </if>
  114. <if test="null != tenantId">
  115. and tenant_id =#{tenantId}
  116. </if>
  117. </select>
  118. <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  119. select count(id) from wx_c_user_basic_info where 1=1
  120. <if test=" null != startTime ">
  121. and create_date &gt;= #{startTime}
  122. </if>
  123. <if test=" null != endTime">
  124. and create_date &lt;= #{endTime}
  125. </if>
  126. <if test=" null != birthStartTime ">
  127. and birthdate &gt;= #{birthStartTime}
  128. </if>
  129. <if test=" null != birthEndTime">
  130. and birthdate &lt;= #{birthEndTime}
  131. </if>
  132. <if test=" null == birthStartTime and null == birthEndTime">
  133. and birthdate is null
  134. </if>
  135. <if test="null != tenantId">
  136. and tenant_id =#{tenantId}
  137. </if>
  138. </select>
  139. <select id="findCountByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  140. select count(id) from wx_c_user_basic_info where 1=1
  141. <if test=" null != startTime ">
  142. and create_date &gt;= #{startTime}
  143. </if>
  144. <if test=" null != endTime">
  145. and create_date &lt;= #{endTime}
  146. </if>
  147. <if test=" null != levelStartScore ">
  148. and poins &gt;= #{levelStartScore}
  149. </if>
  150. <if test=" null != levelEndScore">
  151. and poins &lt; #{levelEndScore}
  152. </if>
  153. <if test=" null == levelStartScore and null == levelEndScore">
  154. and poins is null
  155. </if>
  156. <if test="null != tenantId">
  157. and tenant_id =#{tenantId}
  158. </if>
  159. </select>
  160. <sql id="allColumnsOfScoreList">
  161. cub.id,cub.phone,cub.birthdate,cub.education,cub.sex,cub.email,cub.address,cub.poins,cub.tag_id,
  162. cub.create_date,cub.update_date,cub.tenant_id,cub.name,cub.level,cub.nick_name
  163. </sql>
  164. <select id="findListByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
  165. select <include refid="allColumnsOfScoreList"/>
  166. from wx_c_user_basic_info cub
  167. inner join wx_c_user cu on cu.id = cub.id
  168. where 1=1
  169. <if test=" null != levelStartScore ">
  170. and cub.poins &gt;= #{levelStartScore}
  171. </if>
  172. <if test=" null != levelEndScore">
  173. and cub.poins &lt;= #{levelEndScore}
  174. </if>
  175. <if test=" null == levelStartScore and null == levelEndScore">
  176. and cub.poins is null
  177. </if>
  178. <if test="null != tenantId">
  179. and cub.tenant_id =#{tenantId}
  180. </if>
  181. </select>
  182. <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  183. select count(id) from wx_c_user_basic_info where 1=1
  184. <if test=" null != startTime ">
  185. and create_date &gt;= #{startTime}
  186. </if>
  187. <if test=" null != endTime">
  188. and create_date &lt; #{endTime}
  189. </if>
  190. <if test="null != tenantId">
  191. and tenant_id =#{tenantId}
  192. </if>
  193. <if test="1 == queryImport">
  194. and create_date like '%00:00:00'
  195. </if>
  196. </select>
  197. <resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.WxCUserBasicInfoVo">
  198. <id column="id" jdbcType="BIGINT" property="id"/>
  199. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  200. <result column="birthdate" jdbcType="TIMESTAMP" property="birthdate"/>
  201. <result column="education" jdbcType="VARCHAR" property="education"/>
  202. <result column="sex" jdbcType="INTEGER" property="sex"/>
  203. <result column="email" jdbcType="VARCHAR" property="email"/>
  204. <result column="address" jdbcType="VARCHAR" property="address"/>
  205. <result column="poins" jdbcType="INTEGER" property="poins"/>
  206. <result column="tag_id" jdbcType="BIGINT" property="tagId"/>
  207. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  208. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  209. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  210. <result column="name" jdbcType="VARCHAR" property="name"/>
  211. <result column="level" jdbcType="VARCHAR" property="level"/>
  212. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  213. <result column="credit" jdbcType="INTEGER" property="credit"/>
  214. <result column="tags" jdbcType="VARCHAR" property="tags"/>
  215. <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/>
  216. </resultMap>
  217. <sql id="allVoColumns">
  218. cu.`id`,cu.`phone`,cu.`birthdate`,cu.`education`,cu.`sex`,cu.`email`,cu.`address`,cu.`poins`,cu.`tag_id`,
  219. cu.`create_date`,cu.`update_date`,cu.`tenant_id`,cu.`name`,cu.`level`,cu.`nick_name`,
  220. cut.`tags`,cu.`credit`,cu.`active_time`
  221. </sql>
  222. <sql id="dynamicVoWhereConditions">
  223. where 1 = 1
  224. <if test=" null != id ">
  225. and cu.`id` = #{id}
  226. </if>
  227. <if test=" null != tenantId ">
  228. and cu.`tenant_id` = #{tenantId}
  229. </if>
  230. <if test=" null != phone ">
  231. and cu.`phone` like concat('%', #{phone},'%')
  232. </if>
  233. <if test=" null != birthdate ">
  234. and cu.`birthdate` = #{birthdate}
  235. </if>
  236. <if test=" null != education ">
  237. and cu.`education` like concat('%', #{education},'%')
  238. </if>
  239. <if test=" null != sex ">
  240. and cu.`sex` = #{sex}
  241. </if>
  242. <if test=" null != email ">
  243. and cu.`email` like concat('%', #{email},'%')
  244. </if>
  245. <if test=" null != address ">
  246. and cu.`address` like concat('%', #{address},'%')
  247. </if>
  248. <if test=" null != poins ">
  249. and cu.`poins` = #{poins}
  250. </if>
  251. <if test=" null != tagId ">
  252. and cu.`tag_id` = #{tagId}
  253. </if>
  254. <if test=" null != createDate ">
  255. and cu.`create_date` = #{createDate}
  256. </if>
  257. <if test=" null != updateDate ">
  258. and cu.`update_date` = #{updateDate}
  259. </if>
  260. <if test=" null != name ">
  261. and `name` like concat('%', #{name},'%')
  262. </if>
  263. <if test=" null != startTime and null!=endTime">
  264. and cu.`create_date` between #{startTime} and #{endTime}
  265. </if>
  266. <if test=" null != ids ">
  267. and id in
  268. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  269. #{idItem}
  270. </foreach>
  271. </if>
  272. <if test=" null != sortColumns">order by ${sortColumns}</if>
  273. </sql>
  274. <select id="findVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="VoBaseResultMap">
  275. select
  276. <include refid="allVoColumns"/>
  277. from wx_c_user_basic_info cu
  278. left join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  279. <include refid="dynamicVoWhereConditions"/>
  280. </select>
  281. <select id="countVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="java.lang.Integer">
  282. select
  283. count(*)
  284. from wx_c_user_basic_info cu
  285. left join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  286. <include refid="dynamicVoWhereConditions"/>
  287. </select>
  288. <sql id="msgColumns">
  289. cu.`id`,cu.`phone`,cu.`email`
  290. </sql>
  291. <sql id="filterWhereConditions">
  292. where 1=1
  293. <if test="null != tenantId">
  294. and cu.tenant_id =#{tenantId}
  295. </if>
  296. <if test=" null != startTime ">
  297. and cu.create_date &gt;= #{startTime}
  298. </if>
  299. <if test=" null != endTime">
  300. and cu.create_date &lt;= #{endTime}
  301. </if>
  302. <if test=" null != birthStartTime ">
  303. and cu.birthdate &gt;= #{birthStartTime}
  304. </if>
  305. <if test=" null != birthEndTime">
  306. and cu.birthdate &lt; #{birthEndTime}
  307. </if>
  308. <if test=" null != phones">
  309. and cu.phone in (${phones})
  310. </if>
  311. <if test=" null != levelStartScore and (0 != levelStartScore and '' != levelStartScore)">
  312. and cu.poins &gt;= #{levelStartScore}
  313. <if test=" null != levelEndScore">
  314. and cu.poins &lt; #{levelEndScore}
  315. </if>
  316. </if>
  317. <if test=" null != levelStartScore and (0 == levelStartScore or '' == levelStartScore)">
  318. and (cu.poins is null or
  319. (cu.poins &gt;= #{levelStartScore}
  320. <if test=" null != levelEndScore">
  321. and cu.poins &lt; #{levelEndScore}
  322. </if>
  323. ))
  324. </if>
  325. <if test=" null != tagIds ">
  326. and JSON_CONTAINS(JSON_ARRAY(cut.tags),JSON_ARRAY
  327. <foreach collection="tagIds" index="index" item="idItem" open="(" separator="," close=")">
  328. #{idItem}
  329. </foreach>
  330. )
  331. </if>
  332. <if test=" null != sortColumns">order by ${sortColumns}</if>
  333. </sql>
  334. <select id="findCountByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  335. select count(*) from wx_c_user_basic_info cu
  336. join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  337. <include refid="filterWhereConditions"/>
  338. </select>
  339. <select id="findListByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
  340. select <include refid="msgColumns"/>
  341. from wx_c_user_basic_info cu
  342. join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  343. <include refid="filterWhereConditions"/>
  344. </select>
  345. <select id="findImportUserCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  346. SELECT count(*) FROM wx_c_user_basic_info cubi left join wx_c_user cu on cubi.id=cu.id where cu.id is null
  347. <if test="null != tenantId">
  348. and cubi.tenant_id =#{tenantId}
  349. </if>
  350. </select>
  351. <select id="findGrowUserCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  352. SELECT count(*) FROM wx_c_user_basic_info cubi left join wx_c_user cu on cubi.id=cu.id where cu.id is not null
  353. <if test="null != tenantId">
  354. and cubi.tenant_id =#{tenantId}
  355. </if>
  356. </select>
  357. </mapper>