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

1019 строки
38 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="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>-->
  18. <result column="final_tenant_id" jdbcType="VARCHAR" property="finalTenantId"/>
  19. <result column="name" jdbcType="VARCHAR" property="name"/>
  20. <result column="level" jdbcType="VARCHAR" property="level"/>
  21. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  22. <result column="avatar_url" jdbcType="VARCHAR" property="avatarUrl"/>
  23. <result column="credit" jdbcType="INTEGER" property="credit"/>
  24. <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/>
  25. <result column="login_count" jdbcType="INTEGER" property="loginCount"/>
  26. <result column="act_record" jdbcType="INTEGER" property="actRecord"/>
  27. <result column="score_date" jdbcType="TIMESTAMP" property="scoreDate"/>
  28. <result column="status" jdbcType="INTEGER" property="status"/>
  29. </resultMap>
  30. <sql id="allColumns">
  31. distinct wcubi.`id`,wcubi.`phone`,wcubi.`birthdate`,wcubi.`education`,wcubi.`sex`,wcubi.`email`,
  32. wcubi.`address`,wcubi.`poins`,wcubi.`tag_id`,wcubi.`create_date`,wcubi.`update_date`,
  33. wcubi.`final_tenant_id`,wcubi.`name`,wcubi.`nick_name`,
  34. wcubi.`avatar_url`,wcubi.`credit`,wcubi.`active_time`,wcubi.`login_count`,wcubi.`act_record`
  35. ,(select level from wx_level_config
  36. where poins >= points and tenant_id=wcubi.final_tenant_id
  37. order by points desc limit 1 ) level,wcubi.status
  38. </sql>
  39. <sql id="allSimpleColumns">
  40. `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,
  41. `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`name`,`nick_name`,`credit`,`active_time`,`act_record`
  42. </sql>
  43. <sql id="dynamicWhereConditions">
  44. where 1 = 1
  45. <if test=" null != id ">
  46. and wcubi.`id` = #{id}
  47. </if>
  48. <if test=" null != finalTenantId and '' != finalTenantId">
  49. and wcubi.`final_tenant_id` = #{finalTenantId}
  50. </if>
  51. <if test=" null != phone ">
  52. and wcubi.`phone` like concat('%', #{phone},'%')
  53. </if>
  54. <if test=" null != birthdate ">
  55. and wcubi.`birthdate` = #{birthdate}
  56. </if>
  57. <if test=" null != education ">
  58. and wcubi.`education` like concat('%', #{education},'%')
  59. </if>
  60. <if test=" null != sex ">
  61. and wcubi.`sex` = #{sex}
  62. </if>
  63. <if test=" null != email ">
  64. and wcubi.`email` like concat('%', #{email},'%')
  65. </if>
  66. <if test=" null != address ">
  67. and wcubi.`address` like concat('%', #{address},'%')
  68. </if>
  69. <if test=" null != poins ">
  70. and wcubi.`poins` = #{poins}
  71. </if>
  72. <if test=" null != credit ">
  73. and wcubi.`credit` = #{credit}
  74. </if>
  75. <if test=" null != tagId ">
  76. and wcubi.`tag_id` = #{tagId}
  77. </if>
  78. <if test=" null != createDate ">
  79. and wcubi.`create_date` = #{createDate}
  80. </if>
  81. <if test=" null != updateDate ">
  82. and wcubi.`update_date` = #{updateDate}
  83. </if>
  84. <if test=" null != actRecord ">
  85. and wcubi.`act_record` = #{actRecord}
  86. </if>
  87. <if test=" null != name ">
  88. and wcubi.`name` like concat('%', #{name},'%')
  89. </if>
  90. <if test=" null != startTime and null!=endTime">
  91. and wcubi.`create_date` between #{startTime} and #{endTime}
  92. </if>
  93. <if test=" null != status ">
  94. and wcubi.`status` = #{status}
  95. </if>
  96. <if test=" null != ids ">
  97. and wcubi.id in
  98. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  99. #{idItem}
  100. </foreach>
  101. </if>
  102. order by wcubi.`active_time` DESC
  103. <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>-->
  104. </sql>
  105. <select id="findList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap">
  106. select r.* from (
  107. select
  108. <include refid="allColumns"/>
  109. from wx_c_user_basic_info wcubi
  110. <include refid="dynamicWhereConditions"/>
  111. ) r where 1=1
  112. <if test="null != level and '' != level">
  113. and r.level =#{level}
  114. </if>
  115. </select>
  116. <sql id="dynamicWhereConditions1">
  117. where 1 = 1
  118. <if test=" null != basicInfo.id ">
  119. and wcubi.`id` = #{basicInfo.id}
  120. </if>
  121. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  122. and wcubi.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  123. </if>
  124. <if test=" null != basicInfo.phone ">
  125. and wcubi.`phone` like concat('%', #{basicInfo.phone},'%')
  126. </if>
  127. <if test=" null != basicInfo.birthdate ">
  128. and wcubi.`birthdate` = #{basicInfo.birthdate}
  129. </if>
  130. <if test=" null != basicInfo.education ">
  131. and wcubi.`education` like concat('%', #{basicInfo.education},'%')
  132. </if>
  133. <if test=" null != basicInfo.sex ">
  134. and wcubi.`sex` = #{basicInfo.sex}
  135. </if>
  136. <if test=" null != basicInfo.email ">
  137. and wcubi.`email` like concat('%', #{basicInfo.email},'%')
  138. </if>
  139. <if test=" null != basicInfo.address ">
  140. and wcubi.`address` like concat('%', #{basicInfo.address},'%')
  141. </if>
  142. <if test=" null != basicInfo.poins ">
  143. and wcubi.`poins` = #{basicInfo.poins}
  144. </if>
  145. <if test=" null != basicInfo.credit ">
  146. and wcubi.`credit` = #{basicInfo.credit}
  147. </if>
  148. <if test=" null != basicInfo.tagId ">
  149. and wcubi.`tag_id` = #{basicInfo.tagId}
  150. </if>
  151. <if test=" null != basicInfo.createDate ">
  152. and wcubi.`create_date` = #{basicInfo.createDate}
  153. </if>
  154. <if test=" null != basicInfo.updateDate ">
  155. and wcubi.`update_date` = #{basicInfo.updateDate}
  156. </if>
  157. <if test=" null != basicInfo.actRecord ">
  158. and wcubi.`act_record` = #{basicInfo.actRecord}
  159. </if>
  160. <if test=" null != basicInfo.name ">
  161. and wcubi.`name` like concat('%', #{basicInfo.name},'%')
  162. </if>
  163. <if test=" null != basicInfo.startTime and null != basicInfo.endTime">
  164. and wcubi.`create_date` between #{basicInfo.startTime} and #{basicInfo.endTime}
  165. </if>
  166. <if test=" null != basicInfo.status ">
  167. and wcubi.`status` = #{basicInfo.status}
  168. </if>
  169. <if test=" null != basicInfo.ids ">
  170. and wcubi.id in
  171. <foreach collection="basicInfo.ids" index="index" item="idItem" open="(" separator="," close=")">
  172. #{idItem}
  173. </foreach>
  174. </if>
  175. order by wcubi.`active_time` DESC
  176. <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>-->
  177. </sql>
  178. <select id="findList1" resultMap="BaseResultMap">
  179. select r.* from (
  180. select
  181. <include refid="allColumns"/>
  182. from wx_c_user_basic_info wcubi
  183. <include refid="dynamicWhereConditions1"/>
  184. ) r where 1=1
  185. <if test="null != basicInfo.level and '' != basicInfo.level">
  186. and r.level =#{basicInfo.level}
  187. </if>
  188. </select>
  189. <update id="updateScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo">
  190. update wx_c_user_basic_info set poins=#{poins}
  191. where id=#{id}
  192. </update>
  193. <update id="updateUpScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo">
  194. update wx_c_user_basic_info set poins=poins+#{poins}
  195. where id=#{id}
  196. </update>
  197. <update id="updateDownScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo">
  198. update wx_c_user_basic_info set poins=poins-#{poins}
  199. where id=#{id}
  200. </update>
  201. <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserBaseVo">
  202. update wx_c_user_basic_info set id=#{newId} , credit=#{credit} , poins=#{poins}
  203. where id = #{id}
  204. </update>
  205. <select id="findCountBySex" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  206. select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
  207. where wcubi.sex =#{sex}
  208. <if test=" null != finalTenantId and '' != finalTenantId">
  209. and wcubi.`final_tenant_id` = #{finalTenantId}
  210. </if>
  211. <if test=" null != startTime ">
  212. and wcubi.create_date &gt;= #{startTime}
  213. </if>
  214. <if test=" null != endTime">
  215. and wcubi.create_date &lt;= #{endTime}
  216. </if>
  217. </select>
  218. <select id="findCountBySex1" resultType="java.lang.Long">
  219. select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
  220. where wcubi.sex =#{basicInfo.sex}
  221. <if test=" null != basicInfo.startTime ">
  222. and wcubi.create_date &gt;= #{basicInfo.startTime}
  223. </if>
  224. <if test=" null != basicInfo.endTime">
  225. and wcubi.create_date &lt;= #{basicInfo.endTime}
  226. </if>
  227. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  228. and wcubi.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  229. </if>
  230. </select>
  231. <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  232. select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
  233. where 1=1
  234. <if test=" null != finalTenantId and '' != finalTenantId">
  235. and wcubi.`final_tenant_id` = #{finalTenantId}
  236. </if>
  237. <if test=" null != startTime ">
  238. and wcubi.create_date &gt;= #{startTime}
  239. </if>
  240. <if test=" null != endTime">
  241. and wcubi.create_date &lt;= #{endTime}
  242. </if>
  243. <if test=" null != birthStartTime ">
  244. and wcubi.birthdate &gt;= #{birthStartTime}
  245. </if>
  246. <if test=" null != birthEndTime">
  247. and wcubi.birthdate &lt;= #{birthEndTime}
  248. </if>
  249. <if test=" null == birthStartTime and null == birthEndTime">
  250. and wcubi.birthdate is null
  251. </if>
  252. </select>
  253. <select id="findCountByAge1" resultType="java.lang.Long">
  254. select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
  255. where 1=1
  256. <if test=" null != basicInfo.startTime ">
  257. and wcubi.create_date &gt;= #{basicInfo.startTime}
  258. </if>
  259. <if test=" null != basicInfo.endTime">
  260. and wcubi.create_date &lt;= #{basicInfo.endTime}
  261. </if>
  262. <if test=" null != basicInfo.birthStartTime ">
  263. and wcubi.birthdate &gt;= #{basicInfo.birthStartTime}
  264. </if>
  265. <if test=" null != basicInfo.birthEndTime">
  266. and wcubi.birthdate &lt;= #{basicInfo.birthEndTime}
  267. </if>
  268. <if test=" null == basicInfo.birthStartTime and null == basicInfo.birthEndTime">
  269. and wcubi.birthdate is null
  270. </if>
  271. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  272. and wcubi.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  273. </if>
  274. </select>
  275. <select id="findCountByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  276. select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
  277. where 1=1
  278. <if test=" null != finalTenantId and '' != finalTenantId">
  279. and wcubi.`final_tenant_id` = #{finalTenantId}
  280. </if>
  281. <if test=" null != startTime ">
  282. and wcubi.create_date &gt;= #{startTime}
  283. </if>
  284. <if test=" null != endTime">
  285. and wcubi.create_date &lt;= #{endTime}
  286. </if>
  287. <if test=" null != levelStartScore ">
  288. and wcubi.poins &gt;= #{levelStartScore}
  289. </if>
  290. <if test=" null != levelEndScore">
  291. and wcubi.poins &lt; #{levelEndScore}
  292. </if>
  293. <if test=" null == levelStartScore and null == levelEndScore">
  294. and wcubi.poins is null
  295. </if>
  296. </select>
  297. <select id="findCountByScore1" resultType="java.lang.Long">
  298. select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
  299. where 1=1
  300. <if test=" null != basicInfo.startTime ">
  301. and wcubi.create_date &gt;= #{basicInfo.startTime}
  302. </if>
  303. <if test=" null != basicInfo.endTime">
  304. and wcubi.create_date &lt;= #{basicInfo.endTime}
  305. </if>
  306. <if test=" null != basicInfo.levelStartScore ">
  307. and wcubi.poins &gt;= #{basicInfo.levelStartScore}
  308. </if>
  309. <if test=" null != basicInfo.levelEndScore">
  310. and wcubi.poins &lt; #{basicInfo.levelEndScore}
  311. </if>
  312. <if test=" null == basicInfo.levelStartScore and null == basicInfo.levelEndScore">
  313. and wcubi.poins is null
  314. </if>
  315. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  316. and wcubi.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  317. </if>
  318. </select>
  319. <sql id="allColumnsOfScoreList">
  320. distinct cub.id,cub.phone,cub.birthdate,cub.education,cub.sex,cub.email,cub.address,cub.poins,cub.tag_id,
  321. cub.create_date,cub.update_date,cub.name,cub.level,cub.nick_name,cub.score_date,cub.final_tenant_id
  322. </sql>
  323. <select id="findListByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
  324. select <include refid="allColumnsOfScoreList"/>
  325. from wx_c_user_basic_info cub
  326. where cub.status=0
  327. <if test=" null != finalTenantId and '' != finalTenantId">
  328. and cub.`final_tenant_id` = #{finalTenantId}
  329. </if>
  330. <if test=" null != levelStartScore ">
  331. and cub.poins &gt;= #{levelStartScore}
  332. </if>
  333. <if test=" null != levelEndScore">
  334. and cub.poins &lt;= #{levelEndScore}
  335. </if>
  336. <if test=" null == levelStartScore and null == levelEndScore">
  337. and cub.poins is null
  338. </if>
  339. order by cub.`active_time` DESC
  340. </select>
  341. <select id="findListByScore1" resultMap="BaseResultMap">
  342. select <include refid="allColumnsOfScoreList"/>
  343. from wx_c_user_basic_info cub
  344. where cub.status=0
  345. <if test=" null != basicInfo.levelStartScore ">
  346. and cub.poins &gt;= #{basicInfo.levelStartScore}
  347. </if>
  348. <if test=" null != basicInfo.levelEndScore">
  349. and cub.poins &lt;= #{basicInfo.levelEndScore}
  350. </if>
  351. <if test=" null == basicInfo.levelStartScore and null == basicInfo.levelEndScore">
  352. and cub.poins is null
  353. </if>
  354. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  355. and cub.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  356. </if>
  357. order by cub.`active_time` DESC
  358. </select>
  359. <select id="findBirthdayList" resultMap="BaseResultMap">
  360. select <include refid="allColumnsOfScoreList"/>
  361. from wx_c_user_basic_info cub
  362. where cub.status = 0
  363. AND DATE_FORMAT(cub.birthdate,'%m-%d') &gt;= #{begin}
  364. AND DATE_FORMAT(cub.birthdate,'%m-%d') &lt;= #{end}
  365. <if test=" null != finalTenantId and '' != finalTenantId">
  366. and cub.`final_tenant_id` = #{finalTenantId}
  367. </if>
  368. order by cub.`active_time` DESC
  369. </select>
  370. <select id="findBirthdayList1" resultMap="BaseResultMap">
  371. select <include refid="allColumnsOfScoreList"/>
  372. from wx_c_user_basic_info cub
  373. where cub.status = 0
  374. AND DATE_FORMAT(cub.birthdate,'%m-%d') &gt;= #{begin}
  375. AND DATE_FORMAT(cub.birthdate,'%m-%d') &lt;= #{end}
  376. <if test=" null != tenantId and '' != tenantId">
  377. and cub.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  378. </if>
  379. order by cub.`active_time` DESC
  380. </select>
  381. <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  382. select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
  383. where 1=1
  384. <if test=" null != finalTenantId and '' != finalTenantId">
  385. and wcubi.`final_tenant_id` = #{finalTenantId}
  386. </if>
  387. <if test=" null != startTime ">
  388. and wcubi.create_date &gt;= #{startTime}
  389. </if>
  390. <if test=" null != endTime">
  391. and wcubi.create_date &lt; #{endTime}
  392. </if>
  393. <if test="1 == queryImport">
  394. and wcubi.create_date like '%00:00:00'
  395. </if>
  396. </select>
  397. <select id="findCount1" resultType="java.lang.Long">
  398. select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
  399. where 1=1
  400. <if test=" null != basicInfo.startTime ">
  401. and wcubi.create_date &gt;= #{basicInfo.startTime}
  402. </if>
  403. <if test=" null != basicInfo.endTime">
  404. and wcubi.create_date &lt; #{basicInfo.endTime}
  405. </if>
  406. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  407. and wcubi.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  408. </if>
  409. <if test="1 == basicInfo.queryImport">
  410. and wcubi.create_date like '%00:00:00'
  411. </if>
  412. </select>
  413. <select id="findCountHistory" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="com.iformall.domain.vo.UserCountVo">
  414. select count(distinct wcubi.id) as incCount,
  415. <if test="1 == reportType ">
  416. date_format(wcubi.create_date, '%Y-%m-%d') as reportTime,
  417. </if>
  418. <if test="2 == reportType ">
  419. date_format(wcubi.create_date, '%Y-%m') as reportTime,
  420. </if>
  421. <if test="3 == reportType ">
  422. date_format(wcubi.create_date, '%Y') as reportTime,
  423. </if>
  424. <if test="1 == reportType or 2 == reportType or 3 == reportType">
  425. (select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
  426. where
  427. <if test="1 == reportType ">
  428. date_format(wcubi.create_date, '%Y-%m-%d') &lt;= reportTime
  429. </if>
  430. <if test="2 == reportType ">
  431. date_format(wcubi.create_date, '%Y-%m') &lt;= reportTime
  432. </if>
  433. <if test="3 == reportType ">
  434. date_format(wcubi.create_date, '%Y') &lt;= reportTime
  435. </if>
  436. <if test=" null != finalTenantId and '' != finalTenantId">
  437. and wcubi.`final_tenant_id` = #{finalTenantId}
  438. </if>
  439. ) as totalCount
  440. </if>
  441. from wx_c_user_basic_info wcubi
  442. where 1=1
  443. <if test=" null != finalTenantId and '' != finalTenantId">
  444. and wcubi.`final_tenant_id` = #{finalTenantId}
  445. </if>
  446. <if test=" null != startTime ">
  447. and wcubi.create_date &gt;= #{startTime}
  448. </if>
  449. <if test=" null != endTime">
  450. and wcubi.create_date &lt; #{endTime}
  451. </if>
  452. <if test="1 == reportType or 2 == reportType or 3 == reportType">
  453. group by reportTime
  454. </if>
  455. </select>
  456. <select id="findCountHistory1" resultType="com.iformall.domain.vo.UserCountVo">
  457. select count(distinct wcubi.id) as incCount,
  458. <if test="1 == basicInfo.reportType ">
  459. date_format(wcubi.create_date, '%Y-%m-%d') as reportTime,
  460. </if>
  461. <if test="2 == basicInfo.reportType ">
  462. date_format(wcubi.create_date, '%Y-%m') as reportTime,
  463. </if>
  464. <if test="3 == basicInfo.reportType ">
  465. date_format(wcubi.create_date, '%Y') as reportTime,
  466. </if>
  467. <if test="1 == basicInfo.reportType or 2 == basicInfo.reportType or 3 == basicInfo.reportType">
  468. (select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
  469. where
  470. <if test="1 == basicInfo.reportType ">
  471. date_format(wcubi.create_date, '%Y-%m-%d') &lt;= reportTime
  472. </if>
  473. <if test="2 == basicInfo.reportType ">
  474. date_format(wcubi.create_date, '%Y-%m') &lt;= reportTime
  475. </if>
  476. <if test="3 == basicInfo.reportType ">
  477. date_format(wcubi.create_date, '%Y') &lt;= reportTime
  478. </if>
  479. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  480. and wcubi.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  481. </if>
  482. ) as totalCount
  483. </if>
  484. from wx_c_user_basic_info wcubi
  485. where 1=1
  486. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  487. and wcubi.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  488. </if>
  489. <if test=" null != basicInfo.startTime ">
  490. and wcubi.create_date &gt;= #{basicInfo.startTime}
  491. </if>
  492. <if test=" null != basicInfo.endTime">
  493. and wcubi.create_date &lt; #{basicInfo.endTime}
  494. </if>
  495. <if test="1 == basicInfo.reportType or 2 == basicInfo.reportType or 3 == basicInfo.reportType">
  496. group by reportTime
  497. </if>
  498. </select>
  499. <resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.WxCUserBasicInfoVo">
  500. <id column="id" jdbcType="BIGINT" property="id"/>
  501. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  502. <result column="birthdate" jdbcType="TIMESTAMP" property="birthdate"/>
  503. <result column="education" jdbcType="VARCHAR" property="education"/>
  504. <result column="sex" jdbcType="INTEGER" property="sex"/>
  505. <result column="email" jdbcType="VARCHAR" property="email"/>
  506. <result column="address" jdbcType="VARCHAR" property="address"/>
  507. <result column="poins" jdbcType="INTEGER" property="poins"/>
  508. <result column="tag_id" jdbcType="BIGINT" property="tagId"/>
  509. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  510. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  511. <!-- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>-->
  512. <!-- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>-->
  513. <result column="final_tenant_id" jdbcType="VARCHAR" property="finalTenantId"/>
  514. <result column="name" jdbcType="VARCHAR" property="name"/>
  515. <result column="level" jdbcType="VARCHAR" property="level"/>
  516. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  517. <result column="credit" jdbcType="INTEGER" property="credit"/>
  518. <result column="tags" jdbcType="VARCHAR" property="tags"/>
  519. <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/>
  520. </resultMap>
  521. <sql id="allVoColumns">
  522. distinct cu.`id`,cu.`phone`,cu.`birthdate`,cu.`education`,cu.`sex`,cu.`email`,cu.`address`,cu.`poins`,cu.`tag_id`,
  523. cu.`create_date`,cu.`update_date`,cu.`name`,cu.`level`,cu.`nick_name`,
  524. cut.`tags`,cu.`credit`,cu.`active_time`,cu.`act_record`,cu.`final_tenant_id`
  525. </sql>
  526. <sql id="dynamicVoWhereConditions">
  527. where 1 = 1
  528. <if test=" null != id ">
  529. and cu.`id` = #{id}
  530. </if>
  531. <if test=" null != finalTenantId and '' != finalTenantId">
  532. and cu.`final_tenant_id` = #{finalTenantId}
  533. </if>
  534. <if test=" null != phone ">
  535. and cu.`phone` like concat('%', #{phone},'%')
  536. </if>
  537. <if test=" null != birthdate ">
  538. and cu.`birthdate` = #{birthdate}
  539. </if>
  540. <if test=" null != education ">
  541. and cu.`education` like concat('%', #{education},'%')
  542. </if>
  543. <if test=" null != sex ">
  544. and cu.`sex` = #{sex}
  545. </if>
  546. <if test=" null != email ">
  547. and cu.`email` like concat('%', #{email},'%')
  548. </if>
  549. <if test=" null != address ">
  550. and cu.`address` like concat('%', #{address},'%')
  551. </if>
  552. <if test=" null != poins ">
  553. and cu.`poins` = #{poins}
  554. </if>
  555. <if test=" null != tagId ">
  556. and cu.`tag_id` = #{tagId}
  557. </if>
  558. <if test=" null != createDate ">
  559. and cu.`create_date` = #{createDate}
  560. </if>
  561. <if test=" null != updateDate ">
  562. and cu.`update_date` = #{updateDate}
  563. </if>
  564. <if test=" null != actRecord ">
  565. and cu.`act_record` = #{actRecord}
  566. </if>
  567. <if test=" null != name ">
  568. and cu.`name` like concat('%', #{name},'%')
  569. </if>
  570. <if test=" null != startTime and null!=endTime">
  571. and cu.`create_date` between #{startTime} and #{endTime}
  572. </if>
  573. <if test=" null != ids ">
  574. and cu.id in
  575. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  576. #{idItem}
  577. </foreach>
  578. </if>
  579. order by cu.`active_time` DESC
  580. <!--<if test=" null != sortColumns">order by ${sortColumns}</if>-->
  581. </sql>
  582. <sql id="dynamicVoWhereConditions1">
  583. where 1 = 1
  584. <if test=" null != basicInfo.id ">
  585. and cu.`id` = #{basicInfo.id}
  586. </if>
  587. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  588. and cu.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  589. </if>
  590. <if test=" null != basicInfo.phone ">
  591. and cu.`phone` like concat('%', #{basicInfo.phone},'%')
  592. </if>
  593. <if test=" null != basicInfo.birthdate ">
  594. and cu.`birthdate` = #{basicInfo.birthdate}
  595. </if>
  596. <if test=" null != basicInfo.education ">
  597. and cu.`education` like concat('%', #{basicInfo.education},'%')
  598. </if>
  599. <if test=" null != basicInfo.sex ">
  600. and cu.`sex` = #{basicInfo.sex}
  601. </if>
  602. <if test=" null != basicInfo.email ">
  603. and cu.`email` like concat('%', #{basicInfo.email},'%')
  604. </if>
  605. <if test=" null != basicInfo.address ">
  606. and cu.`address` like concat('%', #{basicInfo.address},'%')
  607. </if>
  608. <if test=" null != basicInfo.poins ">
  609. and cu.`poins` = #{basicInfo.poins}
  610. </if>
  611. <if test=" null != basicInfo.tagId ">
  612. and cu.`tag_id` = #{basicInfo.tagId}
  613. </if>
  614. <if test=" null != basicInfo.createDate ">
  615. and cu.`create_date` = #{basicInfo.createDate}
  616. </if>
  617. <if test=" null != basicInfo.updateDate ">
  618. and cu.`update_date` = #{basicInfo.updateDate}
  619. </if>
  620. <if test=" null != basicInfo.actRecord ">
  621. and cu.`act_record` = #{basicInfo.actRecord}
  622. </if>
  623. <if test=" null != basicInfo.name ">
  624. and cu.`name` like concat('%', #{basicInfo.name},'%')
  625. </if>
  626. <if test=" null != basicInfo.startTime and null != basicInfo.endTime">
  627. and cu.`create_date` between #{basicInfo.startTime} and #{basicInfo.endTime}
  628. </if>
  629. <if test=" null != basicInfo.ids ">
  630. and cu.id in
  631. <foreach collection="basicInfo.ids" index="index" item="idItem" open="(" separator="," close=")">
  632. #{idItem}
  633. </foreach>
  634. </if>
  635. order by cu.`active_time` DESC
  636. <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>-->
  637. </sql>
  638. <select id="findVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="VoBaseResultMap">
  639. select
  640. <include refid="allSimpleColumns"/>
  641. from wx_c_user_basic_info cu
  642. <include refid="dynamicVoWhereConditions"/>
  643. <if test=" null != begin ">
  644. limit #{begin}, #{limit}
  645. </if>
  646. </select>
  647. <select id="findVoList1" resultMap="VoBaseResultMap">
  648. select
  649. <include refid="allVoColumns"/>
  650. from wx_c_user_basic_info cu
  651. left join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  652. <include refid="dynamicVoWhereConditions1"/>
  653. <if test=" null != basicInfo.begin ">
  654. limit #{basicInfo.begin}, #{basicInfo.limit}
  655. </if>
  656. </select>
  657. <select id="countVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="java.lang.Integer">
  658. select
  659. count(distinct cu.id)
  660. from wx_c_user_basic_info cu
  661. <include refid="dynamicVoWhereConditions"/>
  662. </select>
  663. <select id="countVoList1" resultType="java.lang.Integer">
  664. select
  665. count(distinct cu.id)
  666. from wx_c_user_basic_info cu
  667. left join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  668. <include refid="dynamicVoWhereConditions1"/>
  669. </select>
  670. <sql id="msgColumns">
  671. distinct cu.`id`,cu.`phone`,cu.`email`
  672. </sql>
  673. <sql id="filterWhereConditions">
  674. where 1=1
  675. <if test=" null != finalTenantId and '' != finalTenantId">
  676. and cu.`final_tenant_id` = #{finalTenantId}
  677. </if>
  678. <if test=" null != startTime ">
  679. and cu.create_date &gt;= #{startTime}
  680. </if>
  681. <if test=" null != endTime">
  682. and cu.create_date &lt;= #{endTime}
  683. </if>
  684. <if test=" null != birthStartTime ">
  685. and cu.birthdate &gt;= #{birthStartTime}
  686. </if>
  687. <if test=" null != birthEndTime">
  688. and cu.birthdate &lt; #{birthEndTime}
  689. </if>
  690. <if test=" null != loginStartTime ">
  691. and cu.active_time &gt;= #{loginStartTime}
  692. </if>
  693. <if test=" null != loginEndTime">
  694. and cu.active_time &lt;= #{loginEndTime}
  695. </if>
  696. <if test=" null != verifiedStartTime and null != verifiedEndTime ">
  697. and 0&lt;
  698. (select count(*) from wx_coupon_order co
  699. where cu.id = co.c_user_id
  700. and co.coupon_order_status = 1
  701. and co.update_date &gt;= #{verifiedStartTime}
  702. and co.update_date &lt;= #{verifiedEndTime})
  703. </if>
  704. <if test=" null != phones">
  705. and cu.phone in (${phones})
  706. </if>
  707. <if test=" null != levelStartScore and (0 != levelStartScore and '' != levelStartScore)">
  708. and cu.poins &gt;= #{levelStartScore}
  709. <if test=" null != levelEndScore">
  710. and cu.poins &lt; #{levelEndScore}
  711. </if>
  712. </if>
  713. <if test=" null != levelStartScore and (0 == levelStartScore or '' == levelStartScore)">
  714. and (cu.poins is null or
  715. (cu.poins &gt;= #{levelStartScore}
  716. <if test=" null != levelEndScore">
  717. and cu.poins &lt; #{levelEndScore}
  718. </if>
  719. ))
  720. </if>
  721. <if test=" null != tagIds ">
  722. and JSON_CONTAINS(JSON_ARRAY(cut.tags),JSON_ARRAY
  723. <foreach collection="tagIds" index="index" item="idItem" open="(" separator="," close=")">
  724. #{idItem}
  725. </foreach>
  726. )
  727. </if>
  728. <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>-->
  729. </sql>
  730. <sql id="filterWhereConditions1">
  731. where 1=1
  732. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  733. and cu.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  734. </if>
  735. <if test=" null != basicInfo.startTime ">
  736. and cu.create_date &gt;= #{basicInfo.startTime}
  737. </if>
  738. <if test=" null != basicInfo.endTime">
  739. and cu.create_date &lt;= #{basicInfo.endTime}
  740. </if>
  741. <if test=" null != basicInfo.birthStartTime ">
  742. and cu.birthdate &gt;= #{basicInfo.birthStartTime}
  743. </if>
  744. <if test=" null != basicInfo.birthEndTime">
  745. and cu.birthdate &lt; #{basicInfo.birthEndTime}
  746. </if>
  747. <if test=" null != basicInfo.loginStartTime ">
  748. and cu.active_time &gt;= #{basicInfo.loginStartTime}
  749. </if>
  750. <if test=" null != basicInfo.loginEndTime">
  751. and cu.active_time &lt;= #{basicInfo.loginEndTime}
  752. </if>
  753. <if test=" null != basicInfo.verifiedStartTime and null != basicInfo.verifiedEndTime ">
  754. and 0&lt;
  755. (select count(*) from wx_coupon_order co
  756. where cu.id = co.c_user_id
  757. and co.coupon_order_status = 1
  758. and co.update_date &gt;= #{basicInfo.verifiedStartTime}
  759. and co.update_date &lt;= #{basicInfo.verifiedEndTime})
  760. </if>
  761. <if test=" null != basicInfo.phones">
  762. and cu.phone in (${basicInfo.phones})
  763. </if>
  764. <if test=" null != basicInfo.levelStartScore and (0 != basicInfo.levelStartScore and '' != basicInfo.levelStartScore)">
  765. and cu.poins &gt;= #{basicInfo.levelStartScore}
  766. <if test=" null != basicInfo.levelEndScore">
  767. and cu.poins &lt; #{basicInfo.levelEndScore}
  768. </if>
  769. </if>
  770. <if test=" null != basicInfo.levelStartScore and (0 == basicInfo.levelStartScore or '' == basicInfo.levelStartScore)">
  771. and (cu.poins is null or
  772. (cu.poins &gt;= #{basicInfo.levelStartScore}
  773. <if test=" null != basicInfo.levelEndScore">
  774. and cu.poins &lt; #{basicInfo.levelEndScore}
  775. </if>
  776. ))
  777. </if>
  778. <if test=" null != basicInfo.tagIds ">
  779. and JSON_CONTAINS(JSON_ARRAY(cut.tags),JSON_ARRAY
  780. <foreach collection="basicInfo.tagIds" index="index" item="idItem" open="(" separator="," close=")">
  781. #{idItem}
  782. </foreach>
  783. )
  784. </if>
  785. <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>-->
  786. </sql>
  787. <select id="findCountByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  788. select count(distinct cu.id) from wx_c_user_basic_info cu
  789. <if test=" null != tagIds ">
  790. join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  791. </if>
  792. <include refid="filterWhereConditions"/>
  793. </select>
  794. <select id="findCountByFilter1" resultType="java.lang.Long">
  795. select count(distinct cu.id) from wx_c_user_basic_info cu
  796. <if test=" null != basicInfo.tagIds ">
  797. join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  798. </if>
  799. <include refid="filterWhereConditions1"/>
  800. </select>
  801. <select id="findListByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
  802. select <include refid="msgColumns"/>
  803. from wx_c_user_basic_info cu
  804. <if test=" null != tagIds ">
  805. join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  806. </if>
  807. <include refid="filterWhereConditions"/>
  808. </select>
  809. <select id="findListByFilter1" resultMap="BaseResultMap">
  810. select <include refid="msgColumns"/>
  811. from wx_c_user_basic_info cu
  812. <if test=" null != basicInfo.tagIds ">
  813. join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  814. </if>
  815. <include refid="filterWhereConditions1"/>
  816. </select>
  817. <!-- <select id="findImportUserCount" resultType="java.lang.Long">
  818. SELECT count(distinct cubi.id) FROM wx_c_user_basic_info cubi
  819. left join wx_c_user cu on cubi.id=cu.user_id
  820. where cu.id is null
  821. <if test=" null != finalTenantId and '' != finalTenantId">
  822. and cubi.`final_tenant_id` = #{finalTenantId}
  823. </if>
  824. </select>
  825. <select id="findImportUserCount1" resultType="java.lang.Long">
  826. SELECT count(distinct cubi.id) FROM wx_c_user_basic_info cubi
  827. left join wx_c_user cu on cubi.id=cu.user_id
  828. where cu.id is null
  829. <if test=" null != tenantId and '' != tenantId">
  830. and cubi.`tenant_id` like concat('%,', #{tenantInfo.tenantId},',%')
  831. </if>
  832. </select> -->
  833. <select id="findGrowUserCount" resultType="java.lang.Long">
  834. SELECT count(distinct cubi.id) FROM wx_c_user_basic_info cubi
  835. left join wx_c_user cu on cubi.id=cu.user_id
  836. where cu.id is not null
  837. <if test=" null != finalTenantId and '' != finalTenantId">
  838. and cubi.`final_tenant_id` = #{finalTenantId}
  839. </if>
  840. </select>
  841. <select id="findGrowUserCount1" resultType="java.lang.Long">
  842. SELECT count(distinct cubi.id) FROM wx_c_user_basic_info cubi
  843. left join wx_c_user cu on cubi.id=cu.user_id
  844. where cu.id is not null
  845. <if test=" null != tenantId and '' != tenantId">
  846. and cubi.`tenant_id` like concat('%,', #{tenantId},',%')
  847. </if>
  848. </select>
  849. <update id="incActRecordById" parameterType="java.lang.Long">
  850. UPDATE wx_c_user_basic_info set act_record = act_record +1 where id = #{id}
  851. </update>
  852. <!--<select id="selectNotCUserList" resultMap="BaseResultMap">
  853. select id,credit from wx_c_user_basic_info cub where not exists (select * from wx_c_user c where c.user_id=cub.id) and cub.credit is null
  854. </select>-->
  855. <update id="cuserOldToNew" statementType="CALLABLE" >
  856. {call cuser_old_to_new(#{oldCuserId},#{newCuserId})}
  857. </update>
  858. </mapper>