insert into
tb_pluss_merchant_order(orderNumber,merchantCode,merchantName,payTypeCode,payTypeName,consumeFee,transNo,memberCode,storeId,storeName,createDt,staffCode,status,rate,marketAmt)
VALUES
(#{orderNumber},#{merchantCode},#{merchantName},#{payTypeCode},#{payTypeName},#{consumeFee},#{transNo},#{memberCode},#{storeId},#{storeName},#{createDt},#{staffCode},#{status},#{rate},#{marketAmt}
)
SELECT * from tb_pluss_merchant_order
and id = #{id}
and orderNumber = #{orderNumber}
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo = #{transNo}
and memberCode = #{memberCode}
and storeId = #{storeId}
and storeName = #{storeName}
and createDt = #{createDt}
and staffCode = #{staffCode}
and status = #{status}
and enterFee = #{enterFee}
and aisleSwitch = #{aisleSwitch}
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
and leshuaTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and promoteruserId = #{promoteruserId}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and settlementType = #{settlementType}
SELECT sum(consumeFee) from tb_pluss_merchant_order
and merchantCode = #{merchantCode}
and consumeFee = #{consumeFee}
and createDt = #{createDt}
and status = #{status}
and createDt #{endTime}
and transDt = #{transDt}
and staffName = #{staffName}
and transDt =]]> #{stTime}
and transDt #{endTime}
SELECT sum(consumeFee) from tb_pluss_merchant_order
and merchantCode = #{merchantCode}
and consumeFee = #{consumeFee}
and createDt = #{createDt}
and status = #{status}
and createDt <= #{endTime}
and transDt = #{transDt}
and staffName = #{staffName}
and transDt =]]> #{stTime}
and transDt #{endTime}
and (payTypeCode='leshuaPay0' or payTypeCode= 'aliPay' or payTypeCode='sxfPay0')
SELECT sum(consumeFee) from tb_pluss_merchant_order
and merchantCode = #{merchantCode}
and consumeFee = #{consumeFee}
and createDt = #{createDt}
and status = #{status}
and createDt <= #{endTime}
and transDt = #{transDt}
and staffName = #{staffName}
and transDt =]]> #{stTime}
and transDt #{endTime}
and (payTypeCode='leshuaPay1' or payTypeCode= 'wechatPay' or payTypeCode='sxfPay1')
SELECT sum(consumeFee) from tb_pluss_merchant_order
and merchantCode = #{merchantCode}
and consumeFee = #{consumeFee}
and createDt = #{createDt}
and status = #{status}
and createDt <= #{endTime}
and transDt = #{transDt}
and staffName = #{staffName}
and transDt =]]> #{stTime}
and transDt #{endTime}
and payTypeCode='sxfPay2'
SELECT * from tb_pluss_merchant_order
and id = #{id}
and orderNumber = #{orderNumber}
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo = #{transNo}
and memberCode = #{memberCode}
and storeId = #{storeId}
and storeName = #{storeName}
and createDt = #{createDt}
and staffCode = #{staffCode}
and status = #{status}
and thirdTransNo = #{aliPayTransNo}
and enterFee = #{enterFee}
and thirdTransNo = #{weChatTransNo}
and aisleSwitch = #{aisleSwitch}
and thirdTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and settlementType = #{settlementType}
SELECT sum(consumeFee) from tb_pluss_merchant_order
and merchantCode = #{merchantCode}
and status = #{status}
SELECT * from tb_pluss_merchant_order
and id = #{id}
and orderNumber like CONCAT("%",#{orderNumber},"%")
and merchantCode = #{merchantCode}
and merchantName like CONCAT("%",#{merchantName},"%")
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo like CONCAT("%",#{transNo},"%")
and memberCode like CONCAT("%",#{memberCode},"%")
and storeId = #{storeId}
and storeName like CONCAT("%",#{storeName},"%")
and createDt = #{createDt}
and staffCode = #{staffCode}
and status = #{status}
and thirdTransNo = #{aliPayTransNo}
and enterFee = #{enterFee}
and thirdTransNo = #{weChatTransNo}
and aisleSwitch = #{aisleSwitch}
and thirdTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and userImg = #{userImg}
and nickName = #{nickName}
and createDt >= #{startTime}
and remark = #{remark}
and createDt <= #{endTime}
and transDt = #{transDt}
and staffName = #{staffName}
and transDt =]]> #{stTime}
and transDt #{endTime}
and settlementType = #{settlementType}
SELECT * from tb_pluss_merchant_order
and id = #{id}
and orderNumber = #{orderNumber}
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo = #{transNo}
and memberCode = #{memberCode}
and storeId = #{storeId}
and storeName = #{storeName}
and updateTime >= #{startTime}
and updateTime <= #{endTime}
and staffCode = #{staffCode}
and status = #{status}
and thirdTransNo = #{aliPayTransNo}
and enterFee = #{enterFee}
and thirdTransNo = #{weChatTransNo}
and aisleSwitch = #{aisleSwitch}
and thirdTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and settlementType = #{settlementType}
and merchantCode in
#{item}
order by id desc limit #{pageSize} offset #{offset}
SELECT count(*) from tb_pluss_merchant_order
and id = #{id}
and orderNumber = #{orderNumber}
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo = #{transNo}
and memberCode = #{memberCode}
and storeId = #{storeId}
and storeName = #{storeName}
and updateTime >= #{startTime}
and updateTime <= #{endTime}
and staffCode = #{staffCode}
and status = #{status}
and thirdTransNo = #{aliPayTransNo}
and thirdTransNo = #{weChatTransNo}
and aisleSwitch = #{aisleSwitch}
and thirdTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and settlementType = #{settlementType}
and merchantCode in
#{item}
SELECT count(*) from tb_pluss_merchant_order
and id = #{id}
and orderNumber like CONCAT("%",#{orderNumber},"%")
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo like CONCAT("%",#{transNo},"%")
and memberCode like CONCAT("%",#{memberCode},"%")
and storeId = #{storeId}
and storeName like CONCAT("%",#{storeName},"%")
and createDt = #{createDt}
and staffCode = #{staffCode}
and status = #{status}
and thirdTransNo = #{aliPayTransNo}
and enterFee = #{enterFee}
and thirdTransNo = #{weChatTransNo}
and aisleSwitch = #{aisleSwitch}
and thirdTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and transDt =]]> #{stTime}
and transDt #{endTime}
and settlementType = #{settlementType}
SELECT count(*) from tb_pluss_merchant_order
and id = #{id}
and orderNumber like CONCAT("%",#{orderNumber},"%")
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo like CONCAT("%",#{transNo},"%")
and memberCode like CONCAT("%",#{memberCode},"%")
and storeId = #{storeId}
and storeName like CONCAT("%",#{storeName},"%")
and createDt = #{createDt}
and staffCode = #{staffCode}
and status = #{status}
and thirdTransNo = #{aliPayTransNo}
and enterFee = #{enterFee}
and thirdTransNo = #{weChatTransNo}
and aisleSwitch = #{aisleSwitch}
and thirdTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and transDt =]]> #{stTime}
and transDt #{endTime}
and (payTypeCode='leshuaPay0' or payTypeCode= 'aliPay' or payTypeCode='sxfPay0')
SELECT count(*) from tb_pluss_merchant_order
and id = #{id}
and orderNumber like CONCAT("%",#{orderNumber},"%")
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo like CONCAT("%",#{transNo},"%")
and memberCode like CONCAT("%",#{memberCode},"%")
and storeId = #{storeId}
and storeName like CONCAT("%",#{storeName},"%")
and createDt = #{createDt}
and staffCode = #{staffCode}
and status = #{status}
and thirdTransNo = #{aliPayTransNo}
and enterFee = #{enterFee}
and thirdTransNo = #{weChatTransNo}
and aisleSwitch = #{aisleSwitch}
and thirdTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and transDt =]]> #{stTime}
and transDt #{endTime}
and (payTypeCode='leshuaPay1' or payTypeCode= 'wechatPay' or payTypeCode='sxfPay1')
SELECT count(*) from tb_pluss_merchant_order
and id = #{id}
and orderNumber like CONCAT("%",#{orderNumber},"%")
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo like CONCAT("%",#{transNo},"%")
and memberCode like CONCAT("%",#{memberCode},"%")
and storeId = #{storeId}
and storeName like CONCAT("%",#{storeName},"%")
and createDt = #{createDt}
and staffCode = #{staffCode}
and status = #{status}
and thirdTransNo = #{aliPayTransNo}
and enterFee = #{enterFee}
and thirdTransNo = #{weChatTransNo}
and aisleSwitch = #{aisleSwitch}
and thirdTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and transDt =]]> #{stTime}
and transDt #{endTime}
and payTypeCode='sxfPay2'
select sum(shareMoney)
from tb_pluss_merchant_order
where memberCode = #{memberCode}
and createDt <= (SELECT DATE_ADD(now(), INTERVAL -1 MONTH))
select sum(shareMoney)
from tb_pluss_merchant_order
where memberCode = #{memberCode}
and createDt > (SELECT DATE_ADD(now(), INTERVAL -1 MONTH))
select sum(shareMoney)
from tb_pluss_merchant_order
where memberCode = #{memberCode}
and date (createDt) = curdate()
select sum(shareMoney)
from tb_pluss_merchant_order
where memberCode = #{memberCode}
SELECT count(*) from tb_pluss_merchant_order
and id = #{id}
and orderNumber = #{orderNumber}
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo = #{transNo}
and memberCode = #{memberCode}
and storeId = #{storeCode}
and
(
storeId = #{item}
)
and storeName = #{storeName}
and
(
staffCode = #{item}
)
and status = #{status}
and aisleSwitch = #{aisleSwitch}
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
and leshuaTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and promoteruserId = #{promoteruserId}
and updateTime >= #{startTime}
and updateTime <= #{endTime}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and settlementType = #{settlementType}
and (
payTypeCode = #{item}
)
and merchantCode in
#{item}
SELECT sum(consumeFee) from tb_pluss_merchant_order t
( SELECT count( 1 ) FROM tb_pluss_merchant_order t1 WHERE t1.orderNumber = t.orderNumber AND t1.status IN
(1, 2) ) = 1
and id = #{id}
and orderNumber = #{orderNumber}
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo = #{transNo}
and memberCode = #{memberCode}
and storeId = #{storeCode}
and (
storeId = #{item}
)
and storeName = #{storeName}
and (
staffCode = #{item}
)
and status = #{status}
and aisleSwitch = #{aisleSwitch}
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
and leshuaTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and promoteruserId = #{promoteruserId}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and updateTime >= #{startTime}
and updateTime <= #{endTime}
and (
payTypeCode = #{item}
)
and createDt > #{startDt}
and createDt < #{startDt}
and merchantCode in
#{item}
SELECT * from tb_pluss_merchant_order
and id = #{id}
and orderNumber = #{orderNumber}
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and (
payTypeCode = #{item}
)
and consumeFee = #{consumeFee}
and transNo = #{transNo}
and memberCode = #{memberCode}
and (
storeId = #{item}
)
and storeName = #{storeName}
and (
staffCode = #{item}
)
and status = #{status}
and updateTime >= #{startTime}
and updateTime <= #{endTime}
and enterFee = #{enterFee}
and aisleSwitch = #{aisleSwitch}
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
and leshuaTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and promoteruserId = #{promoteruserId}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
order by createDt desc limit #{pageSize} offset #{offset}
select count(1) orderCount,sum(t.consumeFee)
orderFee,date_format(t.createDt,'%Y-%m-%d') orderDate
from
tb_pluss_merchant_order t
t.status='1'
and merchantCode=#{merchantCode}
group by date_format(t.createDt,'%Y-%m-%d')
order by orderDate DESC
limit 7
select count(1) orderCount,sum(t.consumeFee)
orderFee,t.payTypeName
payTypeName
from tb_pluss_merchant_order t
t.status=1
and merchantCode=#{merchantCode}
group by payTypeName
select sum(case when t.status=1 then 1 end) as dealCount,
sum(case when
t.status=1 then consumeFee end) as dealSum,
sum(case when t.status=2
then consumeFee end) as actualMoney,
count(t.id) as 'refundCount' ,
SUM(t.consumeFee) as 'netRefund',
sum(t.shareMoney) as 'shareMoney'
from tb_pluss_merchant_order t
AND (
t.payTypeCode=#{payTypeCode}
)
AND (
t.storeId=#{storeId}
)
AND (
t.staffCode=#{staffCode}
)
and date(t.createDt) = curdate()
and date(t.createDt) = date_sub(curdate(),interval 1 day)
-7
]]>
-30
]]>
-90
]]>
and t.merchantCode=#{merchantCode}
SELECT mo.* ,mbi.alias from tb_pluss_merchant_order mo LEFT JOIN tb_pluss_merchant_base_info mbi on
mbi.merchantCode = mo.merchantCode
AND (
mo.payTypeCode=#{payTypeCode}
)
AND (
mo.storeId=#{storeId}
)
and mo.status=#{status}
AND (
mo.staffCode=#{staffCode}
)
AND mo.orderNumber=#{orderNumber}
AND mo.orderType=#{orderType}
AND mo.consumeFee=#{consumeFee}
AND mo.merchantCode=#{merchantCode}
and mo.aisleSwitch = #{aisleSwitch}
and mo.leshuaMerchantRefundId = #{leshuaMerchantRefundId}
and mo.promoteruserId = #{promoteruserId}
and date(createDt) = curdate()
and date(createDt) = date_sub(curdate(),interval 1 day)
-7
]]>
-30
]]>
-90
]]>
order by id desc
limit #{pageSize} offset #{offset}
SELECT COUNT(*) FROM(SELECT * from tb_pluss_merchant_order
AND (
payTypeCode=#{payTypeCode}
)
and status=#{status}
AND (
storeId=#{storeId}
)
AND (
staffCode=#{staffCode}
)
AND orderNumber=#{orderNumber}
AND orderType=#{orderType}
AND consumeFee=#{consumeFee}
AND merchantCode=#{merchantCode}
and aisleSwitch = #{aisleSwitch}
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
and orderType = #{orderType}
and promoteruserId = #{promoteruserId}
and date(createDt) = curdate()
and date(createDt) = date_sub(curdate(),interval 1 day)
-7
]]>
-30
]]>
-90
]]>
)ORER
SELECT sum(shareMoney) from tb_pluss_merchant_order
and id = #{id}
and orderNumber = #{orderNumber}
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo = #{transNo}
and memberCode = #{memberCode}
and storeName = #{storeName}
and status = #{status}
and aisleSwitch = #{aisleSwitch}
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
and orderType = #{orderType}
and promoteruserId = #{promoteruserId}
and userImg = #{userImg}
and nickName = #{nickName}
and updateTime >= #{startTime}
and updateTime <= #{endTime}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
select * from tb_pluss_merchant_order where status=#{status}
and updateTime >= #{startTime}
and updateTime <= #{endTime}
SELECT sum(enterFee) from tb_pluss_merchant_order
and id = #{id}
and orderNumber = #{orderNumber}
and merchantCode = #{merchantCode}
and merchantName = #{merchantName}
and payTypeCode = #{payTypeCode}
and payTypeName = #{payTypeName}
and consumeFee = #{consumeFee}
and transNo = #{transNo}
and memberCode = #{memberCode}
and (
storeId = #{item}
)
and storeName = #{storeName}
and (
staffCode = #{item}
)
and status = #{status}
and aisleSwitch = #{aisleSwitch}
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
and leshuaTransNo = #{leshuaTransNo}
and orderType = #{orderType}
and promoteruserId = #{promoteruserId}
and userImg = #{userImg}
and nickName = #{nickName}
and remark = #{remark}
and transDt = #{transDt}
and staffName = #{staffName}
and updateTime >= #{startTime}
and updateTime <= #{endTime}
SELECT sum(shareMoney) from tb_pluss_merchant_order
and updateTime > #{startTime}
and updateTime < #{endTime}
and merchantCode in
#{item.merchantCode}
and status = #{status}
and aisleSwitch = #{aisleSwitch}
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
and leshuaTransNo = #{leshuaTransNo}
and orderType = #{orderType}
SELECT
mo.id,
mo.`status`,
mo.createDt,
mo.transDt,
mo.merchantCode,
mo.thirdTransNo,
mo.transNo,
mo.orderNumber,
mo.merchantName,
mo.orderType,
mo.payTypeName,
mo.payTypeCode,
mo.consumeFee,
mo.ip,
mo.ipAddress,
mo.mercOrderNo,
mo.drType,
mo.mercFee,
mo.enterFee,
mo.rate as mercRate,
mo.profitShareMoney,
mo.fansShareMoney,
mo.marketAmt,
mo.channelFee,
IF(mo.settlementType = 0,mo.consumeFee - mo.enterFee - mo.mercFee ,0) AS cashFee,
IFNULL(mo.channelRate,21) AS aisleRate,
IF(mo.`status` = 1 , IF(mo.orderType = 8 , mo.consumeFee,mo.consumeFee - mo.enterFee - mo.channelFee),0) as platformRevenue,
IF(mo.`status` = 1 , ((mo.consumeFee - mo.profitShareMoney - mo.fansShareMoney - mo.enterFee - channelFee) - ((mo.consumeFee - mo.enterFee - mo.mercFee) * 0.2)),0) as practical
FROM
tb_pluss_merchant_order mo
and mo.merchantName = #{alias}
and mo.id=#{id}
and mo.orderType=#{orderType}
and
(
mo.payTypeCode = #{item}
)
and (mo.orderNumber=#{orderNumber} or mo.transNo = #{orderNumber} or mo.thirdTransNo = #{orderNumber})
and mo.merchantName like CONCAT("%",#{merchantName},"%")
and mo.merchantCode=#{merchantCode}
and mo.storename like CONCAT("%",#{storeName},"%")
and mo.payTypeName=#{payTypeName}
and mo.status=#{status}
and mo.settlementType=#{settlementType}
and mo.aisleSwitch=#{aisleSwitch}
=DATE_FORMAT(#{startTime}, '%Y-%m-%d %H:%i:%S')
]]>
order by createDt desc
limit #{pageSize} offset #{offset}
select count(*) from tb_pluss_merchant_order mo
and mo.merchantName = #{alias}
and mo.id=#{id}
and mo.orderType=#{orderType}
and
(
mo.payTypeCode = #{item}
)
and (mo.orderNumber=#{orderNumber} or mo.transNo = #{orderNumber} or mo.thirdTransNo = #{orderNumber})
and mo.merchantName = #{merchantName}
and mo.merchantCode = #{merchantCode}
and mo.storename = #{storeName}
and mo.payTypeName = #{payTypeName}
and mo.status = #{status}
and mo.settlementType = #{settlementType}
and mo.aisleSwitch = #{aisleSwitch}
=DATE_FORMAT(#{startTime}, '%Y-%m-%d %H:%i:%S')
]]>
select
sum(mo.consumeFee) as consumeFee,sum(IFNULL(mo.fansShareMoney,0.0))
as
fansShareMoney,sum(mo.enterFee) as enterFee,sum(mo.profitShareMoney) as
shareMoney,sum(truncate(mo.consumeFee*(mb.aliRate-0.0038),2))
as
platformRevenue,sum(truncate((mo.consumeFee*(mb.aliRate-0.0038)-mo.profitShareMoney-IFNULL((select
pf.shareMoney from tb_pluss_fans pf where
pf.orderNumber=mo.orderNumber),0.0)),2))
as practical,sum(truncate(mo.consumeFee*0.0038,2)) as aisleHold FROM
tb_pluss_merchant_order mo LEFT JOIN tb_pluss_merchant_base_info mb ON mo.merchantCode=mb.merchantCode WHERE
mo.status='1' and mo.payTypeCode='aliPay'
and updateTime >= #{startTime}
and updateTime <= #{endTime}
and mo.merchantCode=#{merchantCode}
union
select
sum(mo.consumeFee) as consumeFee,sum(IFNULL((select pf.shareMoney from tb_pluss_fans pf where
pf.lastMerchantCode=mo.merchantCode and pf.orderNumber=mo.orderNumber),0.0))
as
fansShareMoney,sum(mo.enterFee) as enterFee,sum(mo.shareMoney) as
shareMoney,sum(truncate(mo.consumeFee*(mb.wechatRate-0.0038),2)) as
platformRevenue,sum(truncate((mo.consumeFee*(mb.wechatRate-0.0038)-mo.profitShareMoney-IFNULL((select
pf.shareMoney
from tb_pluss_fans pf where pf.orderNumber=mo.orderNumber),0.0)),2))
as practical,sum(truncate(mo.consumeFee*0.0038,2)) as aisleHold FROM
tb_pluss_merchant_order mo LEFT JOIN tb_pluss_merchant_base_info mb ON mo.merchantCode=mb.merchantCode WHERE
mo.status='1' and mo.payTypeCode='wechatPay'
and updateTime >= #{startTime}
and updateTime <= #{endTime}
and mo.merchantCode=#{merchantCode}
union
select
sum(mo.consumeFee) as consumeFee,sum(IFNULL((select
pf.shareMoney from tb_pluss_fans pf where
pf.lastMerchantCode=mo.merchantCode and
pf.orderNumber=mo.orderNumber),0.0))
as
fansShareMoney,sum(mo.enterFee) as enterFee,sum(mo.shareMoney) as
shareMoney,sum(truncate(mo.consumeFee*(mo.rate / 10000 - 0.0021),2))
as
platformRevenue,sum(truncate((mo.consumeFee*(mo.rate / 10000-0.0021)-mo.shareMoney-IFNULL((select
pf.shareMoney from tb_pluss_fans pf where
pf.orderNumber=mo.orderNumber),0.0)),2))
as practical,sum(truncate(mo.consumeFee*0.0021,2)) as aisleHold FROM
tb_pluss_merchant_order mo LEFT JOIN tb_pluss_merchant_base_info mb ON mo.merchantCode=mb.merchantCode WHERE
mo.status='1' and mo.payTypeCode='leshuaPay0' or mo.payTypeCode='leshuaPay1' or mo.payTypeCode='leshuaPay2'
and updateTime >= #{startTime}
and updateTime <= #{endTime}
and mo.merchantCode=#{merchantCode}
SELECT IFNULL(sum(truncate(mo.shareMoney, 2)), 0) as shareMoney,
IFNULL((SELECT sum(truncate(tc.cashAmt, 2))
from tb_pluss_cash tc
WHERE tc.`status` = '1'
and tc.type = '1'
and tc.userId = #{userId}), 0) as cashMoney
from tb_pluss_merchant_order mo
WHERE mo.promoteruserId = #{userId}
and mo.status = '1'
select
(SELECT count(id) from tb_pluss_merchant_base_info
and date(createDt) = curdate()
and date(createDt) = date_sub(curdate(),interval
1 day)
) as merchantCount,
(SELECT count(id) from tb_pluss_merchant_store
and date(createDt) = curdate()
and date(createDt) = date_sub(curdate(),interval
1 day)
) as storeCount,
mot.transSum, mot.transCount, mot.refundSum, mot.refundCount, mot.sharemoneySum,
(SELECT COUNT(id) FROM tb_pluss_merchant_menber
and date(createDt) = curdate()
and date(createDt) = date_sub(curdate(),interval
1 day)
) as memberCount,
(SELECT COUNT(id) FROM tb_pluss_user_app WHERE userType='promoter'
and date(createDt) = curdate()
and date(createDt) = date_sub(curdate(),interval 1
day) ) as promoterCount,
(SELECT IFNULL(SUM(shareMoney),0) FROM tb_pluss_fans
and date(createDt) = curdate()
and date(createDt) = date_sub(curdate(),interval
1 day)
) as fansShareMoneySum,
0 aliSum,
0 wechatSum,
(
SELECT IFNULL(TRUNCATE((SUM(mo.consumeFee*(mo.rate / 10000-0.0021)-mo.fansShareMoney-(SELECT
IFNULL(sum(pf.shareMoney),0) as totalSum FROM tb_pluss_fans pf WHERE pf.payWay in('2-0','2-1')))),2),0) FROM
tb_pluss_merchant_order mo LEFT JOIN tb_pluss_merchant_base_info mi ON mo.merchantCode=mi.merchantCode WHERE
mo.`status`='1' AND mo.payTypeCode='leshuaPay0' or mo.payTypeCode='leshuaPay1' or mo.payTypeCode='leshuaPay2'
and date(mo.createDt) = curdate()
and date(mo.createDt) = date_sub(curdate(),interval 1
day)
)as leshuaSum
FROM (
SELECT SUM(IF(`status` = 1, total, 0)) transSum, SUM(IF(`status` = 1, count, 0)) transCount, SUM(IF(`status` =
2, total, 0)) refundSum, SUM(IF(`status` = 2, count, 0)) refundCount, SUM(sharemoneySum) sharemoneySum FROM (
SELECT `status`, SUM(consumeFee) total, COUNT(id) count, IFNULL( sum( TRUNCATE ( IF(`status` = 1,
fansShareMoney, 0), 2 )), 0 ) sharemoneySum FROM tb_pluss_merchant_order WHERE `status` IN ('1', '2')
and date(createDt) = curdate()
and date(createDt) = date_sub(curdate(),interval 1
day)
GROUP BY `status`
) t
) mot
SELECT (SELECT storeName FROM tb_pluss_merchant_store WHERE storeId = #{storeId}) as storeName,
(SELECT IFNULL(sum(consumeFee), 0)
FROM tb_pluss_merchant_order
WHERE status = '1' and storeId = #{storeId} and date(createDt) = curdate()) as nowDayConsumeFee,
(
SELECT IFNULL(sum (consumeFee), 0)
FROM tb_pluss_merchant_order
WHERE status='1' and storeId=#{storeId}) as sumConsumeFee
SELECT (SELECT alias FROM tb_pluss_merchant_base_info WHERE merchantCode = #{merchantCode}) as storeName,
(SELECT IFNULL(sum(consumeFee), 0)
FROM tb_pluss_merchant_order
WHERE status = '1'
and merchantCode = #{merchantCode}
and date(createDt) = curdate()) as nowDayConsumeFee,
(
SELECT IFNULL(sum (consumeFee), 0)
FROM tb_pluss_merchant_order
WHERE status='1' and merchantCode=#{merchantCode}) as sumConsumeFee
SELECT
SUM( mo.consumeFee ) AS transAmountCount,
ROUND(
SUM( mo.consumeFee * (( IFNULL( mo.rate, 38 )- 21 )/ 10000 )) +
ROUND(SUM(IF(locate('YS',mo.orderNumber) and mo.settlementType = 0,IF(mo.consumeFee 100,0,IF(mo.consumeFee ]]>
100 and mo.consumeFee 500, mo.consumeFee * 0.001 - 0.1,mo.consumeFee * 0.0008)),0)),2)
, 2 ) AS profitAmountCount,
ROUND( SUM( mp.shareAmountCount ) , 2 ) AS shareAmountCount,
ROUND( IFNULL( SUM( pf.shareMoney ), 0.00 ), 2 ) AS fansAmountCount,
ROUND(
SUM( mo.consumeFee * (( IFNULL( mo.rate, 38 )- 21 )/ 10000 )) , 2 ) -
ROUND( SUM( mp.shareAmountCount ), 2 ) -
ROUND( IFNULL( SUM( pf.shareMoney ), 0.00 ) +
ROUND(SUM(IF(locate('YS',mo.orderNumber) and mo.settlementType = 0,IF(mo.consumeFee 100,0,IF(mo.consumeFee ]]>
100 and mo.consumeFee 500, mo.consumeFee * 0.001 - 0.1,mo.consumeFee * 0.0008)),0)),2)
, 2 ) AS actualAmountCount
FROM
tb_pluss_merchant_order mo
LEFT JOIN tb_pluss_fans pf ON mo.orderNumber = pf.orderNumber
LEFT JOIN tb_pluss_merchant_base_info mbi ON mo.merchantCode = mbi.merchantCode
LEFT JOIN ( SELECT orderNumber, SUM( price ) AS shareAmountCount FROM tb_pluss_merchant_profit GROUP BY
orderNumber ) mp ON mo.orderNumber = mp.orderNumber
and mo.status = #{status}
and mo.status = '1'
and mo.id = #{id}
and mbi.userId = #{userId}
and mo.orderNumber = #{orderNumber}
and mbi.alias like CONCAT('%',#{alias},'%')
and mo.storeName like CONCAT('%',#{storeName},'%')
and mo.orderType = #{orderType}
and mo.payTypeName = #{payTypeName}
and
(
mo.payTypeCode = #{item}
)
and mo.createDt =]]> #{startTime}
and mo.createDt #{endTime}
SELECT sum(consumeFee) totalConsumeFee, status, merchantCode FROM tb_pluss_merchant_order tpmo
WHERE tpmo.status IN("1", "2") AND
tpmo.merchantCode IN
#{item}
GROUP BY merchantCode, status
SELECT IFNULL(sum(consumeFee),0) FROM tb_pluss_merchant_order WHERE `status` = 1 and merchantCode in
#{item}
SELECT SUM(tpmo.consumeFee)
FROM (SELECT t1.consumeFee, t1.orderNumber, t1.createDt, t1.merchantCode
FROM tb_pluss_merchant_order t1
LEFT JOIN tb_pluss_merchant_order t2
ON t1.orderNumber = t2.orderNumber AND t1.`status` = 1 AND t2.`status` = 2
WHERE t1.status = 1
AND t2.updateTime IS NULL) tpmo
LEFT JOIN tb_pluss_user_app tpua ON tpmo.merchantCode = tpua.merchantCode
WHERE tpua.parentId = #{parentId}
AND tpmo.createDt > DATE_FORMAT(CURDATE(), "%Y-%m")
SELECT SUM(tpmo.consumeFee)
FROM (SELECT t1.consumeFee, t1.orderNumber, t1.createDt, t1.merchantCode
FROM tb_pluss_merchant_order t1
LEFT JOIN tb_pluss_merchant_order t2
ON t1.orderNumber = t2.orderNumber AND t1.`status` = 1 AND t2.`status` = 2
WHERE t1.status = 1
AND t2.updateTime IS NULL) tpmo
LEFT JOIN tb_pluss_user_app tpua ON tpmo.merchantCode = tpua.merchantCode
WHERE tpua.parentId = #{parentId}
AND tpmo.createDt < DATE_FORMAT(CURDATE(), "%Y-%m")
AND tpmo.createDt > DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), "%Y-%m")
update tb_pluss_merchant_order
when id=#{i.id} then #{i.enterFee}
when id=#{i.id} then #{i.rate}
where
id=#{i.id}
SELECT IFNULL(SUM(mo.consumeFee),0.00) AS tradeCountMoney,ua.parentId as agentId FROM tb_pluss_merchant_order mo
LEFT JOIN tb_pluss_user_app ua ON mo.merchantCode = ua.merchantCode
WHERE mo.`status` = 1 AND mo.createDt BETWEEN #{firstDate}
AND #{lastDate} AND ua.parentId in
#{item}
AND ua.parentId is not null GROUP BY ua.parentId ;
SELECT DATE_ADD(t2.day, INTERVAL 1 DAY) date, SUM(t2.consumeFee) consumeFeeSum
FROM (
SELECT DATE_FORMAT(t.updateTime, "%Y-%m-%d") day, t.consumeFee FROM tb_pluss_merchant_order t
WHERE t.`status` = '1' AND t.merchantCode = #{merchantCode} AND t.updateTime BETWEEN #{start} AND #{end}
) t2
GROUP BY t2.day
SELECT a.*,ui.phone AS 'onePhone',ua.userName AS 'oneName', t.phone AS 'twoPhone',ta.userName AS
'twoName',e.phone AS 'threePhone',ea.userName AS 'threeName',p.phone AS 'toUpPhone',pa.userName AS 'toUpName'
FROM (
SELECT
mbi.userId,
mo.orderNumber,
mbi.alias as merchantName,
mo.orderType,
mo.payTypeCode as payType,
mo.consumeFee,
mo.createDt,
IFNULL(mo.rate,38) AS mercRate,
ROUND((mo.consumeFee * (IFNULL(mo.rate,38))/10000),2) AS mercFee ,
IFNULL((SELECT SUM(price) FROM tb_pluss_merchant_profit mp WHERE mp.orderNumber = mo.orderNumber),0.00) AS
shareMoney,
SUM(CASE mp.type WHEN '1' THEN mp.price ELSE 0 END) 'oneFee',
SUM(CASE mp.type WHEN '2' THEN mp.price ELSE 0 END) 'twoFee',
SUM(CASE mp.type WHEN '3' THEN mp.price ELSE 0 END) 'threeFee',
SUM(CASE mp.type WHEN '4' THEN mp.price ELSE 0 END) 'toUpFee',
SUM(CASE mp.type WHEN '5' THEN mp.price ELSE 0 END) 'toAgentFeeCount',
GROUP_CONCAT(CASE mp.type WHEN '1' THEN mp.userId ELSE '' END SEPARATOR '') 'oneUserId',
GROUP_CONCAT(CASE mp.type WHEN '2' THEN mp.userId ELSE '' END SEPARATOR '') 'twoUserId',
GROUP_CONCAT(CASE mp.type WHEN '3' THEN mp.userId ELSE '' END SEPARATOR '') 'threeUserId',
GROUP_CONCAT(CASE mp.type WHEN '4' THEN mp.userId ELSE '' END SEPARATOR '') 'toUpUserId'
FROM
tb_pluss_merchant_order mo
LEFT JOIN tb_pluss_merchant_profit mp ON mp.orderNumber = mo.orderNumber
LEFT JOIN tb_pluss_merchant_base_info mbi ON mo.merchantCode = mbi.merchantCode
WHERE
mo.`status` = '1'
and mbi.alias like concat('%',#{merchantName},'%')
and mp.userId = #{userId}
and mp.price != '0.00'
and mo.orderNumber = #{orderNumber}
GROUP BY mo.orderNumber
ORDER BY
mo.createDt DESC
limit #{pageSize} offset #{offset}
) a
LEFT JOIN tb_pluss_user_info ui on
a.oneUserId = ui.id
LEFT JOIN tb_pluss_user_app ua ON
a.oneUserId = ua.userId
LEFT JOIN tb_pluss_user_info t ON
a.twoUserId = t.id
LEFT JOIN tb_pluss_user_app ta ON
a.twoUserId = ta.userId
LEFT JOIN tb_pluss_user_info e ON
a.threeUserId = e.id
LEFT JOIN tb_pluss_user_app ea ON
a.threeUserId = ea.userId
LEFT JOIN tb_pluss_user_info p ON
a.toUpUserId = p.id
LEFT JOIN tb_pluss_user_app pa ON
a.toUpUserId = pa.userId
ORDER BY a.createDt desc
SELECT count(1) FROM (
SELECT
mbi.userId
FROM
tb_pluss_merchant_order mo
LEFT JOIN tb_pluss_merchant_profit mp ON mp.orderNumber = mo.orderNumber
LEFT JOIN tb_pluss_merchant_base_info mbi ON mo.merchantCode = mbi.merchantCode
WHERE
mo.`status` = '1'
and mbi.alias like concat('%',#{merchantName},'%')
and mp.userId = #{userId}
and mp.price != '0.00'
and mo.orderNumber = #{orderNumber}
GROUP BY mo.orderNumber
) a
SELECT
IFNULL(SUM(mo.consumeFee - refundAmt),0.00) AS tradeAmtCount,
IFNULL(SUM(case when DATE_FORMAT(mo.transDt,'%Y-%m-%d') >= #{date} THEN mo.consumeFee END),0.00) AS dateAmt
FROM tb_pluss_merchant_order mo
WHERE mo.merchantCode = #{merchantCode} and mo.`status` = 1
= #{startDate}]]>
SELECT IFNULL(SUM(mo.consumeFee), 0.00) AS tradeAmtCount
FROM tb_pluss_merchant_order mo
WHERE mo.merchantCode = #{merchantCode}
and mo.`status` = 1
and DATE_FORMAT(mo.transDt, '%Y-%m-%d') >= #{date}
select consumeFee, ROUND(((38-IFNULL(rate,38))/10000)*consumeFee,2) as saveAmt,transDt FROM
tb_pluss_merchant_order
where status = #{order.status} and merchantCode = #{order.merchantCode}
= #{order.startTime}]]>
order by createDt desc
select
IFNULL(ROUND(SUM(((38-IFNULL(rate,38))/10000)*consumeFee),2),0.0) AS 'saveAmtCount',
IFNULL(SUM(case when DATE_FORMAT(transDt,'%Y-%m-%d') = #{date} THEN
ROUND((38-IFNULL(rate,38))/10000*consumeFee,2) END),0.00) AS saveDateAmt
FROM tb_pluss_merchant_order
where status = 1 and merchantCode = #{merchantCode}
= #{startDate}]]>
select mo.*,mbi.alias from tb_pluss_merchant_order mo
left join tb_pluss_merchant_base_info mbi
on mo.merchantCode = mbi.merchantCode
where mo.status = '1'
and mbi.userId = #{order.userId}
and mo.orderType = #{order.orderType}
and mo.transDt >= #{order.startTime}
and mo.transDt #{order.endTime}
and DATE_FORMAT(mo.createDt,'%Y-%m') = #{order.params.createDtStr}
and mo.marketAmt is not null and mo.marketAmt != 0.00
ORDER BY mo.id desc
SELECT IFNULL(SUM(CASE `status`
WHEN '1' THEN consumeFee
WHEN '2' THEN -consumeFee
ELSE 0
), 0) consumeFee,
IFNULL(SUM(CASE `status`
WHEN '1' THEN enterFee
WHEN '2' THEN -enterFee
ELSE 0
), 0) enterFee,
FROM tb_pluss_merchant_order ${ew.customSqlSegment}
SELECT IFNULL(SUM(mo.enterFee - IF(mro.payAmt, mo.enterFee, 0)), 0) as settleAmt
FROM tb_pluss_merchant_order mo
LEFT JOIN tb_pluss_merchant_refund_order mro ON mo.orderNumber = mro.orderNumber
WHERE mo.`status` = 1
and mo.orderType in (2, 3, 9, 10)
AND mo.merchantCode = #{merchantCode}
AND (mro.`status` is null or mro.`status` in (1, 2))
AND DATE_FORMAT(mo.transDt, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
SELECT
SUM(IF( mo.STATUS = 1, mo.consumeFee, 0 )) AS transAmountCount,
SUM(IF( mo.STATUS = 2, IF ( mo.refundAmt = 0, mo.consumeFee, mo.refundAmt ), 0 )) AS refundAmountCount,
SUM(IF( mo.STATUS = 1 AND mo.orderType = 8, mo.consumeFee, 0 )) AS upAmountCount,
SUM(IF( mo.STATUS = 1 AND mo.orderType != 8, mo.mercFee - mo.channelFee, 0 )) AS transProfitAmountCount,
SUM(IF( mo.STATUS = 1 AND mo.settlementType = 0, IF(mo.cashFee = 0,mo.consumeFee - mo.enterFee - mo.mercFee,mo.cashFee),0)) numberAmountCount,
ROUND( SUM( mo.profitShareMoney ), 2 ) AS shareAmountCount,
ROUND( SUM( IFNULL( mo.fansShareMoney, 0 ) ), 2 ) AS fansAmountCount,
SUM(IF(mo.STATUS = 1,IF( mo.orderType = 8, mo.consumeFee, mo.consumeFee - mo.enterFee ) - mo.channelFee,0 )) AS profitAmountCount,
ROUND(SUM(IF(mo.`status` = 1,IF( mo.orderType = 8, mo.consumeFee, mo.consumeFee - mo.enterFee ) - mo.channelFee - mo.profitShareMoney - mo.fansShareMoney - IF(mo.settlementType = 0,IF(mo.cashFee = 0 ,mo.consumeFee - mo.enterFee - mo.mercFee , mo.cashFee) * 0.2,0),0 )),2) AS actualAmountCount
FROM
tb_pluss_merchant_order mo
mo.status in (1,2)
and mo.createDate = #{createDate}
and mo.createDate =]]> #{startCreateDate}
and mo.createDate #{endCreateDate}
and mo.updateDate =]]> #{startUpdateDate}
and mo.updateDate #{endUpdateDate}
and mo.merchantName = #{alias}
and mo.id=#{id}
and mo.orderType=#{orderType}
and
(
mo.payTypeCode = #{item}
)
and (mo.orderNumber=#{orderNumber} or mo.transNo = #{orderNumber} or mo.thirdTransNo = #{orderNumber})
and mo.merchantName like CONCAT("%",#{merchantName},"%")
and mo.merchantCode=#{merchantCode}
and mo.storename like CONCAT("%",#{storeName},"%")
and mo.payTypeName=#{payTypeName}
and mo.status=#{status}
and mo.settlementType=#{settlementType}
and mo.aisleSwitch=#{aisleSwitch}
and mo.updateTime =]]> #{startTime}
and mo.updateTime #{endTime}
SELECT
SUM( consumeFee ) as toDayTransCount,
count(1) as toDayTransNum,
SUM(IF( payTypeCode = 'aliPay' OR payTypeCode = 'sxfPay0', consumeFee, 0 )) as toDayTransAliCount,
SUM(IF( payTypeCode = 'aliPay' OR payTypeCode = 'sxfPay0', 1, 0 )) as toDayTransAliNum,
SUM(IF( payTypeCode = 'wechatPay' OR payTypeCode = 'sxfPay1', consumeFee, 0 )) as toDayTransWxCount,
SUM(IF( payTypeCode = 'wechatPay' OR payTypeCode = 'sxfPay1', 1, 0 )) as toDayTransWxNum,
SUM(IF( payTypeCode = 'bank' OR payTypeCode = 'sxfPay2' , consumeFee, 0 )) as toDayTransUnionCount,
SUM(IF( payTypeCode = 'bank' OR payTypeCode = 'sxfPay2' , 1, 0 )) as toDayTransUnionNum
FROM
tb_pluss_merchant_order
WHERE
createDate = CURDATE() AND STATUS = 1;
SELECT
SUM(
IF
(orderType = 8,enterFee,IF(
settlementType = 1,
mercFee - channelFee,
consumeFee - enterFee - channelFee - (IF(cashFee = 0, consumeFee - enterFee - mercFee,cashFee) * 0.2)))
) AS toDayProfitCount,
SUM( profitShareMoney ) AS toDayShareCount,
SUM( fansShareMoney ) AS toDayFansCount
FROM
tb_pluss_merchant_order
WHERE
createDate = CURDATE()
AND `status` = 1
SELECT
ua.userId,
ua.parentId,
ua.roleCode,
ua.levelCode,
IFNUll(t.transNum,0) ownTransNum,
IFNUll(t2.transNum,0) transNum,
IFNULL( t2.teamTransFlow, 0 ) AS teamTransFlow,
IFNULL( t.ownTransFlow, 0 ) AS ownTransFlow,
IFNULL( t2.directTransFlow, 0 ) AS directTransFlow,
IFNULL( t2.indirectTransFlow, 0 ) AS indirectTransFlow,
IFNULL( t3.totalProfitAmt, 0 ) AS totalProfitAmt,
IFNULL( t3.directProfitAmt, 0 ) AS directProfitAmt,
IFNULL( t3.indirectProfitAmt, 0 ) AS indirectProfitAmt,
IFNULL( t3.otherProfitAmt, 0 ) AS otherProfitAmt
FROM
tb_pluss_user_app ua
LEFT JOIN (
SELECT
mo.merchantCode,
SUM(consumeFee - IFNULL(IFNULL(mro.refundAmt,mro.payAmt),0)) AS ownTransFlow,
count(1) as transNum
FROM
tb_pluss_merchant_order mo
LEFT JOIN
tb_pluss_merchant_refund_order mro ON mo.orderNumber = mro.orderNumber
WHERE
mo.createDate = #{date}
AND mo.`status` = 1
GROUP BY
mo.merchantCode
) t ON ua.merchantCode = t.merchantCode
LEFT JOIN (
SELECT
SUM( ups.ownTransFlow + ups.teamTransFlow ) teamTransFlow,
SUM( ups.ownTransFlow ) directTransFlow,
SUM( ups.directTransFlow ) indirectTransFlow,
SUM( ups.transNum + ups.ownTransNum) transNum,
ua.userId
FROM
tb_pluss_user_profit ups
LEFT JOIN tb_pluss_user_app ua ON ups.parentId = ua.userId
LEFT JOIN tb_pluss_user_level ul ON ul.levelCode = ua.levelCode
WHERE
ups.profitDate = #{date}
AND ua.sort = #{sort}
GROUP BY
ua.userId
) t2 ON t2.userId = ua.userId
LEFT JOIN (
SELECT
SUM(price) totalProfitAmt,
SUM(IF(type = 1,price,0)) AS directProfitAmt,
SUM(IF(type = 2,price,0)) AS indirectProfitAmt,
SUM(IF(type != 1 and type != 2,price,0)) AS otherProfitAmt,
userId
FROM tb_pluss_merchant_profit WHERE recordDate = #{date} AND price != 0 GROUP BY userId
) t3 ON ua.userId = t3.userId
LEFT JOIN tb_pluss_user_level ull ON ull.levelCode = ua.levelCode
WHERE
ua.sort = #{sort}
AND ua.userType NOT IN ( 'agent_staff', 'staff' )
ORDER BY
teamTransFlow DESC,
ownTransFlow DESC
SELECT
MAX(ua.sort)
FROM
(
SELECT
mo.merchantCode,
SUM( consumeFee ) AS transSumAmt,
mo.rate
FROM
tb_pluss_merchant_order mo
WHERE
mo.createDate = #{date}
AND mo.`status` = 1
GROUP BY
mo.merchantCode
) t
LEFT JOIN tb_pluss_user_app ua ON t.merchantCode = ua.merchantCode
WHERE ua.userType = 'promoter'
SELECT
SUM( consumeFee ) AS transCount,
count( 1 ) AS transNum
FROM
tb_pluss_merchant_order
WHERE
`status` = 1
SELECT
IFNULL(SUM(consumeFee - refundAmt),0)
FROM
tb_pluss_merchant_order mo
WHERE status = 1
and createDate = #{date}
and createDate #{date}
AND merchantCode in
#{item}