2024-03-01 04:51:00 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
< !DOCTYPE mapper
2024-03-07 11:24:50 +00:00
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2024-03-01 04:51:00 +00:00
<mapper namespace= "com.xdadan.erp.emis.mapper.EmisCustomerAddressMapper" >
2024-03-07 11:24:50 +00:00
2024-06-02 02:57:46 +00:00
<resultMap type= "EmisCustomerAddress" id= "EmisCustomerAddressResult" extends= "com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult" >
2024-03-01 04:51:00 +00:00
<result property= "id" column= "id" />
<result property= "userId" column= "user_id" />
2024-03-07 11:24:50 +00:00
<result property= "customerCode" column= "customer_code" />
<result property= "shortName" column= "short_name" />
2024-03-01 04:51:00 +00:00
<result property= "alias" column= "alias" />
<result property= "addressType" column= "address_type" />
2024-04-23 10:09:19 +00:00
<result property= "country" column= "country" />
<result property= "name" column= "name" />
<result property= "phone" column= "phone" />
2024-03-01 04:51:00 +00:00
<result property= "province" column= "province" />
<result property= "city" column= "city" />
2024-04-23 11:46:41 +00:00
<result property= "county" column= "county" />
2024-03-01 04:51:00 +00:00
<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" />
2024-04-29 11:27:41 +00:00
<result property= "blSiteDefaultFlag" column= "bl_site_default_flag" />
2024-04-23 10:09:19 +00:00
<result property= "useSite" column= "use_site" />
<result property= "useSiteCode" column= "use_site_code" />
2025-08-25 07:22:06 +00:00
<result property= "enterpriseName" column= "enterprise_name" />
<result property= "enterpriseTaxId" column= "enterprise_tax_id" />
2024-06-02 02:57:46 +00:00
2024-04-23 11:46:41 +00:00
2024-06-02 01:10:24 +00:00
<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" />
2024-06-04 17:07:35 +00:00
<association property= "useSiteName" column= "use_site_code" select= "com.xdadan.erp.emis.mapper.EmisBaseMapper.selectGroupSiteNameByCode" />
2024-03-01 04:51:00 +00:00
</resultMap>
<sql id= "selectEmisCustomerAddressVo" >
2025-08-25 07:22:06 +00:00
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, enterprise_name, enterprise_tax_id, del_flag, create_by, create_time, update_by, update_time, remark, create_site, update_site from emis_customer_address
2024-03-01 04:51:00 +00:00
</sql>
2024-04-23 11:46:41 +00:00
2024-03-01 04:51:00 +00:00
<select id= "selectEmisCustomerAddressList" parameterType= "EmisCustomerAddress" resultMap= "EmisCustomerAddressResult" >
<include refid= "selectEmisCustomerAddressVo" />
2024-03-07 11:24:50 +00:00
<where >
2024-04-24 11:23:29 +00:00
del_flag = '0'
2024-03-01 04:51:00 +00:00
<if test= "id != null " > and id = #{id}</if>
<if test= "userId != null " > and user_id = #{userId}</if>
2024-04-29 11:27:41 +00:00
<if test= "customerCode != null and customerCode != ''" > and customer_code = #{customerCode}</if>
2024-03-07 11:24:50 +00:00
<if test= "shortName != null and shortName != ''" > and short_name like concat('%', #{shortName}, '%')</if>
2024-03-01 04:51:00 +00:00
<if test= "alias != null and alias != ''" > and alias like concat('%', #{alias}, '%')</if>
2024-04-29 11:27:41 +00:00
<if test= "addressType != null and addressType != ''" > and address_type = #{addressType}</if>
2024-05-16 00:23:12 +00:00
<if test= "country != null and country != ''" > and country=#{country}</if>
2024-04-23 10:09:19 +00:00
<if test= "name != null and name != ''" > and name like concat('%', #{name}, '%')</if>
<if test= "phone != null and phone != ''" > and phone like concat('%', #{phone}, '%')</if>
2024-05-16 00:23:12 +00:00
<if test= "province != null and province != ''" > and province =#{province}</if>
2024-03-01 04:51:00 +00:00
<if test= "city != null and city != ''" > and city like concat('%', #{city}, '%')</if>
2024-04-23 11:46:41 +00:00
<if test= "county != null and county != ''" > and county like concat('%', #{county}, '%')</if>
2024-03-01 04:51:00 +00:00
<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>
2025-08-25 07:22:06 +00:00
<if test= "enterpriseName != null and enterpriseName != ''" > and enterprise_name like concat('%', #{enterpriseName}, '%')</if>
<if test= "enterpriseTaxId != null and enterpriseTaxId != ''" > and enterprise_tax_id like concat('%', #{enterpriseTaxId}, '%')</if>
2024-04-29 11:27:41 +00:00
<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>
2024-03-01 04:51:00 +00:00
<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>
2024-04-23 10:09:19 +00:00
<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>
2024-04-27 00:28:26 +00:00
2024-06-04 17:07:35 +00:00
<if test= "useSiteCode != null and useSiteCode != ''" > and FIND_IN_SET(use_site_code, #{useSiteCode})</if>
2024-05-13 18:23:19 +00:00
2024-04-27 01:16:33 +00:00
<if test= "searchValue != null and searchValue != ''" >
2025-08-25 07:22:06 +00:00
and ( name like concat('%',#{searchValue}, '%') or phone like concat('%',#{searchValue}, '%') or company like concat('%',#{searchValue}, '%') or enterprise_name like concat('%',#{searchValue}, '%') or enterprise_tax_id like concat('%',#{searchValue}, '%') )
2024-04-27 00:28:26 +00:00
</if>
2024-03-01 04:51:00 +00:00
</where>
order by create_time desc
</select>
2024-03-07 11:24:50 +00:00
2024-03-01 04:51:00 +00:00
<select id= "selectEmisCustomerAddressById" parameterType= "Long" resultMap= "EmisCustomerAddressResult" >
2025-08-25 07:22:06 +00:00
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, enterprise_name, enterprise_tax_id, del_flag, create_by, create_time, update_by, update_time, remark, create_site, update_site
2024-03-01 04:51:00 +00:00
from emis_customer_address a
where a.id = #{id}
</select>
2024-03-07 11:24:50 +00:00
2024-04-30 07:28:36 +00:00
<insert id= "insertEmisCustomerAddress" parameterType= "EmisCustomerAddress" useGeneratedKeys= "true" keyProperty= "id" >
2024-03-01 04:51:00 +00:00
insert into emis_customer_address
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "userId != null" > user_id,</if>
2024-03-07 11:24:50 +00:00
<if test= "customerCode != null and customerCode != ''" > customer_code,</if>
<if test= "shortName != null and shortName != ''" > short_name,</if>
2024-03-01 04:51:00 +00:00
<if test= "alias != null and alias != ''" > alias,</if>
<if test= "addressType != null and addressType != ''" > address_type,</if>
2024-04-23 10:09:19 +00:00
<if test= "country != null and country != ''" > country,</if>
<if test= "name != null and name != ''" > name,</if>
<if test= "phone != null and phone != ''" > phone,</if>
2024-03-01 04:51:00 +00:00
<if test= "province != null and province != ''" > province,</if>
<if test= "city != null and city != ''" > city,</if>
2024-04-23 11:46:41 +00:00
<if test= "county != null and county != ''" > county,</if>
2024-03-01 04:51:00 +00:00
<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>
2024-04-29 11:27:41 +00:00
<if test= "orderNum != null" > order_num,</if>
<if test= "blSiteDefaultFlag != null and blSiteDefaultFlag != ''" > bl_site_default_flag,</if>
2024-04-23 10:09:19 +00:00
<if test= "useSite != null and useSite != ''" > use_site,</if>
<if test= "useSiteCode != null and useSiteCode != ''" > use_site_code,</if>
2025-08-25 07:22:06 +00:00
<if test= "enterpriseName != null and enterpriseName != ''" > enterprise_name,</if>
<if test= "enterpriseTaxId != null and enterpriseTaxId != ''" > enterprise_tax_id,</if>
2024-03-01 04:51:00 +00:00
<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>
2024-04-23 10:09:19 +00:00
<if test= "createSite != null and createSite != ''" > create_site,</if>
<if test= "updateSite != null and updateSite != ''" > update_site,</if>
2024-03-07 11:24:50 +00:00
</trim>
2024-03-01 04:51:00 +00:00
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "userId != null" > #{userId},</if>
2024-03-07 11:24:50 +00:00
<if test= "customerCode != null and customerCode != ''" > #{customerCode},</if>
<if test= "shortName != null and shortName != ''" > #{shortName},</if>
2024-03-01 04:51:00 +00:00
<if test= "alias != null and alias != ''" > #{alias},</if>
<if test= "addressType != null and addressType != ''" > #{addressType},</if>
2024-04-23 10:09:19 +00:00
<if test= "country != null and country != ''" > #{country},</if>
<if test= "name != null and name != ''" > #{name},</if>
<if test= "phone != null and phone != ''" > #{phone},</if>
2024-03-01 04:51:00 +00:00
<if test= "province != null and province != ''" > #{province},</if>
<if test= "city != null and city != ''" > #{city},</if>
2024-04-23 11:46:41 +00:00
<if test= "county != null and county != ''" > #{county},</if>
2024-03-01 04:51:00 +00:00
<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>
2024-04-29 11:27:41 +00:00
<if test= "orderNum != null" > #{orderNum},</if>
<if test= "blSiteDefaultFlag != null and blSiteDefaultFlag != ''" > #{blSiteDefaultFlag},</if>
2024-04-23 10:09:19 +00:00
<if test= "useSite != null and useSite != ''" > #{useSite},</if>
<if test= "useSiteCode != null and useSiteCode != ''" > #{useSiteCode},</if>
2025-08-25 07:22:06 +00:00
<if test= "enterpriseName != null and enterpriseName != ''" > #{enterpriseName},</if>
<if test= "enterpriseTaxId != null and enterpriseTaxId != ''" > #{enterpriseTaxId},</if>
2024-03-01 04:51:00 +00:00
<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>
2024-04-23 10:09:19 +00:00
<if test= "createSite != null and createSite != ''" > #{createSite},</if>
<if test= "updateSite != null and updateSite != ''" > #{updateSite},</if>
2024-03-07 11:24:50 +00:00
</trim>
2024-03-01 04:51:00 +00:00
</insert>
<update id= "updateEmisCustomerAddress" parameterType= "EmisCustomerAddress" >
update emis_customer_address
<trim prefix= "SET" suffixOverrides= "," >
2024-03-07 11:24:50 +00:00
<if test= "customerCode != null and customerCode != ''" > customer_code = #{customerCode},</if>
<if test= "shortName != null and shortName != ''" > short_name = #{shortName},</if>
2024-03-01 04:51:00 +00:00
<if test= "alias != null and alias != ''" > alias = #{alias},</if>
<if test= "addressType != null and addressType != ''" > address_type = #{addressType},</if>
2024-04-23 10:09:19 +00:00
<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>
2024-03-01 04:51:00 +00:00
<if test= "province != null and province != ''" > province = #{province},</if>
2024-07-30 01:38:31 +00:00
city = #{city},
county = #{county},
town = #{town},
2024-03-01 04:51:00 +00:00
<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>
2024-04-29 11:27:41 +00:00
<if test= "orderNum != null" > order_num = #{orderNum},</if>
<if test= "blSiteDefaultFlag != null and blSiteDefaultFlag != ''" > bl_site_default_flag = #{blSiteDefaultFlag},</if>
2025-08-25 07:22:06 +00:00
<if test= "enterpriseName != null and enterpriseName != ''" > enterprise_name = #{enterpriseName},</if>
<if test= "enterpriseTaxId != null and enterpriseTaxId != ''" > enterprise_tax_id = #{enterpriseTaxId},</if>
2024-04-23 10:09:19 +00:00
<if test= "useSite != null and useSite != ''" > use_site = #{useSite},</if>
<if test= "useSiteCode != null and useSiteCode != ''" > use_site_code = #{useSiteCode},</if>
2024-03-01 04:51:00 +00:00
<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>
2024-04-23 10:09:19 +00:00
<if test= "createSite != null and createSite != ''" > create_site = #{createSite},</if>
<if test= "updateSite != null and updateSite != ''" > update_site = #{updateSite},</if>
2024-03-01 04:51:00 +00:00
</trim>
where id = #{id}
</update>
<delete id= "deleteEmisCustomerAddressById" parameterType= "Long" >
2024-04-24 11:23:29 +00:00
update emis_customer_address set del_flag='1' where id = #{id}
2024-03-01 04:51:00 +00:00
</delete>
2024-04-24 11:23:29 +00:00
<!-- 修改为不能删除地址 -->
2024-03-01 04:51:00 +00:00
<delete id= "deleteEmisCustomerAddressByIds" parameterType= "String" >
2024-04-24 11:23:29 +00:00
update emis_customer_address set del_flag='1' where id in
2024-03-01 04:51:00 +00:00
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
2024-04-29 11:27:41 +00:00
<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>
2024-05-22 10:06:36 +00:00
2024-06-04 17:07:35 +00:00
<update id= "updateAddessCustomerCodeAndUseSite" parameterType= "EmisCustomerAddress" >
update emis_customer_address set customer_code = #{customerCode},use_site_code=#{useSiteCode} where id = #{id}
</update>
<select id= "selectExistAddressList" parameterType= "EmisCustomerAddress" resultMap= "EmisCustomerAddressResult" >
select id,customer_code,use_site_code from emis_customer_address
where del_flag='0'
and country = #{country}
and `name` = #{name}
and phone = #{phone}
and province = #{province}
2024-06-09 13:56:33 +00:00
<if test= "city != null and city != ''" > and city = #{city}</if>
<if test= "city == null" > and city is null</if>
<if test= "county != null and county != ''" > and county = #{county}</if>
<if test= "county == null " > and county is null</if>
<if test= "address != null and address != ''" > and address = #{address}</if>
<if test= "address == null" > and address is null</if>
<if test= "company != null and company != ''" > and company = #{company}</if>
<if test= "company == null" > and company is null</if>
2025-08-25 07:22:06 +00:00
<if test= "enterpriseName != null and enterpriseName != ''" > and enterprise_name = #{enterpriseName}</if>
<if test= "enterpriseName == null" > and enterprise_name is null</if>
<if test= "enterpriseTaxId != null and enterpriseTaxId != ''" > and enterprise_tax_id = #{enterpriseTaxId}</if>
<if test= "enterpriseTaxId == null" > and enterprise_tax_id is null</if>
2024-06-04 17:07:35 +00:00
and address_type = #{addressType}
and customer_code is null
</select>
2024-05-22 10:06:36 +00:00
<select id= "checkUnique" parameterType= "EmisCustomerAddress" resultType= "int" >
select count(1) from emis_customer_address
where del_flag='0'
and country = #{country}
and `name` = #{name}
and phone = #{phone}
and province = #{province}
2024-06-09 13:56:33 +00:00
<if test= "city != null and city != ''" > and city = #{city}</if>
<if test= "city == null" > and city is null</if>
<if test= "county != null and county != ''" > and county = #{county}</if>
<if test= "county == null " > and county is null</if>
<if test= "address != null and address != ''" > and address = #{address}</if>
<if test= "address == null" > and address is null</if>
<if test= "company != null and company != ''" > and company = #{company}</if>
<if test= "company == null" > and company is null</if>
and address_type = #{addressType}
2024-05-22 10:06:36 +00:00
limit 1
</select>
2025-08-25 07:22:06 +00:00
<select id= "checkAndQuery" parameterType= "EmisCustomerAddress" resultMap= "EmisCustomerAddressResult" >
select * from emis_customer_address
where del_flag='0'
and country = #{country}
and `name` = #{name}
and phone = #{phone}
and province = #{province}
<if test= "city != null and city != ''" > and city = #{city}</if>
<if test= "city == null" > and city is null</if>
<if test= "county != null and county != ''" > and county = #{county}</if>
<if test= "county == null " > and county is null</if>
<if test= "address != null and address != ''" > and address = #{address}</if>
<if test= "address == null" > and address is null</if>
<if test= "company != null and company != ''" > and company = #{company}</if>
<if test= "company == null" > and company is null</if>
2025-08-30 07:08:33 +00:00
<!-- <if test="enterpriseName != null and enterpriseName != ''">and enterprise_name = #{enterpriseName}</if> -->
<!-- <if test="enterpriseName == null">and enterprise_name is null</if> -->
2025-08-25 07:22:06 +00:00
2025-08-30 07:08:33 +00:00
<!-- <if test="enterpriseTaxId != null and enterpriseTaxId != ''">and enterprise_tax_id = #{enterpriseTaxId}</if> -->
<!-- <if test="enterpriseTaxId == null">and enterprise_tax_id is null</if> -->
2025-08-25 07:22:06 +00:00
and address_type = #{addressType}
</select>
2024-05-22 10:06:36 +00:00
2025-08-25 07:22:06 +00:00
</mapper>