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

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