AppUserMapper.xml 27 KB

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