PickUpPointMapper.xml 10.6 KB
<?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.diligrp.website.dao.impl.PickUpPointDaoImpl">
    <resultMap id="pickInfo" type="com.diligrp.website.domain.PickUpPointDomain">
        <id property="id" column="id"/>
        <result property="pickName" column="pickup_name"/>
        <result property="pickCode" column="pickup_code"/>
        <result property="addressId" column="address_id"/>
        <result property="addressTxt" column="address_txt"/>
        <result property="remark" column="description"/>
        <result property="isMarket" column="is_market"/>
        <result property="isDeaflutMarket" column="is_default"/>
        <result property="longitude" column="longitude"/>
        <result property="latitude" column="latitude"/>
        <result property="abbreviation" column="abbreviation"/>
        <result property="createTime" column="created"/>
        <result property="modifyTime" column="modified"/>
        <result property="yn" column="yn"/>
        <result property="operateId" column="operate_id"/>
        <result property="operateName" column="operate_name"/>
        <result property="parentPickId" column="parent_pickId"/>
        <result property="relationMarket" column="relation_market"/>
        <result property="recommend" column="recommend"/>
        <result property="myself" column="myself"/>
        <association property="personList" column="id"
                     select="com.diligrp.website.dao.impl.PickUpPersonDaoImpl.SELECT-PICK-UP-PERSON-INFO"/>
        <association property="cityList" column="id"
                     select="com.diligrp.website.dao.impl.PickUpCityDaoImpl.SELECT-PICK-UP-CITY-INFO"/>
    </resultMap>
    <resultMap id="pickUpPerson" type="com.diligrp.website.domain.PickUpPerson">
        <result property="pickid" column="packup_id"/>
        <result property="contactName" column="contact_name"/>
        <result property="contactPhone" column="contact_tel"/>
    </resultMap>
    <resultMap id="pickUpCity" type="com.diligrp.website.domain.PickUpCity">
        <result property="pickId" column="packup_id"/>
        <result property="cityId" column="city_id"/>
    </resultMap>
    <select id="SELECT-PICK-UP-INFO" parameterType="Query"
            resultMap="pickInfo">
        <![CDATA[
        select id,pickup_code, pickup_name ,abbreviation,is_market,is_default,myself,recommend  from t_packup where yn=1
          ]]>
        <if test="param.pickName != null and param.pickName != ''">
            and instr (pickup_name,#{param.pickName})
        </if>
        <if test="param.abbreviation != null and param.abbreviation!= ''">
            and instr (abbreviation,#{param.abbreviation})
        </if>
        <if test="param.nowTime != null and param.nowTime != ''">
            and period_begin &gt;= #{param.nowTime}
            and period_end
            &lt;= #{param.nowTime}
        </if>
        <if test="param.isMarket != null and param.isMarket != ''">
            and is_market = #{param.isMarket}
        </if>
        <if test="param.myself != null and param.myself != ''">
            and myself = #{param.myself}
        </if>
        <![CDATA[
		 order by created desc
		limit #{startRow},#{pageSize}
		]]>
    </select>
    <select id="SELECT-COUNT-PICK-UP-INFO" parameterType="Query"
            resultType="Integer">
        <![CDATA[
        select count(1)  from t_packup where yn=1
          ]]>
        <if test="param.pickName != null and param.pickName != ''">
            and instr (pickup_name,#{param.pickName})
        </if>
        <if test="param.abbreviation != null and param.abbreviation!= ''">
            and instr (abbreviation,#{param.abbreviation})
        </if>
        <if test="param.nowTime != null and param.nowTime != ''">
            and period_begin &gt;= #{param.nowTime}
            and period_end
            &lt;= #{param.nowTime}
        </if>
        <if test="param.isMarket != null and param.isMarket != ''">
            and is_market = #{param.isMarket}
        </if>
        <if test="param.myself != null and param.myself != ''">
            and myself = #{param.myself}
        </if>
    </select>

    <insert id="INSERT-PICKUP-INFO" parameterType="com.diligrp.website.domain.PickUpPointDomain">
        <selectKey keyProperty="id" resultType="long" order="AFTER">
            select
            LAST_INSERT_ID() ;
        </selectKey>
        <![CDATA[
		insert into
		t_packup(pickup_name,pickup_code,address_id,address_txt,description,is_market,is_default,recommend,myself,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market)
		values
		(#{pickName},#{pickCode},#{addressId},#{addressTxt},#{remark},#{isMarket},#{isDeaflutMarket},#{recommend},#{myself},
		#{longitude},#{latitude},#{abbreviation},#{operateId},#{operateName},sysdate(),#{parentPickId},#{relationMarket})
		]]>

    </insert>
    <select id="SELECT-ONE-PICK-UP-INFO" resultMap="pickInfo">
		select
		id,pickup_name,pickup_code,address_id,address_txt,description,is_market,is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
		from t_packup where id=#{id} and yn=1
	</select>
    <select id="SELECT-DEFALUT-PICK-UP-INFO" resultMap="pickInfo">
		select
		id,pickup_name,pickup_code,address_id,address_txt,description,is_market,is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
		from t_packup where is_default=1 and yn=1
	</select>
    <update id="UPDATE-PICKUP-INFO" parameterType="com.diligrp.website.domain.PickUpPointDomain">
		update t_packup set pickup_name=#{pickName} ,pickup_code=#{pickCode},address_id=#{addressId},address_txt=#{addressTxt},
		description=#{remark},longitude=#{longitude},latitude=#{latitude},abbreviation=#{abbreviation},recommend=#{recommend},myself=#{myself}
		,operate_id = #{operateId},operate_name=#{operateName},modified=sysdate(),parent_pickId=#{parentPickId} where id=#{id}
	</update>
    <update id="UPDATE-PICKUP-INFO-STATE" parameterType="Long">
		update t_packup set  is_default=1,modified=sysdate() where id=#{id}
	</update>
    <update id="UPDATE-PICKUP-INFO-STATE-NOT-DEAFULT">
		update t_packup set  is_default=0 where is_default=1 and is_market=1
	</update>
    <select id="SELECT-RELATION-PICKINFO" resultMap="pickInfo" parameterType="Long">
		select
		id,pickup_name,pickup_code,address_id,address_txt,description,is_market,
		is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
		from t_packup where parent_pickId=#{id} and yn=1
	</select>
    <select id="SELECT-IS-MARKET-RELATION-PICKINFO" resultMap="pickInfo">
		select
		id,pickup_name,pickup_code,address_id,address_txt,description,is_market,
		is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
		from t_packup where is_market=2 and relation_market=0  and yn=1
	</select>
    <!-- 供管理服务用 是市场的提货点信息-->
    <select id="SELECT-IS-MARKET-PICKINFO" resultMap="pickInfo">
		select
		id,pickup_name,pickup_code,address_id,address_txt,description,is_market,
		is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
		from t_packup where is_market=1   and yn=1
	</select>
    <!-- 供管理服务用  不是市场-->
    <select id="SELECT-IS-NOT-MARKET-PICKINFO" resultMap="pickInfo">
		select
		id,pickup_name,pickup_code,address_id,address_txt,description,is_market,
		is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
		from t_packup where is_market=2  and yn=1
	</select>
    <!-- 所有 提货点信息 -->
    <select id="SELECT-ALL-MARKET-PICKINFO" resultMap="pickInfo">
	 select
		id,pickup_name,pickup_code,address_id,address_txt,description,is_market,
		is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
		from t_packup   where   yn=1 ORDER BY recommend desc
	</select>
    <update id="UPDATE-RELATION-PICKINFO" parameterType="Map">
		update t_packup set  parent_pickId=#{pickId},relation_market=1 where id=#{id}
	</update>
    <update id="UPDATE-PICKUP-RELATION-INFO-STATE" parameterType="Long">
		update t_packup set  parent_pickId=null,relation_market=0 where parent_pickId=#{id}
	</update>

    <!-- 根据code查询提货点信心 -->
    <select id="SELECT-CODE-BY-PICKINFO" resultMap="pickInfo" parameterType="String">
	 select
		id,pickup_name,pickup_code,address_id,address_txt,description,is_market,
		is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
		from t_packup where pickup_code=#{code} and yn=1
	</select>

    <!-- 根据Name查询提货点信息 -->
    <select id="getPickUpInfoByName" resultMap="pickInfo" parameterType="String">
        select
        id,pickup_name,pickup_code,address_id,address_txt,description,is_market,
        is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
        from t_packup where pickup_name like "%"#{pickName}"%" and yn=1
    </select>

    <!-- 获取推荐提货点 -->
    <select id="getRecommendPickUp" resultMap="pickInfo">
        select
        id,pickup_name,pickup_code,address_id,address_txt,description,is_market,
        is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
        from t_packup where recommend = 2 and yn=1
    </select>

    <!-- 根据城市Name模糊查询提货点信息 -->
    <select id="getPickUpInfoByCityName" resultMap="pickInfo" parameterType="String">
        select
        id,pickup_name,pickup_code,address_id,address_txt,description,is_market,
        is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
        from t_packup left join t_city on region_id = address_id where region_name like "%"#{cityName}"%" and yn=1
    </select>

    <!-- 根据城市Id查询所有提货点信息 -->
    <select id="getAllPickUpListByCityId" resultMap="pickInfo" parameterType="Long">
        select
        id,pickup_name,pickup_code,address_id,address_txt,description,is_market,
        is_default,longitude,latitude,abbreviation,operate_id,operate_name,created,parent_pickId,relation_market,recommend,myself
        from t_packup p left join t_city ct on ct.region_id = p.address_id where ct.parent_id = #{cityId} or ct.region_id = #{cityId} and yn=1
    </select>

</mapper>