puzhibing
2023-08-31 ef04ce57881e6a338b10d596c5eb76b2220598bf
driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/RevenueMapper.xml
@@ -16,13 +16,14 @@
    <select id="queryTotalAmount" resultType="double">
        select sum(amount) as amount from t_revenue where userType = 2 and userId = #{driverId}
        select sum(amount) as amount from t_revenue where userType = 2 and userId = #{driverId} and type in (1,2)
    </select>
    <select id="queryDriverRank" resultType="com.supersavedriving.driver.modular.system.warpper.PerformanceRankingWarpper">
        select
        aa.driverId,
        @ROW :=@ROW + 1 as rank,
        aa.`name`,
        UNIX_TIMESTAMP(aa.createTime) * 1000 as createTime,
        aa.number as amountOfData
@@ -54,6 +55,31 @@
            </if>
        </if>
        group by a.userId,b.`name`
        ) as aa order by aa.number desc
        ) as aa,( SELECT @ROW := 0 ) AS itable order by aa.number desc
    </select>
    <select id="queryAgentBalance" resultType="double">
        select
        sum(aa.income) - sum(aa.disburse) as balance
        from (
        select sum(amount) as income, 0 as disburse from t_revenue where userType = 3 and userId = #{companyId}
        union all
        select 0 as ncome, sum(amount) as disburse from t_settlement_record where type = 2 and objectId = #{companyId}
        ) as aa
    </select>
    <select id="queryCompanyBalance" resultType="double">
        select
        sum(aa.income) - sum(aa.disburse) + sum(aa.recharge) as balance
        from (
        select sum(amount) as income, 0 as disburse, 0 as recharge from t_revenue where userType = 4
        union all
        select 0 as ncome, sum(amount) as disburse, 0 as recharge from t_settlement_record where type = 1
        union all
        select 0 as ncome, 0 as disburse, sum(surplusDividedAmount) as recharge from t_recharge_record where type = 4 and payStatus = 2
        ) as aa
    </select>
</mapper>