No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

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