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

590 строки
22 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="name" jdbcType="VARCHAR" property="name"/>
  19. <result column="level" jdbcType="VARCHAR" property="level"/>
  20. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  21. <result column="credit" jdbcType="INTEGER" property="credit"/>
  22. <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/>
  23. <result column="act_record" jdbcType="INTEGER" property="actRecord"/>
  24. <result column="score_date" jdbcType="TIMESTAMP" property="scoreDate"/>
  25. <result column="status" jdbcType="INTEGER" property="status"/>
  26. </resultMap>
  27. <sql id="allColumns">
  28. `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,
  29. `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`name`,`nick_name`,`credit`,`active_time`,`act_record`
  30. ,(select level from wx_level_config
  31. where poins >= points and tenant_id=wcubi.tenant_id
  32. order by points desc limit 1 ) level,status
  33. </sql>
  34. <sql id="allSimpleColumns">
  35. `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,
  36. `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`name`,`nick_name`,`credit`,`active_time`,`act_record`
  37. </sql>
  38. <sql id="dynamicWhereConditions">
  39. where 1 = 1
  40. <if test=" null != id ">
  41. and `id` = #{id}
  42. </if>
  43. <if test=" null != tenantId and '' != tenantId">
  44. and `tenant_id` = #{tenantId}
  45. </if>
  46. <if test=" null != parentTenantId and '' != parentTenantId">
  47. and `parent_tenant_id` = #{parentTenantId}
  48. </if>
  49. <if test=" null != phone ">
  50. and `phone` like concat('%', #{phone},'%')
  51. </if>
  52. <if test=" null != birthdate ">
  53. and `birthdate` = #{birthdate}
  54. </if>
  55. <if test=" null != education ">
  56. and `education` like concat('%', #{education},'%')
  57. </if>
  58. <if test=" null != sex ">
  59. and `sex` = #{sex}
  60. </if>
  61. <if test=" null != email ">
  62. and `email` like concat('%', #{email},'%')
  63. </if>
  64. <if test=" null != address ">
  65. and `address` like concat('%', #{address},'%')
  66. </if>
  67. <if test=" null != poins ">
  68. and `poins` = #{poins}
  69. </if>
  70. <if test=" null != credit ">
  71. and `credit` = #{credit}
  72. </if>
  73. <if test=" null != tagId ">
  74. and `tag_id` = #{tagId}
  75. </if>
  76. <if test=" null != createDate ">
  77. and `create_date` = #{createDate}
  78. </if>
  79. <if test=" null != updateDate ">
  80. and `update_date` = #{updateDate}
  81. </if>
  82. <if test=" null != actRecord ">
  83. and `act_record` = #{actRecord}
  84. </if>
  85. <if test=" null != name ">
  86. and `name` like concat('%', #{name},'%')
  87. </if>
  88. <if test=" null != startTime and null!=endTime">
  89. and `create_date` between #{startTime} and #{endTime}
  90. </if>
  91. <if test=" null != status ">
  92. and `status` = #{status}
  93. </if>
  94. <if test=" null != ids ">
  95. and id in
  96. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  97. #{idItem}
  98. </foreach>
  99. </if>
  100. <if test=" null != sortColumns">order by ${sortColumns}</if>
  101. </sql>
  102. <select id="findList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap">
  103. select r.* from (
  104. select
  105. <include refid="allColumns"/>
  106. from wx_c_user_basic_info wcubi
  107. <include refid="dynamicWhereConditions"/>
  108. ) r where 1=1
  109. <if test="null != level and '' != level">
  110. and r.level =#{level}
  111. </if>
  112. </select>
  113. <sql id="allUserColumns">
  114. c.`id`,c.`phone`,cb.`birthdate`,cb.`education`,cb.`sex`,cb.`email`,cb.`address`,cb.`poins`,cb.`tag_id`,
  115. cb.`create_date`,cb.`update_date`,c.`tenant_id`,cb.`name`,cb.`level`,cb.`nick_name`,cb.`act_record`,cb.`parent_tenant_id`
  116. </sql>
  117. <update id="updateScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo">
  118. update wx_c_user_basic_info set poins=#{poins}
  119. where phone=#{phone}
  120. and id=#{id}
  121. </update>
  122. <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserBaseVo">
  123. update wx_c_user_basic_info set id=#{newId} , credit=#{credit} , poins=#{poins}
  124. where id = #{id}
  125. </update>
  126. <select id="findCountBySex" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  127. select count(id) from wx_c_user_basic_info
  128. where sex =#{sex}
  129. <if test=" null != startTime ">
  130. and create_date &gt;= #{startTime}
  131. </if>
  132. <if test=" null != endTime">
  133. and create_date &lt;= #{endTime}
  134. </if>
  135. <if test=" null != tenantId and '' != tenantId">
  136. and `tenant_id` = #{tenantId}
  137. </if>
  138. <if test=" null != parentTenantId and '' != parentTenantId">
  139. and `parent_tenant_id` = #{parentTenantId}
  140. </if>
  141. </select>
  142. <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  143. select count(id) from wx_c_user_basic_info where 1=1
  144. <if test=" null != startTime ">
  145. and create_date &gt;= #{startTime}
  146. </if>
  147. <if test=" null != endTime">
  148. and create_date &lt;= #{endTime}
  149. </if>
  150. <if test=" null != birthStartTime ">
  151. and birthdate &gt;= #{birthStartTime}
  152. </if>
  153. <if test=" null != birthEndTime">
  154. and birthdate &lt;= #{birthEndTime}
  155. </if>
  156. <if test=" null == birthStartTime and null == birthEndTime">
  157. and birthdate is null
  158. </if>
  159. <if test=" null != tenantId and '' != tenantId">
  160. and `tenant_id` = #{tenantId}
  161. </if>
  162. <if test=" null != parentTenantId and '' != parentTenantId">
  163. and `parent_tenant_id` = #{parentTenantId}
  164. </if>
  165. </select>
  166. <select id="findCountByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  167. select count(id) from wx_c_user_basic_info where 1=1
  168. <if test=" null != startTime ">
  169. and create_date &gt;= #{startTime}
  170. </if>
  171. <if test=" null != endTime">
  172. and create_date &lt;= #{endTime}
  173. </if>
  174. <if test=" null != levelStartScore ">
  175. and poins &gt;= #{levelStartScore}
  176. </if>
  177. <if test=" null != levelEndScore">
  178. and poins &lt; #{levelEndScore}
  179. </if>
  180. <if test=" null == levelStartScore and null == levelEndScore">
  181. and poins is null
  182. </if>
  183. <if test=" null != tenantId and '' != tenantId">
  184. and `tenant_id` = #{tenantId}
  185. </if>
  186. <if test=" null != parentTenantId and '' != parentTenantId">
  187. and `parent_tenant_id` = #{parentTenantId}
  188. </if>
  189. </select>
  190. <sql id="allColumnsOfScoreList">
  191. cub.id,cub.phone,cub.birthdate,cub.education,cub.sex,cub.email,cub.address,cub.poins,cub.tag_id,
  192. cub.create_date,cub.update_date,cub.tenant_id,cub.name,cub.level,cub.nick_name,cub.score_date,cub.parent_tenant_id
  193. </sql>
  194. <select id="findListByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
  195. select <include refid="allColumnsOfScoreList"/>
  196. from wx_c_user_basic_info cub
  197. inner join wx_c_user cu on cu.id = cub.id
  198. where 1=1 and cub.status=0
  199. <if test=" null != levelStartScore ">
  200. and cub.poins &gt;= #{levelStartScore}
  201. </if>
  202. <if test=" null != levelEndScore">
  203. and cub.poins &lt;= #{levelEndScore}
  204. </if>
  205. <if test=" null == levelStartScore and null == levelEndScore">
  206. and cub.poins is null
  207. </if>
  208. <if test=" null != tenantId and '' != tenantId">
  209. and cub.`tenant_id` = #{tenantId}
  210. </if>
  211. <if test=" null != parentTenantId and '' != parentTenantId">
  212. and cub.`parent_tenant_id` = #{parentTenantId}
  213. </if>
  214. </select>
  215. <select id="findBirthdayList" resultMap="BaseResultMap">
  216. select <include refid="allColumnsOfScoreList"/>
  217. from wx_c_user_basic_info cub
  218. inner join wx_c_user cu on cu.id = cub.id
  219. where cub.status = 0 and cu.phone is not null
  220. AND DATE_FORMAT(cub.birthdate,'%m-%d') &gt;= #{begin}
  221. AND DATE_FORMAT(cub.birthdate,'%m-%d') &lt;= #{end}
  222. <if test=" null != tenantId and '' != tenantId">
  223. and cub.`tenant_id` = #{tenantId}
  224. </if>
  225. <if test=" null != parentTenantId and '' != parentTenantId">
  226. and cub.`parent_tenant_id` = #{parentTenantId}
  227. </if>
  228. </select>
  229. <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  230. select count(id) from wx_c_user_basic_info where 1=1
  231. <if test=" null != startTime ">
  232. and create_date &gt;= #{startTime}
  233. </if>
  234. <if test=" null != endTime">
  235. and create_date &lt; #{endTime}
  236. </if>
  237. <if test=" null != tenantId and '' != tenantId">
  238. and `tenant_id` = #{tenantId}
  239. </if>
  240. <if test=" null != parentTenantId and '' != parentTenantId">
  241. and `parent_tenant_id` = #{parentTenantId}
  242. </if>
  243. <if test="1 == queryImport">
  244. and create_date like '%00:00:00'
  245. </if>
  246. </select>
  247. <select id="findCountHistory" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="com.iformall.domain.vo.UserCountVo">
  248. select count(id) as incCount,
  249. <if test="1 == reportType ">
  250. date_format(create_date, '%Y-%m-%d') as reportTime,
  251. </if>
  252. <if test="2 == reportType ">
  253. date_format(create_date, '%Y-%m') as reportTime,
  254. </if>
  255. <if test="3 == reportType ">
  256. date_format(create_date, '%Y') as reportTime,
  257. </if>
  258. <if test="1 == reportType or 2 == reportType or 3 == reportType">
  259. (select count(id) from wx_c_user_basic_info
  260. where
  261. <if test="1 == reportType ">
  262. date_format(create_date, '%Y-%m-%d') &lt;= reportTime
  263. </if>
  264. <if test="2 == reportType ">
  265. date_format(create_date, '%Y-%m') &lt;= reportTime
  266. </if>
  267. <if test="3 == reportType ">
  268. date_format(create_date, '%Y') &lt;= reportTime
  269. </if>
  270. <if test=" null != tenantId and '' != tenantId">
  271. and `tenant_id` = #{tenantId}
  272. </if>
  273. <if test=" null != parentTenantId and '' != parentTenantId">
  274. and `parent_tenant_id` = #{parentTenantId}
  275. </if>
  276. ) as totalCount
  277. </if>
  278. from wx_c_user_basic_info where 1=1
  279. <if test=" null != tenantId and '' != tenantId">
  280. and `tenant_id` = #{tenantId}
  281. </if>
  282. <if test=" null != parentTenantId and '' != parentTenantId">
  283. and `parent_tenant_id` = #{parentTenantId}
  284. </if>
  285. <if test=" null != startTime ">
  286. and create_date &gt;= #{startTime}
  287. </if>
  288. <if test=" null != endTime">
  289. and create_date &lt; #{endTime}
  290. </if>
  291. <if test="1 == reportType or 2 == reportType or 3 == reportType">
  292. group by reportTime
  293. </if>
  294. </select>
  295. <resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.WxCUserBasicInfoVo">
  296. <id column="id" jdbcType="BIGINT" property="id"/>
  297. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  298. <result column="birthdate" jdbcType="TIMESTAMP" property="birthdate"/>
  299. <result column="education" jdbcType="VARCHAR" property="education"/>
  300. <result column="sex" jdbcType="INTEGER" property="sex"/>
  301. <result column="email" jdbcType="VARCHAR" property="email"/>
  302. <result column="address" jdbcType="VARCHAR" property="address"/>
  303. <result column="poins" jdbcType="INTEGER" property="poins"/>
  304. <result column="tag_id" jdbcType="BIGINT" property="tagId"/>
  305. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  306. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  307. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  308. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  309. <result column="name" jdbcType="VARCHAR" property="name"/>
  310. <result column="level" jdbcType="VARCHAR" property="level"/>
  311. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  312. <result column="credit" jdbcType="INTEGER" property="credit"/>
  313. <result column="tags" jdbcType="VARCHAR" property="tags"/>
  314. <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/>
  315. </resultMap>
  316. <sql id="allVoColumns">
  317. cu.`id`,cu.`phone`,cu.`birthdate`,cu.`education`,cu.`sex`,cu.`email`,cu.`address`,cu.`poins`,cu.`tag_id`,
  318. cu.`create_date`,cu.`update_date`,cu.`tenant_id`,cu.`name`,cu.`level`,cu.`nick_name`,
  319. cut.`tags`,cu.`credit`,cu.`active_time`,cu.`act_record`,cu.`parent_tenant_id`
  320. </sql>
  321. <sql id="dynamicVoWhereConditions">
  322. where 1 = 1
  323. <if test=" null != id ">
  324. and cu.`id` = #{id}
  325. </if>
  326. <if test=" null != tenantId and '' != tenantId">
  327. and cu.`tenant_id` = #{tenantId}
  328. </if>
  329. <if test=" null != parentTenantId and '' != parentTenantId">
  330. and cu.`parent_tenant_id` = #{parentTenantId}
  331. </if>
  332. <if test=" null != phone ">
  333. and cu.`phone` like concat('%', #{phone},'%')
  334. </if>
  335. <if test=" null != birthdate ">
  336. and cu.`birthdate` = #{birthdate}
  337. </if>
  338. <if test=" null != education ">
  339. and cu.`education` like concat('%', #{education},'%')
  340. </if>
  341. <if test=" null != sex ">
  342. and cu.`sex` = #{sex}
  343. </if>
  344. <if test=" null != email ">
  345. and cu.`email` like concat('%', #{email},'%')
  346. </if>
  347. <if test=" null != address ">
  348. and cu.`address` like concat('%', #{address},'%')
  349. </if>
  350. <if test=" null != poins ">
  351. and cu.`poins` = #{poins}
  352. </if>
  353. <if test=" null != tagId ">
  354. and cu.`tag_id` = #{tagId}
  355. </if>
  356. <if test=" null != createDate ">
  357. and cu.`create_date` = #{createDate}
  358. </if>
  359. <if test=" null != updateDate ">
  360. and cu.`update_date` = #{updateDate}
  361. </if>
  362. <if test=" null != actRecord ">
  363. and cu.`act_record` = #{actRecord}
  364. </if>
  365. <if test=" null != name ">
  366. and `name` like concat('%', #{name},'%')
  367. </if>
  368. <if test=" null != startTime and null!=endTime">
  369. and cu.`create_date` between #{startTime} and #{endTime}
  370. </if>
  371. <if test=" null != ids ">
  372. and id in
  373. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  374. #{idItem}
  375. </foreach>
  376. </if>
  377. <if test=" null != sortColumns">order by ${sortColumns}</if>
  378. </sql>
  379. <select id="findVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="VoBaseResultMap">
  380. select
  381. <include refid="allSimpleColumns"/>
  382. from wx_c_user_basic_info cu
  383. <include refid="dynamicVoWhereConditions"/>
  384. <if test=" null != begin ">
  385. limit #{begin}, #{limit}
  386. </if>
  387. </select>
  388. <select id="countVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="java.lang.Integer">
  389. select
  390. count(1)
  391. from wx_c_user_basic_info cu
  392. <include refid="dynamicVoWhereConditions"/>
  393. </select>
  394. <sql id="msgColumns">
  395. cu.`id`,cu.`phone`,cu.`email`
  396. </sql>
  397. <sql id="filterWhereConditions">
  398. where 1=1
  399. <if test=" null != tenantId and '' != tenantId">
  400. and cu.`tenant_id` = #{tenantId}
  401. </if>
  402. <if test=" null != parentTenantId and '' != parentTenantId">
  403. and cu.`parent_tenant_id` = #{parentTenantId}
  404. </if>
  405. <if test=" null != startTime ">
  406. and cu.create_date &gt;= #{startTime}
  407. </if>
  408. <if test=" null != endTime">
  409. and cu.create_date &lt;= #{endTime}
  410. </if>
  411. <if test=" null != birthStartTime ">
  412. and cu.birthdate &gt;= #{birthStartTime}
  413. </if>
  414. <if test=" null != birthEndTime">
  415. and cu.birthdate &lt; #{birthEndTime}
  416. </if>
  417. <if test=" null != loginStartTime ">
  418. and cu.active_time &gt;= #{loginStartTime}
  419. </if>
  420. <if test=" null != loginEndTime">
  421. and cu.active_time &lt;= #{loginEndTime}
  422. </if>
  423. <if test=" null != verifiedStartTime and null != verifiedEndTime ">
  424. and 0&lt;
  425. (select count(*) from wx_coupon_order co
  426. where cu.id = co.c_user_id
  427. and co.coupon_order_status = 1
  428. and co.update_date &gt;= #{verifiedStartTime}
  429. and co.update_date &lt;= #{verifiedEndTime})
  430. </if>
  431. <if test=" null != phones">
  432. and cu.phone in (${phones})
  433. </if>
  434. <if test=" null != levelStartScore and (0 != levelStartScore and '' != levelStartScore)">
  435. and cu.poins &gt;= #{levelStartScore}
  436. <if test=" null != levelEndScore">
  437. and cu.poins &lt; #{levelEndScore}
  438. </if>
  439. </if>
  440. <if test=" null != levelStartScore and (0 == levelStartScore or '' == levelStartScore)">
  441. and (cu.poins is null or
  442. (cu.poins &gt;= #{levelStartScore}
  443. <if test=" null != levelEndScore">
  444. and cu.poins &lt; #{levelEndScore}
  445. </if>
  446. ))
  447. </if>
  448. <if test=" null != tagIds ">
  449. and JSON_CONTAINS(JSON_ARRAY(cut.tags),JSON_ARRAY
  450. <foreach collection="tagIds" index="index" item="idItem" open="(" separator="," close=")">
  451. #{idItem}
  452. </foreach>
  453. )
  454. </if>
  455. <if test=" null != sortColumns">order by ${sortColumns}</if>
  456. </sql>
  457. <select id="findCountByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  458. select count(*) from wx_c_user_basic_info cu
  459. <if test=" null != tagIds ">
  460. join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  461. </if>
  462. <include refid="filterWhereConditions"/>
  463. </select>
  464. <select id="findListByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
  465. select <include refid="msgColumns"/>
  466. from wx_c_user_basic_info cu
  467. <if test=" null != tagIds ">
  468. join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  469. </if>
  470. <include refid="filterWhereConditions"/>
  471. </select>
  472. <select id="findImportUserCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  473. SELECT count(*) FROM wx_c_user_basic_info cubi left join wx_c_user cu on cubi.id=cu.id where cu.id is null
  474. <if test=" null != tenantId and '' != tenantId">
  475. and cubi.`tenant_id` = #{tenantId}
  476. </if>
  477. <if test=" null != parentTenantId and '' != parentTenantId">
  478. and cubi.`parent_tenant_id` = #{parentTenantId}
  479. </if>
  480. </select>
  481. <select id="findGrowUserCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  482. SELECT count(*) FROM wx_c_user_basic_info cubi left join wx_c_user cu on cubi.id=cu.id where cu.id is not null
  483. <if test=" null != tenantId and '' != tenantId">
  484. and cubi.`tenant_id` = #{tenantId}
  485. </if>
  486. <if test=" null != parentTenantId and '' != parentTenantId">
  487. and cubi.`parent_tenant_id` = #{parentTenantId}
  488. </if>
  489. </select>
  490. <update id="incActRecordById" parameterType="java.lang.Long">
  491. UPDATE wx_c_user_basic_info set act_record = act_record +1 where id = #{id}
  492. </update>
  493. <select id="selectNotCUserList" resultMap="BaseResultMap">
  494. select id,credit from wx_c_user_basic_info cub where not exists (select * from wx_c_user c where c.id=cub.id) and cub.credit is null
  495. </select>
  496. </mapper>