|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- <?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.iformall.mapper.WxBusinessMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBusiness">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- </resultMap>
-
- <sql id="allColumns">
- `id`,`title`,`type`,`create_date`,`update_date`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != title ">
- and `title` like concat('%', #{title},'%')
- </if>
-
- <if test=" null != type ">
- and `type` = #{type}
- </if>
-
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxBusiness" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_business
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="findListAll" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_business
- order by create_date asc
- </select>
-
- <select id="findListForMerchant" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_business b
- where
- (select count(*) from wx_merchant m
- where b.id = m.business_id
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and m.status = 1
- and m.is_public = 1) > 0
- order by create_date asc
- </select>
-
- <select id="findListForCoupon" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_business b
- where
- (select count(*) from wx_coupon_channel cc
- where b.id = cc.business
- and cc.status = 0
- <if test=" null != tenantId and '' != tenantId">
- and cc.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cc.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != platCode and platCode == 1">
- and cc.target_ad = 1
- </if>
- <if test=" null != platCode and platCode == 3">
- and cc.target_ad = 101
- </if>
- ) > 0
- order by create_date asc
- </select>
-
- <select id="businessDataList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
- select b.id,b.title,
-
- round(
- (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
- from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
- /100,2) volume,
-
- round(
- (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
- from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
- /
- (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
- from wx_merchant m
- left join wx_merchant_shop mtd on mtd.merchant_id = m.id
- left join wx_shop ws on(mtd.shop_id = ws.id)
- where m.business_id = b.id and m.status = 1 and m.is_del = 0
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- )
- /100,2) sale,
-
- (select ifnull(sum(rent_area),0) from wx_rent_contract where business_id=b.id
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and status in (2,3,4)) area,
- round(
- (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
- from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 ) /
- (select sum(mtd.trade_count)
- from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
- /100,2) comPrice
-
- from wx_business b
- </select>
-
- <select id="devoteList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
- select mm.name merchantName,
-
- round(
- (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
- from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
- where m.business_id = #{id}
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and mtd.report_date between #{startdate} and #{enddate}
- and m.status = 1 and m.is_del = 0 and m.id = mm.id)
- /
- (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
- from wx_merchant m
- left join wx_merchant_shop mtd on mtd.merchant_id = m.id
- left join wx_shop ws on(mtd.shop_id = ws.id)
- where m.status = 1 and m.is_del = 0 and m.business_id = #{id}
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and m.id = mm.id)
- /100,2) sale,
-
- round(
-
- round(
- (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
- from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
- where m.business_id = #{id}
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and mtd.report_date between #{startdate} and #{enddate}
- and m.status = 1 and m.is_del = 0 and m.id = mm.id)/
- (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
- from wx_merchant m
- left join wx_merchant_shop mtd on mtd.merchant_id = m.id
- left join wx_shop ws on(mtd.shop_id = ws.id)
- where m.status = 1 and m.is_del = 0 and m.business_id = #{id}
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and m.id = mm.id)/100,2)
- /
- round(
- (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
- from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
- where m.business_id = #{id}
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and mtd.report_date between #{startdate} and #{enddate}
- and m.status = 1 and m.is_del = 0 )
- /
- (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
- from wx_merchant m
- left join wx_merchant_shop mtd on mtd.merchant_id = m.id
- left join wx_shop ws on(mtd.shop_id = ws.id)
- where m.business_id = #{id}
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- and m.status = 1 and m.is_del = 0 )
- /100,2)
-
- *100,2) devoteRate
-
- from wx_merchant mm
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = mm.id
- left join wx_merchant_shop wmt on wmt.merchant_id = mm.id
- left join wx_shop ws on(wmt.shop_id = ws.id)
- where mm.business_id=#{id}
- <if test=" null != tenantId and '' != tenantId">
- and mm.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and mm.`parent_tenant_id` = #{parentTenantId}
- </if>
- and mm.status = 1 and mm.is_del = 0
- and mtd.report_date between #{startdate} and #{enddate}
- group by mm.id
- order by devoteRate desc
-
- <if test="null != limitStart and null != limitEnd">
- limit #{limitStart},#{limitEnd}
- </if>
- </select>
-
- </mapper>
|