Files
sczx_sync/src/main/resources/mapper/CompanyInfoMapper.xml
2025-09-01 14:13:11 +08:00

151 lines
5.0 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.sczx.sync.mapper.CompanyInfoMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.sczx.sync.po.CompanyInfo">
<result column="company_name" property="company_name" />
<result column="contact_name" property="contact_name" />
<result column="phone" property="phone" />
<result column="address" property="address" />
<result column="citys" property="citys" />
<result column="del_flag" property="isDelete" />
<result column="b_op_id" property="bOpId" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
b_op_id, company_name, contact_name, phone, address, citys, del_flag
</sql>
<!-- 根据电话号码查询公司信息 -->
<select id="selectByPhone" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM zc_company
WHERE phone = #{phone}
AND is_delete = 0
</select>
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM zc_company
WHERE id = #{id}
</select>
<!-- 根据bOpId查询公司信息 -->
<select id="selectByOpId" parameterType="java.lang.Long" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM zc_company
WHERE b_op_id = #{bOpId}
AND is_delete = 0
</select>
<!-- 根据公司名称查询公司信息 -->
<select id="selectByCompanyName" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM zc_company
WHERE company_name = #{company_name}
AND is_delete = 0
</select>
<!-- 根据电话号码更新公司信息 -->
<update id="updateByPhone" parameterType="com.sczx.sync.po.CompanyInfo" >
<selectKey keyProperty='id' resultType='java.lang.Long' order='AFTER'>
SELECT
id
from zc_company
where phone = #{phone}
</selectKey>
UPDATE zc_company
<set>
<if test="company_name != null and company_name != ''">
company_name = #{company_name},
</if>
<if test="contact_name != null and contact_name != ''">
contact_name = #{contact_name},
</if>
<if test="address != null and address != ''">
address = #{address},
</if>
<if test="citys != null and citys != ''">
citys = #{citys},
</if>
<if test="isDelete != null">
is_delete = #{isDelete},
</if>
<if test="bOpId != null">
b_op_id = #{bOpId},
</if>
phone = #{phone}
</set>
WHERE phone = #{phone}
</update>
<!-- 根据电话号码更新公司信息 -->
<update id="updateByOpId" parameterType="com.sczx.sync.po.CompanyInfo">
<selectKey keyProperty='id' resultType='java.lang.Long' order='AFTER'>
SELECT
id
from zc_company
where phone = #{phone}
</selectKey>
UPDATE zc_company
<set>
<if test="company_name != null and company_name != ''">
company_name = #{company_name},
</if>
<if test="contact_name != null and contact_name != ''">
contact_name = #{contact_name},
</if>
<if test="address != null and address != ''">
address = #{address},
</if>
<if test="citys != null and citys != ''">
citys = #{citys},
</if>
<if test="is_delete != null">
is_delete = #{is_delete},
</if>
<if test="bOpId != null">
b_op_id = #{bOpId},
</if>
phone = #{phone}
</set>
WHERE b_op_id = #{bOpId}
</update>
<!-- 插入公司信息 -->
<insert id="insertCompanyInfo" parameterType="com.sczx.sync.po.CompanyInfo" useGeneratedKeys="true" keyProperty="id">
INSERT INTO zc_company (
b_op_id,
company_name,
contact_name,
phone,
address,
citys,
is_delete,
is_add_rules,
sharing_ratio,
wechat_receiving_account,
wechat_key,
ali_receiving_account,
ali_key
) VALUES (
#{bOpId},
#{companyName},
#{contactName},
#{phone},
#{address},
#{citys},
#{isDelete},
0,0,0,0,0,0
)
</insert>
</mapper>