AppUserMapper.xml 27 KB

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