AppUserMapper.xml 31 KB

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