`id`,`tenant_id`,`meter_id`,`merchant_id`,`status`,`create_time`,`update_time`
where 1 = 1
and `id` = #{id}
and `tenant_id` = #{tenantId}
and `merchant_id` = #{merchantId}
and `meter_id` = #{meterId}
and `status` = #{status}
and id in
#{idItem}
order by ${sortColumns}
select
from kw_merchant_meter
select m.`id`, m.`total_power` from kw_merchant_meter mm
left join kw_meter m on mm.`meter_id` = m.id
where mm.`status` = 0
and mm.`merchant_id` = #{merchantId}
`id`, `tenant_id`, `merchant_id`, `status`, `name`, `link_phone`
select
from (
select merchant_id from kw_merchant_meter
where `status` = 0
and `tenant_id` = #{tenantId}
and `merchant_id` = #{merchantId}
group by merchant_id
) temp
, wx_merchant
where temp.merchant_id = id
and `name` like concat('%', #{merchantName},'%')
and `link_phone` like concat('%', #{merchantLinkPhone},'%')
and `status` = #{merchantStatus}
and `business_id` = #{businessId}
select m.* from kw_merchant_meter mm
left join kw_meter m on mm.`meter_id` = m.id
where mm.`status` = 0
and mm.`merchant_id` = #{merchantId}
select
from (
select merchant_id from kw_merchant_meter
where `status` = 0
and `merchant_id` = #{merchantId}
group by merchant_id
) temp
, wx_merchant
where temp.merchant_id = id
where 1 = 1
and `tenant_id` = #{tenantId}
and `box_id` = #{boxId}
and `meter_id` = #{meterId}
and `address` = #{address}
and `create_time` between #{startTime} and #{endTime}
select
temp.tenant_id,
mm.merchant_id as merchantId,
m.name as merchantName,
m.link_phone as merchantLinkPhone,
m.business_id as businessId,
min(temp.recordStartTime) as recordStartTime,
max(temp.recordEndTime) as recordEndTime,
sum(temp.totalPower) as totalPower,
sum(temp.lastTotalPower) as lastTotalPower,
sum(temp.usedPower) as usedPower
from
kw_merchant_meter mm,
(SELECT
tenant_id,box_id,meter_id,
min(last_device_time) as recordStartTime,
min(last_total_power) as lastTotalPower,
max(device_time) as recordEndTime,
max(total_power) as totalPower,
sum(used_power) as usedPower
FROM kw_meter_data
group by tenant_id,box_id,meter_id
) as temp,
wx_merchant m
where mm.status = 0
and mm.meter_id = temp.meter_id
and mm.merchant_id = m.id
and m`status` = #{merchantStatus}
group by
temp.tenant_id
,merchantId
,businessId
order by ${sortColumns}
limit #{limitCount}
update kw_merchant_meter set status = 1
where status = 0
and `merchant_id` = #{merchantId}
update kw_merchant_meter set status = 1
where status = 0
and `meter_id` = #{meterId}
select m.id as merchant_id,m.name as merchant_name,ifnull(mm.status,0) has from wx_merchant m
left join (select merchant_id,1 as status from kw_merchant_meter where status=0 group by merchant_id) mm on m.id=mm.merchant_id
where m.status=1 and m.id not in(select merchant_id from wx_merchant_power_bill_config where tenant_id=#{tenantId})