ChannelCommissionMapper.xml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.qs.mp.channel.mapper.ChannelCommissionMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.qs.mp.channel.domain.ChannelCommission">
  6. <id column="id" property="id" />
  7. <result column="channel_id" property="channelId" />
  8. <result column="order_id" property="orderId" />
  9. <result column="ticket_id" property="ticketId" />
  10. <result column="sale_amt" property="saleAmt" />
  11. <result column="sale_comm_rate" property="saleCommRate" />
  12. <result column="sale_comm_amt" property="saleCommAmt" />
  13. <result column="comm_rate" property="commRate" />
  14. <result column="comm_amt" property="commAmt" />
  15. <result column="created_time" property="createdTime" />
  16. <result column="updated_time" property="updatedTime" />
  17. </resultMap>
  18. <!-- 通用查询结果列 -->
  19. <sql id="Base_Column_List">
  20. id, channel_id, order_id, ticket_id, sale_amt, sale_comm_rate, sale_comm_amt, comm_rate, comm_amt, created_time, updated_time
  21. </sql>
  22. <!-- 查询子渠道一定时间范围内的佣金金额 -->
  23. <select id="getChannelCommAmtCnt" resultType="integer">
  24. select IFNULL(SUM(t1.comm_amt),0) as commAmt
  25. from mp_channel_commission t1
  26. left join mp_channel t2 on t1.channel_id = t2.channel_id
  27. where (t2.channel_no like concat(#{channelNo},'.%') or t2.channel_no = #{channelNo})
  28. AND t1.created_time > DATE_SUB(CURDATE(),INTERVAL #{days} DAY)
  29. </select>
  30. <!-- 查询子渠道一定时间范围内的销售金额 -->
  31. <select id="getChannelSaleAmtCnt" resultType="integer">
  32. select IFNULL(SUM(t3.sale_amt),0) as saleAmt
  33. from (
  34. select t1.ticket_id, MIN(t1.sale_amt) sale_amt
  35. from mp_channel_commission t1
  36. left join mp_channel t2 on t1.channel_id = t2.channel_id
  37. where (t2.channel_no like concat(#{channelNo},'.%') or t2.channel_no = #{channelNo})
  38. AND t1.created_time > between DATE_SUB(CURDATE(),INTERVAL #{days} DAY)
  39. GROUP BY t1.ticket_id
  40. ) t3
  41. </select>
  42. </mapper>