Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

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