后台服务
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

448 lignes
17 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.TtCUserMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.tt.TtCUser">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="user_id" jdbcType="BIGINT" property="userId"/>
  7. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  8. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  9. <result column="open_id" jdbcType="VARCHAR" property="openId"/>
  10. <result column="union_id" jdbcType="VARCHAR" property="unionId"/>
  11. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  12. <result column="gender" jdbcType="INTEGER" property="gender"/>
  13. <result column="avatar_url" jdbcType="VARCHAR" property="avatarUrl"/>
  14. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  15. <result column="pure_phone" jdbcType="VARCHAR" property="purePhone"/>
  16. <result column="city" jdbcType="VARCHAR" property="city"/>
  17. <result column="province" jdbcType="VARCHAR" property="province"/>
  18. <result column="language" jdbcType="VARCHAR" property="language"/>
  19. <result column="country_code" jdbcType="VARCHAR" property="countryCode"/>
  20. <result column="register_ip" jdbcType="VARCHAR" property="registerIp"/>
  21. <result column="verify_code_phone" jdbcType="VARCHAR" property="verifyCodePhone"/>
  22. <result column="qrcode_source" jdbcType="VARCHAR" property="qrcodeSource"/>
  23. <result column="scene" jdbcType="VARCHAR" property="scene"/>
  24. <result column="scene_address" jdbcType="VARCHAR" property="sceneAddress"/>
  25. <result column="session_key" jdbcType="VARCHAR" property="sessionKey"/>
  26. <result column="score" jdbcType="INTEGER" property="score"/>
  27. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  28. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  29. <result column="app_id" jdbcType="VARCHAR" property="appId"/>
  30. <result column="token" jdbcType="VARCHAR" property="token"/>
  31. <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime"/>
  32. <result column="latitude" jdbcType="DECIMAL" property="latitude"/>
  33. <result column="longitude" jdbcType="DECIMAL" property="longitude"/>
  34. <result column="login_count" jdbcType="INTEGER" property="loginCount"/>
  35. <result column="extra_info" jdbcType="VARCHAR" property="extraInfo"/>
  36. <result column="is_subscribe" jdbcType="TINYINT" property="isSubscribe"/>
  37. <result column="open_app_id" jdbcType="VARCHAR" property="openAppId"/>
  38. <result column="mp_open_id" jdbcType="VARCHAR" property="mpOpenId"/>
  39. <result column="mp_app_id" jdbcType="VARCHAR" property="mpAppId"/>
  40. <result column="mp_subscribe" jdbcType="TINYINT" property="mpSubscribe"/>
  41. <result column="mp_subscribe_time" jdbcType="TIMESTAMP" property="mpSubscribeTime"/>
  42. <result column="mp_subscribe_scene" jdbcType="VARCHAR" property="mpSubscribeScene"/>
  43. <result column="subs_open_id" jdbcType="VARCHAR" property="subsOpenId"/>
  44. <result column="subs_app_id" jdbcType="VARCHAR" property="subsAppId"/>
  45. <result column="subs_subscribe" jdbcType="TINYINT" property="subsSubscribe"/>
  46. <result column="subs_subscribe_time" jdbcType="TIMESTAMP" property="subsSubscribeTime"/>
  47. <result column="subs_subscribe_scene" jdbcType="VARCHAR" property="subsSubscribeScene"/>
  48. <result column="credit" jdbcType="INTEGER" property="credit"/>
  49. <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/>
  50. <result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
  51. </resultMap>
  52. <sql id="allColumns">
  53. `id`,`user_id`,`tenant_id`,`parent_tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`,
  54. `city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`,
  55. `qrcode_source`,`scene`,`scene_address`,`session_key`,`score`,
  56. `update_date`,`create_date`,`app_id`,`token`,`expire_time`,`latitude`, `longitude`,
  57. `login_count`, `extra_info`, `is_subscribe`,
  58. `open_app_id`,
  59. `mp_open_id`,`mp_app_id`,`mp_subscribe`,`mp_subscribe_time`,`mp_subscribe_scene`,
  60. `subs_open_id`,`subs_app_id`,`subs_subscribe`,`subs_subscribe_time`,`subs_subscribe_scene`,`credit`,`active_time`,`qr_code`
  61. </sql>
  62. <sql id="dynamicWhereConditions">
  63. where 1 = 1
  64. <if test=" null != id ">
  65. and `id` = #{id}
  66. </if>
  67. <if test=" null != userId ">
  68. and `user_id` = #{userId}
  69. </if>
  70. <if test=" null != tenantId and '' != tenantId">
  71. and `tenant_id` = #{tenantId}
  72. </if>
  73. <if test=" null != parentTenantId and '' != parentTenantId">
  74. and `parent_tenant_id` = #{parentTenantId}
  75. </if>
  76. <if test=" null != openId ">
  77. and `open_id` = #{openId}
  78. </if>
  79. <if test=" null != unionId ">
  80. and `union_id` = #{unionId}
  81. </if>
  82. <if test=" null != nickName ">
  83. and `nick_name` like concat('%', #{nickName},'%')
  84. </if>
  85. <if test=" null != gender ">
  86. and `gender` = #{gender}
  87. </if>
  88. <if test=" null != avatarUrl ">
  89. and `avatar_url` like concat('%', #{avatarUrl},'%')
  90. </if>
  91. <if test=" null != phone ">
  92. and `phone` like concat('%', #{phone},'%')
  93. </if>
  94. <if test=" null != purePhone ">
  95. and `pure_phone` like concat('%', #{purePhone},'%')
  96. </if>
  97. <if test=" null != city ">
  98. and `city` like concat('%', #{city},'%')
  99. </if>
  100. <if test=" null != province ">
  101. and `province` like concat('%', #{province},'%')
  102. </if>
  103. <if test=" null != language ">
  104. and `language` like concat('%', #{language},'%')
  105. </if>
  106. <if test=" null != countryCode ">
  107. and `country_code` like concat('%', #{countryCode},'%')
  108. </if>
  109. <if test=" null != registerIp ">
  110. and `register_ip` like concat('%', #{registerIp},'%')
  111. </if>
  112. <if test=" null != verifyCodePhone ">
  113. and `verify_code_phone` like concat('%', #{verifyCodePhone},'%')
  114. </if>
  115. <if test=" null != qrcodeSource ">
  116. and `qrcode_source` like concat('%', #{qrcodeSource},'%')
  117. </if>
  118. <if test=" null != scene ">
  119. and `scene` like concat('%', #{scene},'%')
  120. </if>
  121. <if test=" null != sceneAddress ">
  122. and `scene_address` like concat('%', #{sceneAddress},'%')
  123. </if>
  124. <if test=" null != sessionKey ">
  125. and `session_key` like concat('%', #{sessionKey},'%')
  126. </if>
  127. <if test=" null != score ">
  128. and `score` = #{score}
  129. </if>
  130. <if test=" null != updateDate ">
  131. and `update_date` = #{updateDate}
  132. </if>
  133. <if test=" null != createDate ">
  134. and `create_date` = #{createDate}
  135. </if>
  136. <if test=" null != appId ">
  137. and `app_id` like concat('%', #{appId},'%')
  138. </if>
  139. <if test=" null != token ">
  140. and `token` like concat('%', #{token},'%')
  141. </if>
  142. <if test=" null != expireTime ">
  143. and `expire_time` = #{expireTime}
  144. </if>
  145. <if test=" null != latitude ">
  146. and `latitude` = #{latitude}
  147. </if>
  148. <if test=" null != longitude ">
  149. and `longitude` = #{longitude}
  150. </if>
  151. <if test=" null != loginCount ">
  152. and `login_count` = #{loginCount}
  153. </if>
  154. <if test=" null != extraInfo ">
  155. and `extra_info` = #{extraInfo}
  156. </if>
  157. <if test=" null != isSubscribe ">
  158. and `is_subscribe` = #{isSubscribe}
  159. </if>
  160. <if test=" null != openAppId ">
  161. and `open_app_id` = #{openAppId}
  162. </if>
  163. <if test=" null != mpOpenId ">
  164. and `mp_open_id` = #{mpOpenId}
  165. </if>
  166. <if test=" null != mpAppId ">
  167. and `mp_app_id` = #{mpAppId}
  168. </if>
  169. <if test=" null != subsOpenId ">
  170. and `subs_open_id` = #{subsOpenId}
  171. </if>
  172. <if test=" null != subsAppId ">
  173. and `subs_app_id` = #{subsAppId}
  174. </if>
  175. <if test=" null != credit ">
  176. and `credit` = #{credit}
  177. </if>
  178. <if test=" null != ids ">
  179. and id in
  180. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  181. #{idItem}
  182. </foreach>
  183. </if>
  184. <if test=" null != sortColumns">order by ${sortColumns}</if>
  185. </sql>
  186. <select id="findList" parameterType="com.iformall.domain.po.tt.TtCUser" resultMap="BaseResultMap">
  187. select
  188. <include refid="allColumns"/>
  189. from tt_c_user
  190. <include refid="dynamicWhereConditions"/>
  191. </select>
  192. <select id="listOpenId" parameterType="com.iformall.domain.po.tt.TtCUser" resultType="String">
  193. select open_id
  194. from tt_c_user
  195. where msg_count &gt;= 10
  196. <if test=" null != tenantId and '' != tenantId">
  197. and `tenant_id` = #{tenantId}
  198. </if>
  199. <if test=" null != parentTenantId and '' != parentTenantId">
  200. and `parent_tenant_id` = #{parentTenantId}
  201. </if>
  202. <if test=" null != userIds ">
  203. and user_id in
  204. <foreach collection="userIds" index="index" item="userIdItem" open="(" separator="," close=")">
  205. #{userIdItem}
  206. </foreach>
  207. </if>
  208. </select>
  209. <update id="updateMsgCount" parameterType="com.iformall.domain.po.tt.TtCUser">
  210. update tt_c_user
  211. set msg_count = msg_count+2
  212. where msg_count &lt; 10
  213. <if test=" null != id ">
  214. and `id` = #{id}
  215. </if>
  216. <if test=" null != openId ">
  217. and `open_id` = #{openId}
  218. </if>
  219. <if test=" null != tenantId and '' != tenantId">
  220. and `tenant_id` = #{tenantId}
  221. </if>
  222. <if test=" null != parentTenantId and '' != parentTenantId">
  223. and `parent_tenant_id` = #{parentTenantId}
  224. </if>
  225. </update>
  226. <!-- <update id="updateMsgCountDown">-->
  227. <!-- update tt_c_user set msg_count = msg_count-1-->
  228. <!-- where msg_count &gt; 0-->
  229. <!-- <if test=" null != tenantId and '' != tenantId">-->
  230. <!-- and `tenant_id` = #{tenantId}-->
  231. <!-- </if>-->
  232. <!-- and `open_id` = #{openId}-->
  233. <!-- </update>-->
  234. <select id="findByOpenId" parameterType="com.iformall.domain.po.tt.TtCUser" resultMap="BaseResultMap">
  235. select <include refid="allColumns"/>
  236. from tt_c_user
  237. where `open_id` = #{openId}
  238. <if test=" null != appId and '' != appId">
  239. and `app_id` = #{appId}
  240. </if>
  241. </select>
  242. <select id="findByUnionId" parameterType="com.iformall.domain.po.tt.TtCUser" resultMap="BaseResultMap">
  243. select <include refid="allColumns"/>
  244. from tt_c_user
  245. where `open_app_id` = #{openAppId} and `union_id` = #{unionId}
  246. </select>
  247. <select id="findByToken" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  248. select <include refid="allColumns"/>
  249. from tt_c_user
  250. where `token` = #{token} and `tenant_id` = #{tenantId}
  251. </select>
  252. <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  253. select <include refid="allColumns"/>
  254. from tt_c_user
  255. where id = #{id}
  256. and `tenant_id` = #{tenantId}
  257. </select>
  258. <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  259. select count(id)
  260. from tt_c_user
  261. where `tenant_id` = #{tenantId}
  262. <if test=" null != parentTenantId and '' != parentTenantId">
  263. and `parent_tenant_id` = #{parentTenantId}
  264. </if>
  265. <if test=" null != sex ">
  266. and gender =#{sex}
  267. </if>
  268. <if test=" null != startTime ">
  269. and create_date &gt;= #{startTime}
  270. </if>
  271. <if test=" null != endTime">
  272. and create_date &lt; #{endTime}
  273. </if>
  274. </select>
  275. <select id="findCountData" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="com.iformall.domain.vo.UserStructureVo">
  276. select DATE_FORMAT(create_date,'%m/%d') as name,count(id) count
  277. from tt_c_user
  278. where `tenant_id` = #{tenantId}
  279. <if test=" null != parentTenantId and '' != parentTenantId">
  280. and `parent_tenant_id` = #{parentTenantId}
  281. </if>
  282. <if test=" null != sex ">
  283. and gender =#{sex}
  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. group by name
  292. </select>
  293. <select id="findCountHistory" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="com.iformall.domain.vo.UserCountVo">
  294. select count(id) as incCount,
  295. <if test="1 == reportType ">
  296. date_format(create_date, '%Y-%m-%d') as reportTime
  297. </if>
  298. <if test="2 == reportType ">
  299. date_format(create_date, '%Y-%m') as reportTime
  300. </if>
  301. <if test="3 == reportType ">
  302. date_format(create_date, '%Y') as reportTime
  303. </if>
  304. from tt_c_user
  305. where `tenant_id` = #{tenantId}
  306. <if test=" null != parentTenantId and '' != parentTenantId">
  307. and `parent_tenant_id` = #{parentTenantId}
  308. </if>
  309. <if test=" null != startTime ">
  310. and create_date &gt;= #{startTime}
  311. </if>
  312. <if test=" null != endTime">
  313. and create_date &lt; #{endTime}
  314. </if>
  315. <if test="1 == reportType or 2 == reportType or 3 == reportType">
  316. group by reportTime
  317. </if>
  318. </select>
  319. <select id="listByChannel" resultMap="BaseResultMap" >
  320. select id,user_id,nick_name,phone,create_date,scene_address
  321. from tt_c_user
  322. where `tenant_id` = #{tenantId}
  323. <if test=" null != parentTenantId and '' != parentTenantId">
  324. and `parent_tenant_id` = #{parentTenantId}
  325. </if>
  326. <if test=" null != startDate ">
  327. and create_date &gt;= #{startDate}
  328. </if>
  329. <if test=" null != endDate">
  330. and create_date &lt; #{endDate}
  331. </if>
  332. <if test=" sceneList!= null ">
  333. and scene_address in
  334. <foreach collection="sceneList" index="index" item="scene" open="(" separator="," close=")">
  335. #{scene}
  336. </foreach>
  337. </if>
  338. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  339. <if test=" null == sortColumns"> order by create_date desc </if>
  340. </select>
  341. <select id="countByChannel" resultType="java.lang.Long" >
  342. select count(id)
  343. from tt_c_user
  344. where `tenant_id` = #{tenantId}
  345. <if test=" null != parentTenantId and '' != parentTenantId">
  346. and `parent_tenant_id` = #{parentTenantId}
  347. </if>
  348. <if test=" null != startDate ">
  349. and create_date &gt;= #{startDate}
  350. </if>
  351. <if test=" null != endDate">
  352. and create_date &lt; #{endDate}
  353. </if>
  354. <if test=" sceneList!= null ">
  355. and scene_address in
  356. <foreach collection="sceneList" index="index" item="scene" open="(" separator="," close=")">
  357. #{scene}
  358. </foreach>
  359. </if>
  360. </select>
  361. <update id="updateUserId" parameterType="com.iformall.domain.po.tt.TtCUser">
  362. update tt_c_user
  363. set user_id=#{userId}
  364. where id = #{id}
  365. </update>
  366. <update id="delForUserIdOnly">
  367. update tt_c_user set update_date=now(),
  368. phone = null,
  369. pure_phone = null,
  370. user_id = null
  371. where user_id = #{userId} and tenant_id = #{tenantId} and id != #{id}
  372. </update>
  373. <select id="findTokenList" parameterType="hashmap" resultType="String" >
  374. select token from tt_c_user where user_id=#{userId} and tenant_id = #{tenantId} and id != #{id}
  375. </select>
  376. <!-- tenant_id = IF(tenant_id is null ,null,CONCAT(tenant_id,"_del")),-->
  377. <!-- parent_tenant_id = IF(parent_tenant_id is null ,null,CONCAT(parent_tenant_id,"_del")),-->
  378. <!-- open_id = IF(open_id is null ,null,CONCAT(open_id,"_del")),-->
  379. <!-- union_id = IF(union_id is null ,null,CONCAT(union_id,"_del"))-->
  380. <select id="findOpenIdList" parameterType="hashmap" resultType="String" >
  381. select open_id from tt_c_user where user_id=#{userId} and tenant_id = #{tenantId}
  382. </select>
  383. </mapper>