<?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.McsInformationDAO">
|
|
<resultMap type="com.panzhihua.service_community.entity.McsInformation" id="McsInformationMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="address" column="address" jdbcType="VARCHAR"/>
|
<result property="lat" column="lat" jdbcType="VARCHAR"/>
|
<result property="lon" column="lon" jdbcType="VARCHAR"/>
|
<result property="cover" column="cover" jdbcType="VARCHAR"/>
|
<result property="content" column="content" jdbcType="VARCHAR"/>
|
<result property="status" column="status" jdbcType="INTEGER"/>
|
<result property="publishAt" column="publish_at" jdbcType="TIMESTAMP"/>
|
<result property="isDel" column="is_del" jdbcType="VARCHAR"/>
|
<result property="merchantId" column="merchant_id" jdbcType="INTEGER"/>
|
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
<result property="createdBy" column="created_by" jdbcType="INTEGER"/>
|
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
<result property="updatedBy" column="updated_by" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<!-- 批量插入 -->
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.mcs_information(name, address, lat, lon, cover, content, status, publish_at, is_del,
|
merchant_id, created_at, created_by, updated_at, updated_by)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.name}, #{entity.address}, #{entity.lat}, #{entity.lon}, #{entity.cover}, #{entity.content},
|
#{entity.status}, #{entity.publishAt}, #{entity.isDel}, #{entity.merchantId}, #{entity.createdAt},
|
#{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy})
|
</foreach>
|
</insert>
|
<!-- 批量插入或按主键更新 -->
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.mcs_information(name, address, lat, lon, cover, content, status, publish_at, is_del,
|
merchant_id, created_at, created_by, updated_at, updated_by)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.name}, #{entity.address}, #{entity.lat}, #{entity.lon}, #{entity.cover}, #{entity.content},
|
#{entity.status}, #{entity.publishAt}, #{entity.isDel}, #{entity.merchantId}, #{entity.createdAt},
|
#{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy})
|
</foreach>
|
on duplicate key update
|
name = values(name) , address = values(address) , lat = values(lat) , lon = values(lon) , cover = values(cover)
|
, content = values(content) , status = values(status) , publish_at = values(publish_at) , is_del =
|
values(is_del) , merchant_id = values(merchant_id) , created_at = values(created_at) , created_by =
|
values(created_by) , updated_at = values(updated_at) , updated_by = values(updated_by)
|
</insert>
|
<update id="setOffByMerchantIds">
|
UPDATE mcs_information SET `status` = 3 WHERE merchant_id IN
|
<foreach collection="needDealIds" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</update>
|
<select id="pageMcsInfo"
|
resultType="com.panzhihua.common.model.vos.community.microCommercialStreet.McsInformationVO">
|
SELECT t1.id, t1.`name`, t1.publish_at, t1.`status`, t1.merchant_id, t2.`name` AS merchantName, t1.cover
|
FROM mcs_information t1
|
LEFT JOIN mcs_merchant t2 ON t1.merchant_id = t2.id
|
WHERE t1.is_del = 0
|
<if test="pageMcsInformationDTO.userId != null">
|
AND t2.user_id = #{pageMcsInformationDTO.userId}
|
</if>
|
<if test="pageMcsInformationDTO.status != null">
|
AND t1.`status` = #{pageMcsInformationDTO.status}
|
</if>
|
<if test="pageMcsInformationDTO.keyword != null and pageMcsInformationDTO.keyword != """>
|
AND t1.`name` LIKE CONCAT(#{pageMcsInformationDTO.keyword}, '%')
|
</if>
|
ORDER BY t1.created_at DESC
|
</select>
|
<select id="pageH5McsInfo"
|
resultType="com.panzhihua.common.model.vos.community.microCommercialStreet.McsInformationVO">
|
SELECT * FROM (
|
SELECT t1.id, t1.`name`, t1.publish_at, t1.`status`, t1.merchant_id, t1.lat, t1.lon, t1.cover, t2.`name` AS
|
merchantName,
|
ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN((t1.lat * PI() / 180 - #{pageMcsInformationDTO.lat} * PI() / 180) / 2),2)
|
+
|
COS(t1.lat * PI() / 180) * COS(#{pageMcsInformationDTO.lat} * PI() / 180) * POW(SIN((t1.lon * PI() / 180 -
|
#{pageMcsInformationDTO.lon} * PI() / 180) / 2),2))), 2) AS distance
|
FROM mcs_information t1
|
LEFT JOIN mcs_merchant t2 ON t1.merchant_id = t2.id
|
LEFT JOIN sys_user t3 ON t2.user_id = t3.user_id
|
WHERE t1.is_del = 0 AND t1.`status` = 2 AND t3.`status` = 1
|
<if test="pageMcsInformationDTO.keyword != null and pageMcsInformationDTO.keyword != """>
|
AND t1.`name` LIKE CONCAT(#{pageMcsInformationDTO.keyword}, '%')
|
</if>
|
<if test="pageMcsInformationDTO.merchantId != null">
|
AND t1.merchant_id = #{pageMcsInformationDTO.merchantId}
|
</if>
|
ORDER BY t1.created_at DESC
|
) temp WHERE 1=1
|
<if test="pageMcsInformationDTO.distance != null">
|
AND distance <= #{pageMcsInformationDTO.distance}
|
</if>
|
</select>
|
|
</mapper>
|