| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- <?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.tdba.cxb.ares.api.repository.UserMapper">
- <select id="selectByTimeRegion" resultType="com.tdba.cxb.ares.api.model.UserDto">
- select
- uid,
- spread_uid
- from
- rrx_user
- where
- -- <![CDATA[ spread_uid > 0 ]]>
- <![CDATA[ create_time >= #{beginTime} ]]>
- <![CDATA[ and create_time <= #{endTime} ]]>
- </select>
- <select id="selectDacang" resultType="com.tdba.cxb.ares.api.model.UserDto">
- select
- count(1) 'num',
- u.spread_uid,
- group_concat(u.uid) 'uid_concat'
- from
- rrx_da_cang_user da
- left join
- rrx_user u
- on da.uid = u.uid
- where
- da.status = 1
- <![CDATA[ and da.ctime >= #{beginTime} ]]>
- <![CDATA[ and da.ctime <= #{endTime} ]]>
- and u.spread_uid > 0
- group by u.spread_uid
- </select>
- <select id="selectMerchant" resultType="com.tdba.cxb.ares.api.model.UserDto">
- select
- count(1) 'num',
- u.spread_uid,
- group_concat(u.uid) 'uid_concat'
- from
- rrx_merchant_admin da
- left join
- rrx_user u
- on da.uid = u.uid
- where
- da.status = 1
- <![CDATA[ and da.create_time >= #{beginTime} ]]>
- <![CDATA[ and da.create_time <=#{endTime} ]]>
- and u.spread_uid > 0
- group by u.spread_uid
- </select>
- <select id="selectChannel" resultType="com.tdba.cxb.ares.api.model.UserDto">
- select
- count(1) 'num',
- u.spread_uid,
- group_concat(u.uid) 'uid_concat'
- from
- rrx_channel_user da
- left join
- rrx_user u
- on da.uid = u.uid
- where
- da.status = 1
- <![CDATA[ and da.ctime >= #{beginTime} ]]>
- <![CDATA[ and da.ctime <= #{endTime} ]]>
- and u.spread_uid > 0
- group by u.spread_uid
- </select>
- <select id="selectAgent" resultType="com.tdba.cxb.ares.api.model.UserDto">
- select
- count(1) 'num',
- u.spread_uid,
- group_concat(u.uid) 'uid_concat'
- from
- rrx_user u
- where
- u.identity in (1, 2, 3)
- <![CDATA[ and u.create_time >= #{beginTime} ]]>
- <![CDATA[ and u.create_time <= #{endTime} ]]>
- and u.spread_uid > 0
- group by u.spread_uid
- </select>
- <select id="selectByAccount" resultType="com.tdba.cxb.ares.api.model.UserVo">
- select
- u.account 'mobile',
- u.uid 'id',
- u.nickname 'name',
- u.avatar
- from
- user_operator uo
- left join
- rrx_user u
- on uo.uid = u.uid
- where
- uo.del_flag = 0
- and u.status = 1
- and u.account = #{mobile}
- limit 1
- </select>
- <select id="selectByUid" resultType="com.tdba.cxb.ares.api.model.UserVo">
- select
- u.account 'mobile',
- u.uid 'id',
- u.nickname 'name',
- u.avatar
- from
- user_operator uo
- left join
- rrx_user u
- on uo.uid = u.uid
- where
- uo.del_flag = 0
- and u.status = 1
- and u.uid = #{uid}
- limit 1
- </select>
- <select id="selectByBindUid" resultType="com.tdba.cxb.ares.api.model.UserVo">
- select
- u.account 'mobile',
- u.uid 'id',
- u.nickname,
- u.avatar,
- ub.name,
- '1' as 'status'
- from
- user_bind ub
- left join
- rrx_user u
- on ub.uid = u.uid
- where
- ub.del_flag = 0
- and ub.bind_uid = #{bindUid}
- </select>
- <select id="selectByAccountForSimple" resultType="com.tdba.cxb.ares.api.model.UserVo">
- select
- u.account 'mobile',
- u.uid 'id',
- u.nickname 'name',
- u.avatar
- from
- rrx_user u
- where
- u.account = #{mobile}
- limit 1
- </select>
- <select id="selectTotal" resultType="com.tdba.cxb.ares.api.model.DataTotalResp">
- select
- user_type,
- sum(num) 'count'
- from
- user_count
- where
- del_flag = 0
- <choose>
- <when test="uid != null">
- and uid = #{uid}
- </when>
- <otherwise>
- and uid in (
- select
- uid
- from
- user_bind ub
- where
- ub.del_flag = 0
- and ub.type = 0
- and ub.bind_uid = #{bindUid}
- )
- </otherwise>
- </choose>
- group by
- user_type
- </select>
- <select id="selectList" resultType="com.tdba.cxb.ares.api.model.DataListResp">
- select
- <choose>
- <when test="type == null || type == 0">
- DATE_FORMAT(date,'%Y-%m-%d') as 'date',
- </when>
- <when test="type == 1">
- DATE_FORMAT(date,'%Y-%m') as 'date',
- </when>
- </choose>
- sum(IF(user_type = 0, num, 0)) as 'user_count',
- sum(IF(user_type = 1, num, 0)) as 'warehouse_count',
- sum(IF(user_type = 2, num, 0)) as 'merchant_count',
- sum(IF(user_type = 3, num, 0)) as 'channel_count',
- sum(IF(user_type = 4, num, 0)) as 'agent_count'
- from
- user_count
- where
- del_flag = 0
- and uid in (
- select
- uid
- from
- user_bind ub
- where
- ub.del_flag = 0
- and ub.type = 0
- and ub.bind_uid = #{uid}
- )
- <choose>
- <when test="type == null || type == 0">
- group by `date`
- </when>
- <when test="type == 1">
- group by DATE_FORMAT(date,'%Y-%m')
- </when>
- </choose>
- <choose>
- <when test="type == null || type == 0">
- order by `date` desc
- </when>
- <when test="type == 1">
- order by DATE_FORMAT(date,'%Y-%m') desc
- </when>
- </choose>
- </select>
- </mapper>
|