Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

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