AppUserMapper.xml 25 KB

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