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

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