<?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.delivery.mapper.SalesReportMapper"> <!--总值统计--> <select id="SalesReportCountAll" resultType="cn.iocoder.yudao.module.delivery.entity.SalesReportRespAll"> SELECT ( SELECT sum(if(transport_id = 1, sum_volume, sum_weight)) FROM ecw_order c WHERE is_del = 0 AND (transport_id = 1 OR transport_id = 3) AND rucang_time BETWEEN #{sDate} AND #{eDate} <include refid="WherePage"/> ) AS curValue, (SELECT sum(if(transport_id = 1, sum_volume, sum_weight)) FROM ecw_order c WHERE is_del = 0 AND (transport_id = 1 OR transport_id = 3) AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate} <include refid="WherePage"/> ) AS tbValue, (SELECT sum(if(transport_id = 1, sum_volume, sum_weight)) FROM ecw_order c WHERE is_del = 0 AND (transport_id = 1 OR transport_id = 3) AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate} <include refid="WherePage"/> ) AS hbValue, ( SELECT sum(sum_volume) FROM ecw_order c WHERE is_del = 0 AND transport_id = 1 AND rucang_time BETWEEN #{sDate} AND #{eDate} <include refid="WherePage"/> ) AS curValue1, (SELECT sum(sum_volume) FROM ecw_order c WHERE is_del = 0 AND transport_id = 1 AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate} <include refid="WherePage"/> ) AS tbValue1, (SELECT round(sum(sum_volume) / (SELECT vz FROM ecw_vz WHERE fuhao = 'M3' LIMIT 1), 2) FROM ecw_order c WHERE is_del = 0 AND transport_id = 1 AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate} <include refid="WherePage"/> ) AS hbValue1, (SELECT round(sum(sum_weight) / (SELECT vz FROM ecw_vz WHERE fuhao = 'KG' LIMIT 1), 2) FROM ecw_order c WHERE is_del = 0 AND transport_id = 3 AND rucang_time BETWEEN #{sDate} AND #{eDate} <include refid="WherePage"/> ) AS curValue3, (SELECT sum(sum_weight) FROM ecw_order c WHERE is_del = 0 AND transport_id = 3 AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate} <include refid="WherePage"/> ) AS tbValue3, (SELECT sum(sum_weight) FROM ecw_order c WHERE is_del = 0 AND transport_id = 3 AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate} <include refid="WherePage"/> ) AS hbValue3 FROM DUAL </select> <select id="SalesReportCount" resultType="cn.iocoder.yudao.module.delivery.entity.SalesReportResp"> SELECT ( SELECT sum(if(transport_id = 1, sum_volume, sum_weight)) FROM ecw_order c WHERE is_del = 0 AND (transport_id = 1 OR transport_id = 3) AND rucang_time BETWEEN #{sDate} AND #{eDate} <include refid="WherePage"/> ) AS curValue, (SELECT sum(if(transport_id = 1, sum_volume, sum_weight)) FROM ecw_order c WHERE is_del = 0 AND (transport_id = 1 OR transport_id = 3) AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate} <include refid="WherePage"/> ) AS tbValue, (SELECT sum(if(transport_id = 1, sum_volume, sum_weight)) FROM ecw_order c WHERE is_del = 0 AND (transport_id = 1 OR transport_id = 3) AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate} <include refid="WherePage"/> ) AS hbValue FROM DUAL </select> <!--海运统计--> <select id="SalesReportCountSea" resultType="cn.iocoder.yudao.module.delivery.entity.SalesReportResp"> SELECT ( SELECT sum(sum_volume) FROM ecw_order c WHERE is_del = 0 AND transport_id = 1 AND rucang_time BETWEEN #{sDate} AND #{eDate} <include refid="WherePage"/> ) AS curValue, (SELECT sum(sum_volume) FROM ecw_order c WHERE is_del = 0 AND transport_id = 1 AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate} <include refid="WherePage"/> ) AS tbValue, (SELECT sum(sum_volume) FROM ecw_order c WHERE is_del = 0 AND transport_id = 1 AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate} <include refid="WherePage"/> ) AS hbValue FROM DUAL </select> <!--空运统计--> <select id="SalesReportCountAir" resultType="cn.iocoder.yudao.module.delivery.entity.SalesReportResp"> SELECT ( SELECT sum(sum_weight) FROM ecw_order c WHERE is_del = 0 AND transport_id = 3 AND rucang_time BETWEEN #{sDate} AND #{eDate} <include refid="WherePage"/> ) AS curValue, (SELECT sum(sum_weight) FROM ecw_order c WHERE is_del = 0 AND transport_id = 3 AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate} <include refid="WherePage"/> ) AS tbValue, (SELECT sum(sum_weight) FROM ecw_order c WHERE is_del = 0 AND transport_id = 3 AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate} <include refid="WherePage"/> ) AS hbValue FROM DUAL </select> <!--2024-04-22--> <select id="FirstCustomerCount" resultType="int"> SELECT count(c.customer_id) as s_customer_id from ecw_order a left join ecw_order_consignee c on a.order_id = c.order_id left join ecw_customer cc on cc.id = c.customer_id where cc.is_new = 0 and a.is_del = 0 and a.status > 0 and a.rucang_time BETWEEN #{sDate} AND #{eDate} and a.drawee = 2 </select> <select id="CustomerTargetCount" resultType="int"> <!--根据业绩达成日志来统计--> SELECT COUNT( DISTINCT customer_id) as countTargrt from ecw_target_log <where> deleted=0 <if test="sDate!=null and sDate!='' and eDate!=null and eDate!=''"> and achievement_time BETWEEN #{sDate} and #{eDate} </if> <if test="salesmanid!=null and salesmanid!=''"> <!--客户经理查询条件--> and user_id= #{salesmanid} </if> <if test="deptid!=null and deptid!=''"> <!--部门查询条件--> and user_id= #{salesmanid} </if> </where> </select> <sql id="WherePage"> <if test="salesmanid!=null and salesmanid!=''"> and c.salesman_id= #{salesmanid} </if> <if test="deptid!=null and deptid!=''"> and c.salesman_id in (SELECT id from system_user where dept_id =#{deptid} ) </if> </sql> </mapper>