AppUserMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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.irun.dao.AppUserMapper">
  4. <insert id="addOne" parameterType="com.ytpm.app.model.YtDyzUser">
  5. insert into yt_dyz_user
  6. (
  7. user_id,
  8. nick_name,
  9. head_img,
  10. registry_time,
  11. last_login_time,
  12. last_login_ip,
  13. login_days,
  14. total_video,
  15. total_income,
  16. red_packet_balance,
  17. red_packet_amount,
  18. points_balance,
  19. points_total,
  20. withdraw_total,
  21. sign_days,
  22. user_status,
  23. risk_reason,
  24. wx_open_id,
  25. ditch_id,
  26. platform_id,
  27. app_id,
  28. power,
  29. phone,
  30. phone_json,
  31. device_id
  32. )
  33. values
  34. (
  35. #{userId},
  36. #{nickName},
  37. #{headImg},
  38. #{registryTime},
  39. #{lastLoginTime},
  40. #{lastLoginIp},
  41. #{loginDays},
  42. #{totalVideo},
  43. #{totalIncome},
  44. #{redPacketBalance},
  45. #{redPacketAmount},
  46. #{pointsBalance},
  47. #{pointsTotal},
  48. #{withdrawTotal},
  49. #{signDays},
  50. #{userStatus},
  51. #{riskReason},
  52. #{wxOpenId},
  53. #{ditchId},
  54. #{platformId},
  55. #{appId},
  56. #{power},
  57. #{phone},
  58. #{phoneJson},
  59. #{deviceId}
  60. )
  61. </insert>
  62. <insert id="addPowerRecord">
  63. insert into yt_dyz_power_record
  64. (
  65. record_id, user_id, type, remark, add_time
  66. )
  67. values
  68. (
  69. #{recordId},#{userId},#{type},#{remark},#{addTime}
  70. )
  71. </insert>
  72. <insert id="saveAppConfig">
  73. insert into yt_app_default_config
  74. (
  75. config_name,
  76. open_id,
  77. secret,
  78. app_id,
  79. app_key,
  80. app_type
  81. )
  82. values
  83. (
  84. #{configName},
  85. #{openId},
  86. #{secret},
  87. #{appId},
  88. #{appKey},
  89. #{appType}
  90. )
  91. </insert>
  92. <update id="addOnePower">
  93. update yt_dyz_user set power = power+1 where user_id = #{userId}
  94. </update>
  95. <update id="subOnePower">
  96. update yt_dyz_user set power = power-1 where user_id = #{userId}
  97. </update>
  98. <update id="updateUser" parameterType="com.ytpm.app.model.YtDyzUser">
  99. update yt_dyz_user
  100. <set>
  101. <if test="nickName != null">
  102. nick_name = #{nickName},
  103. </if>
  104. <if test="phone != null">
  105. phone = #{phone},
  106. </if>
  107. <if test="deviceId != null">
  108. device_id = #{deviceId},
  109. </if>
  110. <if test="headImg != null">
  111. head_img = #{headImg},
  112. </if>
  113. <if test="power != null">
  114. power = #{power},
  115. </if>
  116. <if test="lastLoginTime != null">
  117. last_login_time = #{lastLoginTime},
  118. </if>
  119. <if test="lastLoginIp != null">
  120. last_login_ip = #{lastLoginIp},
  121. </if>
  122. <if test="loginDays != null">
  123. login_days = #{loginDays},
  124. </if>
  125. <if test="totalVideo != null">
  126. total_video = #{totalVideo},
  127. </if>
  128. <if test="totalIncome != null">
  129. total_income = #{totalIncome},
  130. </if>
  131. <if test="redPacketBalance != null">
  132. red_packet_balance = #{redPacketBalance},
  133. </if>
  134. <if test="redPacketAmount != null">
  135. red_packet_amount = #{redPacketAmount},
  136. </if>
  137. <if test="pointsBalance != null">
  138. points_balance = #{pointsBalance},
  139. </if>
  140. <if test="pointsTotal != null">
  141. points_total = #{pointsTotal},
  142. </if>
  143. <if test="withdrawTotal != null">
  144. withdraw_total = #{withdrawTotal},
  145. </if>
  146. <if test="signDays != null">
  147. sign_days = #{signDays},
  148. </if>
  149. <if test="userStatus != null">
  150. user_status = #{userStatus},
  151. </if>
  152. <if test="riskReason != null">
  153. risk_reason = #{riskReason},
  154. </if>
  155. <if test="wxOpenId != null">
  156. wx_open_id = #{wxOpenId},
  157. </if>
  158. <if test="platformId != null">
  159. platform_id = #{platformId}
  160. </if>
  161. </set>
  162. where user_id = #{userId}
  163. </update>
  164. <delete id="delByAppId">
  165. delete from yt_app_default_config where app_id = #{appId}
  166. </delete>
  167. <select id="getYtAppUser" resultType="com.ytpm.app.model.YtDyzUser">
  168. select
  169. user_id, app_id,phone,device_id, ditch_id, nick_name,head_img, power, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, platform_id
  170. from yt_dyz_user
  171. where wx_open_id = #{openid}
  172. and ditch_id = #{ditchId}
  173. </select>
  174. <select id="queryAll" resultType="com.ytpm.app.view.YtAppUserListView">
  175. select
  176. user_id,app_id,phone,device_id, ditch_id, nick_name,head_img, power, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, platform_id
  177. from yt_dyz_user
  178. where 1 = 1
  179. <if test="userId != null and userId !=''">
  180. and user_id = #{userId}
  181. </if>
  182. <if test="nickName != null and nickName !=''">
  183. and nick_name like concat('%',#{nickName},'%')
  184. </if>
  185. <if test="ditchId != null">
  186. and ditch_id = #{ditchId}
  187. </if>
  188. <if test="userStatus != null">
  189. and user_status = #{userStatus}
  190. </if>
  191. <if test="registryTimeBegin != null">
  192. and DATE_FORMAT(registry_time, '%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{registryTimeBegin}, '%Y-%m-%d')
  193. </if>
  194. <if test="registryTimeEnd != null">
  195. and DATE_FORMAT(registry_time, '%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{registryTimeEnd}, '%Y-%m-%d')
  196. </if>
  197. <if test="lastLoginTimeBegin != null">
  198. and DATE_FORMAT(last_login_time, '%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{lastLoginTimeBegin}, '%Y-%m-%d')
  199. </if>
  200. <if test="lastLoginTimeEnd != null">
  201. and DATE_FORMAT(last_login_time, '%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{lastLoginTimeEnd}, '%Y-%m-%d')
  202. </if>
  203. <if test="appIds != null and appIds != ''">
  204. and app_id in
  205. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  206. #{item}
  207. </foreach>
  208. </if>
  209. order by user_id desc
  210. </select>
  211. <select id="selectPrimaryKey" resultType="com.ytpm.app.model.YtDyzUser">
  212. select
  213. user_id,app_id,phone,device_id, ditch_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, platform_id, power
  214. from yt_dyz_user
  215. where user_id = #{userId}
  216. </select>
  217. <resultMap id="UserMap" type="com.ytpm.app.model.YtDyzUser">
  218. <id column="user_id" property="userId" />
  219. <result column="head_img" property="headImg" />
  220. <result column="nick_name" property="nickName" />
  221. <result column="phone" property="phone" />
  222. <result column="device_id" property="deviceId" />
  223. <result column="registry_time" property="registryTime" />
  224. <result column="last_login_time" property="lastLoginTime" />
  225. <result column="last_login_ip" property="lastLoginIp" />
  226. <result column="login_days" property="loginDays" />
  227. <result column="total_video" property="totalVideo" />
  228. <result column="total_income" property="totalIncome" />
  229. <result column="red_packet_balance" property="redPacketBalance" />
  230. <result column="red_packet_amount" property="redPacketAmount" />
  231. <result column="points_balance" property="pointsBalance" />
  232. <result column="points_total" property="pointsTotal" />
  233. <result column="withdraw_total" property="withdrawTotal" />
  234. <result column="sign_days" property="signDays" />
  235. <result column="user_status" property="userStatus" />
  236. <result column="risk_reason" property="riskReason" />
  237. <result column="wx_open_id" property="wxOpenId" />
  238. <result column="ditch_id" property="ditchId" />
  239. <result column="app_id" property="appId" />
  240. <result column="platform_id" property="platformId" />
  241. <result column="power" property="power" />
  242. <collection property="loginRecordList" ofType="com.ytpm.app.model.YtDyzLoginRecord">
  243. <result column="record_id" property="recordId" />
  244. <result column="user_id" property="userId" />
  245. <result column="login_time" property="loginTime" />
  246. <result column="device_brand" property="deviceBrand" />
  247. <result column="device_model" property="deviceModel" />
  248. <result column="login_ip" property="loginIp" />
  249. <result column="operator" property="operator" />
  250. <result column="ip_addr" property="ipAddr" />
  251. </collection>
  252. </resultMap>
  253. <select id="getUserList" resultMap="UserMap">
  254. select
  255. du.user_id,
  256. du.head_img,
  257. du.nick_name,
  258. du.phone,
  259. du.device_id,
  260. du.registry_time,
  261. du.last_login_time,
  262. du.last_login_ip,
  263. du.login_days,
  264. du.total_video,
  265. du.total_income,
  266. du.red_packet_balance,
  267. du.red_packet_amount,
  268. du.points_balance,
  269. du.points_total,
  270. du.withdraw_total,
  271. du.sign_days,
  272. du.user_status,
  273. du.risk_reason,
  274. du.wx_open_id,
  275. du.ditch_id,
  276. du.app_id,
  277. du.platform_id,
  278. du.power,
  279. lr.record_id,
  280. lr.login_time,
  281. lr.device_brand,
  282. lr. device_model,
  283. lr.login_ip,
  284. lr.operator,
  285. lr.ip_addr
  286. from yt_dyz_user du
  287. left join yt_dyz_login_record lr on du.user_id = lr.user_id
  288. <where>
  289. <if test="userIds != null and userIds != ''">
  290. and du.user_id in
  291. <foreach collection="userIds.split(',')" item="item" separator="," open="(" close=")">
  292. #{item}
  293. </foreach>
  294. </if>
  295. <if test="loginTimeBegin != null">
  296. and du.last_login_time <![CDATA[>=]]> #{loginTimeBegin}
  297. </if>
  298. <if test="loginTimeEnd != null">
  299. and du.last_login_time <![CDATA[<=]]> #{loginTimeEnd}
  300. </if>
  301. </where>
  302. group by du.user_id
  303. </select>
  304. <select id="queryAllByTime" resultType="com.ytpm.app.model.YtDyzUser">
  305. SELECT
  306. user_id,app_id,phone,device_id, nick_name, head_img, power, registry_time,
  307. last_login_time, last_login_ip, login_days, total_video,
  308. total_income, red_packet_balance, red_packet_amount,
  309. points_balance, points_total, withdraw_total, sign_days,
  310. user_status, risk_reason, wx_open_id, platform_id
  311. FROM yt_dyz_user
  312. <where>
  313. <if test="startTime != null">
  314. AND registry_time >= #{startTime}
  315. </if>
  316. <if test="endTime != null">
  317. AND registry_time &lt;= #{endTime}
  318. </if>
  319. <choose>
  320. <when test="appIdList == null or appIdList.isEmpty()">
  321. AND 1 = 0
  322. </when>
  323. <otherwise>
  324. AND app_id IN
  325. <foreach collection="appIdList" item="item"
  326. open="(" close=")" separator=",">
  327. #{item}
  328. </foreach>
  329. </otherwise>
  330. </choose>
  331. </where>
  332. ORDER BY registry_time DESC
  333. </select>
  334. <select id="countUsersByHour" resultType="com.ytpm.app.view.HourCountView">
  335. SELECT HOUR(registry_time) AS hour, COUNT(*) AS count
  336. FROM yt_dyz_user
  337. WHERE registry_time BETWEEN #{startTime} AND #{endTime}
  338. <choose>
  339. <when test="appIdList == null or appIdList.isEmpty()">
  340. AND 1 = 0
  341. </when>
  342. <otherwise>
  343. AND app_id IN
  344. <foreach collection="appIdList" item="item"
  345. open="(" close=")" separator=",">
  346. #{item}
  347. </foreach>
  348. </otherwise>
  349. </choose>
  350. GROUP BY HOUR(registry_time)
  351. </select>
  352. <select id="queryTodayBanned" resultType="com.ytpm.app.model.YtDyzUser">
  353. select user_id from yt_dyz_user
  354. where registry_time BETWEEN #{startTime} AND #{endTime}
  355. and user_id in
  356. <foreach collection="userIdList" item="item"
  357. open="(" close=")" separator=",">
  358. #{item}
  359. </foreach>
  360. </select>
  361. <select id="getDefaultConfig" resultType="com.ytpm.app.view.WxDefaultConfig">
  362. select
  363. config_id, config_name, open_id appId, secret, app_id platformAppId, app_key platformAppSecret, app_type,user_path,login_path,ad_path,answer_path,power_path
  364. from yt_app_default_config
  365. where app_type = #{appType}
  366. </select>
  367. <select id="getSecretByAppId" resultType="java.lang.String">
  368. select
  369. secret
  370. from yt_app_default_config
  371. where app_id = #{appId}
  372. </select>
  373. <select id="queryByOpenid" resultType="com.ytpm.app.model.YtDyzUser">
  374. select
  375. user_id,phone,device_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id, power
  376. from yt_dyz_user
  377. where wx_open_id = #{openid}
  378. </select>
  379. <select id="getByDeviceId" resultType="java.lang.String">
  380. select
  381. platform_id
  382. from yt_dyz_user
  383. where device_id = #{deviceId}
  384. and wx_open_id = #{openid}
  385. limit 1
  386. </select>
  387. <select id="getConfigByIds" resultType="com.ytpm.app.view.WxDefaultConfig">
  388. select
  389. config_id, config_name, open_id, secret, app_id, app_key, app_type,user_path,login_path,ad_path,answer_path,power_path
  390. from yt_app_default_config
  391. where app_id in
  392. <foreach collection="appIds.split(',')" item="item" separator="," open="(" close=")">
  393. #{item}
  394. </foreach>
  395. </select>
  396. <select id="getAdCount" resultType="java.lang.Integer">
  397. select
  398. sum(total_video)
  399. from yt_dyz_user
  400. where app_id in
  401. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  402. #{item}
  403. </foreach>
  404. </select>
  405. <select id="getRevenueCount" resultType="java.math.BigDecimal">
  406. select
  407. sum(total_income)
  408. from yt_dyz_user
  409. where app_id in
  410. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  411. #{item}
  412. </foreach>
  413. </select>
  414. <select id="getAppRanking" resultType="com.ytpm.middle.view.AppRankingListVO">
  415. SELECT
  416. u.app_id,
  417. sum( ar.revenue ) totalRevenue
  418. FROM
  419. yt_dyz_ad_record ar
  420. JOIN yt_dyz_user u ON ar.user_id = u.user_id
  421. <where>
  422. <if test="sortBy != null">
  423. <choose>
  424. <when test="sortBy == 1">
  425. DATE_FORMAT( ar.finish_time, '%Y-%m-%d' ) = CURRENT_DATE()
  426. </when>
  427. <when test=" sortBy == 2">
  428. YEARWEEK( ar.finish_time, 1 ) = YEARWEEK(now(),1)
  429. </when>
  430. <otherwise>
  431. DATE_FORMAT( ar.finish_time, '%Y-%m' ) = DATE_FORMAT(NOW(), '%Y-%m')
  432. </otherwise>
  433. </choose>
  434. </if>
  435. </where>
  436. GROUP BY
  437. u.app_id
  438. ORDER BY
  439. sum( ar.revenue ) DESC
  440. LIMIT #{limit}
  441. </select>
  442. <select id="getUserRanking" resultType="com.ytpm.middle.view.UserRankingListVO">
  443. SELECT
  444. u.user_id,
  445. u.nick_name,
  446. u.head_img,
  447. u.total_video,
  448. sum( ar.revenue ) totalIncome
  449. FROM
  450. yt_dyz_ad_record ar
  451. JOIN yt_dyz_user u ON ar.user_id = u.user_id
  452. <where>
  453. <if test="sortBy != null">
  454. <choose>
  455. <when test="sortBy == 1">
  456. DATE_FORMAT( ar.finish_time, '%Y-%m-%d' ) = CURRENT_DATE()
  457. </when>
  458. <when test=" sortBy == 2">
  459. YEARWEEK( ar.finish_time, 1 ) = YEARWEEK(now(),1)
  460. </when>
  461. <otherwise>
  462. DATE_FORMAT( ar.finish_time, '%Y-%m' ) = DATE_FORMAT(NOW(), '%Y-%m')
  463. </otherwise>
  464. </choose>
  465. </if>
  466. </where>
  467. GROUP BY ar.user_id
  468. ORDER BY
  469. sum( ar.revenue ) DESC
  470. limit #{limit}
  471. </select>
  472. <select id="countUserByAppIds" resultType="java.lang.Integer">
  473. select
  474. count(user_id)
  475. from yt_dyz_user
  476. where app_id in
  477. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  478. #{item}
  479. </foreach>
  480. </select>
  481. <select id="countRevenueByAppIds" resultType="java.math.BigDecimal">
  482. select
  483. sum(total_income)
  484. from yt_dyz_user
  485. where app_id in
  486. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  487. #{item}
  488. </foreach>
  489. </select>
  490. <select id="countBannedByAppIds" resultType="java.lang.Integer">
  491. select
  492. count(user_id)
  493. from yt_dyz_user
  494. where user_status > 1 and app_id in
  495. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  496. #{item}
  497. </foreach>
  498. </select>
  499. <select id="countRegistryUser" resultType="java.lang.Integer">
  500. select
  501. count(user_id)
  502. from yt_dyz_user
  503. where app_id = #{appId}
  504. <if test="type != null and type ==1">
  505. and DATE(registry_time) = DATE(now())
  506. </if>
  507. <if test="type != null and type ==2">
  508. and DATE(registry_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
  509. </if>
  510. <if test="type != null and type ==3">
  511. and DATE_FORMAT(registry_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
  512. </if>
  513. </select>
  514. <select id="countLoginUser" resultType="java.lang.Integer">
  515. select
  516. count(user_id)
  517. from yt_dyz_user
  518. where app_id = #{appId}
  519. <if test="type != null and type ==1">
  520. and DATE(last_login_time) = DATE(now())
  521. </if>
  522. <if test="type != null and type ==2">
  523. and DATE(last_login_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
  524. </if>
  525. <if test="type != null and type ==3">
  526. and DATE_FORMAT(last_login_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
  527. </if>
  528. </select>
  529. <select id="countRegistryHour" resultType="com.ytpm.middle.view.AppUserHourVO">
  530. select
  531. DATE_FORMAT(registry_time,'%Y-%m-%d %H:00:00') as `time`,
  532. count(user_id) `count`
  533. from yt_dyz_user
  534. where app_id = #{appId}
  535. <if test="type != null and type ==1">
  536. and DATE(registry_time) = DATE(now())
  537. </if>
  538. <if test="type != null and type ==2">
  539. and DATE(registry_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
  540. </if>
  541. <if test="type != null and type ==3">
  542. and DATE_FORMAT(registry_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
  543. </if>
  544. group by `time`
  545. </select>
  546. <select id="countLoginHour" resultType="com.ytpm.middle.view.AppUserHourVO">
  547. select
  548. DATE_FORMAT(last_login_time,'%Y-%m-%d %H:00:00') as `time`,
  549. count(user_id) `count`
  550. from yt_dyz_user
  551. where app_id = #{appId}
  552. <if test="type != null and type ==1">
  553. and DATE(last_login_time) = DATE(now())
  554. </if>
  555. <if test="type != null and type ==2">
  556. and DATE(last_login_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
  557. </if>
  558. <if test="type != null and type ==3">
  559. and DATE_FORMAT(last_login_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
  560. </if>
  561. group by `time`
  562. </select>
  563. <select id="queryByUserIds" resultType="com.ytpm.app.model.YtDyzUser">
  564. select
  565. user_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id, power, phone, device_id
  566. from yt_dyz_user
  567. where user_id in
  568. <foreach collection="userIds.split(',')" separator="," item="item" open="(" close=")">
  569. #{item}
  570. </foreach>
  571. </select>
  572. <resultMap id="UserAdMap" type="com.ytpm.agent.view.AgentAuditCheckVO">
  573. <id column="user_id" property="userId" />
  574. <result column="app_id" property="appId" />
  575. <result column="nick_name" property="nickName" />
  576. <collection property="adRecordList" ofType="com.ytpm.app.model.YtDyzAdRecord">
  577. <result column="record_id" property="recordId" />
  578. <result column="placement_id" property="placementId" />
  579. <result column="ad_source_id" property="adSourceId" />
  580. <result column="ad_source_type" property="adSourceType" />
  581. <result column="ad_source_index" property="adSourceIndex" />
  582. <result column="revenue" property="revenue" />
  583. <result column="ecpm" property="ecpm" />
  584. <result column="network_form_id" property="networkFormId" />
  585. <result column="network_name" property="networkName" />
  586. <result column="network_placement_id" property="networkPlacementId" />
  587. <result column="finish_time" property="finishTime" />
  588. <result column="begin_time" property="beginTime" />
  589. </collection>
  590. </resultMap>
  591. <select id="queryTodayUserAd" resultMap="UserAdMap">
  592. select
  593. u.user_id,
  594. u.app_id,
  595. u.nick_name,
  596. ar.record_id,
  597. ar.placement_id,
  598. ar.ad_source_id,
  599. ar.ad_source_type,
  600. ar.ad_source_index,
  601. ar.revenue,
  602. ar.ecpm,
  603. ar.network_form_id,
  604. ar.network_name,
  605. ar.network_placement_id,
  606. ar.finish_time,
  607. ar.begin_time
  608. from yt_dyz_ad_record ar
  609. join yt_dyz_user u on ar.user_id = u.user_id
  610. where ar.ad_source_type = #{adSourceType} and ar.app_id = #{appId} and ar.user_id in
  611. <foreach collection="userIds.split(',')" separator="," item="item" open="(" close=")">
  612. #{item}
  613. </foreach>
  614. and DATE_FORMAT(ar.finish_time, '%Y-%m-%d') = current_date()
  615. </select>
  616. <select id="getMonthRegistryUser" resultType="com.ytpm.app.model.YtDyzUser">
  617. select
  618. user_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id, power, phone, device_id
  619. from yt_dyz_user
  620. where app_id in
  621. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  622. #{item}
  623. </foreach>
  624. <if test="type != null and type == 1">
  625. and DATE_FORMAT(registry_time, '%Y-%m') = DATE_FORMAT(now(),'%Y-%m')
  626. </if>
  627. <if test="type != null and type == 2">
  628. and DATE_FORMAT(last_login_time, '%Y-%m') = DATE_FORMAT(now(),'%Y-%m')
  629. </if>
  630. </select>
  631. <update id="unlockUser">
  632. update yt_dyz_user
  633. set user_status = 1
  634. where user_status > 1
  635. and user_id in
  636. <foreach collection="userIds.split(',')" item="item" separator="," open="(" close=")">
  637. #{item}
  638. </foreach>
  639. </update>
  640. </mapper>