ciqihuo-video-approve/yudao-module-crm/yudao-module-bi-biz/src/main/resources/mapper/rank/BiRankingMapper.xml

43 lines
1.9 KiB
XML

<?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="cn.iocoder.yudao.module.bi.dal.mysql.BiRankingMapper">
<select id="contractRanKing"
resultType="cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiContractRanKingRespVO">
SELECT IFNULL(SUM(t.price), 0) AS price, su.nickname, t.owner_user_id, dept.name AS deptName
FROM crm_contract t
LEFT JOIN system_users AS su ON su.id = t.owner_user_id
LEFT JOIN system_dept AS dept ON dept.id = su.dept_id
WHERE t.deleted = 0
AND t.audit_status = 20
<if test="userIds != null and userIds.size() > 0">
and t.owner_user_id in
<foreach collection="userIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
AND DATE_FORMAT(t.order_date,'${sqlDateFormat}') between #{beginTime} and #{finalTime}
GROUP BY t.owner_user_id
ORDER BY price DESC
</select>
<select id="receivablesRanKing"
resultType="cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiReceivablesRanKingRespVO">
SELECT IFNULL(SUM(t.price), 0) AS price, su.nickname, t.owner_user_id, dept.name AS deptName
FROM crm_receivable t
LEFT JOIN system_users AS su ON su.id = t.owner_user_id
LEFT JOIN system_dept AS dept ON dept.id = su.dept_id
WHERE t.deleted = 0
AND t.audit_status = 20
<if test="userIds != null and userIds.size() > 0">
and t.owner_user_id in
<foreach collection="userIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
AND DATE_FORMAT(t.return_time,'${sqlDateFormat}') between #{beginTime} and #{finalTime}
GROUP BY t.owner_user_id
ORDER BY price DESC
</select>
</mapper>