AppUserMapper.xml 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  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="appId != null">
  229. app_id = #{appId},
  230. </if>
  231. <if test="ditchId != null">
  232. ditch_id = #{ditchId},
  233. </if>
  234. <if test="phoneJson != null">
  235. phone_json = #{phoneJson},
  236. </if>
  237. <if test="platformId != null">
  238. platform_id = #{platformId}
  239. </if>
  240. </set>
  241. where user_id = #{userId}
  242. </update>
  243. <delete id="delByAppId">
  244. delete from yt_app_default_config where app_id = #{appId}
  245. </delete>
  246. <select id="getYtAppUser" resultType="com.ytpm.app.model.YtDyzUser">
  247. select
  248. 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
  249. from yt_dyz_user
  250. where wx_open_id = #{openid}
  251. and ditch_id = #{ditchId}
  252. </select>
  253. <select id="selectById" 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 user_id = #{userId}
  258. </select>
  259. <select id="selectByIosId" resultType="com.ytpm.app.model.YtDyzUser">
  260. select
  261. 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
  262. from yt_dyz_user
  263. where ios_id = #{iosId}
  264. Limit 1
  265. </select>
  266. <select id="getYtAppUserForIos" resultType="com.ytpm.app.model.YtDyzUser">
  267. select
  268. 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
  269. from yt_dyz_user
  270. where ios_id = #{iosId}
  271. and ditch_id = #{ditchId}
  272. </select>
  273. <select id="queryAll" resultType="com.ytpm.app.view.YtAppUserListView">
  274. select
  275. 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
  276. from yt_dyz_user
  277. where 1 = 1
  278. <if test="userId != null and userId !=''">
  279. and user_id = #{userId}
  280. </if>
  281. <if test="nickName != null and nickName !=''">
  282. and nick_name like concat('%',#{nickName},'%')
  283. </if>
  284. <if test="ditchId != null">
  285. and ditch_id = #{ditchId}
  286. </if>
  287. <if test="userStatus != null">
  288. and user_status = #{userStatus}
  289. </if>
  290. <if test="registryTimeBegin != null">
  291. and DATE_FORMAT(registry_time, '%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{registryTimeBegin}, '%Y-%m-%d')
  292. </if>
  293. <if test="registryTimeEnd != null">
  294. and DATE_FORMAT(registry_time, '%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{registryTimeEnd}, '%Y-%m-%d')
  295. </if>
  296. <if test="lastLoginTimeBegin != null">
  297. and DATE_FORMAT(last_login_time, '%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{lastLoginTimeBegin}, '%Y-%m-%d')
  298. </if>
  299. <if test="lastLoginTimeEnd != null">
  300. and DATE_FORMAT(last_login_time, '%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{lastLoginTimeEnd}, '%Y-%m-%d')
  301. </if>
  302. <if test="appIds != null and appIds != ''">
  303. and app_id in
  304. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  305. #{item}
  306. </foreach>
  307. </if>
  308. order by user_id desc
  309. </select>
  310. <select id="selectPrimaryKey" resultType="com.ytpm.app.model.YtDyzUser">
  311. select
  312. 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
  313. from yt_dyz_user
  314. where user_id = #{userId}
  315. </select>
  316. <resultMap id="UserMap" type="com.ytpm.app.model.YtDyzUser">
  317. <id column="user_id" property="userId" />
  318. <result column="head_img" property="headImg" />
  319. <result column="nick_name" property="nickName" />
  320. <result column="phone" property="phone" />
  321. <result column="device_id" property="deviceId" />
  322. <result column="registry_time" property="registryTime" />
  323. <result column="last_login_time" property="lastLoginTime" />
  324. <result column="last_login_ip" property="lastLoginIp" />
  325. <result column="login_days" property="loginDays" />
  326. <result column="total_video" property="totalVideo" />
  327. <result column="total_income" property="totalIncome" />
  328. <result column="red_packet_balance" property="redPacketBalance" />
  329. <result column="red_packet_amount" property="redPacketAmount" />
  330. <result column="points_balance" property="pointsBalance" />
  331. <result column="points_total" property="pointsTotal" />
  332. <result column="withdraw_total" property="withdrawTotal" />
  333. <result column="sign_days" property="signDays" />
  334. <result column="user_status" property="userStatus" />
  335. <result column="risk_reason" property="riskReason" />
  336. <result column="wx_open_id" property="wxOpenId" />
  337. <result column="ios_id" property="iosId" />
  338. <result column="ditch_id" property="ditchId" />
  339. <result column="app_id" property="appId" />
  340. <result column="platform_id" property="platformId" />
  341. <result column="power" property="power" />
  342. <collection property="loginRecordList" ofType="com.ytpm.app.model.YtDyzLoginRecord">
  343. <result column="record_id" property="recordId" />
  344. <result column="user_id" property="userId" />
  345. <result column="login_time" property="loginTime" />
  346. <result column="device_brand" property="deviceBrand" />
  347. <result column="device_model" property="deviceModel" />
  348. <result column="login_ip" property="loginIp" />
  349. <result column="operator" property="operator" />
  350. <result column="ip_addr" property="ipAddr" />
  351. </collection>
  352. </resultMap>
  353. <select id="getUserList" resultMap="UserMap">
  354. select
  355. du.user_id,
  356. du.head_img,
  357. du.nick_name,
  358. du.phone,
  359. du.device_id,
  360. du.registry_time,
  361. du.last_login_time,
  362. du.last_login_ip,
  363. du.login_days,
  364. du.total_video,
  365. du.total_income,
  366. du.red_packet_balance,
  367. du.red_packet_amount,
  368. du.points_balance,
  369. du.points_total,
  370. du.withdraw_total,
  371. du.sign_days,
  372. du.user_status,
  373. du.risk_reason,
  374. du.wx_open_id,
  375. du.ditch_id,
  376. du.app_id,
  377. du.platform_id,
  378. du.power,
  379. lr.record_id,
  380. lr.login_time,
  381. lr.device_brand,
  382. lr. device_model,
  383. lr.login_ip,
  384. lr.operator,
  385. lr.ip_addr
  386. from yt_dyz_user du
  387. left join yt_dyz_login_record lr on du.user_id = lr.user_id
  388. <where>
  389. <if test="userIds != null and userIds != ''">
  390. and du.user_id in
  391. <foreach collection="userIds.split(',')" item="item" separator="," open="(" close=")">
  392. #{item}
  393. </foreach>
  394. </if>
  395. <if test="loginTimeBegin != null">
  396. and du.last_login_time <![CDATA[>=]]> #{loginTimeBegin}
  397. </if>
  398. <if test="loginTimeEnd != null">
  399. and du.last_login_time <![CDATA[<=]]> #{loginTimeEnd}
  400. </if>
  401. </where>
  402. group by du.user_id
  403. </select>
  404. <select id="queryAllByTime" resultType="com.ytpm.app.model.YtDyzUser">
  405. SELECT
  406. user_id,app_id,phone,device_id, nick_name, head_img, power, registry_time,
  407. last_login_time, last_login_ip, login_days, total_video,
  408. total_income, red_packet_balance, red_packet_amount,
  409. points_balance, points_total, withdraw_total, sign_days,
  410. user_status, risk_reason, wx_open_id, ios_id, platform_id
  411. FROM yt_dyz_user
  412. <where>
  413. <if test="startTime != null">
  414. AND registry_time >= #{startTime}
  415. </if>
  416. <if test="endTime != null">
  417. AND registry_time &lt;= #{endTime}
  418. </if>
  419. <choose>
  420. <when test="appIdList == null or appIdList.isEmpty()">
  421. AND 1 = 0
  422. </when>
  423. <otherwise>
  424. AND app_id IN
  425. <foreach collection="appIdList" item="item"
  426. open="(" close=")" separator=",">
  427. #{item}
  428. </foreach>
  429. </otherwise>
  430. </choose>
  431. </where>
  432. ORDER BY registry_time DESC
  433. </select>
  434. <select id="countUsersByHour" resultType="com.ytpm.app.view.HourCountView">
  435. SELECT HOUR(registry_time) AS hour, COUNT(*) AS count
  436. FROM yt_dyz_user
  437. WHERE registry_time BETWEEN #{startTime} AND #{endTime}
  438. <choose>
  439. <when test="appIdList == null or appIdList.isEmpty()">
  440. AND 1 = 0
  441. </when>
  442. <otherwise>
  443. AND app_id IN
  444. <foreach collection="appIdList" item="item"
  445. open="(" close=")" separator=",">
  446. #{item}
  447. </foreach>
  448. </otherwise>
  449. </choose>
  450. GROUP BY HOUR(registry_time)
  451. </select>
  452. <select id="queryTodayBanned" resultType="com.ytpm.app.model.YtDyzUser">
  453. select user_id from yt_dyz_user
  454. where registry_time BETWEEN #{startTime} AND #{endTime}
  455. and user_id in
  456. <foreach collection="userIdList" item="item"
  457. open="(" close=")" separator=",">
  458. #{item}
  459. </foreach>
  460. </select>
  461. <select id="getConfigByAppId" resultType="com.ytpm.app.model.YtAppDefaultConfig">
  462. select
  463. config_id,
  464. config_name,
  465. open_id,
  466. secret,
  467. app_id,
  468. app_key,
  469. app_type,
  470. user_path,
  471. login_path,
  472. ad_path,
  473. answer_path,
  474. power_path,
  475. taku_app_id,
  476. taku_key,
  477. taku_banner_pid,
  478. taku_native_pid,
  479. taku_reward_pid,
  480. taku_interstitial_pid,
  481. can_use_root,
  482. can_use_adb,
  483. can_use_float,
  484. can_accumulation,
  485. can_simulator,
  486. ditch_id,
  487. power_wait_time,
  488. interstitial_interval_time,
  489. low_value_tip,
  490. brush_tip,
  491. flow_interval_time,
  492. task_limit_tip,
  493. start_wait_time,
  494. can_cache_video,
  495. can_allow_auto_refresh
  496. from yt_app_default_config
  497. where app_id = #{appId}
  498. </select>
  499. <select id="getByAppId" resultType="com.ytpm.app.view.WxDefaultConfig">
  500. select
  501. config_id,
  502. config_name,
  503. open_id,
  504. secret,
  505. app_id,
  506. app_key,
  507. app_type,
  508. user_path,
  509. login_path,
  510. ad_path,
  511. answer_path,
  512. power_path,
  513. taku_app_id,
  514. taku_key,
  515. taku_banner_pid,
  516. taku_native_pid,
  517. taku_reward_pid,
  518. taku_interstitial_pid,
  519. can_use_root,
  520. can_use_adb,
  521. can_use_float,
  522. can_accumulation,
  523. can_simulator,
  524. ditch_id,
  525. power_wait_time,
  526. interstitial_interval_time,
  527. low_value_tip,
  528. brush_tip,
  529. flow_interval_time,
  530. task_limit_tip,
  531. start_wait_time,
  532. can_cache_video,
  533. can_allow_auto_refresh
  534. from yt_app_default_config
  535. where app_id = #{appId}
  536. </select>
  537. <select id="getDefaultConfig" resultType="com.ytpm.app.view.WxDefaultConfig">
  538. select
  539. config_id,
  540. config_name,
  541. open_id,
  542. secret,
  543. app_id,
  544. app_key,
  545. app_type,
  546. user_path,
  547. login_path,
  548. ad_path,
  549. answer_path,
  550. power_path,
  551. taku_app_id,
  552. taku_key,
  553. taku_banner_pid,
  554. taku_native_pid,
  555. taku_reward_pid,
  556. taku_interstitial_pid,
  557. can_use_root,
  558. can_use_adb,
  559. can_use_float,
  560. can_accumulation,
  561. can_simulator,
  562. ditch_id,
  563. power_wait_time,
  564. interstitial_interval_time,
  565. low_value_tip,
  566. brush_tip,
  567. flow_interval_time,
  568. task_limit_tip,
  569. start_wait_time,
  570. can_cache_video,
  571. can_allow_auto_refresh
  572. from yt_app_default_config
  573. where app_type = #{appType}
  574. </select>
  575. <select id="getDefaultConfigByDitchId" resultType="com.ytpm.app.view.WxDefaultConfig">
  576. select
  577. config_id,
  578. config_name,
  579. open_id,
  580. secret,
  581. app_id,
  582. app_key,
  583. app_type,
  584. user_path,
  585. login_path,
  586. ad_path,
  587. answer_path,
  588. power_path,
  589. taku_app_id,
  590. taku_key,
  591. taku_banner_pid,
  592. taku_native_pid,
  593. taku_reward_pid,
  594. taku_interstitial_pid,
  595. can_use_root,
  596. can_use_adb,
  597. can_use_float,
  598. can_accumulation,
  599. can_simulator,
  600. ditch_id,
  601. power_wait_time,
  602. interstitial_interval_time,
  603. low_value_tip,
  604. brush_tip,
  605. flow_interval_time,
  606. task_limit_tip,
  607. start_wait_time,
  608. can_cache_video,
  609. can_allow_auto_refresh
  610. from yt_app_default_config
  611. where ditch_id = #{ditchId}
  612. </select>
  613. <select id="getLastOne" resultType="com.ytpm.app.view.WxDefaultConfig">
  614. select
  615. config_id,
  616. config_name,
  617. open_id,
  618. secret,
  619. app_id,
  620. app_key,
  621. app_type,
  622. user_path,
  623. login_path,
  624. ad_path,
  625. answer_path,
  626. power_path,
  627. taku_app_id,
  628. taku_key,
  629. taku_banner_pid,
  630. taku_native_pid,
  631. taku_reward_pid,
  632. taku_interstitial_pid,
  633. can_use_root,
  634. can_use_adb,
  635. can_use_float,
  636. can_accumulation,
  637. can_simulator,
  638. ditch_id,
  639. power_wait_time,
  640. interstitial_interval_time,
  641. low_value_tip,
  642. brush_tip,
  643. flow_interval_time,
  644. task_limit_tip,
  645. start_wait_time,
  646. can_cache_video,
  647. can_allow_auto_refresh
  648. from yt_app_default_config
  649. where app_id = #{appId}
  650. limit 1
  651. </select>
  652. <select id="getLastDefaultConfig" resultType="com.ytpm.app.view.WxDefaultConfig">
  653. SELECT
  654. config_id,
  655. config_name,
  656. open_id,
  657. secret,
  658. app_id,
  659. app_key,
  660. app_type,
  661. user_path,
  662. login_path,
  663. ad_path,
  664. answer_path,
  665. power_path,
  666. taku_app_id,
  667. taku_key,
  668. taku_banner_pid,
  669. taku_native_pid,
  670. taku_reward_pid,
  671. taku_interstitial_pid,
  672. can_use_root,
  673. can_use_adb,
  674. can_use_float,
  675. can_accumulation,
  676. can_simulator,
  677. ditch_id,
  678. power_wait_time,
  679. interstitial_interval_time,
  680. low_value_tip,
  681. brush_tip,
  682. flow_interval_time,
  683. task_limit_tip,
  684. start_wait_time,
  685. can_cache_video,
  686. can_allow_auto_refresh
  687. FROM yt_app_default_config
  688. ORDER BY config_id DESC
  689. LIMIT 1
  690. </select>
  691. <select id="getSecretByAppId" resultType="java.lang.String">
  692. select
  693. secret
  694. from yt_app_default_config
  695. where app_id = #{appId}
  696. </select>
  697. <select id="queryByOpenid" resultType="com.ytpm.app.model.YtDyzUser">
  698. select
  699. 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
  700. from yt_dyz_user
  701. where wx_open_id = #{openid}
  702. </select>
  703. <select id="queryByIosId" resultType="com.ytpm.app.model.YtDyzUser">
  704. select
  705. 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
  706. from yt_dyz_user
  707. where ios_id = #{iosId}
  708. </select>
  709. <select id="getByDeviceId" resultType="java.lang.String">
  710. select
  711. platform_id
  712. from yt_dyz_user
  713. where device_id = #{deviceId}
  714. and wx_open_id = #{openid}
  715. limit 1
  716. </select>
  717. <select id="getConfigByIds" resultType="com.ytpm.app.view.WxDefaultConfig">
  718. select
  719. config_id,
  720. config_name,
  721. open_id,
  722. secret,
  723. app_id,
  724. app_key,
  725. app_type,
  726. user_path,
  727. login_path,
  728. ad_path,
  729. answer_path,
  730. power_path,
  731. taku_app_id,
  732. taku_key,
  733. taku_banner_pid,
  734. taku_native_pid,
  735. taku_reward_pid,
  736. taku_interstitial_pid,
  737. can_use_root,
  738. can_use_adb,
  739. can_use_float,
  740. can_accumulation,
  741. can_simulator,
  742. ditch_id,
  743. power_wait_time,
  744. interstitial_interval_time,
  745. low_value_tip,
  746. brush_tip,
  747. flow_interval_time,
  748. task_limit_tip,
  749. start_wait_time,
  750. can_cache_video,
  751. can_allow_auto_refresh
  752. from yt_app_default_config
  753. where app_id in
  754. <foreach collection="appIds.split(',')" item="item" separator="," open="(" close=")">
  755. #{item}
  756. </foreach>
  757. </select>
  758. <select id="getAdCount" resultType="java.lang.Integer">
  759. select
  760. sum(total_video)
  761. from yt_dyz_user
  762. where app_id in
  763. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  764. #{item}
  765. </foreach>
  766. </select>
  767. <select id="getRevenueCount" resultType="java.math.BigDecimal">
  768. select
  769. sum(total_income)
  770. from yt_dyz_user
  771. where app_id in
  772. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  773. #{item}
  774. </foreach>
  775. </select>
  776. <select id="getAppRanking" resultType="com.ytpm.middle.view.AppRankingListVO">
  777. SELECT
  778. u.app_id,
  779. sum( ar.revenue ) totalRevenue
  780. FROM
  781. yt_dyz_ad_record ar
  782. JOIN yt_dyz_user u ON ar.user_id = u.user_id
  783. <where>
  784. <if test="sortBy != null">
  785. <choose>
  786. <when test="sortBy == 1">
  787. DATE_FORMAT( ar.finish_time, '%Y-%m-%d' ) = CURRENT_DATE()
  788. </when>
  789. <when test=" sortBy == 2">
  790. YEARWEEK( ar.finish_time, 1 ) = YEARWEEK(now(),1)
  791. </when>
  792. <otherwise>
  793. DATE_FORMAT( ar.finish_time, '%Y-%m' ) = DATE_FORMAT(NOW(), '%Y-%m')
  794. </otherwise>
  795. </choose>
  796. </if>
  797. </where>
  798. GROUP BY
  799. u.app_id
  800. ORDER BY
  801. sum( ar.revenue ) DESC
  802. LIMIT #{limit}
  803. </select>
  804. <select id="getUserRanking" resultType="com.ytpm.middle.view.UserRankingListVO">
  805. SELECT
  806. u.user_id,
  807. u.nick_name,
  808. u.head_img,
  809. u.total_video,
  810. sum( ar.revenue ) totalIncome
  811. FROM
  812. yt_dyz_ad_record ar
  813. JOIN yt_dyz_user u ON ar.user_id = u.user_id
  814. <where>
  815. <if test="sortBy != null">
  816. <choose>
  817. <when test="sortBy == 1">
  818. DATE_FORMAT( ar.finish_time, '%Y-%m-%d' ) = CURRENT_DATE()
  819. </when>
  820. <when test=" sortBy == 2">
  821. YEARWEEK( ar.finish_time, 1 ) = YEARWEEK(now(),1)
  822. </when>
  823. <otherwise>
  824. DATE_FORMAT( ar.finish_time, '%Y-%m' ) = DATE_FORMAT(NOW(), '%Y-%m')
  825. </otherwise>
  826. </choose>
  827. </if>
  828. </where>
  829. GROUP BY ar.user_id
  830. ORDER BY
  831. sum( ar.revenue ) DESC
  832. limit #{limit}
  833. </select>
  834. <select id="countUserByAppIds" resultType="java.lang.Integer">
  835. select
  836. count(user_id)
  837. from yt_dyz_user
  838. where app_id in
  839. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  840. #{item}
  841. </foreach>
  842. </select>
  843. <select id="countRevenueByAppIds" resultType="java.math.BigDecimal">
  844. select
  845. sum(total_income)
  846. from yt_dyz_user
  847. where app_id in
  848. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  849. #{item}
  850. </foreach>
  851. </select>
  852. <select id="countBannedByAppIds" resultType="java.lang.Integer">
  853. select
  854. count(user_id)
  855. from yt_dyz_user
  856. where user_status > 1 and app_id in
  857. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  858. #{item}
  859. </foreach>
  860. </select>
  861. <select id="countRegistryUser" resultType="java.lang.Integer">
  862. select
  863. count(user_id)
  864. from yt_dyz_user
  865. where app_id = #{appId}
  866. <if test="type != null and type ==1">
  867. and DATE(registry_time) = DATE(now())
  868. </if>
  869. <if test="type != null and type ==2">
  870. and DATE(registry_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
  871. </if>
  872. <if test="type != null and type ==3">
  873. and DATE_FORMAT(registry_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
  874. </if>
  875. </select>
  876. <select id="countLoginUser" resultType="java.lang.Integer">
  877. select
  878. count(user_id)
  879. from yt_dyz_user
  880. where app_id = #{appId}
  881. <if test="type != null and type ==1">
  882. and DATE(last_login_time) = DATE(now())
  883. </if>
  884. <if test="type != null and type ==2">
  885. and DATE(last_login_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
  886. </if>
  887. <if test="type != null and type ==3">
  888. and DATE_FORMAT(last_login_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
  889. </if>
  890. </select>
  891. <select id="countRegistryHour" resultType="com.ytpm.middle.view.AppUserHourVO">
  892. select
  893. DATE_FORMAT(registry_time,'%Y-%m-%d %H:00:00') as `time`,
  894. count(user_id) `count`
  895. from yt_dyz_user
  896. where app_id = #{appId}
  897. <if test="type != null and type ==1">
  898. and DATE(registry_time) = DATE(now())
  899. </if>
  900. <if test="type != null and type ==2">
  901. and DATE(registry_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
  902. </if>
  903. <if test="type != null and type ==3">
  904. and DATE_FORMAT(registry_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
  905. </if>
  906. group by `time`
  907. </select>
  908. <select id="countLoginHour" resultType="com.ytpm.middle.view.AppUserHourVO">
  909. select
  910. DATE_FORMAT(last_login_time,'%Y-%m-%d %H:00:00') as `time`,
  911. count(user_id) `count`
  912. from yt_dyz_user
  913. where app_id = #{appId}
  914. <if test="type != null and type ==1">
  915. and DATE(last_login_time) = DATE(now())
  916. </if>
  917. <if test="type != null and type ==2">
  918. and DATE(last_login_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
  919. </if>
  920. <if test="type != null and type ==3">
  921. and DATE_FORMAT(last_login_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
  922. </if>
  923. group by `time`
  924. </select>
  925. <select id="queryByUserIds" resultType="com.ytpm.app.model.YtDyzUser">
  926. select
  927. 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
  928. from yt_dyz_user
  929. where user_id in
  930. <foreach collection="userIds.split(',')" separator="," item="item" open="(" close=")">
  931. #{item}
  932. </foreach>
  933. </select>
  934. <resultMap id="UserAdMap" type="com.ytpm.agent.view.AgentAuditCheckVO">
  935. <id column="user_id" property="userId" />
  936. <result column="app_id" property="appId" />
  937. <result column="nick_name" property="nickName" />
  938. <collection property="adRecordList" ofType="com.ytpm.app.model.YtDyzAdRecord">
  939. <result column="record_id" property="recordId" />
  940. <result column="placement_id" property="placementId" />
  941. <result column="ad_source_id" property="adSourceId" />
  942. <result column="ad_source_type" property="adSourceType" />
  943. <result column="ad_source_index" property="adSourceIndex" />
  944. <result column="revenue" property="revenue" />
  945. <result column="ecpm" property="ecpm" />
  946. <result column="network_form_id" property="networkFormId" />
  947. <result column="network_name" property="networkName" />
  948. <result column="network_placement_id" property="networkPlacementId" />
  949. <result column="finish_time" property="finishTime" />
  950. <result column="begin_time" property="beginTime" />
  951. </collection>
  952. </resultMap>
  953. <select id="queryTodayUserAd" resultMap="UserAdMap">
  954. select
  955. u.user_id,
  956. u.app_id,
  957. u.nick_name,
  958. ar.record_id,
  959. ar.placement_id,
  960. ar.ad_source_id,
  961. ar.ad_source_type,
  962. ar.ad_source_index,
  963. ar.revenue,
  964. ar.ecpm,
  965. ar.network_form_id,
  966. ar.network_name,
  967. ar.network_placement_id,
  968. ar.finish_time,
  969. ar.begin_time
  970. from yt_dyz_ad_record ar
  971. join yt_dyz_user u on ar.user_id = u.user_id
  972. where ar.ad_source_type = #{adSourceType} and ar.app_id = #{appId} and ar.user_id in
  973. <foreach collection="userIds.split(',')" separator="," item="item" open="(" close=")">
  974. #{item}
  975. </foreach>
  976. and DATE_FORMAT(ar.finish_time, '%Y-%m-%d') = current_date()
  977. </select>
  978. <select id="getMonthRegistryUser" resultType="com.ytpm.app.model.YtDyzUser">
  979. select
  980. 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
  981. from yt_dyz_user
  982. where app_id in
  983. <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
  984. #{item}
  985. </foreach>
  986. <if test="type != null and type == 1">
  987. and DATE_FORMAT(registry_time, '%Y-%m') = DATE_FORMAT(now(),'%Y-%m')
  988. </if>
  989. <if test="type != null and type == 2">
  990. and DATE_FORMAT(last_login_time, '%Y-%m') = DATE_FORMAT(now(),'%Y-%m')
  991. </if>
  992. </select>
  993. <update id="unlockUser">
  994. update yt_dyz_user
  995. set user_status = 1
  996. where user_status > 1
  997. and user_id in
  998. <foreach collection="userIds.split(',')" item="item" separator="," open="(" close=")">
  999. #{item}
  1000. </foreach>
  1001. </update>
  1002. </mapper>