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

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