Files
zhwl/zhwl-wcsc/target/classes/mapper/wcsc/ZdyWcscStoreMapper.xml
2025-07-01 17:54:58 +08:00

436 lines
17 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.zhwl.wcsc.mapper.ZdyWcscStoreMapper">
<resultMap type="ZdyWcscStore" id="ZdyWcscStoreResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="storeType" column="store_type"/>
<result property="images" column="images"/>
<result property="realname" column="realname"/>
<result property="phone" column="phone"/>
<result property="provinceName" column="province_name"/>
<result property="cityName" column="city_name"/>
<result property="areaName" column="area_name"/>
<result property="provinceId" column="province_id"/>
<result property="cityId" column="city_id"/>
<result property="areaId" column="area_id"/>
<result property="address" column="address"/>
<result property="latitude" column="latitude"/>
<result property="longitude" column="longitude"/>
<result property="store" column="store"/>
<result property="selfetch" column="selfetch"/>
<result property="serviceType" column="service_type"/>
<result property="serviceRadius" column="service_radius"/>
<result property="serviceProvinceIds" column="service_province_ids"/>
<result property="serviceCityIds" column="service_city_ids"/>
<result property="serviceAreaIds" column="service_area_ids"/>
<result property="openhours" column="openhours"/>
<result property="openweeks" column="openweeks"/>
<result property="status" column="status"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="deletetime" column="deletetime"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="scenicId" column="scenic_id"/>
<result property="deptId" column="dept_id"/>
<result property="storeId" column="store_id"/>
<result property="registerAuditStatus" column="register_audit_status"/>
</resultMap>
<sql id="selectZdyWcscStoreVo">
SELECT a.id,
a.store_type,
a.province_name,
a.city_name,
a.area_name,
a.province_id,
a.city_id,
a.area_id,
a.store,
a.selfetch,
a.service_type,
a.service_radius,
a.service_province_ids,
a.service_city_ids,
a.service_area_ids,
a.deletetime,
a.scenic_id,
a.store_id,
sbi.name,
sbi.images,
sbi.contact_name realname,
sbi.contact_phone phone,
sbi.address,
sbi.latitude,
sbi.longitude,
concat(sbi.business_start_hours, '-', sbi.business_end_hours) openhours,
sbi.business_days_on_weekly openweeks,
sbi.grounding_status status,
sbi.register_audit_status register_audit_status,
sbi.create_time,
sbi.update_time,
sbi.create_by,
sbi.update_by,
sbi.dept_id
FROM zdy_wcsc_store a
inner join zdy_store_base_info sbi on a.store_id = sbi.id
</sql>
<select id="selectZdyWcscStoreList" parameterType="ZdyWcscStore" resultMap="ZdyWcscStoreResult">
<include refid="selectZdyWcscStoreVo"/>
LEFT JOIN sys_dept d ON d.dept_id = sbi.dept_id
<where>
ISNULL(a.deletetime)
<if test="name != null and name != ''">
and sbi.name like concat('%', #{name}, '%')
</if>
<if test="storeType != null and storeType != ''">
and a.store_type = #{storeType}
</if>
<if test="images != null and images != ''">
and sbi.images = #{images}
</if>
<if test="realname != null and realname != ''">
and sbi.contact_name like concat('%', #{realname}, '%')
</if>
<if test="phone != null and phone != ''">
and sbi.contact_phone = #{phone}
</if>
<if test="store != null and store != ''">
and a.store = #{store}
</if>
<if test="selfetch != null and selfetch != ''">
and a.selfetch = #{selfetch}
</if>
<if test="serviceType != null and serviceType != ''">
and a.service_type = #{serviceType}
</if>
<choose>
<when test="statusArray != null and statusArray.length != 0">
and sbi.grounding_status in
<foreach item="status" collection="statusArray" open="(" separator="," close=")">
#{status}
</foreach>
</when>
<otherwise>
<if test="status != null and status != ''">
and sbi.grounding_status = #{status}
</if>
</otherwise>
</choose>
<if test="registerAuditStatus != null and registerAuditStatus != ''">
and sbi.register_audit_status = #{registerAuditStatus}
</if>
${params.dataScope}
</where>
</select>
<select id="selectZdyWcscStoreById" parameterType="Long"
resultMap="ZdyWcscStoreResult">
<include refid="selectZdyWcscStoreVo"/>
where a.id = #{id}
</select>
<select id="selectZdyWcscStoreByStoreId" parameterType="Long"
resultMap="ZdyWcscStoreResult">
<include refid="selectZdyWcscStoreVo"/>
where a.store_id = #{id}
</select>
<insert id="insertZdyWcscStore" parameterType="ZdyWcscStore" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_wcsc_store
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="storeId != null">
id,
</if>
<if test="storeType != null and storeType != ''">store_type,
</if>
<if test="provinceName != null and provinceName != ''">province_name,
</if>
<if test="cityName != null and cityName != ''">city_name,
</if>
<if test="areaName != null and areaName != ''">area_name,
</if>
<if test="provinceId != null">province_id,
</if>
<if test="cityId != null">city_id,
</if>
<if test="areaId != null">area_id,
</if>
<if test="store != null and store != ''">store,
</if>
<if test="selfetch != null and selfetch != ''">selfetch,
</if>
<if test="serviceType != null and serviceType != ''">service_type,
</if>
<if test="serviceRadius != null">service_radius,
</if>
<if test="serviceProvinceIds != null">service_province_ids,
</if>
<if test="serviceCityIds != null">service_city_ids,
</if>
<if test="serviceAreaIds != null">service_area_ids,
</if>
<if test="deletetime != null">deletetime,
</if>
<if test="scenicId != null">scenic_id,
</if>
<if test="storeId != null">store_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="storeId != null">#{storeId},
</if>
<if test="storeType != null and storeType != ''">#{storeType},
</if>
<if test="provinceName != null and provinceName != ''">#{provinceName},
</if>
<if test="cityName != null and cityName != ''">#{cityName},
</if>
<if test="areaName != null and areaName != ''">#{areaName},
</if>
<if test="provinceId != null">#{provinceId},
</if>
<if test="cityId != null">#{cityId},
</if>
<if test="areaId != null">#{areaId},
</if>
<if test="store != null and store != ''">#{store},
</if>
<if test="selfetch != null and selfetch != ''">#{selfetch},
</if>
<if test="serviceType != null and serviceType != ''">#{serviceType},
</if>
<if test="serviceRadius != null">#{serviceRadius},
</if>
<if test="serviceProvinceIds != null">#{serviceProvinceIds},
</if>
<if test="serviceCityIds != null">#{serviceCityIds},
</if>
<if test="serviceAreaIds != null">#{serviceAreaIds},
</if>
<if test="deletetime != null">#{deletetime},
</if>
<if test="scenicId != null">#{scenicId},
</if>
<if test="storeId != null">#{storeId},
</if>
</trim>
</insert>
<update id="updateZdyWcscStore" parameterType="ZdyWcscStore">
update zdy_wcsc_store
<trim prefix="SET" suffixOverrides=",">
<if test="storeType != null and storeType != ''">store_type =
#{storeType},
</if>
<if test="provinceName != null and provinceName != ''">province_name =
#{provinceName},
</if>
<if test="cityName != null and cityName != ''">city_name =
#{cityName},
</if>
<if test="areaName != null and areaName != ''">area_name =
#{areaName},
</if>
<if test="provinceId != null">province_id =
#{provinceId},
</if>
<if test="cityId != null">city_id =
#{cityId},
</if>
<if test="areaId != null">area_id =
#{areaId},
</if>
<if test="store != null and store != ''">store =
#{store},
</if>
<if test="selfetch != null and selfetch != ''">selfetch =
#{selfetch},
</if>
<if test="serviceType != null and serviceType != ''">service_type =
#{serviceType},
</if>
<if test="serviceRadius != null">service_radius =
#{serviceRadius},
</if>
<if test="serviceProvinceIds != null">service_province_ids =
#{serviceProvinceIds},
</if>
<if test="serviceCityIds != null">service_city_ids =
#{serviceCityIds},
</if>
<if test="serviceAreaIds != null">service_area_ids =
#{serviceAreaIds},
</if>
<if test="deletetime != null">deletetime =
#{deletetime},
</if>
<if test="scenicId != null">scenic_id =
#{scenicId},
</if>
<if test="storeId != null">store_id =
#{storeId},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteZdyWcscStoreById" parameterType="Long">
delete
from zdy_wcsc_store
where id = #{id}
</delete>
<update id="deleteZdyWcscStoreByIds">
update zdy_wcsc_store set deletetime = sysdate() where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="selectZdyWcscStoreByAdminId" parameterType="Long"
resultMap="ZdyWcscStoreResult">
SELECT st.id,
st.store_type,
st.province_name,
st.city_name,
st.area_name,
st.province_id,
st.city_id,
st.area_id,
st.store,
st.selfetch,
st.service_type,
st.service_radius,
st.service_province_ids,
st.service_city_ids,
st.service_area_ids,
sbi.name,
sbi.images,
sbi.contact_name realname,
sbi.contact_phone phone,
sbi.address,
sbi.latitude,
sbi.longitude,
concat(sbi.business_start_hours, '-', sbi.business_end_hours) openhours,
sbi.business_days_on_weekly openweeks,
sbi.grounding_status status,
sbi.register_audit_status register_audit_status
FROM `zdy_wcsc_store` st
inner join zdy_store_base_info sbi on st.store_id = sbi.id
left join zdy_wcsc_user_store ust ON ust.store_id = st.id
WHERE ust.user_id = #{userId} limit 1
</select>
<select id="getStoreInfoByDeptId" parameterType="Long"
resultMap="ZdyWcscStoreResult">
<include refid="selectZdyWcscStoreVo"/>
where sbi.dept_id = #{deptId}
</select>
<update id="updateStoreInfoByStoreId" parameterType="ZdyWcscStore">
update zdy_wcsc_store
<trim prefix="SET" suffixOverrides=",">
<if test="storeType != null and storeType != ''">store_type =
#{storeType},
</if>
<if test="provinceName != null and provinceName != ''">province_name =
#{provinceName},
</if>
<if test="cityName != null and cityName != ''">city_name =
#{cityName},
</if>
<if test="areaName != null and areaName != ''">area_name =
#{areaName},
</if>
<if test="provinceId != null">province_id =
#{provinceId},
</if>
<if test="cityId != null">city_id =
#{cityId},
</if>
<if test="areaId != null">area_id =
#{areaId},
</if>
<if test="store != null and store != ''">store =
#{store},
</if>
<if test="selfetch != null and selfetch != ''">selfetch =
#{selfetch},
</if>
<if test="serviceType != null and serviceType != ''">service_type =
#{serviceType},
</if>
<if test="serviceRadius != null">service_radius =
#{serviceRadius},
</if>
<if test="serviceProvinceIds != null">service_province_ids =
#{serviceProvinceIds},
</if>
<if test="serviceCityIds != null">service_city_ids =
#{serviceCityIds},
</if>
<if test="serviceAreaIds != null">service_area_ids =
#{serviceAreaIds},
</if>
<if test="deletetime != null">deletetime =
#{deletetime},
</if>
<if test="scenicId != null">scenic_id =
#{scenicId},
</if>
<if test="storeId != null">
store_id = #{storeId}
</if>
</trim>
where store_id = #{storeId}
</update>
<select id="getByStoreId" parameterType="Long" resultMap="ZdyWcscStoreResult">
<include refid="selectZdyWcscStoreVo"/>
where a.store_id = #{storeId}
</select>
<select id="listIdsHavingOrders" resultType="java.lang.Long">
SELECT
store_id
FROM
( SELECT store_id, COUNT(*) AS order_count FROM zdy_wcsc_order_item
WHERE store_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
GROUP BY store_id ) t
WHERE
t.order_count > 0
</select>
<select id="listStoreIdsByIds" resultType="java.lang.Long">
SELECT store_id
FROM zdy_wcsc_store
WHERE id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="listDeptIdsByIds" resultType="java.lang.Long">
SELECT
zsbi.dept_id
FROM zdy_wcsc_store zws
LEFT JOIN zdy_store_base_info zsbi on zws.store_id = zsbi.id
WHERE zws.id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>