AppUserMapper.xml 39 KB

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