AppUserMapper.xml 25 KB

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