`id`,`title`,`type`,`create_date`,`update_date`
where 1 = 1
and `id` = #{id}
and `title` like concat('%', #{title},'%')
and `type` = #{type}
and `create_date` = #{createDate}
and `update_date` = #{updateDate}
and id in
#{idItem}
order by ${sortColumns}
select
from wx_business
select
from wx_business
order by create_date asc
select
from wx_business b
where
(select count(*) from wx_merchant m
where b.id = m.business_id
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
and m.status = 1
and m.is_public = 1) > 0
order by create_date asc
select
from wx_business b
where
(select count(*) from wx_coupon_channel cc
where b.id = cc.business
and cc.status = 0
and cc.`tenant_id` = #{tenantId}
and cc.`parent_tenant_id` = #{parentTenantId}
and cc.target_ad = 1
and cc.target_ad = 101
) > 0
order by create_date asc
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
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
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
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
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
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
)
/100,2) sale,
(select ifnull(sum(rent_area),0) from wx_rent_contract where business_id=b.id
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
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
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
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
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
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 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}
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
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}
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
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}
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
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}
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
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}
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
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}
and m.`tenant_id` = #{tenantId}
and m.`parent_tenant_id` = #{parentTenantId}
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}
and mm.`tenant_id` = #{tenantId}
and mm.`parent_tenant_id` = #{parentTenantId}
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
limit #{limitStart},#{limitEnd}