${ew.customSqlSegment}
SELECT DISTINCT ua.*, ui.phone, IFNULL(sp.permissionBill, 1) permissionBill
FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
LEFT JOIN tb_pluss_merchant_staff_conn msc ON ua.userId = msc.userId
LEFT JOIN tb_pluss_staff_permission sp ON ua.userId = sp.userId AND msc.merchantCode = sp.merchantCode
SELECT count(*) from tb_pluss_user_app
and id = #{id}
and userId = #{userId}
and logo = #{logo}
and level = #{level}
and userType = #{userType}
and createDt = #{createDt}
and createDt >= #{stTime}
and createDt <= #{enTime}
and status = #{status}
and certnum = #{certnum}
and certBacKPhoto = #{certBacKPhoto}
and handCertPhoto = #{handCertPhoto}
and bankName = #{bankName}
and bankAddress = #{bankAddress}
and bankBranch = #{bankBranch}
and bankNo = #{bankNo}
and bankPhoto = #{bankPhoto}
and merchantCode = #{merchantCode}
and fansProfit = #{fansProfit}
and extendProfit = #{extendProfit}
and cashProfit = #{cashProfit}
and userName = #{userName}
and staffType = #{staffType}
and parentId = #{parentId}
and inviteNum = #{inviteNum}
and bankStatus = #{bankStatus}
and merchantStatus = #{merchantStatus}
and certReason = #{certReason}
and bankReason = #{bankReason}
and merchantReason = #{merchantReason}
and certPeriod = #{certPeriod}
and certStartTime = #{certStartTime}
and bankAddressCode = #{bankAddressCode}
and phone = #{phone}
and merchantName = #{merchantName}
and merchantAddress = #{merchantAddress}
and merchantDetailAddress = #{merchantDetailAddress}
and contactName = #{contactName}
and contactPhone = #{contactPhone}
and productDesc = #{productDesc}
and bussAuthNum = #{bussAuthNum}
and bussAuthPeriod = #{bussAuthPeriod}
and storeId = #{storeId}
and appAuthToken = #{appAuthToken}
and tradeMoney = #{tradeMoney}
and authCount = #{authCount}
and subMchId = #{subMchId}
and aisleSwitch = #{aisleSwitch}
and unionpay = #{unionpay}
and mccCode = #{mccCode}
and contactEmail = #{contactEmail}
and mccName = #{mccName}
and leshuaLicenseName = #{leshuaLicenseName}
and aliAccount = #{aliAccount}
and aliName = #{aliName}
and aliSignUrl = #{aliSignUrl}
and wechatSignUrl = #{wechatSignUrl}
and token = #{token}
and createDt =]]> #{startTime}
and createDt #{endTime}
and isVoice = #{isVoice}
and parentId in
#{item}
SELECT DISTINCT SQL_CALC_FOUND_ROWS
ua.id,
ui.status AS uiStatus,
ua.roleCode AS roleCode,
ua.userType AS userType,
ua.merchantCode AS merchantCode,
mbi.alias,
mbi.merchantName,
mbi.contactMobile AS contactMobile,
ua.parentId AS parentId,
ua.userName AS userName,
ua.inviteNum AS inviteNum,
pui.phone AS parentPhone,
pui.loginName AS parentLoginName,
pua.userType AS parentUserType,
pua.userId AS parentUserId,
pua.userName as parentUserName,
ui.loginName AS loginName,
ua.`level` AS level,
ul.levelName as levelName,
ui.phone AS phone,
ua.`status` AS status,
ua.createDt AS createDt,
ua.userId AS userId,
ua.spreadFlag,
mbi.merchantType AS merchantType,
pp.thirdStatus AS ppThirdStatus,
pp.status AS ppStatus,
IF(rb.id IS NULL, false, true) isBlack
FROM
tb_pluss_user_app ua1
LEFT JOIN tb_pluss_operation_record opr ON opr.userId = ua1.userId
LEFT JOIN tb_pluss_operation_record opr2 ON opr.ip = opr2.ip
LEFT JOIN tb_pluss_user_app ua ON ua.userId = opr2.userId
tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app pua ON pua.userId = ua.parentId
LEFT JOIN tb_pluss_merchant_channel_status mcs ON mcs.merchantCode = ua.merchantCode
LEFT JOIN tb_pluss_user_info pui ON pui.id = ua.parentId
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
LEFT JOIN tb_pluss_merchant_base_info mbi ON mbi.merchantCode = ua.merchantCode
LEFT JOIN tb_pluss_risk_blacklist rb ON rb.userId = ua.userId
LEFT JOIN tb_pluss_user_level ul ON ul.levelCode = ua.levelCode
LEFT JOIN tb_pluss_sub_merchant sm ON sm.merchantId = mcs.merchantId
LEFT JOIN (
SELECT mp.* FROM
(
SELECT userId, MAX(createTime) createTime
FROM tb_pluss_merchant_plugin GROUP BY userId
) t LEFT JOIN
tb_pluss_merchant_plugin mp
ON t.userId = mp.userId AND mp.createTime = t.createTime
) pp
ON ua.userId = pp.userId
and ua.userType = 'agent' and pua.userId is not null
and ua.userType = 'agent' and pua.userId is null
and ua.userType=#{userType}
and ua.userType ]]> 'staff'
and ua1.userId = #{userId}
and ua.userId = #{userId}
and mbi.merchantType = #{merchantType}
and ua.inviteNum LIKE CONCAT("%",#{inviteNum},"%")
and ua.merchantCode = #{merchantCode}
and mbi.alias LIKE CONCAT("%",#{alias},"%")
and ua.userName LIKE CONCAT("%",#{userName},"%")
and mcs.merchantId LIKE CONCAT("%",#{merchantId},"%")
and mcs.merchantId LIKE CONCAT("%",#{merchantId},"%")
and ui.phone LIKE CONCAT("%",#{phone},"%")
and pui.phone LIKE CONCAT("%",#{parentPhone},"%")
and mbi.contactMobile LIKE CONCAT("%",#{contactMobile},"%")
and ua.status=#{status}
and sm.subMchType = 'WX'
and sm.subMchId LIKE CONCAT('%', #{wxMercNo}, '%')
and sm.subMchType = 'ZFB'
and sm.subMchId LIKE CONCAT('%', #{wxMercNo}, '%')
and (mcs.status = '2' or (mcs.status = '0' and mcs.thirdStatus = '-100'))
and mcs.status = #{mcsStatus}
and mcs.thirdStatus ]]> '-100'
and mcs.thirdStatus = #{thirdStatus}
and (pp.status = '2' or (pp.status = '0' and pp.thirdStatus = '-100'))
and pp.status = #{ppStatus}
and pp.thirdStatus ]]> '-100'
and pp.thirdStatus = #{ppThirdStatus}
and pua.userId IN (SELECT ua.userId
FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app pua ON pua.userId = ua.parentId
WHERE ua.userType = 'agent' and pua.userId is not null)
and pua.userId IN (SELECT ua.userId
FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app pua ON pua.userId = ua.parentId
WHERE ua.userType = 'agent' and pua.userId is null)
and pua.userType=#{parentUserType}
and mbi.merchantCode=#{merchantCode}
order by ua.id desc limit #{pageSize} offset #{offset};
SELECT found_rows() as count
SELECT
ua.id,
mbi.alias,
mbi.merchantName,
mbi.contactMobile AS contactMobile,
ua.userName AS userName,
ua.inviteNum AS inviteNum,
pui.phone AS parentPhone,
pui.loginName AS parentLoginName,
pua.userType AS parentUserType,
ui.loginName AS loginName,
ua.`level` AS LEVEL,
ui.phone AS phone,
ua.`status` AS STATUS,
ua.createDt AS createDt,
ua.userId AS userId
FROM
tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app pua ON pua.userId = ua.parentId
LEFT JOIN tb_pluss_user_info pui ON pui.id = ua.parentId
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
LEFT JOIN tb_pluss_merchant_base_info mbi ON mbi.merchantCode = ua.merchantCode
and ua.userId = #{userId}
and ua.inviteNum LIKE CONCAT("%",#{inviteNum},"%")
and mbi.alias LIKE CONCAT("%",#{alias},"%")
and ua.userName LIKE CONCAT("%",#{userName},"%")
and ui.phone LIKE CONCAT("%",#{phone},"%")
and pui.phone LIKE CONCAT("%",#{parentPhone},"%")
and mbi.contactMobile LIKE CONCAT("%",#{contactMobile},"%")
and ua.userType=#{userType}
and ua.status=#{status}
and pua.userType=#{parentUserType}
and ua.merchantCode in (SELECT merchantCode
FROM tb_pluss_merchant_base_info
WHERE bindingCode =(SELECT bindingCode
FROM tb_pluss_merchant_base_info
where merchantCode = #{merchantCode}))
order by ua.id desc limit #{pageSize} offset #{offset}
select count(1)
from
tb_pluss_user_app ua1
LEFT JOIN tb_pluss_operation_record opr ON opr.userId = ua1.userId
LEFT JOIN tb_pluss_operation_record opr2 ON opr.ip = opr2.ip
LEFT JOIN tb_pluss_user_app ua ON ua.userId = opr2.userId
tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui
ON ua.userId=ui.id
LEFT JOIN tb_pluss_user_info pui ON pui.id = ua.parentId
LEFT JOIN tb_pluss_user_app pua ON pua.userId = ua.parentId
LEFT JOIN tb_pluss_merchant_channel_status mcs ON mcs.merchantCode = ua.merchantCode
LEFT JOIN tb_pluss_merchant_base_info mbi
on mbi.merchantCode = ua.merchantCode
LEFT JOIN tb_pluss_merchant_plugin pp ON pp.userId = ua.userId
and ua.userType = 'agent' and pua.userId is not null
and ua.userType = 'agent' and pua.userId is null
and ua.userType=#{userType}
and ua.userType ]]> 'staff'
and ua.merchantCode = #{merchantCode}
and mbi.merchantType = #{merchantType}
and ua1.userId = #{userId}
and ua.userId = #{userId}
and (mcs.status = '2' or (mcs.status = '0' and mcs.thirdStatus = '-100'))
and mcs.status = #{mcsStatus}
and mcs.thirdStatus ]]> '-100'
and mcs.thirdStatus = #{thirdStatus}
and (pp.status = '2' or (pp.status = '0' and pp.thirdStatus = '-100'))
and pp.status = #{ppStatus}
and pp.thirdStatus ]]> '-100'
and pp.thirdStatus = #{ppThirdStatus}
and pui.phone LIKE CONCAT("%",#{parentPhone},"%")
and ua.inviteNum LIKE CONCAT("%",#{inviteNum},"%")
and mbi.alias LIKE CONCAT("%",#{alias},"%")
and ua.userName LIKE CONCAT("%",#{userName},"%")
and ui.phone LIKE CONCAT("%",#{phone},"%")
and mbi.contactMobile LIKE CONCAT("%",#{contactMobile},"%")
and ua.status=#{status}
and pua.userId IN (SELECT ua.userId
FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app pua ON pua.userId = ua.parentId
WHERE ua.userType = 'agent' and pua.userId is not null)
and pua.userId IN (SELECT ua.userId
FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app pua ON pua.userId = ua.parentId
WHERE ua.userType = 'agent' and pua.userId is null)
and pua.userType=#{parentUserType}
select count(*)
from tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui
ON ua.userId=ui.id
LEFT JOIN tb_pluss_user_info pui ON pui.id = ua.parentId
LEFT JOIN tb_pluss_user_app pua ON pua.userId = ua.parentId
LEFT JOIN tb_pluss_merchant_bank_card mb
ON mb.userId=ua.userId
LEFT JOIN tb_pluss_merchant_base_info mbi
on mbi.merchantCode = ua.merchantCode
and ua.merchantCode in (SELECT merchantCode
FROM tb_pluss_merchant_base_info
WHERE bindingCode =(SELECT bindingCode
FROM tb_pluss_merchant_base_info
where merchantCode = #{merchantCode}))
and ua.userId = #{userId}
and pui.phone LIKE CONCAT("%",#{parentPhone},"%")
and ua.inviteNum LIKE CONCAT("%",#{inviteNum},"%")
and mbi.alias LIKE CONCAT("%",#{alias},"%")
and ua.userName LIKE CONCAT("%",#{userName},"%")
and ui.phone LIKE CONCAT("%",#{phone},"%")
and mbi.contactMobile LIKE CONCAT("%",#{contactMobile},"%")
and ua.status=#{status}
and ua.userType=#{userType}
and pua.userType=#{parentUserType}
select ua.id, ua.userId, ua.userName, ui.phone, ua.logo, ua.createDt
from tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
where (ua.status = '0' or ua.status = '1' or ua.status = '2' or ua.status is null)
and ua.parentId = #{parentId}
select count(ua.id)
from tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
where (ua.status = '0' or ua.status = '1' or ua.status = '2' or ua.status is null)
and ua.parentId = #{parentId}
select ua.id, ua.userId, ua.userName, ui.phone, ua.logo, ua.createDt
from tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
where ua.status = '3'
and ua.parentId = #{parentId}
select count(ua.id)
from tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
where ua.status = '3'
and ua.parentId = #{parentId}
select ua.id, ua.userId, ua.userName, ui.phone, ua.logo, ua.createDt
from tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
where ua.status = '3'
and ua.parentId = #{parentId}
and (ua.wechatStatus = '3' or ua.aliStatus = '3')
select count(ua.id)
from tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
where ua.status = '3'
and ua.parentId = #{parentId}
and (ua.wechatStatus = '3' or ua.aliStatus = '3')
SELECT u.loginName,a.logo,a.userName,a.createDt,a.userId,a.status from tb_pluss_user_app a left
join tb_pluss_user_info u on a.userId=u.id
instr(u.loginName, '@') = 0
and a.level = #{level}
and a.status = #{status}
and a.parentId = #{parentId}
and a.agentStaffId = #{agentStaffId}
and a.parentId in
#{item}
and u.loginName is not null and u.loginName > '13000000000' and length(u.loginName)=11 AND u.loginName
NOT LIKE '%@%'
SELECT u.loginName,a.logo,a.userName,a.createDt,a.userId,a.status,a.level,a.parentId from
tb_pluss_user_app a left join tb_pluss_user_info u on a.userId=u.id
and a.level = #{level}
and a.status = #{status}
and a.parentId = #{parentId}
and a.agentStaffId = #{agentStaffId}
and a.parentId in
#{item}
and u.loginName is not null and u.loginName > '13000000000' and length(u.loginName)=11 AND u.loginName
NOT LIKE '%@%'
and userId in (select userId from tb_pluss_merchant_base_info where alias like
CONCAT('%',#{merchantName},'%'))
and createDt > #{startTime}
and createDt < #{endTime}
order by a.createDt desc limit #{pageSize} offset #{offset}
SELECT count(*) from tb_pluss_user_app a left join tb_pluss_user_info u on a.userId=u.id
and a.level = #{level}
and a.status = #{status}
and a.parentId = #{parentId}
and a.parentId in
#{item}
and a.agentStaffId = #{agentStaffId}
and u.loginName is not null and u.loginName > '13000000000' and length(u.loginName)=11 AND u.loginName
NOT LIKE '%@%'
and createDt > #{startTime}
and createDt < #{endTime}
and userId in (select userId from tb_pluss_merchant_base_info where alias like
CONCAT('%',#{merchantName},'%'))
SELECT ua.id,
ua.userName AS userName,
ua.inviteNum AS inviteNum,
ua.loginName AS loginName,
ua.`level` AS LEVEL,
ui.phone AS phone,
ua.`status` AS STATUS,
ua.createDt AS createDt,
ua.userId AS userId,
ua.userType AS userType,
ua.parentId AS parentId,
ua.`sort` AS sort,
ua.`roleCode` AS roleCode,
ua.`levelCode` AS levelCode,
ua.`status` AS status,
ua.`bankStatus` AS bankStatus
FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
where inviteNum = #{inviteNum}
SELECT u.loginName,a.logo,a.userName,a.createDt,a.userId,channel.status,a.level,a.parentId,
a.agentStaffId from
tb_pluss_user_app a left join tb_pluss_user_info u on a.userId=u.id
LEFT JOIN tb_pluss_merchant_channel_status channel ON channel.merchantCode = a.merchantCode
and a.userType = 'promoter'
and instr(u.loginName, '@') = 0
and a.level = #{expandDto.level}
and a.parentId in
#{item}
and userId in (select userId from tb_pluss_merchant_base_info where alias like
CONCAT('%',#{expandDto.merchantName},'%'))
and agentStaffId= #{expandDto.agentStaffId}
and createDt > #{expandDto.startTime}
and createDt < #{expandDto.endTime}
and
a.status != 3
a.status = 3
a.status = 3 and channel.status = 3
order by a.createDt DESC
SELECT DISTINCT *
FROM (
SELECT tpui.loginName,
tpua.userId,
userName,
tpua.logo,
tpua.createDt,
tpua.merchantCode,
tpmbi.merchantName,
tpmbi.alias,
tpmcs.`status`,
tpua.parentId,
tpua.agentStaffId
FROM tb_pluss_user_app tpua
LEFT JOIN tb_pluss_user_info tpui ON tpua.userId = tpui.id
LEFT JOIN tb_pluss_merchant_base_info tpmbi ON tpua.userId = tpmbi.userId
LEFT JOIN tb_pluss_merchant_channel_status tpmcs ON tpmcs.merchantCode = tpua.merchantCode
) t ${ew.customSqlSegment}
SELECT pua.id,
pua.userName,
ui.loginName,
pua.status,
pua.merchantCode,
pua.userId,
id.id AS 'idCard.id', id.certNo AS 'idCard.certNo', id.imgPositive AS 'idCard.imgPositive', id.imgNegative AS 'idCard.imgNegative', id.certStartTime AS 'idCard.certStartTime', id.certEndTime AS 'idCard.certEndTime', pbc.bankCardNo AS 'bankCard.bankCardNo', pbc.branchName AS 'bankCard.branchName', pbc.imgUrl AS 'bankCard.imgUrl', pbc.phone AS 'bankCard.phone', pbc.bankName AS 'bankCard.bankName', pbc.branchProvince AS 'bankCard.branchProvince', pbc.branchCity AS 'bankCard.branchCity', pbc.branchArea AS 'bankCard.branchArea', pmai.id AS 'merchantBaseInfo.id', pmai.merchantName AS 'merchantBaseInfo.merchantName', pmai.merchantType AS 'merchantBaseInfo.merchantType', pmai.alias AS 'merchantBaseInfo.alias', pmai.address AS 'merchantBaseInfo.address', pmai.contactName AS 'merchantBaseInfo.contactName', pmai.email AS 'merchantBaseInfo.email', pmai.contactMobile AS 'merchantBaseInfo.contactMobile', pmai.aliAccount AS 'merchantBaseInfo.aliAccount', pmai.mcc AS 'merchantBaseInfo.mcc', pmai.mccName AS 'merchantBaseInfo.mccName', pmai.province AS 'merchantBaseInfo.province', pmai.city AS 'merchantBaseInfo.city', pmai.district AS 'merchantBaseInfo.district', pmai.principalPerson AS 'merchantBaseInfo.principalPerson', pmai.bussAuthName AS 'merchantBaseInfo.bussAuthName', pmai.bussAuthNum AS 'merchantBaseInfo.bussAuthNum', pmai.bussAuthAddress AS 'merchantBaseInfo.bussAuthAddress', pmai.bussAuthStartTime AS 'merchantBaseInfo.bussAuthStartTime', pmai.bussAuthEndTime AS 'merchantBaseInfo.bussAuthEndTime', pp.thirdStatus AS ppThirdStatus,
pp.`status` AS ppStatus
FROM tb_pluss_user_app pua
left join tb_pluss_merchant_base_info pmai on pua.merchantCode = pmai.merchantCode
left join tb_pluss_bank_card pbc on pbc.userId = pua.userId
left join tb_pluss_id_card id on id.userId = pua.userId
LEFT JOIN tb_pluss_user_info ui ON pua.userId = ui.id
LEFT JOIN (SELECT *
FROM tb_pluss_merchant_plugin
WHERE userId = #{userId}
ORDER BY createTime DESC LIMIT 1) pp
ON pua.userId = pp.userId
where pua.userId = #{userId}
AND id.userType = "01"
AND pbc.accountType = '03'
SELECT pua.*,
pmai.id AS 'merchantBaseInfo.id', pmai.userId AS 'merchantBaseInfo.userId', pmai.merchantName AS 'merchantBaseInfo.merchantName', pmai.merchantType AS 'merchantBaseInfo.merchantType', pmai.alias AS 'merchantBaseInfo.alias', pmai.province AS 'merchantBaseInfo.province', pmai.city AS 'merchantBaseInfo.city', pmai.district AS 'merchantBaseInfo.district', pmai.address AS 'merchantBaseInfo.address', pmai.contactName AS 'merchantBaseInfo.contactName', pmai.email AS 'merchantBaseInfo.email', pmai.contactMobile AS 'merchantBaseInfo.contactMobile', pmai.aliAccount AS 'merchantBaseInfo.aliAccount', pmbc.id AS 'merchantBankCard.id', pmbc.merchantCode AS 'merchantBankCard.merchantCode', pmbc.storeId AS 'merchantBankCard.storeId', pmbc.bankCardNo AS 'merchantBankCard.bankCardNo', pmbc.bankAddressNo AS 'merchantBankCard.bankAddressNo', pmbc.bankCertName AS 'merchantBankCard.bankCertName', pmbc.bankName AS 'merchantBankCard.bankName', pmbc.branchName AS 'merchantBankCard.branchName', pmbc.accountType AS 'merchantBankCard.accountType', pmbc.contactLine AS 'merchantBankCard.contactLine', pmbc.certNo AS 'merchantBankCard.certNo', pmbc.phone AS 'merchantBankCard.phone', pmbc.certFullPhoto AS 'merchantBankCard.certFullPhoto', pmbc.certBacKPhoto AS 'merchantBankCard.certBacKPhoto', pmbc.bankCardFrontPic AS 'merchantBankCard.bankCardFrontPic'
FROM tb_pluss_user_app pua
left join tb_pluss_merchant_base_info pmai on pua.merchantCode = pmai.merchantCode
left join tb_pluss_merchant_bank_card pmbc on pua.merchantCode = pmbc.merchantCode
where pua.userId = #{userId}
SELECT count(DISTINCT userId)
FROM (
SELECT t1.userId,
t1.userType,
t1.logo,
t1.level,
t1.createDt,
t1.status,
t1.parentId,
t1.bankStatus,
t1.agentStaffId,
t2.status merchantAuditStatus
FROM tb_pluss_user_app t1
LEFT JOIN tb_pluss_user_info ui ON t1.userId = ui.id
LEFT JOIN tb_pluss_merchant_channel_status t2 ON t1.merchantCode = t2.merchantCode
WHERE ui.loginName NOT LIKE '%@%'
) t ${ew.customSqlSegment}
SELECT *
FROM (
SELECT t1.*, t2.status merchantAuditStatus
FROM tb_pluss_user_app t1
LEFT JOIN tb_pluss_merchant_channel_status t2 ON t1.merchantCode = t2.merchantCode
) t
${ew.customSqlSegment}
SELECT ua.status,
CONCAT(LEFT(ui.loginName, 3),'****', RIGHT(ui.loginName, 4)) as 'loginName', ua.createDt
FROM tb_pluss_user_app ua
left join tb_pluss_user_info ui on ua.userId = ui.id
where ua.parentId = #{userId}
and ua.userType = 'promoter'
AND instr(ui.loginName, '@') = 0
order By ua.createDt desc
SELECT ua.status,
CONCAT(LEFT(ui.loginName, 3),'****',RIGHT(ui.loginName, 4)) as 'loginName',
ua.createDt , cs.`status` AS merchantAuditStatus
FROM tb_pluss_user_app ua
left join tb_pluss_user_info ui on ua.userId = ui.id
left join tb_pluss_merchant_channel_status cs on ua.merchantCode = cs.merchantCode
where ua.parentId = #{userApp.userId} and ua.userType = 'promoter' AND instr(ui.loginName,'@') = 0
= DATE_FORMAT(#{userApp.startDate},'%Y-%m-%d')]]>
GROUP BY ua.merchantCode
order By ua.createDt desc
SELECT count( 1 ) FROM tb_pluss_user_app ua LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
WHERE
ua.parentId = #{userId}
AND userType = 'promoter'
AND instr( ui.loginName, '@' ) = 0
= #{startDate}]]>
SELECT
t4.userId,
t4.nextRegisterCount,
t4.nextCertCount,
t4.nextIncomingCount,
ua.id,
ua.userName,
ua.`level`,
mbi.alias,
ui.loginName,
pui.phone AS parentPhone,
mbi.contactMobile,
ua.createDt,
ua.`status`
FROM
(
SELECT
t3.userId,
SUM( t3.nextCount ) AS nextRegisterCount,
SUM( IF ( t3.cStatus = '2', t3.nextCount, 0 )) AS nextCertCount,
SUM( IF ( t3.cStatus = '3', t3.nextCount, 0 )) AS nextIncomingCount
FROM
(
SELECT
ua.userId,
IFNULL( t2.count, 0 ) AS nextCount,
t2.`status` AS cStatus
FROM
tb_pluss_user_app ua
LEFT JOIN (
SELECT
t.parentId,
t.`status`,
count( 1 ) count
FROM
(
SELECT
ua.parentId,
IF
( ua.bankStatus = 3, IF ( mcs.`status` = 3, 3, 2 ), 1 ) `status`
FROM
tb_pluss_user_app ua
LEFT JOIN tb_pluss_merchant_channel_status mcs ON ua.merchantCode = mcs.merchantCode
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
WHERE
INSTR( ui.loginName, '@' ) = 0
AND DATE_FORMAT(ua.createDt,'%Y-%m-%d') = ]]> DATE_FORMAT(#{userInfoVO.startTime},'%Y-%m-%d')
AND DATE_FORMAT(ua.createDt,'%Y-%m-%d') DATE_FORMAT(#{userInfoVO.endTime},'%Y-%m-%d')
AND ua.userType = 'promoter'
) t
GROUP BY
t.parentId,
t.`status`
) t2 ON ua.userId = t2.parentId
) t3
GROUP BY
t3.userId
) t4
LEFT JOIN tb_pluss_user_app ua ON t4.userId = ua.userId
LEFT JOIN tb_pluss_merchant_base_info mbi ON mbi.merchantCode = ua.merchantCode
LEFT JOIN tb_pluss_user_info ui ON ui.id = t4.userId
LEFT JOIN tb_pluss_user_info pui ON ua.parentId = pui.id
and t3.userId = #{userInfoVO.userId}
and t3.userName like CONCAT('%',#{userInfoVO.userName},'%')
and ui.loginName = #{userInfoVO.loginName}
and mbi.alias like CONCAT('%',#{userInfoVO.alias},'%')
and mbi.contactMobile = #{userInfoVO.contactMobile}
and pui.phone = #{userInfoVO.parentPhone}
ORDER BY
nextRegisterCount DESC
select count(pua.userId)
from tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app pua ON pua.userId = ua.parentId
where ua.userId = #{parentUserId}
SELECT ua.userId
FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_merchant_channel_status mcs ON ua.merchantCode = mcs.merchantCode
WHERE mcs.merchantCode = #{merchantCode}
AND ua.userType = 'promoter'
AND mcs.merchantId IS NULL
SELECT ua.userId as nowUserId,
ua.LEVEL AS nowLevel,
ua.userType as nowType,
ua.pIdArr AS nowPidArr,
ua1.userId as prevOneUserId,
ua1.LEVEL AS prevOneLevel,
ua1.userType as prevOneType,
ua1.pIdArr AS prevOnePidArr,
ua2.userId as prevTwoUserId,
ua2.LEVEL AS prevTwoLevel,
ua2.userType as prevTwoType,
ua2.pIdArr AS prevTwoPidArr,
ua3.userId AS prevThreeUserId,
ua3.LEVEL AS prevThreeLevel,
ua3.userType as prevThreeType,
ua3.pIdArr AS prevThreePidArr,
ua4.userId AS prevFourUserId,
ua4.LEVEL AS prevFourLevel,
ua4.userType as prevFourType,
ua4.pIdArr AS prevFourPidArr
FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app ua1 ON ua.parentId = ua1.userId
LEFT JOIN tb_pluss_user_app ua2 ON ua1.parentId = ua2.userId
LEFT JOIN tb_pluss_user_app ua3 ON ua2.parentId = ua3.userId
LEFT JOIN tb_pluss_user_app ua4 ON ua3.parentId = ua4.userId
WHERE ua.userId = #{userId};
SELECT
SUM(IF(type = 'toDayPromoter',num,0)) AS addToDayPromoterNum,
SUM(IF(type = 'toDayMember',num,0))AS addToDayMemberNum,
SUM(IF(type = 'toDayStore',num,0)) AS addToDayStoreNum,
SUM(IF(type = 'mercNum',num,0)) AS mercCountNum,
SUM(IF(type = 'fansNum',num,0)) AS fansCountNum,
SUM(IF(type = 'promNum',num,0)) AS promCountNum,
SUM(IF(type = 'memberNum',num,0)) AS memberCountNum
FROM (
SELECT count(1) AS num, 'toDayPromoter' as type, 'add' as addType FROM tb_pluss_user_app WHERE date(createDt) = curdate()
union
SELECT count(1) AS num, 'toDayMember' AS type,'add' as addType FROM tb_pluss_merchant_menber WHERE date(createDt) = curdate()
union
SELECT count(1) AS num, 'toDayStore' AS type,'add' as addType FROM tb_pluss_merchant_store WHERE date(createDt) = curdate()
union
SELECT count(1) AS num, 'mercNum' AS type,'add' as addType FROM tb_pluss_merchant_base_info
union
SELECT count(1) AS num, 'fansNum' AS type,'add' as addType FROM tb_pluss_real_fans
union
SELECT count(1) AS num, 'promNum' AS type,'add' as addType FROM tb_pluss_user_app
union
SELECT count(1) AS num, 'memberNum' AS type,'add' as addType FROM tb_pluss_merchant_menber
)as
a GROUP BY addType
SELECT
ua.createDt createTime,
ua.userId,
mbi.alias,
mbi.merchantCode,
IFNULL(mos.count, 0) count,
IFNULL(mos.totalFee, 0.00) totalFee,
IFNULL(mos.retFee, 0.00) retFee,
IFNULL(mos.retCount, 0) retCount,
IFNULL(mcsD1.`status`, "-1") `d1Status`,
IFNULL(mcsD1.`thirdStatus`, "-1") `d1thirdStatus`,
mcsD1.`remark` `d1Remark`,
IFNULL(mcsD0.`status`, "-1") `d0Status`,
IFNULL(mcsD0.`thirdStatus`, "-1") `d0thirdStatus`,
mcsD0.`remark` `d0Remark`,
ms.`status` `d1StoreStatus`,
ms.`status` `d0StoreStatus`,
IFNULL(mcsD1.`authorizationStatus`, '0') `d1WxCertStatus`,
IFNULL(mcsD0.`authorizationStatus`, '0') `d0WxCertStatus`,
IF(ua.parentId = #{condition.userId}, "1", "0") directFlag
FROM
(
SELECT ua.userId, ua.createDt, ua.merchantCode, ua.parentId, ua.agentStaffId FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app ua1 ON ua1.userId = ua.parentId WHERE ua1.userId = #{condition.userId}
SELECT ua.userId, ua.createDt, ua.merchantCode, ua.parentId, ua.agentStaffId FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app ua1 ON ua1.userId = ua.parentId
LEFT JOIN tb_pluss_user_app ua2 ON ua2.userId = ua1.parentId WHERE ua2.userId = #{condition.userId}
SELECT ua.userId, ua.createDt, ua.merchantCode, ua.parentId, ua.agentStaffId FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app ua1 ON ua1.userId = ua.parentId WHERE ua1.userId = #{condition.userId}
UNION
SELECT ua.userId, ua.createDt, ua.merchantCode, ua.parentId, ua.agentStaffId FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app ua1 ON ua1.userId = ua.parentId
LEFT JOIN tb_pluss_user_app ua2 ON ua2.userId = ua1.parentId WHERE ua2.userId = #{condition.userId}
) ua
LEFT JOIN tb_pluss_merchant_base_info mbi ON mbi.userId = ua.userId
LEFT JOIN tb_pluss_merchant_store ms ON ms.merchantCode = ua.merchantCode
LEFT JOIN
tb_pluss_merchant_channel_status mcsD1
ON mcsD1.merchantCode = mbi.merchantCode AND (mcsD1.channel IN (1,3) OR mcsD1.channel IS NULL)
LEFT JOIN
tb_pluss_merchant_channel_status mcsD0
ON mcsD0.merchantCode = mbi.merchantCode AND (mcsD0.channel IN (4) OR mcsD0.channel IS NULL)
LEFT JOIN (
SELECT
merchantCode,
SUM( count ) count,
SUM( totalFee ) totalFee,
SUM( retFee ) retFee,
SUM( retCount ) retCount
FROM
tb_pluss_merchant_order_statistics mos
WHERE mos.`startDate` = '1970-01-01'
GROUP BY
merchantCode
) mos ON mos.merchantCode = mbi.merchantCode
WHERE (mcsD1.`status` IS NOT NULL OR mcsD0.`status` IS NOT NULL)
AND mbi.alias LIKE CONCAT('%', #{condition.merchantName}, '%')
AND ua.agentStaffId IN
#{item}
AND ua.createDt >= #{condition.startTime}
AND ua.createDt <= #{condition.endTime}
SELECT
IFNULL(SUM(mos.count), 0) `count`,
IFNULL(SUM(mos.totalFee), 0.00) totalFee
FROM (
SELECT ua.* FROM tb_pluss_user_app ua
WHERE ua.parentId = #{condition.userId}
SELECT ua1.* FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app ua1 ON ua1.parentId = ua.userId
WHERE ua.parentId = #{condition.userId}
UNION
SELECT ua2.* FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app ua1 ON ua1.parentId = ua.userId
LEFT JOIN tb_pluss_user_app ua2 ON ua2.parentId = ua1.userId
WHERE ua.parentId = #{condition.userId}
SELECT ua.* FROM tb_pluss_user_app ua
WHERE ua.parentId = #{condition.userId}
UNION
SELECT ua1.* FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app ua1 ON ua1.parentId = ua.userId
WHERE ua.parentId = #{condition.userId}
UNION
SELECT ua2.* FROM tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_app ua1 ON ua1.parentId = ua.userId
LEFT JOIN tb_pluss_user_app ua2 ON ua2.parentId = ua1.userId
WHERE ua.parentId = #{condition.userId}
) ua
LEFT JOIN tb_pluss_merchant_base_info mbi ON mbi.userId = ua.userId
LEFT JOIN tb_pluss_merchant_store ms ON ms.merchantCode = ua.merchantCode
LEFT JOIN tb_pluss_merchant_channel_status mcsD1 ON mcsD1.merchantCode = mbi.merchantCode AND mcsD1.channel IN (1,3)
LEFT JOIN tb_pluss_merchant_channel_status mcsD0 ON mcsD0.merchantCode = mbi.merchantCode AND mcsD0.channel IN (4)
LEFT JOIN (
SELECT
merchantCode,
SUM( count ) count,
SUM( totalFee ) totalFee,
SUM( retFee ) retFee,
SUM( retCount ) retCount
FROM
tb_pluss_merchant_order_statistics
WHERE startDate = '1970-01-01'
GROUP BY
merchantCode
) mos ON mos.merchantCode = mbi.merchantCode
WHERE (mcsD1.`status` IN (1, 2, 3) OR mcsD0.`status` IN (1, 2, 3))
AND mbi.alias LIKE CONCAT('%', #{condition.merchantName}, '%')
AND ua.agentStaffId IN
#{item}
AND ua.createDt >= #{condition.startTime}
AND ua.createDt <= #{condition.endTime}
SELECT
MAX(sort)
FROM
tb_pluss_user_app
SELECT
IFNULL(SUM(t.totalNum), 0) as totalNum,
IFNULL(SUM(IF(t.createDate = #{date},1,0)),0) AS addNum
FROM (
SELECT
count(1) as totalNum,
DATE_FORMAT(createDt, '%Y-%m-%d' ) AS createDate
DATE_FORMAT(createDt, '%Y-%m' ) AS createDate
DATE_FORMAT(createDt, '%Y' ) AS createDate
FROM tb_pluss_user_app WHERE parentId = #{userId} and userType not in ('staff','agent_staff')
GROUP BY
DATE_FORMAT(createDt, '%Y-%m-%d')
DATE_FORMAT(createDt, '%Y-%m')
DATE_FORMAT(createDt, '%Y')
) t
SELECT ua.*,ui.phone FROM tb_pluss_user_app ua
left join tb_pluss_user_info ui on ua.userId = ui.id
where ui.phone = #{phone} and userType not in ('agent_staff','staff') AND LENGTH(ui.phone) = 11