RiskUserMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.ytpm.dao.RiskUserMapper">
  4. <insert id="addBannedRecord">
  5. insert yt_platform_banned
  6. (
  7. banned_id,
  8. user_id,
  9. app_id,
  10. agent_id,
  11. channel_id,
  12. banned_time,
  13. banned_reason,
  14. banned_type,
  15. banned_limit,
  16. operator,
  17. operator_name,
  18. risk_code
  19. )
  20. values
  21. (
  22. #{bannedId},
  23. #{userId},
  24. #{appId},
  25. #{agentId},
  26. #{channelId},
  27. #{bannedTime},
  28. #{bannedReason},
  29. #{bannedType},
  30. #{bannedLimit},
  31. #{operator},
  32. #{operatorName},
  33. #{riskCode}
  34. )
  35. </insert>
  36. <update id="updateByUserId">
  37. update yt_app_user
  38. <set>
  39. <if test="appId !=null and appId!=''">
  40. app_id = {appId},
  41. </if>
  42. <if test="nickName !=null and nickName!=''">
  43. nick_name = #{nickName},
  44. </if>
  45. <if test="registryTime !=null">
  46. registry_time = #{registryTime},
  47. </if>
  48. <if test="lastLoginTime !=null">
  49. last_login_time = #{lastLoginTime},
  50. </if>
  51. <if test="lastLoginIp !=null and lastLoginIp!=''">
  52. last_login_ip = #{lastLoginIp},
  53. </if>
  54. <if test="loginDays !=null">
  55. login_days = #{loginDays},
  56. </if>
  57. <if test="channelType !=null">
  58. channel_type = #{channelType},
  59. </if>
  60. <if test="channelOrigin !=null">
  61. channel_origin = #{channelOrigin},
  62. </if>
  63. <if test="userType !=null">
  64. user_type = #{userType},
  65. </if>
  66. <if test="totalVideo !=null">
  67. total_video = #{totalVideo},
  68. </if>
  69. <if test="totalIncome !=null">
  70. total_income = #{totalIncome},
  71. </if>
  72. <if test="redPacketBalance !=null">
  73. red_packet_balance = #{redPacketBalance},
  74. </if>
  75. <if test="redPacketAmount !=null">
  76. red_packet_amount = #{redPacketAmount},
  77. </if>
  78. <if test="pointsBalance !=null">
  79. points_balance = #{pointsBalance},
  80. </if>
  81. <if test="pointsTotal !=null">
  82. points_total = #{pointsTotal},
  83. </if>
  84. <if test="withdrawTotal !=null">
  85. withdraw_total = #{withdrawTotal},
  86. </if>
  87. <if test="signDays !=null">
  88. sign_days = #{signDays},
  89. </if>
  90. <if test="userStatus !=null">
  91. user_status = #{userStatus},
  92. </if>
  93. <if test="lockReason !=null">
  94. lock_reason = #{lockReason},
  95. </if>
  96. </set>
  97. where user_id = #{userId}
  98. </update>
  99. <update id="banned">
  100. update yt_app_user set user_status = 3
  101. where user_id in
  102. <foreach collection="userIdList" separator="," item="item" index="index" open="(" close=")">
  103. #{item}
  104. </foreach>
  105. </update>
  106. <update id="unBanned">
  107. update yt_app_user set user_status = 1
  108. where user_id in
  109. <foreach collection="userIdList" separator="," item="item" index="index" open="(" close=")">
  110. #{item}
  111. </foreach>
  112. </update>
  113. <select id="selectByUserId" resultType="com.ytpm.agent.model.YtAppUser">
  114. select
  115. user_id, app_id, channel_id, platform_id, nick_name,lock_reason, registry_time, last_login_time, last_login_ip, login_days, channel_type, channel_origin, user_type, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status
  116. from yt_app_user
  117. where user_id = #{userId}
  118. </select>
  119. <select id="getBannedUserList" resultType="com.ytpm.agent.model.YtAppUser">
  120. select
  121. user_id, app_id, channel_id, platform_id, nick_name, registry_time, last_login_time, last_login_ip, login_days, channel_type, channel_origin, user_type, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, wx_open_id, platform_id, channel_id
  122. from yt_app_user
  123. where user_id = #{userId}
  124. <if test="bannedTargetId != null and bannedTargetId != ''">
  125. <choose>
  126. <when test="bannedType == 1 ">
  127. and channel_id = #{bannedTargetId}
  128. </when>
  129. <otherwise>
  130. and platform_id = #{bannedTargetId}
  131. </otherwise>
  132. </choose>
  133. </if>
  134. </select>
  135. <select id="selectByWx" resultType="com.ytpm.agent.model.YtAppUser">
  136. select user_id, app_id, nick_name, registry_time, last_login_time, last_login_ip, login_days, channel_type, channel_origin, user_type, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, lock_reason, wx_open_id, platform_id, channel_id from yt_app_user where wx_open_id = #{openid}
  137. </select>
  138. <select id="selectByAppId" resultType="com.ytpm.risk.view.RiskAccessView">
  139. select
  140. a.app_id,
  141. a.app_name,
  142. pua.access_id,
  143. pua.access_secret,
  144. pua.user_id
  145. from yt_app a
  146. join yt_platform_user_access pua on a.user_id = pua.user_id and pua.enabled = 1
  147. where a.app_id = #{appId}
  148. </select>
  149. <select id="getTimedUser" resultType="java.lang.String">
  150. SELECT
  151. user_id
  152. FROM
  153. yt_platform_banned
  154. GROUP BY
  155. user_id
  156. HAVING
  157. TIMESTAMPDIFF(
  158. HOUR,
  159. max( banned_time ),
  160. NOW()) > 24
  161. </select>
  162. </mapper>