ChannelCommissionMapper.xml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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="box_id" property="boxId" />
  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, box_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.order_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 > DATE_SUB(CURDATE(),INTERVAL #{days} DAY)
  39. GROUP BY t1.order_id
  40. ) t3
  41. </select>
  42. <!-- 查询子渠道全部的佣金金额 -->
  43. <select id="getChannelTotalCommAmtCnt" resultType="integer">
  44. select IFNULL(SUM(t1.comm_amt),0) as commAmt
  45. from mp_channel_commission t1
  46. left join mp_channel t2 on t1.channel_id = t2.channel_id
  47. where (t2.channel_no like concat(#{channelNo},'.%') or t2.channel_no = #{channelNo})
  48. </select>
  49. <!-- 查询子渠道全部的销售金额 -->
  50. <select id="getChannelTotalSaleAmtCnt" resultType="integer">
  51. select IFNULL(SUM(t3.sale_amt),0) as saleAmt
  52. from (
  53. select t1.order_id, MIN(t1.sale_amt) sale_amt
  54. from mp_channel_commission t1
  55. left join mp_channel t2 on t1.channel_id = t2.channel_id
  56. where (t2.channel_no like concat(#{channelNo},'.%') or t2.channel_no = #{channelNo})
  57. GROUP BY t1.order_id
  58. ) t3
  59. </select>
  60. </mapper>