231 lines
15 KiB
XML
231 lines
15 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.xdadan.erp.emis.mapper.EmisCustomerAddressMapper">
|
|
|
|
<resultMap type="EmisCustomerAddress" id="EmisCustomerAddressResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
|
|
<result property="id" column="id" />
|
|
<result property="userId" column="user_id" />
|
|
<result property="customerCode" column="customer_code" />
|
|
<result property="shortName" column="short_name" />
|
|
<result property="alias" column="alias" />
|
|
<result property="addressType" column="address_type" />
|
|
<result property="country" column="country" />
|
|
<result property="name" column="name" />
|
|
<result property="phone" column="phone" />
|
|
<result property="province" column="province" />
|
|
<result property="city" column="city" />
|
|
<result property="county" column="county" />
|
|
<result property="town" column="town" />
|
|
<result property="address" column="address" />
|
|
<result property="postCode" column="post_code" />
|
|
<result property="email" column="email" />
|
|
<result property="company" column="company" />
|
|
<result property="blDefaultFlag" column="bl_default_flag" />
|
|
<result property="orderNum" column="order_num" />
|
|
<result property="blSiteDefaultFlag" column="bl_site_default_flag" />
|
|
<result property="useSite" column="use_site" />
|
|
<result property="useSiteCode" column="use_site_code" />
|
|
|
|
|
|
<association property="countryName" column="country" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectCountryNameByCode"/>
|
|
<association property="provinceName" column="province" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectRegionNameByCode"/>
|
|
<association property="cityName" column="city" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectRegionNameByCode"/>
|
|
<association property="countyName" column="county" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectRegionNameByCode"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectEmisCustomerAddressVo">
|
|
select id, user_id, customer_code, short_name, alias, address_type, country, name, phone, province, city, county, town, address, post_code, email, company, bl_default_flag, order_num, bl_site_default_flag, use_site, use_site_code, del_flag, create_by, create_time, update_by, update_time, remark, create_site, update_site from emis_customer_address
|
|
</sql>
|
|
|
|
|
|
<select id="selectEmisCustomerAddressList" parameterType="EmisCustomerAddress" resultMap="EmisCustomerAddressResult">
|
|
<include refid="selectEmisCustomerAddressVo"/>
|
|
<where>
|
|
del_flag = '0'
|
|
<if test="id != null "> and id = #{id}</if>
|
|
<if test="userId != null "> and user_id = #{userId}</if>
|
|
<if test="customerCode != null and customerCode != ''"> and customer_code = #{customerCode}</if>
|
|
<if test="shortName != null and shortName != ''"> and short_name like concat('%', #{shortName}, '%')</if>
|
|
<if test="alias != null and alias != ''"> and alias like concat('%', #{alias}, '%')</if>
|
|
<if test="addressType != null and addressType != ''"> and address_type = #{addressType}</if>
|
|
<if test="country != null and country != ''"> and country=#{country}</if>
|
|
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
|
<if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
|
|
<if test="province != null and province != ''"> and province =#{province}</if>
|
|
<if test="city != null and city != ''"> and city like concat('%', #{city}, '%')</if>
|
|
<if test="county != null and county != ''"> and county like concat('%', #{county}, '%')</if>
|
|
<if test="town != null and town != ''"> and town like concat('%', #{town}, '%')</if>
|
|
<if test="address != null and address != ''"> and address like concat('%', #{address}, '%')</if>
|
|
<if test="postCode != null and postCode != ''"> and post_code like concat('%', #{postCode}, '%')</if>
|
|
<if test="email != null and email != ''"> and email like concat('%', #{email}, '%')</if>
|
|
<if test="company != null and company != ''"> and company like concat('%', #{company}, '%')</if>
|
|
<if test="blDefaultFlag != null and blDefaultFlag != ''"> and bl_default_flag = #{blDefaultFlag}</if>
|
|
<if test="orderNum != null "> and order_num like concat('%', #{orderNum}, '%')</if>
|
|
<if test="blSiteDefaultFlag != null and blSiteDefaultFlag != ''"> and bl_site_default_flag like concat('%', #{blSiteDefaultFlag}, '%')</if>
|
|
<if test="useSite != null and useSite != ''"> and use_site = #{useSite}</if>
|
|
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
|
|
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
|
|
<if test="createTime != null "> and create_time = #{createTime}</if>
|
|
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
|
|
<if test="updateTime != null "> and update_time = #{updateTime}</if>
|
|
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
|
|
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
|
|
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
|
|
|
|
<if test="useSiteCode != null and useSiteCode != ''"> and use_site_code=#{useSiteCode}</if>
|
|
|
|
<if test="searchValue != null and searchValue != ''">
|
|
and ( name like concat(#{searchValue}, '%') or phone like concat(#{searchValue}, '%') or company like concat(#{searchValue}, '%') )
|
|
</if>
|
|
|
|
</where>
|
|
order by create_time desc
|
|
</select>
|
|
|
|
<select id="selectEmisCustomerAddressById" parameterType="Long" resultMap="EmisCustomerAddressResult">
|
|
select id, user_id, customer_code, short_name, alias, address_type, country, name, phone, province, city, county, town, address, post_code, email, company, bl_default_flag, order_num, bl_site_default_flag, use_site, use_site_code, del_flag, create_by, create_time, update_by, update_time, remark, create_site, update_site
|
|
from emis_customer_address a
|
|
where a.id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertEmisCustomerAddress" parameterType="EmisCustomerAddress" useGeneratedKeys="true" keyProperty="id">
|
|
insert into emis_customer_address
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">user_id,</if>
|
|
<if test="customerCode != null and customerCode != ''">customer_code,</if>
|
|
<if test="shortName != null and shortName != ''">short_name,</if>
|
|
<if test="alias != null and alias != ''">alias,</if>
|
|
<if test="addressType != null and addressType != ''">address_type,</if>
|
|
<if test="country != null and country != ''">country,</if>
|
|
<if test="name != null and name != ''">name,</if>
|
|
<if test="phone != null and phone != ''">phone,</if>
|
|
<if test="province != null and province != ''">province,</if>
|
|
<if test="city != null and city != ''">city,</if>
|
|
<if test="county != null and county != ''">county,</if>
|
|
<if test="town != null and town != ''">town,</if>
|
|
<if test="address != null and address != ''">address,</if>
|
|
<if test="postCode != null and postCode != ''">post_code,</if>
|
|
<if test="email != null and email != ''">email,</if>
|
|
<if test="company != null and company != ''">company,</if>
|
|
<if test="blDefaultFlag != null and blDefaultFlag != ''">bl_default_flag,</if>
|
|
<if test="orderNum != null">order_num,</if>
|
|
<if test="blSiteDefaultFlag != null and blSiteDefaultFlag != ''">bl_site_default_flag,</if>
|
|
<if test="useSite != null and useSite != ''">use_site,</if>
|
|
<if test="useSiteCode != null and useSiteCode != ''">use_site_code,</if>
|
|
<if test="delFlag != null and delFlag != ''">del_flag,</if>
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null and updateBy != ''">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="remark != null and remark != ''">remark,</if>
|
|
<if test="createSite != null and createSite != ''">create_site,</if>
|
|
<if test="updateSite != null and updateSite != ''">update_site,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">#{userId},</if>
|
|
<if test="customerCode != null and customerCode != ''">#{customerCode},</if>
|
|
<if test="shortName != null and shortName != ''">#{shortName},</if>
|
|
<if test="alias != null and alias != ''">#{alias},</if>
|
|
<if test="addressType != null and addressType != ''">#{addressType},</if>
|
|
<if test="country != null and country != ''">#{country},</if>
|
|
<if test="name != null and name != ''">#{name},</if>
|
|
<if test="phone != null and phone != ''">#{phone},</if>
|
|
<if test="province != null and province != ''">#{province},</if>
|
|
<if test="city != null and city != ''">#{city},</if>
|
|
<if test="county != null and county != ''">#{county},</if>
|
|
<if test="town != null and town != ''">#{town},</if>
|
|
<if test="address != null and address != ''">#{address},</if>
|
|
<if test="postCode != null and postCode != ''">#{postCode},</if>
|
|
<if test="email != null and email != ''">#{email},</if>
|
|
<if test="company != null and company != ''">#{company},</if>
|
|
<if test="blDefaultFlag != null and blDefaultFlag != ''">#{blDefaultFlag},</if>
|
|
<if test="orderNum != null">#{orderNum},</if>
|
|
<if test="blSiteDefaultFlag != null and blSiteDefaultFlag != ''">#{blSiteDefaultFlag},</if>
|
|
<if test="useSite != null and useSite != ''">#{useSite},</if>
|
|
<if test="useSiteCode != null and useSiteCode != ''">#{useSiteCode},</if>
|
|
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="remark != null and remark != ''">#{remark},</if>
|
|
<if test="createSite != null and createSite != ''">#{createSite},</if>
|
|
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateEmisCustomerAddress" parameterType="EmisCustomerAddress">
|
|
update emis_customer_address
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="customerCode != null and customerCode != ''">customer_code = #{customerCode},</if>
|
|
<if test="shortName != null and shortName != ''">short_name = #{shortName},</if>
|
|
<if test="alias != null and alias != ''">alias = #{alias},</if>
|
|
<if test="addressType != null and addressType != ''">address_type = #{addressType},</if>
|
|
<if test="country != null and country != ''">country = #{country},</if>
|
|
<if test="name != null and name != ''">name = #{name},</if>
|
|
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
|
<if test="province != null and province != ''">province = #{province},</if>
|
|
<if test="city != null and city != ''">city = #{city},</if>
|
|
<if test="county != null and county != ''">county = #{county},</if>
|
|
<if test="town != null and town != ''">town = #{town},</if>
|
|
<if test="address != null and address != ''">address = #{address},</if>
|
|
<if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
|
|
<if test="email != null and email != ''">email = #{email},</if>
|
|
<if test="company != null and company != ''">company = #{company},</if>
|
|
<if test="blDefaultFlag != null and blDefaultFlag != ''">bl_default_flag = #{blDefaultFlag},</if>
|
|
<if test="orderNum != null">order_num = #{orderNum},</if>
|
|
<if test="blSiteDefaultFlag != null and blSiteDefaultFlag != ''">bl_site_default_flag = #{blSiteDefaultFlag},</if>
|
|
<if test="useSite != null and useSite != ''">use_site = #{useSite},</if>
|
|
<if test="useSiteCode != null and useSiteCode != ''">use_site_code = #{useSiteCode},</if>
|
|
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
|
|
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
|
<if test="createSite != null and createSite != ''">create_site = #{createSite},</if>
|
|
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteEmisCustomerAddressById" parameterType="Long">
|
|
update emis_customer_address set del_flag='1' where id = #{id}
|
|
</delete>
|
|
<!--修改为不能删除地址-->
|
|
<delete id="deleteEmisCustomerAddressByIds" parameterType="String">
|
|
update emis_customer_address set del_flag='1' where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<update id="cancelUseSiteDefaultFlag" parameterType="String">
|
|
update emis_customer_address set bl_default_flag = '0' where use_site_code = #{useSiteCode}
|
|
</update>
|
|
|
|
<update id="cancelCustomerDefaultFlag" parameterType="String">
|
|
update emis_customer_address set bl_site_default_flag = '0' where customer_code = #{customerCode}
|
|
</update>
|
|
|
|
|
|
<select id="checkUnique" parameterType="EmisCustomerAddress" resultType="int">
|
|
select count(1) from emis_customer_address
|
|
where del_flag='0'
|
|
and customer_code = #{customerCode}
|
|
and country = #{country}
|
|
and `name` = #{name}
|
|
and phone = #{phone}
|
|
and province = #{province}
|
|
and city = #{city}
|
|
and county = #{county}
|
|
and address = #{address}
|
|
and company = #{company}
|
|
and address_type = #{addressType}
|
|
limit 1
|
|
</select>
|
|
|
|
|
|
</mapper> |