<?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.panzhihua.service_community.dao.ConvenientMerchantDAO">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ConvenientMerchantDO">
|
<id column="id" property="id" />
|
<id column="name" property="name" />
|
<id column="community_id" property="communityId" />
|
<id column="community_name" property="communityName" />
|
<id column="logo" property="logo" />
|
<id column="contacts" property="contacts" />
|
<id column="id_card" property="idCard" />
|
<id column="phone" property="phone" />
|
<id column="address" property="address" />
|
<id column="lat" property="lat" />
|
<id column="lon" property="lon" />
|
<id column="begin_at" property="beginAt" />
|
<id column="end_at" property="endAt" />
|
<id column="period" property="period" />
|
<id column="introduction" property="introduction" />
|
<id column="business_status" property="businessStatus" />
|
<id column="user_id" property="userId" />
|
<id column="consultation_volume" property="consultationVolume" />
|
<id column="view_num" property="viewNum" />
|
<id column="is_del" property="isDel" />
|
<id column="created_at" property="createdAt" />
|
<id column="created_by" property="createdBy" />
|
<id column="updated_at" property="updatedAt" />
|
<id column="updated_by" property="updatedBy" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
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
|
</sql>
|
<select id="pageMerchant" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO">
|
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
|
<if test="pageConvenientMerchantDTO.serviceId != null and pageConvenientMerchantDTO.serviceId != 0">
|
AND ccss.service_category_id = #{pageConvenientMerchantDTO.serviceId}
|
</if>
|
<if test="pageConvenientMerchantDTO.accountStatus != null">
|
AND su.status = #{pageConvenientMerchantDTO.accountStatus}
|
</if>
|
<if test="pageConvenientMerchantDTO.communityId != null and pageConvenientMerchantDTO.communityId != 0">
|
AND ccm.community_id = #{pageConvenientMerchantDTO.communityId}
|
</if>
|
<if test="pageConvenientMerchantDTO.businessStatus != null">
|
AND ccm.business_status = #{pageConvenientMerchantDTO.businessStatus}
|
</if>
|
<if test="pageConvenientMerchantDTO.keyword != null and pageConvenientMerchantDTO.keyword != """>
|
AND (
|
ccm.name LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%')
|
OR ccm.address LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%')
|
OR ccm.phone LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%')
|
)
|
</if>
|
GROUP BY ccm.id ORDER BY ccm.created_at DESC
|
</select>
|
<select id="selectMerchantById" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO">
|
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>
|
<select id="getPopularMerchants" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO">
|
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} AND ccm.business_status = 1 GROUP BY cccs.id
|
) temp GROUP BY temp.id ORDER BY SUM(temp.consultation_volume) DESC
|
</select>
|
<select id="getClassifyMerchants" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO">
|
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.community_id = #{pageClassifyMerchantDTO.communityId} AND ccm.business_status = 1 AND ccss.service_category_id = #{pageClassifyMerchantDTO.serviceId}
|
GROUP BY cccs.id
|
) temp GROUP BY temp.id ORDER BY SUM(temp.consultation_volume) DESC
|
</select>
|
<select id="getMerchantDetail" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO">
|
SELECT
|
temp.id, temp.name, temp.introduction, temp.logo, temp.phone, temp.begin_at, temp.end_at, temp.period,
|
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.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>
|
<select id="pageSearchMerchant" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO">
|
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 = #{pageSearchDTO.communityId} 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>
|
<select id="exportMerchantBySearch" resultType="com.panzhihua.common.model.vos.community.convenient.ExportMerchantVO">
|
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
|
<if test="exportMerchantDTO.serviceId != null and exportMerchantDTO.serviceId != 0">
|
AND ccss.service_category_id = #{exportMerchantDTO.serviceId}
|
</if>
|
<if test="exportMerchantDTO.accountStatus != null">
|
AND su.status = #{exportMerchantDTO.accountStatus}
|
</if>
|
<if test="exportMerchantDTO.businessStatus != null">
|
AND ccm.business_status = #{exportMerchantDTO.businessStatus}
|
</if>
|
<if test="exportMerchantDTO.keyword != null and exportMerchantDTO.keyword != """>
|
AND (
|
ccm.name LIKE CONCAT('%', #{exportMerchantDTO.keyword}, '%')
|
OR ccm.address LIKE CONCAT('%', #{exportMerchantDTO.keyword}, '%')
|
OR ccm.phone LIKE CONCAT('%', #{exportMerchantDTO.keyword}, '%')
|
)
|
</if>
|
GROUP BY ccm.id
|
</select>
|
<select id="exportMerchantByIds" resultType="com.panzhihua.common.model.vos.community.convenient.ExportMerchantVO">
|
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
|
<foreach collection="needExportIds" open="(" separator="," close=")" index="index" item="item">
|
#{item}
|
</foreach>
|
GROUP BY ccm.id
|
</select>
|
<update id="deleteMerchantById">
|
UPDATE com_convenient_merchants SET is_del = 1, updated_by = #{operator} WHERE id = #{merchantId}
|
</update>
|
<update id="batchUpdateMerchantConsultationNum">
|
UPDATE `com_convenient_merchants` SET consultation_volume = CASE id
|
<foreach collection="consultationVOList" item="item" index="index">
|
WHEN #{item.merchantId} THEN #{item.totalConsultationNum}
|
</foreach>
|
END
|
WHERE id = CASE id
|
<foreach collection="consultationVOList" item="item" index="index">
|
WHEN #{item.merchantId} THEN #{item.merchantId}
|
</foreach>
|
END
|
</update>
|
<update id="batchUpdateMerchantViewNum">
|
UPDATE `com_convenient_merchants` SET view_num = CASE id
|
<foreach collection="viewVOList" item="item" index="index">
|
WHEN #{item.merchantId} THEN #{item.totalViewNum}
|
</foreach>
|
END
|
WHERE id = CASE id
|
<foreach collection="viewVOList" item="item" index="index">
|
WHEN #{item.merchantId} THEN #{item.merchantId}
|
</foreach>
|
END
|
</update>
|
<update id="batchUpdateBusinessStatus">
|
UPDATE `com_convenient_merchants` SET business_status = #{status}
|
WHERE id IN
|
<foreach collection="convenientMerchantDOList" open="(" separator="," close=")" item="item" index="index">
|
#{item.id}
|
</foreach>
|
</update>
|
</mapper>
|