You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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