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

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