id,`name`,community_id,community_name,logo,contacts,id_card,phone,address,lat,lon,begin_at,end_at,period,introduction,
business_status,user_id,consultation_volume,is_del,created_at,created_by,updated_at,updated_by,area_code,service_range,mobile_phone,detailed_address
SELECT ccm.*, su.account, su.status AS accountStatus, GROUP_CONCAT(ccss.service_name) AS serviceScope
FROM com_convenient_merchants ccm
LEFT JOIN sys_user su ON ccm.user_id = su.user_id
LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id
WHERE ccm.is_del = 0
AND ccss.service_category_id = #{pageConvenientMerchantDTO.serviceId}
AND su.status = #{pageConvenientMerchantDTO.accountStatus}
AND ccm.community_id = ${pageConvenientMerchantDTO.communityId}
AND ccm.area_code = ${pageConvenientMerchantDTO.areaCode}
AND ccm.business_status = #{pageConvenientMerchantDTO.businessStatus}
AND (
ccm.name LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%')
OR ccm.address LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%')
OR ccm.phone LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%')
)
GROUP BY ccm.id ORDER BY ccm.created_at DESC
SELECT ccm.*, su.account, su.status AS accountStatus
FROM com_convenient_merchants ccm
LEFT JOIN sys_user su ON ccm.user_id = su.user_id
WHERE ccm.id = #{merchantId}
SELECT ccm.*, su.account, su.status AS accountStatus
FROM com_convenient_merchants ccm
LEFT JOIN sys_user su ON ccm.user_id = su.user_id
WHERE ccm.user_id = #{userId}
SELECT
temp.id,
temp.NAME,
temp.introduction,
temp.logo,
temp.serviceScope,
IF
(
SUM( temp.consultation_volume ) IS NULL,
0,
SUM( temp.consultation_volume )) AS monthConsultationVolume
FROM
(
SELECT
ccm.id,
ccm.NAME,
ccm.introduction,
ccm.logo,
cccs.consultation_volume,
GROUP_CONCAT( ccss.service_name ) AS serviceScope
FROM
com_convenient_merchants ccm
LEFT JOIN (
SELECT
*
FROM
com_convenient_consultation_statistics
WHERE
statistic_date LIKE #{currentMon}) cccs ON ccm.id = cccs.merchant_id
LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id
WHERE
( ccm.community_id = ${communityId} or ccm.community_id = 0) AND ccm.business_status = 1 and ccm.is_del = 0 and ccm.`name` = '犇师傅维修中心' GROUP BY cccs.id
) temp
GROUP BY
temp.id
ORDER BY
SUM( temp.consultation_volume ) DESC
SELECT
temp.id, temp.name, temp.introduction, temp.logo,
temp.serviceScope, IF(SUM(cccs.consultation_volume) is null, 0, SUM(cccs.consultation_volume)) as monthConsultationVolume
FROM (
SELECT
ccm.id, ccm.name, ccm.introduction, ccm.logo,
GROUP_CONCAT(ccss.service_name) AS serviceScope
FROM com_convenient_merchants ccm
LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id
WHERE ccm.area_code=#{areaCode} and ( ccm.community_id = ${communityId} or ccm.community_id = 0)
AND ccm.business_status = 1 and ccm.is_del = 0 and ccm.`name` != '犇师傅维修中心'
GROUP BY ccm.id
) temp
LEFT JOIN (SELECT * FROM com_convenient_consultation_statistics WHERE statistic_date LIKE #{currentMon}) cccs ON temp.id = cccs.merchant_id
GROUP BY temp.id ORDER BY SUM(cccs.consultation_volume) DESC
SELECT
temp.id, temp.name, temp.introduction, temp.logo,
IF(SUM(temp.consultation_volume) is null,0,SUM(temp.consultation_volume)) as monthConsultationVolume
FROM (
SELECT
ccm.id, ccm.name, ccm.introduction, ccm.logo, cccs.consultation_volume
FROM com_convenient_merchants ccm
LEFT JOIN (SELECT * FROM com_convenient_consultation_statistics WHERE statistic_date LIKE #{currentMon}) cccs ON ccm.id = cccs.merchant_id
LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id
WHERE ccm.area_code=#{pageClassifyMerchantDTO.areaCode} and (ccm.community_id = ${pageClassifyMerchantDTO.communityId} or ccm.community_id = 0) and ccm.is_del = 0 AND ccm.business_status = 1 AND ccss.service_category_id = #{pageClassifyMerchantDTO.serviceId}
) temp GROUP BY temp.id ORDER BY SUM(temp.consultation_volume) DESC
SELECT
temp.id, temp.name, temp.introduction, temp.logo, temp.phone, temp.begin_at, temp.end_at, temp.period,temp.detailed_address,
temp.address, temp.lat, temp.lon, temp.serviceScope, IF(SUM(temp.consultation_volume) is null,0,SUM(temp.consultation_volume)) as monthConsultationVolume
FROM (
SELECT
ccm.id, ccm.name, ccm.introduction, ccm.logo, ccm.phone, ccm.begin_at, ccm.end_at, ccm.period,ccm.detailed_address,
ccm.address, ccm.lat, ccm.lon, cccs.consultation_volume,GROUP_CONCAT(ccss.service_name) AS serviceScope
FROM com_convenient_merchants ccm
LEFT JOIN (SELECT * FROM com_convenient_consultation_statistics WHERE statistic_date LIKE #{currentMon}) cccs ON ccm.id = cccs.merchant_id
LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id
WHERE ccm.id = #{merchantId} GROUP BY cccs.id
) temp GROUP BY temp.id ORDER BY SUM(temp.consultation_volume) DESC
SELECT
temp.id, temp.name, temp.introduction, temp.logo,temp.detailed_address,
temp.serviceScope, IF(SUM(temp.consultation_volume) is null,0,SUM(temp.consultation_volume)) as monthConsultationVolume
FROM (
SELECT
ccm.id, ccm.name, ccm.introduction, ccm.logo,ccm.detailed_address,
cccs.consultation_volume,GROUP_CONCAT(ccss.service_name) AS serviceScope
FROM com_convenient_merchants ccm
LEFT JOIN (SELECT * FROM com_convenient_consultation_statistics WHERE statistic_date LIKE #{currentMon}) cccs ON ccm.id = cccs.merchant_id
LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id
WHERE (ccm.community_id = ${pageSearchDTO.communityId} or ccm.community_id = 0) AND ccm.business_status = 1 AND ccm.`name` LIKE CONCAT('%', #{pageSearchDTO.keyword}, '%')
AND ccm.is_del = 0 GROUP BY cccs.id
) temp GROUP BY temp.id ORDER BY SUM(temp.consultation_volume) DESC
SELECT ccm.*, su.account, su.status AS accountStatus, GROUP_CONCAT(ccss.service_name) AS serviceScope,
CONCAT(ccm.period,DATE_FORMAT(ccm.begin_at,'%T'),'~',DATE_FORMAT(ccm.end_at,'%T')) AS businessTime
FROM com_convenient_merchants ccm
LEFT JOIN sys_user su ON ccm.user_id = su.user_id
LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id
WHERE ccm.community_id = ${exportMerchantDTO.communityId} AND ccm.is_del = 0
AND ccss.service_category_id = #{exportMerchantDTO.serviceId}
AND su.status = #{exportMerchantDTO.accountStatus}
AND ccm.business_status = #{exportMerchantDTO.businessStatus}
AND (
ccm.name LIKE CONCAT('%', #{exportMerchantDTO.keyword}, '%')
OR ccm.address LIKE CONCAT('%', #{exportMerchantDTO.keyword}, '%')
OR ccm.phone LIKE CONCAT('%', #{exportMerchantDTO.keyword}, '%')
OR ccm.detailed_address LIKE CONCAT('%', #{exportMerchantDTO.keyword}, '%')
)
GROUP BY ccm.id
SELECT ccm.*, su.account, su.status AS accountStatus, GROUP_CONCAT(ccss.service_name) AS serviceScope,
CONCAT(ccm.period,DATE_FORMAT(ccm.begin_at,'%T'),'~',DATE_FORMAT(ccm.end_at,'%T')) AS businessTime
FROM com_convenient_merchants ccm
LEFT JOIN sys_user su ON ccm.user_id = su.user_id
LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id
WHERE ccm.id IN
#{item}
GROUP BY ccm.id
SELECT * FROM (
SELECT id, `name`, consultation_volume, view_num
FROM com_convenient_merchants
WHERE area_code=#{pagePopularMerchantDTO.areaCode} and (community_id = ${pagePopularMerchantDTO.communityId} OR community_id = 0) AND is_del = 0 ORDER BY (consultation_volume + consultation_volume) DESC LIMIT 100
) temp
SELECT
(SELECT 0) AS resourceTypeNum,
(SELECT COUNT(id) FROM com_convenient_merchants WHERE (community_id = ${communityId} OR community_id = 0) AND is_del = 0) AS merchantNum,
(SELECT SUM(t1.consultation_volume)
FROM com_convenient_consultation_statistics t1
LEFT JOIN com_convenient_merchants t2 ON t1.merchant_id = t2.id
WHERE (t2.community_id = ${communityId} OR t2.community_id = 0)) AS serviceTimes
SELECT t1.`name` AS filed, COUNT(t3.id) AS num
FROM com_convenient_service_categories t1
LEFT JOIN com_convenient_service_scope t2 ON t1.id = t2.service_category_id
LEFT JOIN com_convenient_merchants t3 ON t2.merchant_id = t3.id
WHERE (t3.community_id = ${communityId} OR t3.community_id = 0) AND t3.is_del = 0 GROUP BY t1.id
SELECT filed, SUM(num) AS num FROM (
SELECT DATE_FORMAT( t1.statistic_date, '%Y-%m' ) AS filed, SUM(t1.consultation_volume) AS num
FROM com_convenient_consultation_statistics t1
LEFT JOIN com_convenient_merchants t2 ON t1.merchant_id = t2.id
WHERE (t2.community_id = ${communityId} OR t2.community_id = 0) AND DATE_FORMAT( t1.statistic_date, '%Y-%m' ) > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed
UNION ALL SELECT * FROM
(
SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
) temT
) temp GROUP BY filed ORDER BY filed ASC
SELECT IF(SUM(t1.consultation_volume) IS NULL,0,SUM(t1.consultation_volume)) AS num
FROM com_convenient_consultation_statistics t1
LEFT JOIN com_convenient_merchants t2 ON t1.merchant_id = t2.id
WHERE (t2.community_id = ${communityId} OR t2.community_id = 0) AND DATE_FORMAT( t1.statistic_date, '%Y-%m' ) <= #{date}
SELECT t1.id, t1.`name`, t1.logo, t1.introduction, GROUP_CONCAT(t2.`service_name`) serviceScope
FROM com_convenient_merchants t1
LEFT JOIN com_convenient_service_scope t2 ON t1.id = t2.merchant_id
WHERE (t1.community_id = ${pageBaseDTO.communityId} OR t1.community_id = 0)
AND t2.service_category_id = #{pageBaseDTO.paramId}
GROUP BY t1.id ORDER BY t1.id DESC
UPDATE com_convenient_merchants SET is_del = 1, updated_by = #{operator} WHERE id = #{merchantId}
UPDATE `com_convenient_merchants` SET consultation_volume = CASE id
WHEN #{item.merchantId} THEN #{item.totalConsultationNum}
END
WHERE id = CASE id
WHEN #{item.merchantId} THEN #{item.merchantId}
END
UPDATE `com_convenient_merchants` SET view_num = CASE id
WHEN #{item.merchantId} THEN #{item.totalViewNum}
END
WHERE id = CASE id
WHEN #{item.merchantId} THEN #{item.merchantId}
END
UPDATE `com_convenient_merchants` SET business_status = #{status}
WHERE id IN
#{item.id}
SELECT
ccm.id, ccm.name, ccm.introduction, ccm.logo, ccm.phone, ccm.begin_at, ccm.end_at, ccm.period,ccm.detailed_address,
ccm.address, ccm.lat, ccm.lon,u.status account_status,u.account,ccm.business_status
FROM com_convenient_merchants ccm LEFT JOIN sys_user u on ccm.user_id = u.user_id WHERE u.type = 5
and u.account = #{account}