admin
2019-09-16 8b7fc3718d7cf847858e26db6a1b3421710ce1f8
UserInfo DAO层修改
11个文件已修改
939 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/UserInfoMapper.java 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/UserInfoMapper.xml 735 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserSystemMsgServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/UserInfoMapper.java
@@ -17,9 +17,15 @@
    int insertSelective(UserInfo record);
    UserInfo selectByPrimaryKey(Long id);
    UserInfo selectByPKey(Long id);
     UserInfo selectByPrimaryKey(Long id);
    /**
     * 查询有效的
     *
     * @param id
     * @return
     */
    UserInfo selectAvailableByPrimaryKey(Long id);
    UserInfo selectByPrimaryKeyForUpdate(Long id);
@@ -47,14 +53,13 @@
    // 根据AppId与电话号码获取用户
    List<UserInfo> listByAppIdAndPhone(@Param("appId") String appId, @Param("phone") String phone);
    // 根据获取电话号码有效用户
    UserInfo getEffectiveUserInfoByPhone(@Param("phone") String phone);
    // 根据获WXUnionId有效用户
    UserInfo getEffectiveUserInfoByWXUnionId(@Param("unionId") String unionId);
    Long getMaxUid();
    /**
@@ -63,33 +68,38 @@
     * @param mainUid-主账号
     * @param lessUid-副账号
     */
    void connectUser(@Param("mainUid")Long mainUid,@Param("lessUid") Long lessUid);
    void connectUser(@Param("mainUid") Long mainUid, @Param("lessUid") Long lessUid);
    /**
     * 
     * @param start
     * @param count
     * @param key  查询条件
     * @param userType  用户类型
     * @param days      天数
     * @param startTime  注册时间 -小
     * @param endTime    注册时间 -大
     * @param orderMode  排序方式
     * @param key
     *            查询条件
     * @param userType
     *            用户类型
     * @param days
     *            天数
     * @param startTime
     *            注册时间 -小
     * @param endTime
     *            注册时间 -大
     * @param orderMode
     *            排序方式
     * @return
     */
    List<UserInfoVO> query(@Param("start") long start, @Param("count") int count, @Param("userState")Integer userState,
            @Param("key") String key, @Param("keyType") Integer keyType,
            @Param("userRank") String userRank,    @Param("days")Integer days,
            @Param("startTime") String startTime, @Param("endTime") String endTime,
    List<UserInfoVO> query(@Param("start") long start, @Param("count") int count, @Param("userState") Integer userState,
            @Param("key") String key, @Param("keyType") Integer keyType, @Param("userRank") String userRank,
            @Param("days") Integer days, @Param("startTime") String startTime, @Param("endTime") String endTime,
            @Param("orderField") Integer orderField, @Param("orderMode") Integer orderMode);
    long queryCount( @Param("userState")Integer userState, @Param("key") String key,  @Param("keyType") Integer keyType,
            @Param("userRank")String userRank,@Param("days")Integer days,
            @Param("startTime") String startTime, @Param("endTime") String endTime);
    long queryCount(@Param("userState") Integer userState, @Param("key") String key, @Param("keyType") Integer keyType,
            @Param("userRank") String userRank, @Param("days") Integer days, @Param("startTime") String startTime,
            @Param("endTime") String endTime);
    /**
     * 统计当前查询结果总金额
     *
     * @param title
     * @param userType
     * @param days
@@ -97,87 +107,93 @@
     * @param endTime
     * @return
     */
    double querySumMoney(@Param("key") String key, @Param("userType")Integer userType,    @Param("days")Integer days,
    double querySumMoney(@Param("key") String key, @Param("userType") Integer userType, @Param("days") Integer days,
            @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 统计用户数量
     * @param isToday  统计今日
     * @param isMonth  统计当月  二则不可同时存在
     *
     * @param isToday
     *            统计今日
     * @param isMonth
     *            统计当月 二则不可同时存在
     * @return
     */
    long countNewUser(@Param("isToday") Integer isToday, @Param("isMonth") Integer isMonth);
    /**
     * 根据等级统计用户数量
     *
     * @param rank
     * @return
     */
    long countRank(@Param("rank") Integer rank);
    /**
     * 统计所有用户总金额  或  可提现金额
     * 统计所有用户总金额 或 可提现金额
     *
     * @param minMoney
     * @return
     */
    BigDecimal countAllMoney(@Param("minMoney") Double minMoney);
    /**
     * 超过 daysNum  天未登陆的用户
     * 超过 daysNum 天未登陆的用户
     *
     * @param minMoney
     * @return
     */
    List<Long> longTimeNoLogin(@Param("daysNum") int daysNum, @Param("list") List<Long> list);
    /**
     * 统计流失用户数量:( num 天未使用登录并且无任何资金流动的账号数量)
     * @param num 180
     *
     * @param num
     *            180
     * @return
     */
    long countLoseUser(@Param("num") int num);
    /**
     * 累计有购买用户数
     *
     * @return
     */
    long countHasOrderUser();
    /**
     * 统计新增用户
     *
     * @return
     */
    List<Map<String, Object>> countNewUserByDate(@Param("channel")String channel,@Param("type")Integer type, @Param("years") String years,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    List<Map<String, Object>> countNewUserByDate(@Param("channel") String channel, @Param("type") Integer type,
            @Param("years") String years, @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 统计新增用户当日产生订单用户数量
     *
     * @return
     */
    List<Map<String, Object>> getTodayHasOrder(@Param("channel")String channel,@Param("type")Integer type, @Param("years") String years,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    List<Map<String, Object>> getTodayHasOrder(@Param("channel") String channel, @Param("type") Integer type,
            @Param("years") String years, @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 统计新增用户一周产生订单用户数量
     *
     * @return
     */
    Map<String, Object> getWeekHasOrder(@Param("channel")String channel, @Param("startTime")String startTime,
            @Param("endTime")String endTime, @Param("orderNum")Integer orderNum);
    Map<String, Object> getWeekHasOrder(@Param("channel") String channel, @Param("startTime") String startTime,
            @Param("endTime") String endTime, @Param("orderNum") Integer orderNum);
    /**
     * 根据电话号码、邀请码获取邀请用户
     *
     * @param phone
     * @param inviteCode
     * @return
     */
    UserInfo getInfoByPhoneOrInviteCode(@Param("phone")String phone, @Param("inviteCode")String inviteCode);
    UserInfo getInfoByPhoneOrInviteCode(@Param("phone") String phone, @Param("inviteCode") String inviteCode);
    // 根据AppId与电话号码获取用户
    List<UserInfo> listByClosed(@Param("appId") String appId, @Param("phone") String phone);
fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java
@@ -97,11 +97,11 @@
        e.printStackTrace();
        String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd");
        String os = System.getProperty("os.name");
        String filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.txt", date);
        String filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date);
        if (os.toLowerCase().startsWith("win")) {
            filePath = String.format("C:/logs/error_detail_%s.txt", date);
            filePath = String.format("C:/logs/error_detail_%s.log", date);
        } else
            filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.txt", date);
            filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date);
        OutputStream out = null;
@@ -128,11 +128,11 @@
        e.printStackTrace();
        String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd");
        String os = System.getProperty("os.name");
        String filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.txt", date);
        String filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date);
        if (os.toLowerCase().startsWith("win")) {
            filePath = String.format("C:/logs/error_detail_%s.txt", date);
            filePath = String.format("C:/logs/error_detail_%s.log", date);
        } else
            filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.txt", date);
            filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date);
        OutputStream out = null;
        try {
            out = new FileOutputStream(new File(filePath), true);
fanli/src/main/java/com/yeshi/fanli/mapping/UserInfoMapper.xml
@@ -30,7 +30,7 @@
        <!-- <association property="system" column="sid" resultMap="com.yeshi.fanli.dao.mybatis.SystemMapper.BaseResultMap" 
            /> -->
    </resultMap>
    <resultMap id="BaseResultMapVO" type="com.yeshi.fanli.vo.user.UserInfoVO">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="identifycode" property="openid" jdbcType="VARCHAR" />
@@ -38,7 +38,8 @@
        <result column="wx_open_id" property="wxOpenId" jdbcType="VARCHAR" />
        <result column="wx_union_id" property="wxUnionId" jdbcType="VARCHAR" />
        <result column="nick_name" property="nickName" jdbcType="VARCHAR" />
        <result column="uiet_taobao_nick_name" property="tbName" jdbcType="VARCHAR" />
        <result column="uiet_taobao_nick_name" property="tbName"
            jdbcType="VARCHAR" />
        <result column="tbPic" property="tbPic" jdbcType="VARCHAR" />
        <result column="wxName" property="wxName" jdbcType="VARCHAR" />
        <result column="wxPic" property="wxPic" jdbcType="VARCHAR" />
@@ -56,42 +57,49 @@
        <result column="phone" property="phone" jdbcType="VARCHAR" />
        <result column="state" property="state" jdbcType="INTEGER" />
        <result column="state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="ur_id" property="rankId" jdbcType="BIGINT" />
        <result column="ur_name" property="rankName"    jdbcType="VARCHAR" />
        <result column="ur_picture" property="rankPicture"    jdbcType="VARCHAR" />
        <result column="totalOrder" property="totalOrder"    jdbcType="BIGINT" />
        <result column="monthOrder" property="monthOrder"    jdbcType="BIGINT" />
        <result column="uiet_special_id" property="tbSpecialId"    jdbcType="VARCHAR" />
        <result column="uiet_relation_id" property="tbRelationId"    jdbcType="VARCHAR" />
        <result column="uiet_taobao_uid" property="taoBaoUid"    jdbcType="VARCHAR" />
        <result column="wxUnionIdInvalid" property="wxUnionIdInvalid"    jdbcType="VARCHAR" />
        <result column="taobaoUidInvalid" property="taobaoUidInvalid"    jdbcType="VARCHAR" />
        <result column="phoneInvalid" property="phoneInvalid"    jdbcType="VARCHAR" />
        <result column="alipayAccountInvalid" property="alipayAccountInvalid"    jdbcType="VARCHAR" />
        <result column="uie_gold_coin" property="goldCoin"    jdbcType="INTEGER" />
        <result column="ur_name" property="rankName" jdbcType="VARCHAR" />
        <result column="ur_picture" property="rankPicture" jdbcType="VARCHAR" />
        <result column="totalOrder" property="totalOrder" jdbcType="BIGINT" />
        <result column="monthOrder" property="monthOrder" jdbcType="BIGINT" />
        <result column="uiet_special_id" property="tbSpecialId"
            jdbcType="VARCHAR" />
        <result column="uiet_relation_id" property="tbRelationId"
            jdbcType="VARCHAR" />
        <result column="uiet_taobao_uid" property="taoBaoUid" jdbcType="VARCHAR" />
        <result column="wxUnionIdInvalid" property="wxUnionIdInvalid"
            jdbcType="VARCHAR" />
        <result column="taobaoUidInvalid" property="taobaoUidInvalid"
            jdbcType="VARCHAR" />
        <result column="phoneInvalid" property="phoneInvalid" jdbcType="VARCHAR" />
        <result column="alipayAccountInvalid" property="alipayAccountInvalid"
            jdbcType="VARCHAR" />
        <result column="uie_gold_coin" property="goldCoin" jdbcType="INTEGER" />
    </resultMap>
    <sql id="Base_Column_List">id,identifycode,login_type,wx_open_id,wx_union_id,nick_name,tbName,tbPic,wxName,wxPic,portrait,createtime,last_logintime,loginip,tuiguang_code,appid,my_hongBao,pay_password,sid,rank,phone,state,state_desc
    </sql>
    <!-- 不能查询缓存 -->
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        parameterType="java.lang.Long" flushCache="true" useCache="false">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where id = #{id,jdbcType=BIGINT}
    </select>
        <!-- 不能查询缓存 -->
    <select id="selectAvailableByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long" flushCache="true" useCache="false">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where id = #{id,jdbcType=BIGINT} and `state`=0
    </select>
    <select id="selectByPKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
@@ -245,360 +253,437 @@
    <select id="listByAppIdAndPhone" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where appid=#{appId} and phone=#{phone}
        from yeshi_ec_user where appid=#{appId} and phone=#{phone}
    </select>
    <!-- 根据AppId与电话号码获取用户 -->
    <select id="getEffectiveUserInfoByPhone" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" /> from yeshi_ec_user
        where phone=#{phone} AND state = 0
        LIMIT 1
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user
        where phone=#{phone} AND state = 0
        LIMIT 1
    </select>
    <!-- 根据AppId与电话号码获取用户 -->
    <select id="getEffectiveUserInfoByWXUnionId" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" /> from yeshi_ec_user
        where wx_union_id=#{unionId} AND state = 0
        LIMIT 1
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user
        where wx_union_id=#{unionId} AND state = 0
        LIMIT 1
    </select>
    <select id="getMaxUid" resultType="java.lang.Long">select max(id) from
        yeshi_ec_user
    </select>
    <!-- 两个账号的业务融合 -->
    <select id="connectUser" >
     call procedure_connect_user(#{mainUid},#{lessUid})
    <select id="connectUser">
        call procedure_connect_user(#{mainUid},#{lessUid})
    </select>
    <select id="query"  resultMap="BaseResultMapVO">
           SELECT *
           ,(SELECT COUNT(hb.hb_id) FROM `yeshi_ec_hongbao_v2` hb
                   WHERE hb.hb_uid = u.id AND hb.hb_type = 1 )AS totalOrder <!-- 累计订单 -->
           ,(SELECT COUNT(hb.hb_id) FROM `yeshi_ec_hongbao_v2` hb
                   WHERE hb.hb_uid = u.id AND hb.hb_type = 1
                   AND DATE_FORMAT(hb.`hb_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m'))AS monthOrder <!-- 累计本月订单 -->
        ,(SELECT COUNT(tr.`id`) FROM `yeshi_ec_threesale` tr  <!-- 队员 -->
             WHERE  tr.`boss_id`=u.id AND tr.state = 1) AS totalPlayers
           FROM yeshi_ec_user u
               LEFT JOIN yeshi_ec_binding_account  b ON u.`id` = b.`uid`
               LEFT JOIN yeshi_ec_user_info_extra  ext ON u.`id` = ext.uie_uid
               LEFT JOIN yeshi_ec_user_rank rak ON rak.ur_id = ext.uie_rank_id
               LEFT JOIN yeshi_ec_user_info_extra_taobao tb ON  tb.`uiet_uid` = u.id
        <if test="userState == 2">
               LEFT JOIN
                (SELECT A.uid AS buid,MAX(A.f_wxUnionId) AS wxUnionIdInvalid ,MAX(A.f_taobaoUid) AS taobaoUidInvalid,MAX(A.f_phone) AS phoneInvalid,MAX(A.f_alipayAccount) AS alipayAccountInvalid FROM
                    (SELECT u.`id`AS uid,b.account AS alipayAccount,b.name AS alipayAccountName,fu.* FROM yeshi_ec_user u
                LEFT JOIN yeshi_ec_binding_account b ON b.`uid` = u.`id`
                LEFT JOIN yeshi_ec_user_info_extra_taobao tb ON  tb.`uiet_uid` = u.id
                LEFT JOIN (SELECT fc.fuc_effective,IF(fc.`fuc_type` = 'wxUnionId',fc.`fuc_identify_code`,NULL)AS f_wxUnionId,
                    IF(fc.`fuc_type` = 'taobaoUid',fc.`fuc_identify_code`,NULL)AS f_taobaoUid,
                    IF(fc.`fuc_type` = 'phone',fc.`fuc_identify_code`,NULL)AS f_phone,
                    IF(fc.`fuc_type` = 'alipayAccount',fc.`fuc_identify_code`,NULL)AS f_alipayAccount
                FROM yeshi_ec_forbidden_user_identify_code fc WHERE fc.fuc_effective = 1 )fu ON (fu.f_wxUnionId = u.`wx_union_id` OR fu.f_taobaoUid = tb.`uiet_taobao_uid` OR fu.f_phone = u.`phone` OR fu.f_alipayAccount = b.`account`)
                WHERE u.`state` =2
            )A GROUP BY A.uid) B ON u.id= B.buid
           </if>
           where 1=1
               <if test="userState == 1">
                   AND u.`state` <![CDATA[<>]]> 2 <!--  正常用户 -->
               </if>
               <if test="userState == 2">
                    AND u.`state` =2   <!-- 封禁用户 -->
               </if>
               <if test="startTime != null and startTime !='' ">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[>=]]> DATE_FORMAT(#{startTime},'%Y%m%d')
               </if>
               <if test="endTime != null and endTime !=''">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[<=]]> DATE_FORMAT(#{endTime},'%Y%m%d')
               </if>
                  <if test="userRank != null">
                   AND rak.ur_name = #{userRank}
               </if>
               <if test="days != null">
                    <!--  注册时间   -->
                    AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(u.createtime/1000)]]>
    <select id="query" resultMap="BaseResultMapVO">
        SELECT *
        ,(SELECT COUNT(hb.hb_id) FROM `yeshi_ec_hongbao_v2` hb
        WHERE
        hb.hb_uid = u.id AND hb.hb_type = 1 )AS totalOrder <!-- 累计订单 -->
        ,(SELECT COUNT(hb.hb_id) FROM `yeshi_ec_hongbao_v2` hb
        WHERE hb.hb_uid
        = u.id AND hb.hb_type = 1
        AND DATE_FORMAT(hb.`hb_create_time`,'%Y%m') =
        DATE_FORMAT(CURDATE(),'%Y%m'))AS monthOrder <!-- 累计本月订单 -->
        ,(SELECT COUNT(tr.`id`) FROM `yeshi_ec_threesale` tr  <!-- 队员 -->
        WHERE tr.`boss_id`=u.id AND tr.state = 1) AS totalPlayers
        FROM
        yeshi_ec_user u
        LEFT JOIN yeshi_ec_binding_account b ON u.`id` =
        b.`uid`
        LEFT JOIN yeshi_ec_user_info_extra ext ON u.`id` = ext.uie_uid
        LEFT JOIN yeshi_ec_user_rank rak ON rak.ur_id = ext.uie_rank_id
        LEFT
        JOIN yeshi_ec_user_info_extra_taobao tb ON tb.`uiet_uid` = u.id
        <if test="userState == 2">
            LEFT JOIN
            (SELECT A.uid AS buid,MAX(A.f_wxUnionId) AS
            wxUnionIdInvalid
            ,MAX(A.f_taobaoUid) AS
            taobaoUidInvalid,MAX(A.f_phone) AS
            phoneInvalid,MAX(A.f_alipayAccount) AS alipayAccountInvalid FROM
            (SELECT u.`id`AS uid,b.account AS alipayAccount,b.name AS
            alipayAccountName,fu.* FROM yeshi_ec_user u
            LEFT JOIN
            yeshi_ec_binding_account b ON b.`uid` = u.`id`
            LEFT JOIN
            yeshi_ec_user_info_extra_taobao tb ON tb.`uiet_uid` = u.id
            LEFT JOIN
            (SELECT fc.fuc_effective,IF(fc.`fuc_type` =
            'wxUnionId',fc.`fuc_identify_code`,NULL)AS f_wxUnionId,
            IF(fc.`fuc_type` = 'taobaoUid',fc.`fuc_identify_code`,NULL)AS
            f_taobaoUid,
            IF(fc.`fuc_type` = 'phone',fc.`fuc_identify_code`,NULL)AS
            f_phone,
            IF(fc.`fuc_type` =
            'alipayAccount',fc.`fuc_identify_code`,NULL)AS f_alipayAccount
            FROM
            yeshi_ec_forbidden_user_identify_code fc WHERE fc.fuc_effective
            = 1
            )fu ON (fu.f_wxUnionId = u.`wx_union_id` OR fu.f_taobaoUid =
            tb.`uiet_taobao_uid` OR fu.f_phone = u.`phone` OR fu.f_alipayAccount
            = b.`account`)
            WHERE u.`state` =2
            )A GROUP BY A.uid) B ON u.id= B.buid
        </if>
        where 1=1
        <if test="userState == 1">
            AND u.`state` <![CDATA[<>]]>
            2 <!-- 正常用户 -->
        </if>
        <if test="userState == 2">
            AND u.`state` =2   <!-- 封禁用户 -->
        </if>
        <if test="startTime != null and startTime !='' ">
            AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[>=]]>
            DATE_FORMAT(#{startTime},'%Y%m%d')
        </if>
        <if test="endTime != null and endTime !=''">
            AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[<=]]>
            DATE_FORMAT(#{endTime},'%Y%m%d')
        </if>
        <if test="userRank != null">
            AND rak.ur_name = #{userRank}
        </if>
        <if test="days != null">
            <!-- 注册时间 -->
            AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(u.createtime/1000)]]>
        </if>
        <if test="key != null and key !='' ">
            <if test="keyType == 1">
                AND u.id = #{key}
            </if>
               <if test="key != null and key !='' ">
                   <if test="keyType == 1">
                       AND    u.id  = #{key}
                   </if>
                   <if test="keyType == 2">
                       AND    u.`nick_name` LIKE '%${key}%'
                   </if>
                   <if test="keyType == 3">
                       AND    u.`phone` = #{key}
                   </if>
                   <if test="keyType == 4">
                       AND    b.`account` = #{key}
                   </if>
               </if>
              ORDER BY
              <if test="orderField == 1">
                  totalOrder,
              </if>
              <if test="orderField == 2">
                  totalOrder DESC,
              </if>
              <if test="orderField == 3">
                  monthOrder,
              </if>
              <if test="orderField == 4">
                  monthOrder DESC,
              </if>
              <if test="orderField == 5">
                  totalPlayers,
              </if>
              <if test="orderField == 6">
                  totalPlayers DESC,
              </if>
              u.createtime DESC
              LIMIT ${start},${count}
            <if test="keyType == 2">
                AND u.`nick_name` LIKE '%${key}%'
            </if>
            <if test="keyType == 3">
                AND u.`phone` = #{key}
            </if>
            <if test="keyType == 4">
                AND b.`account` = #{key}
            </if>
        </if>
        ORDER BY
        <if test="orderField == 1">
            totalOrder,
        </if>
        <if test="orderField == 2">
            totalOrder DESC,
        </if>
        <if test="orderField == 3">
            monthOrder,
        </if>
        <if test="orderField == 4">
            monthOrder DESC,
        </if>
        <if test="orderField == 5">
            totalPlayers,
        </if>
        <if test="orderField == 6">
            totalPlayers DESC,
        </if>
        u.createtime DESC
        LIMIT ${start},${count}
    </select>
    <select id="queryCount" resultType="java.lang.Long">
           SELECT IFNULL(count(u.id),0) FROM yeshi_ec_user u
               LEFT JOIN yeshi_ec_binding_account  b ON u.`id` = b.`uid`
               LEFT JOIN yeshi_ec_user_info_extra  ext ON u.`id` = ext.uie_uid
               LEFT JOIN yeshi_ec_user_rank rak ON rak.ur_id = ext.uie_rank_id
           where 1=1
                <if test="userState == 1">
                   AND u.`state` <![CDATA[<>]]> 2 <!--  正常用户 -->
               </if>
               <if test="userState == 2">
                    AND u.`state` =2   <!-- 封禁用户 -->
               </if>
                <if test="startTime != null and startTime !='' ">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[>=]]> DATE_FORMAT(#{startTime},'%Y%m%d')
                </if>
                <if test="endTime != null and endTime !=''">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[<=]]> DATE_FORMAT(#{endTime},'%Y%m%d')
                </if>
                   <if test="userRank != null">
                   AND rak.ur_name = #{userRank}
                </if>
                <if test="days != null">  <!--  注册时间   -->
                    AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(u.createtime/1000)]]>
             </if>
             <if test="key != null and key !='' ">
                   <if test="keyType == 1">
                       AND    u.id  = #{key}
                   </if>
                   <if test="keyType == 2">
                       AND    u.`nick_name` LIKE '%${key}%'
                   </if>
                   <if test="keyType == 3">
                       AND    u.`phone` = #{key}
                   </if>
                   <if test="keyType == 4">
                       AND    b.`account` = #{key}
                   </if>
               </if>
        SELECT IFNULL(count(u.id),0) FROM yeshi_ec_user u
        LEFT JOIN
        yeshi_ec_binding_account b ON u.`id` = b.`uid`
        LEFT JOIN
        yeshi_ec_user_info_extra ext ON u.`id` = ext.uie_uid
        LEFT JOIN
        yeshi_ec_user_rank rak ON rak.ur_id = ext.uie_rank_id
        where 1=1
        <if test="userState == 1">
            AND u.`state` <![CDATA[<>]]>
            2 <!-- 正常用户 -->
        </if>
        <if test="userState == 2">
            AND u.`state` =2   <!-- 封禁用户 -->
        </if>
        <if test="startTime != null and startTime !='' ">
            AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[>=]]>
            DATE_FORMAT(#{startTime},'%Y%m%d')
        </if>
        <if test="endTime != null and endTime !=''">
            AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[<=]]>
            DATE_FORMAT(#{endTime},'%Y%m%d')
        </if>
        <if test="userRank != null">
            AND rak.ur_name = #{userRank}
        </if>
        <if test="days != null">  <!-- 注册时间 -->
            AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(u.createtime/1000)]]>
        </if>
        <if test="key != null and key !='' ">
            <if test="keyType == 1">
                AND u.id = #{key}
            </if>
            <if test="keyType == 2">
                AND u.`nick_name` LIKE '%${key}%'
            </if>
            <if test="keyType == 3">
                AND u.`phone` = #{key}
            </if>
            <if test="keyType == 4">
                AND b.`account` = #{key}
            </if>
        </if>
    </select>
    <select id="querySumMoney" resultType="java.lang.Double">
           SELECT COALESCE(sum(u.my_hongBao),0) FROM yeshi_ec_user u
               LEFT JOIN yeshi_ec_binding_account  b ON u.`id` = b.`uid`
           where <![CDATA[ 1>0 ]]>
                <if test="key != null and key !='' ">
                   AND    (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%'  OR u.`wxName` LIKE '%${key}%'
                   OR u.`nick_name` LIKE '%${key}%'  OR u.`tbName` LIKE '%${key}%' OR b.`account` LIKE '%${key}%')
                </if>
                <if test="startTime != null and startTime !='' ">
                   <![CDATA[ AND FROM_UNIXTIME(createtime/1000) >= '${startTime}' ]]>
                </if>
                <if test="endTime != null and endTime !=''">
                   <![CDATA[ AND FROM_UNIXTIME(createtime/1000) < '${endTime}'  ]]>
                </if>
                   <if test="userType != null">
                   AND u.rank = #{userType}
                </if>
                  <if test="days != null">
                <!--  时间   -->
                    AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(createtime/1000)]]>
            </if>
        SELECT COALESCE(sum(u.my_hongBao),0) FROM yeshi_ec_user u
        LEFT JOIN
        yeshi_ec_binding_account b ON u.`id` = b.`uid`
        where <![CDATA[ 1>0 ]]>
        <if test="key != null and key !='' ">
            AND (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%' OR
            u.`wxName`
            LIKE '%${key}%'
            OR u.`nick_name` LIKE '%${key}%' OR
            u.`tbName` LIKE '%${key}%' OR
            b.`account` LIKE '%${key}%')
        </if>
        <if test="startTime != null and startTime !='' ">
                   <![CDATA[ AND FROM_UNIXTIME(createtime/1000) >= '${startTime}' ]]>
        </if>
        <if test="endTime != null and endTime !=''">
                   <![CDATA[ AND FROM_UNIXTIME(createtime/1000) < '${endTime}'  ]]>
        </if>
        <if test="userType != null">
            AND u.rank = #{userType}
        </if>
        <if test="days != null">
            <!-- 时间 -->
            AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(createtime/1000)]]>
        </if>
    </select>
    <select id="countNewUser" resultType="java.lang.Long">
           SELECT COALESCE(count(id),0) FROM `yeshi_ec_user`
           WHERE 1=1
                <if test="isToday != null and isToday == 1">
                AND TO_DAYS(FROM_UNIXTIME(createtime/1000)) = TO_DAYS(NOW())
            </if>
            <if test="isMonth != null and isMonth == 1">
                AND DATE_FORMAT( FROM_UNIXTIME(createtime/1000), '%Y%m' ) = DATE_FORMAT(CURDATE() , '%Y%m' )
            </if>
        SELECT COALESCE(count(id),0) FROM `yeshi_ec_user`
        WHERE 1=1
        <if test="isToday != null and isToday == 1">
            AND TO_DAYS(FROM_UNIXTIME(createtime/1000)) =
            TO_DAYS(NOW())
        </if>
        <if test="isMonth != null and isMonth == 1">
            AND DATE_FORMAT( FROM_UNIXTIME(createtime/1000), '%Y%m' )
            =
            DATE_FORMAT(CURDATE() , '%Y%m' )
        </if>
    </select>
    <select id="countRank" resultType="java.lang.Long">
       <!--  等级统计 -->
           SELECT COALESCE(count(id),0) FROM `yeshi_ec_user` WHERE rank = #{rank}
        <!-- 等级统计 -->
        SELECT COALESCE(count(id),0) FROM `yeshi_ec_user` WHERE rank = #{rank}
    </select>
    <select id="countAllMoney" resultType="java.math.BigDecimal">
       <!--  金额统计 -->
           SELECT CAST(SUM(my_hongBao)AS DECIMAL(19,2)) FROM `yeshi_ec_user`
           WHERE 1=1
               <if test="minMoney != null">
              AND <![CDATA[ my_hongBao >= #{minMoney}]]>
            </if>
        <!-- 金额统计 -->
        SELECT CAST(SUM(my_hongBao)AS DECIMAL(19,2)) FROM `yeshi_ec_user`
        WHERE 1=1
        <if test="minMoney != null">
            AND <![CDATA[ my_hongBao >= #{minMoney}]]>
        </if>
    </select>
    <select id="countShareAndInviteMoney" resultMap="BaseResultMap">
        SELECT IFNULL(SUM(h.`money`),0),h.`uid` FROM `yeshi_ec_hongbao` h
        WHERE  DATE_FORMAT(FROM_UNIXTIME(h.`createtime`/1000), '%Y-%m-%d' )= '2018-08-02'
        <![CDATA[AND h.state <>4]]>
         AND ( h.`type` =5 OR  h.`type` =6 OR h.`type` =7 OR  h.`type` =20 OR h.`type` =21 OR h.`type` =22 )
        GROUP BY h.`uid`
        ORDER BY SUM(h.`money`) DESC
         LIMIT ${start},${count}
        SELECT IFNULL(SUM(h.`money`),0),h.`uid` FROM `yeshi_ec_hongbao` h
        WHERE DATE_FORMAT(FROM_UNIXTIME(h.`createtime`/1000), '%Y-%m-%d' )=
        '2018-08-02'
        <![CDATA[AND h.state <>4]]>
        AND ( h.`type` =5 OR h.`type` =6 OR h.`type` =7 OR h.`type` =20 OR
        h.`type` =21 OR h.`type` =22 )
        GROUP BY h.`uid`
        ORDER BY SUM(h.`money`)
        DESC
        LIMIT ${start},${count}
    </select>
    <select id="longTimeNoLogin"  resultType="java.lang.Long">
        SELECT u.`id` FROM `yeshi_ec_user` u
        WHERE  u.`id` IN <foreach item="item" collection="list" open="(" separator=","
    <select id="longTimeNoLogin" resultType="java.lang.Long">
        SELECT u.`id` FROM `yeshi_ec_user` u
        WHERE u.`id` IN
        <foreach item="item" collection="list" open="(" separator=","
            close=")">#{item}</foreach>
        AND <![CDATA[ (DATE_SUB(CURDATE(), INTERVAL ${daysNum} DAY) > DATE(FROM_UNIXTIME(u.`last_logintime`/1000))  
            OR (u.`last_logintime` IS NULL 
                AND DATE_SUB(CURDATE(), INTERVAL ${daysNum} DAY) > DATE(FROM_UNIXTIME(u.`createTime`/1000)))) ]]>
    </select>
    <select id="countLoseUser" resultType="java.lang.Long">
        SELECT  COUNT(DISTINCT t.`id` ) FROM `yeshi_ec_user` t
        LEFT JOIN `yeshi_ec_user_money_detail` d ON d.`umd_uid` = t.`id`
        WHERE DATE_SUB(CURDATE(), INTERVAL ${num} DAY)<![CDATA[> ]]> DATE(FROM_UNIXTIME( t.`last_logintime`/1000))
               AND DATE_SUB(CURDATE(), INTERVAL ${num} DAY) <![CDATA[> ]]> DATE(d.`umd_createtime`)
        SELECT COUNT(DISTINCT t.`id` ) FROM `yeshi_ec_user` t
        LEFT JOIN
        `yeshi_ec_user_money_detail` d ON d.`umd_uid` = t.`id`
        WHERE
        DATE_SUB(CURDATE(), INTERVAL ${num} DAY)<![CDATA[> ]]>
        DATE(FROM_UNIXTIME( t.`last_logintime`/1000))
        AND DATE_SUB(CURDATE(),
        INTERVAL ${num} DAY) <![CDATA[> ]]>
        DATE(d.`umd_createtime`)
    </select>
    <select id="countHasOrderUser" resultType="java.lang.Long">
        SELECT COUNT(DISTINCT h.`hb_uid`) FROM yeshi_ec_hongbao_v2 h
        WHERE (h.`hb_type`=1 or  h.`hb_type`=2 or h.`hb_type`= 20)
        SELECT COUNT(DISTINCT
        h.`hb_uid`) FROM yeshi_ec_hongbao_v2 h
        WHERE (h.`hb_type`=1 or
        h.`hb_type`=2 or h.`hb_type`= 20)
    </select>
    <select id="countNewUserByDate" resultType="java.util.HashMap">
        SELECT COUNT(DISTINCT h.`id`) AS showValue,
            <if test="type == 1">
                 FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
            <if test="type == 2">
                 FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'showDate'
            </if>
            <if test="type == 3">
                 FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'showDate'
            </if>
        FROM yeshi_ec_user h
            <if test="channel != null and  channel != 'all' ">
                left join (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`)a ON h.`id`=a.uid
            </if>
        WHERE 1=1
            <if test="channel != null and  channel != 'all' ">
                AND a.uid is not null
            </if>
            <if test="startTime != null and startTime != '' ">
                 AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                 AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="years != null and years != '' ">
                 AND FROM_UNIXTIME(h.`createtime`/1000,'%Y') = '${years}'
            </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')
            FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS
            'showDate'
        </if>
        <if test="type == 2">
             GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m')
            FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'showDate'
        </if>
        <if test="type == 3">
             GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y')
        </if>
            FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'showDate'
        </if>
        FROM yeshi_ec_user h
        <if test="channel != null and  channel != 'all' ">
            left join (SELECT a.`lua_uid` AS uid FROM
            `yeshi_ec_log_user_active` a
            WHERE a.`lua_channel`='${channel}' GROUP
            BY a.`lua_uid`)a ON
            h.`id`=a.uid
        </if>
        WHERE 1=1
        <if test="channel != null and  channel != 'all' ">
            AND a.uid is not null
        </if>
        <if test="startTime != null and startTime != '' ">
            AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
            '${endTime}'
        </if>
        <if test="years != null and years != '' ">
            AND FROM_UNIXTIME(h.`createtime`/1000,'%Y') = '${years}'
        </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
            GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
            GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y')
        </if>
        ORDER BY h.`createtime`
    </select>
    <select id="getTodayHasOrder" resultType="java.util.HashMap">
        SELECT COALESCE(COUNT(DISTINCT u.`id`),0) AS 'showValue',
            <if test="type == 1">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
            <if test="type == 2">
                 FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate'
            </if>
            <if test="type == 3">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate'
            </if>
        FROM  yeshi_ec_user u
        <if test="channel != null and channel != 'all' ">
            LEFT JOIN  (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON u.`id`=a.uid
        </if>
        LEFT JOIN `yeshi_ec_hongbao_v2` h ON h.`hb_uid`= u.`id`
        WHERE (h.`hb_type`=1 OR h.`hb_type`=20)
            <if test="channel != null and  channel != 'all' ">
                AND a.uid is not null
            </if>
            <!-- 当日下单 -->
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = DATE_FORMAT(h.hb_create_time,'%Y-%m-%d')
            <if test="startTime != null and startTime != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="years != null and years != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}'
            </if>
        SELECT COALESCE(COUNT(DISTINCT u.`id`),0) AS 'showValue',
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
            FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS
            'showDate'
        </if>
        <if test="type == 2">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m')
            FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate'
        </if>
        <if test="type == 3">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y')
        </if>
            FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate'
        </if>
        FROM yeshi_ec_user u
        <if test="channel != null and channel != 'all' ">
            LEFT JOIN (SELECT a.`lua_uid` AS uid FROM
            `yeshi_ec_log_user_active` a
            WHERE a.`lua_channel`='${channel}' GROUP
            BY a.`lua_uid`) a ON u.`id`=a.uid
        </if>
        LEFT JOIN `yeshi_ec_hongbao_v2` h ON h.`hb_uid`= u.`id`
        WHERE
        (h.`hb_type`=1 OR h.`hb_type`=20)
        <if test="channel != null and  channel != 'all' ">
            AND a.uid is not null
        </if>
        <!-- 当日下单 -->
        AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') =
        DATE_FORMAT(h.hb_create_time,'%Y-%m-%d')
        <if test="startTime != null and startTime != '' ">
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
            '${endTime}'
        </if>
        <if test="years != null and years != '' ">
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}'
        </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y')
        </if>
        ORDER BY u.`createtime`
    </select>
    <select id="getWeekHasOrder" resultType="java.util.HashMap">
        SELECT COUNT(DISTINCT hb.uid) AS showValue,FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
        FROM (SELECT COUNT(v2.`hb_id`) AS num,v2.hb_uid  AS uid
              FROM yeshi_ec_hongbao_v2 v2
              WHERE   (v2.`hb_type`=1 OR v2.`hb_type`=20)
                  AND DATE_FORMAT(v2.`hb_create_time`,'%Y-%m-%d') <![CDATA[ >= ]]>'${startTime}'
                 AND DATE_FORMAT(v2.`hb_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
              GROUP BY v2.hb_uid HAVING num >= ${orderNum})hb
        LEFT JOIN yeshi_ec_user u  ON u.id = hb.uid
        SELECT COUNT(DISTINCT hb.uid) AS
        showValue,FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
        FROM (SELECT COUNT(v2.`hb_id`) AS num,v2.hb_uid AS uid
        FROM
        yeshi_ec_hongbao_v2 v2
        WHERE (v2.`hb_type`=1 OR v2.`hb_type`=20)
        AND
        DATE_FORMAT(v2.`hb_create_time`,'%Y-%m-%d') <![CDATA[ >= ]]>'${startTime}'
        AND DATE_FORMAT(v2.`hb_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
        GROUP BY v2.hb_uid HAVING num >= ${orderNum})hb
        LEFT JOIN yeshi_ec_user
        u ON u.id = hb.uid
        <if test="channel != null and channel != 'all' ">
            LEFT JOIN  (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON u.`id`=a.uid
            LEFT JOIN (SELECT a.`lua_uid` AS uid FROM
            `yeshi_ec_log_user_active` a
            WHERE a.`lua_channel`='${channel}' GROUP
            BY a.`lua_uid`) a ON u.`id`=a.uid
        </if>
        WHERE FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = '${startTime}'
            <if test="channel != null and  channel != 'all' ">
               AND a.uid is not null
            </if>
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        ORDER BY u.`createtime`
        <if test="channel != null and  channel != 'all' ">
            AND a.uid is not null
        </if>
        GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        ORDER BY
        u.`createtime`
    </select>
    <select id="getInfoByPhoneOrInviteCode" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_user u
        LEFT JOIN yeshi_ec_user_info_extra uf ON uf.`uie_uid` = u.`id`
        WHERE uf.`uie_invite_code` IS NOT NULL
              AND (u.`phone` =#{phone} OR uf.`uie_invite_code` = #{inviteCode})
        SELECT * FROM
        yeshi_ec_user u
        LEFT JOIN yeshi_ec_user_info_extra uf ON uf.`uie_uid` =
        u.`id`
        WHERE
        uf.`uie_invite_code` IS NOT NULL
        AND (u.`phone` =#{phone} OR
        uf.`uie_invite_code` = #{inviteCode})
        LIMIT 1
    </select>
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
@@ -246,7 +246,7 @@
            // throw new ShareGoodsException(4, "生成二维码失败");
            // }
            // 获取到用户的头像
            UserInfo user = userinfoMapper.selectByPrimaryKey(uid);
            UserInfo user = userinfoMapper.selectAvailableByPrimaryKey(uid);
            InputStream portrait = null;
            if (!StringUtil.isNullOrEmpty(user.getPortrait())) {
                try {
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserSystemMsgServiceImpl.java
@@ -118,7 +118,7 @@
    @Override
    public void syncSystemZNX(Long uid) {
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null)
            return;
        long createTime = user.getCreatetime();
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -338,7 +338,7 @@
        // 查询最新的红包数据
        hb1 = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hb1.getId());
        // 正常用户才能到账
        UserInfo mainUser = userInfoMapper.selectByPrimaryKey(hb1.getUserInfo().getId());
        UserInfo mainUser = userInfoMapper.selectAvailableByPrimaryKey(hb1.getUserInfo().getId());
        if (mainUser == null || mainUser.getState() != UserInfo.STATE_NORMAL) {
            return;
        }
@@ -462,7 +462,7 @@
            }
            // 站内信+推送
            UserInfo user = userInfoMapper.selectByPKey(uid);
            UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
            // 新版通知
            userMoneyMsgNotificationService.fanliOrderReceived(uid, hongBaoOrder.getCommonOrder().getOrderNo(),
@@ -652,7 +652,7 @@
                if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
                    CommonOrder co = hongBaoOrder.getCommonOrder();
                    // 上级用户不是正常用户,订单均不能到账
                    UserInfo userInfo = userInfoMapper.selectByPrimaryKey(co.getUserInfo().getId());
                    UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId());
                    if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
                        hongBaoList.remove(i);
                        i--;
@@ -776,7 +776,7 @@
            // 新版通知
            userMoneyMsgNotificationService.inviteOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, inviteOrders.size(),
                    inviteGoodsCount, invitemoney, userInfoMapper.selectByPKey(uid).getMyHongBao());
                    inviteGoodsCount, invitemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
            for (String orderId : drawBackOrders)
                taoBaoWeiQuanDrawBackService.doWeiQuanInvite(orderId);
@@ -870,7 +870,7 @@
            // 新版通知
            userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(),
                    shareGoodsCount, sharemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
                    shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
            for (String orderId : drawBackOrders)
                taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId);
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java
@@ -25,6 +25,7 @@
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
@@ -187,6 +188,9 @@
                    new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), new Date(),
                    new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), app);
        } catch (TaoLiJinCreateException e1) {
            LogHelper.test("商品ID:"+auctionId);
            LogHelper.test("淘礼金验证出错:"+e1.getMsg());
            if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_FORBIDDEN) {
                // 该商品不支持创建淘礼金红包
                deleteByGoodsId(auctionId);
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java
@@ -241,7 +241,7 @@
            BigDecimal drawBackMoney = computeDrawBackMoney(settleMent, wqMoney, userGetMoney);
            // 计算资金是否充足
            UserInfo user = userInfoMapper.selectByPKey(uid);
            UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
            if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 资金不足
            {
                // 添加债务
@@ -284,7 +284,7 @@
            // 新版通知
            userMoneyMsgNotificationService.fanliOrderWeiQuan(uid, orderId, Constant.SOURCE_TYPE_TAOBAO, drawBackMoney,
                    userInfoMapper.selectByPKey(uid).getMyHongBao());
                    userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
        }
    }
@@ -410,7 +410,7 @@
            for (TaoBaoWeiQuanDrawBack drawBack : newWeiQuanDrawBackList)
                taoBaoWeiQuanDrawBackMapper.insertSelective(drawBack);
            // 计算资金是否充足
            UserInfo user = userInfoMapper.selectByPKey(uid);
            UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
            if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 资金不足
            {
                // 添加债务
@@ -451,7 +451,7 @@
            userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail);
            userMoneyMsgNotificationService.shareOrderWeiQuan(uid, orderId, Constant.SOURCE_TYPE_TAOBAO, drawBackMoney,
                    userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
                    userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
        }
    }
@@ -511,7 +511,7 @@
                    if (drawBackMoney != null && drawBackMoney.compareTo(new BigDecimal(0)) > 0) {
                        // 判断资金是否足够扣款
                        UserInfo user = userInfoMapper.selectByPKey(uid);
                        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
                        if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 资金不足
                        {
                            try {
@@ -539,7 +539,7 @@
                        // 新版通知
                        userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId, Constant.SOURCE_TYPE_TAOBAO,
                                drawBackMoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
                                drawBackMoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
                    }
                }
        }
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java
@@ -734,7 +734,7 @@
    @Override
    public void bindPhone(Long uid, String phone) throws UserAccountException {
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null)
            throw new UserAccountException(4, "用户不存在");
@@ -755,7 +755,7 @@
    @Override
    public void unBindPhone(Long uid, String phone) throws UserAccountException {
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null)
            throw new UserAccountException(4, "用户不存在");
@@ -777,7 +777,7 @@
    @Override
    public void bindTaoBao(Long uid, String tbOpenId, String tbNickName, String tbPortrait)
            throws UserAccountException {
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null)
            throw new UserAccountException(4, "用户不存在");
@@ -807,7 +807,7 @@
    @Override
    public void unBindTaoBao(Long uid) throws UserAccountException {
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null)
            throw new UserAccountException(4, "用户不存在");
        if (StringUtil.isNullOrEmpty(user.getOpenid()))
@@ -835,7 +835,7 @@
    @Override
    public void changeWXBind(AcceptData acceptData, Long uid, String code) throws UserAccountException {
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null)
            throw new UserAccountException(4, "用户不存在");
        WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
@@ -886,7 +886,7 @@
                TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMddHHmmss"));
        // 备份用户信息
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        // TODO 备份资金明细
@@ -923,7 +923,7 @@
    public void clearUserPortrait(Long uid) {
        if (uid == null)
            return;
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        String prefix = String.format("/portrait/wx/%s_", user.getWxUnionId());
        ObjectListing list = COSManager.getInstance().getObjectList(prefix, null, 30);
        if (list != null && list.getObjectSummaries() != null)
@@ -938,7 +938,7 @@
    public String repairPortrait(Long uid) {
        if (uid == null)
            return null;
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null)
            return null;
        String prefix = String.format("/portrait/wx/%s_", user.getWxUnionId());
@@ -1173,7 +1173,7 @@
    @Override
    public void bindPhoneNew(Long uid, String phone) throws UserAccountException {
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null) {
            throw new UserAccountException(1, "用户不存在");
        }
@@ -1214,7 +1214,7 @@
    @Override
    public void bindWeiXin(AcceptData acceptData, Long uid, String code) throws UserAccountException {
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null) {
            throw new UserAccountException(1, "用户不存在");
        }
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
@@ -668,7 +668,7 @@
    @Override
    public UserInfo getUserByIdWithMybatis(long uid) {
        UserInfo user = userInfoMapper.selectByPKey(uid);
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        return UserUtil.filterForClientUser(user);
    }
@@ -821,7 +821,7 @@
    @Override
    public UserInfo selectByPKey(Long id) {
        return userInfoMapper.selectByPKey(id);
        return userInfoMapper.selectByPrimaryKey(id);
    }
    @Override
@@ -891,7 +891,7 @@
            throw new UserInfoException(1, "请求参数为空");
        }
        UserInfo userInfo = userInfoMapper.selectByPKey(uid);
        UserInfo userInfo = userInfoMapper.selectByPrimaryKey(uid);
        if (userInfo == null) {
            throw new UserInfoException(1, "用户不存在");
        }
@@ -936,7 +936,7 @@
    @Override
    public BigDecimal getBalance(Long uid) {
        UserInfo user = userInfoMapper.selectByPKey(uid);
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        if (user != null)
            return user.getMyHongBao();
        return null;
@@ -945,7 +945,7 @@
    @Override
    public void uploadPortrait(MultipartFile file, Long uid) throws UserInfoException, IOException {
        UserInfo userInfo = userInfoMapper.selectByPKey(uid);
        UserInfo userInfo = userInfoMapper.selectByPrimaryKey(uid);
        if (userInfo == null) {
            throw new UserInfoException(1, "用户不存在");
        }
@@ -997,7 +997,7 @@
    @Override
    public void saveUserInfo(String nickName, Long uid) throws UserInfoException {
        UserInfo userInfo = userInfoMapper.selectByPKey(uid);
        UserInfo userInfo = userInfoMapper.selectByPrimaryKey(uid);
        if (userInfo == null) {
            throw new UserInfoException(1, "用户不存在");
        }
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java
@@ -458,7 +458,7 @@
        }
        // 获取到用户的头像
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null) {
            throw new UserShareGoodsRecordException(1, "用户信息不存在");
        }
@@ -991,7 +991,7 @@
        }
        // 获取到用户的头像
        UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null) {
            throw new UserShareGoodsRecordException(1, "用户信息不存在");
        }