<?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="com.gree.mall.miniapp.commonmapper.OrderShareRankMapper">
    <select id="queryRankList" resultType="com.gree.mall.miniapp.bean.user.RankItemBean">
        select
            ur.user_id as workUserId,
            ur.nick_name as work_user_name,
            ur.avatar,
            '' as websitName,
            sum(od.pay_amount) as 'total'
        from order_info os join order_detail od on os.order_id = od.order_id
        join user ur on ur.user_id = od.share_user_id
        join admin_company_wechat d on d.company_wechat_id = os.company_wechat_id
        where od.share_user_id !='' and os.order_status in('DFH','YFH','OVER')
          and os.create_time between #{startTime} and #{endTime} and os.company_wechat_id=#{companyWechatId}
          <if test="userId != null and userId !=''">
              and od.share_user_id = #{userId}
          </if>
        group by od.share_user_id
        order by sum(od.pay_amount) desc
        limit 50
    </select>


    <select id="queryWorkerInfo" resultType="com.gree.mall.miniapp.bean.user.RankItemBean">
         select
					 ur.user_id work_user_id,
					 ur.nick_name as work_user_name,
					 ur.avatar,
					 ''      as websitName
        from  user ur
        where ur.user_id = #{userId}
    </select>



</mapper>