AppUserMapper.xml 31 KB

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