You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bsdgy-server/src/main/resources/mapper/StorePromotionDataDOMapper.xml

162 lines
5.8 KiB
XML

<?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.kiisoo.ic.store.mapper.StorePromotionDataDOMapper">
<select id="selectPromotionDataGroupByRegion" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
SELECT
t3.id as regionId,
t3.NAME AS regionName,
sum( t4.customer_id ) AS cusNum
FROM
poi_store t1
LEFT JOIN op_seller_customer_relation t4 on t1.id = t4.store_id
<if test="startDate != null">
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') &gt; DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>
<if test="endDate != null">
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') &lt; DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>,
poi_store_region t2,
poi_region t3
WHERE
t1.id = t2.store_id
and t2.region_id = t3.id
<choose>
<when test="storeIds != null and storeIds.size > 0">
and t1.id in
<foreach collection="storeIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
and 1 = 0
</otherwise>
</choose>
<if test="regionId != null">
and t3.id = #{regionId}
</if>
and t1.status = 1
GROUP BY
t3.id
</select>
<select id="selectPromotionDataGroupByStore" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
SELECT
t1.id as storeId,
t1.NAME as storeName,
sum( t4.customer_id ) AS cusNum
FROM
poi_store t1
LEFT JOIN op_seller_customer_relation t4 on t1.id = t4.store_id
<if test="startDate != null">
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') &gt; DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>
<if test="endDate != null">
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') &lt; DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>,
poi_store_region t2
WHERE
t1.id = t2.store_id
<choose>
<when test="storeIds != null and storeIds.size > 0">
and t1.id in
<foreach collection="storeIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
and 1 = 0
</otherwise>
</choose>
<if test="storeId != null">
and t1.id = #{storeId}
</if>
<if test="regionId != null">
and t3.id = #{regionId}
</if>
and t1.status = 1
GROUP BY
t1.id
</select>
<select id="selectPromotionDataGroupBySeller" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
SELECT
t1.id AS sellerId,
t3.NAME AS sellerName,
sum( t2.customer_id ) AS cusNum
FROM
poi_store_staff t1
LEFT JOIN op_seller_customer_relation t2 ON t1.id = t2.user_id
<if test="startDate != null">
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') &gt; DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>
<if test="endDate != null">
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') &lt; DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>,
privilage_user t3,
poi_store_region t4
WHERE
t1.user_id = t3.id
and t1.store_id = t4.store_id
<choose>
<when test="storeIds != null and storeIds.size > 0">
and t1.id in
<foreach collection="storeIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
and 1 = 0
</otherwise>
</choose>
AND t1.type = 4
AND t1.STATUS = 1
AND t1.deleted = 0
AND t3.STATUS = 1
<if test="storeId != null">
and t1.store_id = #{storeId}
</if>
<if test="regionId != null">
and t4.region_id = #{regionId}
</if>
group by t1.id
</select>
<select id="selectCustomer" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
SELECT
t1.cp_user_id AS userid,
t2.store_id AS storeId,
t3.region_id AS regionId
FROM
privilage_cp_user t1,
privilage_cp_user_store t2,
poi_store_region t3
WHERE
t1.id = t2.cp_user_id
AND t2.store_id = t3.store_id
</select>
<insert id="insertStorePromotionData" parameterType="com.kiisoo.ic.store.entity.WxCusInfoRespDO">
INSERT INTO poi_customer_contact_data_stat (store_id, region_id,
negative_feedback_cnt, new_contact_cnt, stat_time, create_time) VALUES (#{storeId}, #{regionId},
#{negative_feedback_cnt}, #{new_contact_cnt}, #{statTime}, NOW())
</insert>
<select id="selectWxCusInfoByRegionId" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
SELECT sum( new_contact_cnt ) AS newCusNum,
sum( negative_feedback_cnt ) AS delCusNum
FROM poi_customer_contact_data_stat
WHERE region_id = #{regionId}
AND stat_time &gt; #{startDate}
AND stat_time &lt; #{endDate}
</select>
<select id="selectWxCusInfoByStoreId" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
SELECT sum( new_contact_cnt ) AS newCusNum,
sum( negative_feedback_cnt ) AS delCusNum
FROM poi_customer_contact_data_stat
WHERE store_id = #{storeId}
AND stat_time &gt; #{startDate}
AND stat_time &lt; #{endDate}
</select>
</mapper>