AppUserMapper.xml 31 KB

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