ChannelMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.ChannelMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.qs.mp.channel.domain.Channel">
  6. <id column="channel_id" property="channelId" />
  7. <result column="channel_no" property="channelNo" />
  8. <result column="name" property="name" />
  9. <result column="parent_id" property="parentId" />
  10. <result column="level" property="level" />
  11. <result column="site_type" property="siteType" />
  12. <result column="site_name" property="siteName" />
  13. <result column="comm_rate" property="commRate" />
  14. <result column="province" property="province" />
  15. <result column="province_id" property="provinceId" />
  16. <result column="city" property="city" />
  17. <result column="city_id" property="cityId" />
  18. <result column="area" property="area" />
  19. <result column="area_id" property="areaId" />
  20. <result column="address" property="address" />
  21. <result column="contact" property="contact" />
  22. <result column="mobile" property="mobile" />
  23. <result column="user_id" property="userId" />
  24. <result column="money" property="money" />
  25. <result column="frozen_money" property="frozenMoney" />
  26. <result column="certify_status" property="certifyStatus" />
  27. <result column="verify_status" property="verifyStatus" />
  28. <result column="biz_license_pic" property="bizLicensePic" />
  29. <result column="door_pic" property="doorPic" />
  30. <result column="memo" property="memo" />
  31. <result column="invite_pic" property="invitePic" />
  32. <result column="status" property="status" />
  33. <result column="created_time" property="createdTime" />
  34. <result column="updated_time" property="updatedTime" />
  35. </resultMap>
  36. <!-- 通用查询结果列 -->
  37. <sql id="Base_Column_List">
  38. channel_id, channel_no, name, parent_id, level, site_type, site_name, comm_rate, province, province_id, city, city_id, area, area_id, address, contact, mobile, user_id, money, frozen_money, certify_status, verify_status, biz_license_pic, door_pic, memo, invite_pic, status, created_time, updated_time
  39. </sql>
  40. <!-- 查询子渠道信息 -->
  41. <select id="selectChannelVoList" resultType="com.qs.mp.channel.domain.vo.ChannelVO">
  42. select t1.* , t2.name parentName
  43. from mp_channel t1
  44. left join mp_channel t2 on t1.parent_id = t2.channel_id
  45. ${ew.customSqlSegment}
  46. </select>
  47. <!-- 查询渠道及其子渠道经销商数总和 -->
  48. <select id="getChannelSiteCnt" resultType="integer">
  49. select count(t1.channel_id) as siteCnt
  50. from mp_channel t1
  51. where t1.`level`= 0
  52. and (t1.channel_no like concat(#{channelNo}, '.%') or t1.channel_no = #{channelNo})
  53. </select>
  54. <!-- 查询经销商列表信息 -->
  55. <select id="selectSaleSiteList" resultType="com.qs.mp.channel.domain.vo.ChannelVO">
  56. select t1.channel_id as channelId, t1.channel_no, t1.name, t1.parent_id, t1.level, t1.site_type, t1.site_name, t1.comm_rate as commRate, t1.province, t1.province_id, t1.city, t1.city_id, t1.area, t1.area_id, t1.address, t1.contact, t1.mobile, t1.user_id, t1.certify_status, t1.verify_status, t1.status, t1.created_time, t1.updated_time ,
  57. t2.off_line_qty_cnt, t2.off_line_sale_cnt, t4.sale_qty-t2.off_line_sale_cnt as on_line_sale_cnt, t3.user_cnt
  58. from mp_channel t1
  59. left join (
  60. select channel_id, SUM( b.pkg_unit - b.sale_qty ) AS off_line_qty_cnt,
  61. SUM( b.sale_qty ) AS off_line_sale_cnt
  62. from mp_channel_order_detail a
  63. left join mp_ticket_package b on a.pkg_id=b.pkg_id
  64. group by a.channel_id) t2 on t1.channel_id = t2.channel_id
  65. left join (
  66. select channel_id, count(*) AS user_cnt
  67. from mp_channel_user_rel
  68. group by channel_id) t3 on t1.channel_id = t3.channel_id
  69. left join (
  70. select channel_id, count(*) AS sale_qty
  71. from mp_channel_commission
  72. group by channel_id) t4 on t1.channel_id = t4.channel_id
  73. ${ew.customSqlSegment}
  74. </select>
  75. <!-- 统计新增经销商数列表 -->
  76. <select id="selectIndexSiteIncreaseList" resultType="com.qs.mp.admin.domain.vo.IndexVO">
  77. select
  78. DATE_FORMAT(t1.created_time, '%Y%m%d') AS time,
  79. COUNT(t1.channel_id) AS newSiteCnt
  80. from `mp_channel` t1
  81. left join mp_channel t2 on t1.channel_id = t2.channel_id
  82. ${ew.customSqlSegment}
  83. GROUP BY time
  84. </select>
  85. </mapper>