|
|
@@ -0,0 +1,416 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
+<mapper namespace="com.ytpm.dao.xjlrl.XjlrlUserMapper">
|
|
|
+ <insert id="addOne" parameterType="com.ytpm.app.model.YtDyzUser">
|
|
|
+ insert into yt_dyz_user
|
|
|
+ (
|
|
|
+ user_id,
|
|
|
+ nick_name,
|
|
|
+ head_img,
|
|
|
+ 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,
|
|
|
+ platform_id,
|
|
|
+ app_id,
|
|
|
+ power,
|
|
|
+ phone,
|
|
|
+ device_id
|
|
|
+ )
|
|
|
+ values
|
|
|
+ (
|
|
|
+ #{userId},
|
|
|
+ #{nickName},
|
|
|
+ #{headImg},
|
|
|
+ #{registryTime},
|
|
|
+ #{lastLoginTime},
|
|
|
+ #{lastLoginIp},
|
|
|
+ #{loginDays},
|
|
|
+ #{totalVideo},
|
|
|
+ #{totalIncome},
|
|
|
+ #{redPacketBalance},
|
|
|
+ #{redPacketAmount},
|
|
|
+ #{pointsBalance},
|
|
|
+ #{pointsTotal},
|
|
|
+ #{withdrawTotal},
|
|
|
+ #{signDays},
|
|
|
+ #{userStatus},
|
|
|
+ #{riskReason},
|
|
|
+ #{wxOpenId},
|
|
|
+ #{ditchId},
|
|
|
+ #{platformId},
|
|
|
+ #{appId},
|
|
|
+ #{power},
|
|
|
+ #{phone},
|
|
|
+ #{deviceId}
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+ <insert id="addPowerRecord">
|
|
|
+ insert into yt_dyz_power_record
|
|
|
+ (
|
|
|
+ record_id, user_id, type, remark, add_time
|
|
|
+ )
|
|
|
+ values
|
|
|
+ (
|
|
|
+ #{recordId},#{userId},#{type},#{remark},#{addTime}
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+ <insert id="saveAppConfig">
|
|
|
+ insert into yt_app_default_config
|
|
|
+ (
|
|
|
+ config_name,
|
|
|
+ open_id,
|
|
|
+ secret,
|
|
|
+ app_id,
|
|
|
+ app_key,
|
|
|
+ app_type
|
|
|
+ )
|
|
|
+ values
|
|
|
+ (
|
|
|
+ #{configName},
|
|
|
+ #{openId},
|
|
|
+ #{secret},
|
|
|
+ #{appId},
|
|
|
+ #{appKey},
|
|
|
+ #{appType}
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+ <update id="addOnePower">
|
|
|
+ update yt_dyz_user set power = power+1 where user_id = #{userId}
|
|
|
+ </update>
|
|
|
+ <update id="subOnePower">
|
|
|
+ update yt_dyz_user set power = power-1 where user_id = #{userId}
|
|
|
+ </update>
|
|
|
+ <update id="updateUser" parameterType="com.ytpm.app.model.YtDyzUser">
|
|
|
+ update yt_dyz_user
|
|
|
+ <set>
|
|
|
+ <if test="nickName != null">
|
|
|
+ nick_name = #{nickName},
|
|
|
+ </if>
|
|
|
+ <if test="phone != null">
|
|
|
+ phone = #{phone},
|
|
|
+ </if>
|
|
|
+ <if test="deviceId != null">
|
|
|
+ device_id = #{deviceId},
|
|
|
+ </if>
|
|
|
+ <if test="headImg != null">
|
|
|
+ head_img = #{headImg},
|
|
|
+ </if>
|
|
|
+ <if test="power != null">
|
|
|
+ power = #{power},
|
|
|
+ </if>
|
|
|
+ <if test="lastLoginTime != null">
|
|
|
+ last_login_time = #{lastLoginTime},
|
|
|
+ </if>
|
|
|
+ <if test="lastLoginIp != null">
|
|
|
+ last_login_ip = #{lastLoginIp},
|
|
|
+ </if>
|
|
|
+ <if test="loginDays != null">
|
|
|
+ login_days = #{loginDays},
|
|
|
+ </if>
|
|
|
+ <if test="totalVideo != null">
|
|
|
+ total_video = #{totalVideo},
|
|
|
+ </if>
|
|
|
+ <if test="totalIncome != null">
|
|
|
+ total_income = #{totalIncome},
|
|
|
+ </if>
|
|
|
+ <if test="redPacketBalance != null">
|
|
|
+ red_packet_balance = #{redPacketBalance},
|
|
|
+ </if>
|
|
|
+ <if test="redPacketAmount != null">
|
|
|
+ red_packet_amount = #{redPacketAmount},
|
|
|
+ </if>
|
|
|
+ <if test="pointsBalance != null">
|
|
|
+ points_balance = #{pointsBalance},
|
|
|
+ </if>
|
|
|
+ <if test="pointsTotal != null">
|
|
|
+ points_total = #{pointsTotal},
|
|
|
+ </if>
|
|
|
+ <if test="withdrawTotal != null">
|
|
|
+ withdraw_total = #{withdrawTotal},
|
|
|
+ </if>
|
|
|
+ <if test="signDays != null">
|
|
|
+ sign_days = #{signDays},
|
|
|
+ </if>
|
|
|
+ <if test="userStatus != null">
|
|
|
+ user_status = #{userStatus},
|
|
|
+ </if>
|
|
|
+ <if test="riskReason != null">
|
|
|
+ risk_reason = #{riskReason},
|
|
|
+ </if>
|
|
|
+ <if test="wxOpenId != null">
|
|
|
+ wx_open_id = #{wxOpenId},
|
|
|
+ </if>
|
|
|
+ <if test="platformId != null">
|
|
|
+ platform_id = #{platformId}
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where user_id = #{userId}
|
|
|
+ </update>
|
|
|
+ <select id="getYtAppUser" resultType="com.ytpm.app.model.YtDyzUser">
|
|
|
+ select
|
|
|
+ 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
|
|
|
+ from yt_dyz_user
|
|
|
+ where wx_open_id = #{openid}
|
|
|
+ and ditch_id = #{ditchId}
|
|
|
+ </select>
|
|
|
+ <select id="queryAll" resultType="com.ytpm.app.view.YtAppUserListView">
|
|
|
+ select
|
|
|
+ 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
|
|
|
+ from yt_dyz_user
|
|
|
+ where 1 = 1
|
|
|
+ <if test="userId != null and userId !=''">
|
|
|
+ and user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="nickName != null and nickName !=''">
|
|
|
+ and nick_name like concat('%',#{nickName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="ditchId != null">
|
|
|
+ and ditch_id = #{ditchId}
|
|
|
+ </if>
|
|
|
+ <if test="userStatus != null">
|
|
|
+ and user_status = #{userStatus}
|
|
|
+ </if>
|
|
|
+ <if test="registryTimeBegin != null">
|
|
|
+ and DATE_FORMAT(registry_time, '%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{registryTimeBegin}, '%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="registryTimeEnd != null">
|
|
|
+ and DATE_FORMAT(registry_time, '%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{registryTimeEnd}, '%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="lastLoginTimeBegin != null">
|
|
|
+ and DATE_FORMAT(last_login_time, '%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{lastLoginTimeBegin}, '%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="lastLoginTimeEnd != null">
|
|
|
+ and DATE_FORMAT(last_login_time, '%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{lastLoginTimeEnd}, '%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="appIds != null and appIds != ''">
|
|
|
+ and app_id in
|
|
|
+ <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ order by user_id desc
|
|
|
+ </select>
|
|
|
+ <select id="selectPrimaryKey" resultType="com.ytpm.app.model.YtDyzUser">
|
|
|
+ select
|
|
|
+ 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
|
|
|
+ from yt_dyz_user
|
|
|
+ where user_id = #{userId}
|
|
|
+ </select>
|
|
|
+ <select id="getUserList" resultType="com.ytpm.app.model.YtDyzUser">
|
|
|
+ select
|
|
|
+ du.user_id,
|
|
|
+ du.head_img,
|
|
|
+ du.nick_name,
|
|
|
+ du.phone,
|
|
|
+ du.device_id,
|
|
|
+ du.registry_time,
|
|
|
+ du.last_login_time,
|
|
|
+ du.last_login_ip,
|
|
|
+ du.login_days,
|
|
|
+ du.total_video,
|
|
|
+ du.total_income,
|
|
|
+ du.red_packet_balance,
|
|
|
+ du.red_packet_amount,
|
|
|
+ du.points_balance,
|
|
|
+ du.points_total,
|
|
|
+ du.withdraw_total,
|
|
|
+ du.sign_days,
|
|
|
+ du.user_status,
|
|
|
+ du.risk_reason,
|
|
|
+ du.wx_open_id,
|
|
|
+ du.ditch_id,
|
|
|
+ du.app_id,
|
|
|
+ du.platform_id,
|
|
|
+ du.power
|
|
|
+ from yt_dyz_user du
|
|
|
+ where du.user_id in
|
|
|
+ <foreach collection="userIds.split(',')" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="queryAllByTime" resultType="com.ytpm.app.model.YtDyzUser">
|
|
|
+ SELECT
|
|
|
+ user_id,app_id,phone,device_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
|
|
|
+ FROM yt_dyz_user
|
|
|
+ <where>
|
|
|
+ <if test="startTime != null">
|
|
|
+ AND registry_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null">
|
|
|
+ AND registry_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <choose>
|
|
|
+ <when test="appIdList == null or appIdList.isEmpty()">
|
|
|
+ AND 1 = 0
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ AND app_id IN
|
|
|
+ <foreach collection="appIdList" item="item"
|
|
|
+ open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </where>
|
|
|
+ ORDER BY registry_time DESC
|
|
|
+ </select>
|
|
|
+ <select id="countUsersByHour" resultType="com.ytpm.app.view.HourCountView">
|
|
|
+ SELECT HOUR(registry_time) AS hour, COUNT(*) AS count
|
|
|
+ FROM yt_dyz_user
|
|
|
+ WHERE registry_time BETWEEN #{startTime} AND #{endTime}
|
|
|
+ <choose>
|
|
|
+ <when test="appIdList == null or appIdList.isEmpty()">
|
|
|
+ AND 1 = 0
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ AND app_id IN
|
|
|
+ <foreach collection="appIdList" item="item"
|
|
|
+ open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ GROUP BY HOUR(registry_time)
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="queryTodayBanned" resultType="com.ytpm.app.model.YtDyzUser">
|
|
|
+ select user_id from yt_dyz_user
|
|
|
+ where registry_time BETWEEN #{startTime} AND #{endTime}
|
|
|
+ and user_id in
|
|
|
+ <foreach collection="userIdList" item="item"
|
|
|
+ open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getDefaultConfig" resultType="com.ytpm.app.view.WxDefaultConfig">
|
|
|
+ select
|
|
|
+ config_id, config_name, open_id appId, secret, app_id platformAppId, app_key platformAppSecret, app_type,user_path,login_path,ad_path,answer_path,power_path
|
|
|
+ from yt_app_default_config
|
|
|
+ where app_type = #{appType}
|
|
|
+ </select>
|
|
|
+ <select id="getSecretByAppId" resultType="java.lang.String">
|
|
|
+ select
|
|
|
+ secret
|
|
|
+ from yt_app_default_config
|
|
|
+ where app_id = #{appId}
|
|
|
+ </select>
|
|
|
+ <select id="queryByOpenid" resultType="com.ytpm.app.model.YtDyzUser">
|
|
|
+ select
|
|
|
+ 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
|
|
|
+ from yt_dyz_user
|
|
|
+ where wx_open_id = #{openid}
|
|
|
+ </select>
|
|
|
+ <select id="getByDeviceId" resultType="java.lang.String">
|
|
|
+ select
|
|
|
+ platform_id
|
|
|
+ from yt_dyz_user
|
|
|
+ where device_id = #{deviceId}
|
|
|
+ and wx_open_id = #{openid}
|
|
|
+ limit 1
|
|
|
+ </select>
|
|
|
+ <select id="getConfigByIds" resultType="com.ytpm.app.view.WxDefaultConfig">
|
|
|
+ select
|
|
|
+ config_id, config_name, open_id, secret, app_id, app_key, app_type,user_path,login_path,ad_path,answer_path,power_path
|
|
|
+ from yt_app_default_config
|
|
|
+ where app_id in
|
|
|
+ <foreach collection="appIds.split(',')" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </select>
|
|
|
+ <select id="getAdCount" resultType="java.lang.Integer">
|
|
|
+ select
|
|
|
+ sum(total_video)
|
|
|
+ from yt_dyz_user
|
|
|
+ where app_id in
|
|
|
+ <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </select>
|
|
|
+ <select id="getRevenueCount" resultType="java.math.BigDecimal">
|
|
|
+ select
|
|
|
+ sum(total_income)
|
|
|
+ from yt_dyz_user
|
|
|
+ where app_id in
|
|
|
+ <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </select>
|
|
|
+ <select id="getAppRanking" resultType="com.ytpm.middle.view.AppRankingListVO">
|
|
|
+ SELECT
|
|
|
+ u.app_id,
|
|
|
+ sum( ar.revenue ) totalRevenue
|
|
|
+ FROM
|
|
|
+ yt_dyz_ad_record ar
|
|
|
+ JOIN yt_dyz_user u ON ar.user_id = u.user_id
|
|
|
+ <where>
|
|
|
+ <if test="sortBy != null">
|
|
|
+ <choose>
|
|
|
+ <when test="sortBy == 1">
|
|
|
+ DATE_FORMAT( ar.finish_time, '%Y-%m-%d' ) = CURRENT_DATE()
|
|
|
+ </when>
|
|
|
+ <when test=" sortBy == 2">
|
|
|
+ YEARWEEK( ar.finish_time, 1 ) = YEARWEEK(now(),1)
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ DATE_FORMAT( ar.finish_time, '%Y-%m' ) = DATE_FORMAT(NOW(), '%Y-%m')
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ u.app_id
|
|
|
+ ORDER BY
|
|
|
+ sum( ar.revenue ) DESC
|
|
|
+ LIMIT #{limit}
|
|
|
+ </select>
|
|
|
+ <select id="getUserRanking" resultType="com.ytpm.middle.view.UserRankingListVO">
|
|
|
+ SELECT
|
|
|
+ u.user_id,
|
|
|
+ u.nick_name,
|
|
|
+ u.head_img,
|
|
|
+ u.total_video,
|
|
|
+ sum( ar.revenue ) totalIncome
|
|
|
+ FROM
|
|
|
+ yt_dyz_ad_record ar
|
|
|
+ JOIN yt_dyz_user u ON ar.user_id = u.user_id
|
|
|
+ <where>
|
|
|
+ <if test="sortBy != null">
|
|
|
+ <choose>
|
|
|
+ <when test="sortBy == 1">
|
|
|
+ DATE_FORMAT( ar.finish_time, '%Y-%m-%d' ) = CURRENT_DATE()
|
|
|
+ </when>
|
|
|
+ <when test=" sortBy == 2">
|
|
|
+ YEARWEEK( ar.finish_time, 1 ) = YEARWEEK(now(),1)
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ DATE_FORMAT( ar.finish_time, '%Y-%m' ) = DATE_FORMAT(NOW(), '%Y-%m')
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY ar.user_id
|
|
|
+ ORDER BY
|
|
|
+ sum( ar.revenue ) DESC
|
|
|
+ limit #{limit}
|
|
|
+ </select>
|
|
|
+</mapper>
|