123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?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.qs.mp.channel.mapper.ChannelMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.qs.mp.channel.domain.Channel">
- <id column="channel_id" property="channelId" />
- <result column="channel_no" property="channelNo" />
- <result column="name" property="name" />
- <result column="parent_id" property="parentId" />
- <result column="level" property="level" />
- <result column="site_type" property="siteType" />
- <result column="site_name" property="siteName" />
- <result column="comm_rate" property="commRate" />
- <result column="province" property="province" />
- <result column="province_id" property="provinceId" />
- <result column="city" property="city" />
- <result column="city_id" property="cityId" />
- <result column="area" property="area" />
- <result column="area_id" property="areaId" />
- <result column="address" property="address" />
- <result column="contact" property="contact" />
- <result column="mobile" property="mobile" />
- <result column="user_id" property="userId" />
- <result column="money" property="money" />
- <result column="frozen_money" property="frozenMoney" />
- <result column="certify_status" property="certifyStatus" />
- <result column="verify_status" property="verifyStatus" />
- <result column="biz_license_pic" property="bizLicensePic" />
- <result column="door_pic" property="doorPic" />
- <result column="memo" property="memo" />
- <result column="invite_pic" property="invitePic" />
- <result column="status" property="status" />
- <result column="created_time" property="createdTime" />
- <result column="updated_time" property="updatedTime" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- 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
- </sql>
- <!-- 查询子渠道信息 -->
- <select id="selectChannelVoList" resultType="com.qs.mp.channel.domain.vo.ChannelVO">
- select t1.* , t2.name parentName
- from mp_channel t1
- left join mp_channel t2 on t1.parent_id = t2.channel_id
- ${ew.customSqlSegment}
- </select>
- <!-- 查询渠道及其子渠道经销商数总和 -->
- <select id="getChannelSiteCnt" resultType="integer">
- select count(t1.channel_id) as siteCnt
- from mp_channel t1
- where t1.`level`= 0
- and (t1.channel_no like concat(#{channelNo}, '.%') or t1.channel_no = #{channelNo})
- </select>
- <!-- 查询经销商列表信息 -->
- <select id="selectSaleSiteList" resultType="com.qs.mp.channel.domain.vo.ChannelVO">
- 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 ,
- 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
- from mp_channel t1
- left join (
- select channel_id, SUM( b.pkg_unit - b.sale_qty ) AS off_line_qty_cnt,
- SUM( b.sale_qty ) AS off_line_sale_cnt
- from mp_channel_order_detail a
- left join mp_ticket_package b on a.pkg_id=b.pkg_id
- group by a.channel_id) t2 on t1.channel_id = t2.channel_id
- left join (
- select channel_id, count(*) AS user_cnt
- from mp_channel_user_rel
- group by channel_id) t3 on t1.channel_id = t3.channel_id
- left join (
- select channel_id, count(*) AS sale_qty
- from mp_channel_commission
- group by channel_id) t4 on t1.channel_id = t4.channel_id
- ${ew.customSqlSegment}
- </select>
- <!-- 统计新增经销商数列表 -->
- <select id="selectIndexSiteIncreaseList" resultType="com.qs.mp.admin.domain.vo.IndexVO">
- select
- DATE_FORMAT(t1.created_time, '%Y%m%d') AS time,
- COUNT(t1.channel_id) AS newSiteCnt
- from `mp_channel` t1
- left join mp_channel t2 on t1.channel_id = t2.channel_id
- ${ew.customSqlSegment}
- GROUP BY time
- </select>
- </mapper>
|