You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sdny-order/order-management-base-service/src/main/resources/mybatis/mapper/BuyerMapper.xml

1061 lines
40 KiB

<?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.dxhy.order.baseservice.module.buyer.dao.BuyerMapper">
<resultMap id="BaseResultMap"
type="com.dxhy.order.baseservice.module.buyer.model.BuyerEntity">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="taxpayer_code" jdbcType="VARCHAR" property="taxpayerCode"/>
<result column="purchase_name" jdbcType="VARCHAR" property="purchaseName"/>
<result column="address" jdbcType="VARCHAR" property="address"/>
<result column="phone" jdbcType="VARCHAR" property="phone"/>
<result column="bank_of_deposit" jdbcType="VARCHAR" property="bankOfDeposit"/>
<result column="bank_number" jdbcType="VARCHAR" property="bankNumber"/>
<result column="email" jdbcType="VARCHAR" property="email"/>
<result column="sjh" jdbcType="VARCHAR" property="sjh"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
<result column="modify_user_id" jdbcType="VARCHAR" property="modifyUserId"/>
<result column="ghf_qylx" jdbcType="VARCHAR" property="ghfQylx"/>
<result column="xhf_nsrsbh" jdbcType="VARCHAR" property="xhfNsrsbh"/>
<result column="xhf_mc" jdbcType="VARCHAR" property="xhfMc"/>
<result column="buyer_code" jdbcType="VARCHAR" property="buyerCode"/>
<result column="invoice_name" jdbcType="VARCHAR" property="invoiceName"/>
<result column="invoice_taxno" jdbcType="VARCHAR" property="invoiceTaxno"/>
<result column="mdm_multicode_json" jdbcType="VARCHAR" property="mdmMulticodeJson"/>
<result column="status" jdbcType="VARCHAR" property="status"/>
<result column="sync_order" jdbcType="VARCHAR" property="syncOrder"/>
<collection property="buyerEntityDetail" ofType="com.dxhy.order.baseservice.module.buyer.model.BuyerEntityDetail">
<id column="consumer_id" property="consumerId"/>
<result column="buyer_manage_id" jdbcType="VARCHAR" property="buyerManageId"/>
<result column="bank_name" jdbcType="VARCHAR" property="bankName"/>
<result column="bank_account" jdbcType="VARCHAR" property="bankAccount"/>
<result column="bmid_address" jdbcType="VARCHAR" property="address"/>
<result column="bmid_phone" jdbcType="VARCHAR" property="phone"/>
<result column="default_mark" jdbcType="VARCHAR" property="defaultMark"/>
<result column="create_user" jdbcType="VARCHAR" property="createUser"/>
<result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
</collection>
</resultMap>
<sql id="Buyer_Base_Column_List">
id,taxpayer_code,purchase_name,address,phone,bank_of_deposit,bank_number,email,sjh,remarks,create_time,create_user_id,modify_time,modify_user_id,ghf_qylx,xhf_nsrsbh,xhf_mc,buyer_code,invoice_name,invoice_taxno,mdm_multicode_json,status
</sql>
<!-- 查询 -->
<select parameterType="map" id="selectBuyerList" resultMap="BaseResultMap">
<bind name="dataType" value="${dataType}"/>
<if test="dataType ==0 ">
SELECT
bmi.id,
bmi.taxpayer_code,
bmi.purchase_name,
bmi.address,
bmi.phone,
bmi.bank_of_deposit,
bmi.bank_number,
bmi.email,
bmi.sjh,
bmi.remarks,
bmi.create_user_id,
DATE_FORMAT(bmi.create_time, '%Y-%m-%d') createTime,
DATE_FORMAT(bmi.modify_time, '%Y-%m-%d') modifyTime,
bmi.modify_user_id,
bmi.ghf_qylx,
bmi.xhf_nsrsbh,
bmi.xhf_mc,
bmi.buyer_code,
bmi.create_time,
bmi.status,
bmi.sync_order,
bmid.consumer_id,
bmid.buyer_manage_id,
bmid.bank_name,
bmid.bank_account,
bmid.address as bmid_address,
bmid.phone as bmid_phone,
bmid.default_mark,
bmid.create_user,
bmid.update_user
FROM
buyer_manage_info bmi left join buyer_manage_info_detail bmid on bmi.id = bmid.buyer_manage_id
<where>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<!--购买方编码-->
<if test="map.buyerCode != null and map.buyerCode !='' ">
and buyer_code = #{map.buyerCode,jdbcType=VARCHAR}
</if>
<!-- 销货方纳税人名称-->
<if test="map.xhfMc != null and map.xhfMc !='' ">
and xhf_mc = #{map.xhfMc,jdbcType=VARCHAR}
</if>
<!-- 客户状态-->
<if test="map.status != null and map.status !='' ">
and status = #{map.status,jdbcType=VARCHAR}
</if>
<!--购买方纳税人识别号-->
<if test="map.taxpayerCode !=null and map.taxpayerCode !=''">
and taxpayer_code = #{map.taxpayerCode,jdbcType=VARCHAR}
</if>
<if test="map.purchaseName != null and map.purchaseName !='' ">
<choose>
<!--模糊查询的标识(0表示不进行模糊查询,1表示模糊查询)-->
<when test="map.fuzzyQuery != null and map.fuzzyQuery !='' and map.fuzzyQuery =='0'.toString() ">
AND purchase_name = #{map.purchaseName,jdbcType=VARCHAR}
</when>
<otherwise>
AND purchase_name LIKE CONCAT(CONCAT('%',#{map.purchaseName}),'%')
</otherwise>
</choose>
</if>
</where>
order by create_time desc
</if>
<if test="dataType ==1 ">
select temp.*
from (
SELECT
id,
taxpayer_code,
purchase_name,
address,
phone,
bank_of_deposit,
bank_number,
email,
sjh,
remarks,
create_user_id,
to_char(create_time,'yyyy-MM-dd') as createTime,
to_char(modify_time,'yyyy-MM-dd') as modifyTime,
modify_user_id,
ghf_qylx,
xhf_nsrsbh,
xhf_mc,
buyer_code,
rownum as rowno,
status,
sync_order
FROM
buyer_manage_info
<where>
<!--购买方编码-->
<if test="map.buyerCode != null and map.buyerCode !='' ">
and buyer_code = #{map.buyerCode,jdbcType=VARCHAR}
</if>
<!-- 销货方纳税人名称-->
<if test="map.xhfMc != null and map.xhfMc !='' ">
and xhf_mc = #{map.xhfMc,jdbcType=VARCHAR}
</if>
<!-- 客户状态-->
<if test="map.status != null and map.status !='' ">
and status = #{map.status,jdbcType=VARCHAR}
</if>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<!--购买方纳税人识别号-->
<if test="map.taxpayerCode !=null and map.taxpayerCode !=''">
and taxpayer_code = #{map.taxpayerCode,jdbcType=VARCHAR}
</if>
<if test="map.purchaseName != null and map.purchaseName !='' ">
<choose>
<!--模糊查询的标识(0表示不进行模糊查询,1表示模糊查询)-->
<when test="map.fuzzyQuery != null and map.fuzzyQuery !='' and map.fuzzyQuery =='0'.toString() ">
AND purchase_name = #{map.purchaseName,jdbcType=VARCHAR}
</when>
<otherwise>
AND purchase_name LIKE '%' || #{map.purchaseName} || '%'
</otherwise>
</choose>
</if>
</where>
order by create_time desc
) temp
<!-- <if test="offset != null and limit != null">-->
<!-- where temp.rowno &gt; #{offset} and temp.rowno &lt;= ( #{offset} + #{limit} )-->
<!-- </if>-->
</if>
</select>
<!-- 修改-->
<update id="updateBuyer" parameterType="com.dxhy.order.baseservice.module.buyer.model.BuyerEntity">
<bind name="dataType" value="${dataType}"/>
UPDATE buyer_manage_info
<set>
<if test="buyer.taxpayerCode != null">
taxpayer_code = #{buyer.taxpayerCode,jdbcType=VARCHAR},
</if>
<if test="buyer.purchaseName != null ">
purchase_name = #{buyer.purchaseName,jdbcType=VARCHAR},
</if>
<if test="buyer.address != null">
address = #{buyer.address,jdbcType=VARCHAR},
</if>
<if test="buyer.phone != null">
phone = #{buyer.phone,jdbcType=VARCHAR},
</if>
<if test="buyer.bankOfDeposit != null">
bank_of_deposit = #{buyer.bankOfDeposit,jdbcType=VARCHAR},
</if>
<if test="buyer.bankNumber != null">
bank_number = #{buyer.bankNumber,jdbcType=VARCHAR},
</if>
<if test="buyer.bankNumber != null">
bank_number = #{buyer.bankNumber,jdbcType=VARCHAR},
</if>
<if test="buyer.email != null">
email = #{buyer.email,jdbcType=VARCHAR},
</if>
<if test="buyer.sjh != null">
sjh = #{buyer.sjh,jdbcType=VARCHAR},
</if>
<if test="buyer.remarks != null">
remarks = #{buyer.remarks,jdbcType=VARCHAR},
</if>
<if test="dataType ==0">
modify_time = now(),
</if>
<if test="dataType ==1">
modify_time = SYSDATE,
</if>
<if test="buyer.modifyUserId != null">
modify_user_id = #{buyer.modifyUserId,jdbcType=VARCHAR},
</if>
<if test="buyer.ghfQylx != null">
ghf_qylx = #{buyer.ghfQylx,jdbcType=VARCHAR},
</if>
<if test="buyer.xhfNsrsbh != null">
xhf_nsrsbh = #{buyer.xhfNsrsbh,jdbcType=VARCHAR},
</if>
<if test="buyer.xhfMc != null">
xhf_mc = #{buyer.xhfMc,jdbcType=VARCHAR},
</if>
<if test="buyer.buyerCode != null ">
buyer_code = #{buyer.buyerCode,jdbcType=VARCHAR},
</if>
<if test="buyer.invoiceName != null ">
invoice_name = #{buyer.invoiceName,jdbcType=VARCHAR},
</if>
<if test="buyer.invoiceTaxno != null ">
invoice_taxno = #{buyer.invoiceTaxno,jdbcType=VARCHAR},
</if>
<if test="buyer.mdmMulticodeJson != null ">
mdm_multicode_json = #{buyer.mdmMulticodeJson,jdbcType=VARCHAR},
</if>
<if test="buyer.status != null ">
status = #{buyer.status,jdbcType=VARCHAR},
</if>
<if test="buyer.syncOrder != null ">
sync_order = #{buyer.syncOrder,jdbcType=VARCHAR},
</if>
</set>
<where>
id = #{buyer.id,jdbcType=VARCHAR}
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</update>
<update id="batchUpdateBuyer" parameterType="com.dxhy.order.baseservice.module.buyer.model.BuyerEntity">
<bind name="dataType" value="${dataType}"/>
UPDATE buyer_manage_info
<set>
<if test="buyer.taxpayerCode != null">
taxpayer_code = #{buyer.taxpayerCode,jdbcType=VARCHAR},
</if>
<if test="buyer.purchaseName != null ">
purchase_name = #{buyer.purchaseName,jdbcType=VARCHAR},
</if>
<if test="buyer.address != null">
address = #{buyer.address,jdbcType=VARCHAR},
</if>
<if test="buyer.phone != null">
phone = #{buyer.phone,jdbcType=VARCHAR},
</if>
<if test="buyer.bankOfDeposit != null">
bank_of_deposit = #{buyer.bankOfDeposit,jdbcType=VARCHAR},
</if>
<if test="buyer.bankNumber != null">
bank_number = #{buyer.bankNumber,jdbcType=VARCHAR},
</if>
<if test="buyer.bankNumber != null">
bank_number = #{buyer.bankNumber,jdbcType=VARCHAR},
</if>
<if test="buyer.email != null">
email = #{buyer.email,jdbcType=VARCHAR},
</if>
<if test="buyer.sjh != null">
sjh = #{buyer.sjh,jdbcType=VARCHAR},
</if>
<if test="buyer.remarks != null">
remarks = #{buyer.remarks,jdbcType=VARCHAR},
</if>
<if test="dataType ==0">
modify_time = now(),
</if>
<if test="dataType ==1">
modify_time = SYSDATE,
</if>
<if test="buyer.modifyUserId != null">
modify_user_id = #{buyer.modifyUserId,jdbcType=VARCHAR},
</if>
<if test="buyer.ghfQylx != null">
ghf_qylx = #{buyer.ghfQylx,jdbcType=VARCHAR},
</if>
<if test="buyer.xhfNsrsbh != null">
xhf_nsrsbh = #{buyer.xhfNsrsbh,jdbcType=VARCHAR},
</if>
<if test="buyer.xhfMc != null">
xhf_mc = #{buyer.xhfMc,jdbcType=VARCHAR},
</if>
<if test="buyer.buyerCode != null ">
buyer_code = #{buyer.buyerCode,jdbcType=VARCHAR},
</if>
<if test="buyer.invoiceName != null ">
invoice_name = #{buyer.invoiceName,jdbcType=VARCHAR},
</if>
<if test="buyer.invoiceTaxno != null ">
invoice_taxno = #{buyer.invoiceTaxno,jdbcType=VARCHAR},
</if>
<if test="buyer.mdmMulticodeJson != null ">
mdm_multicode_json = #{buyer.mdmMulticodeJson,jdbcType=VARCHAR},
</if>
<if test="buyer.status != null ">
status = #{buyer.status,jdbcType=VARCHAR},
</if>
<if test="buyer.syncOrder != null ">
sync_order = #{buyer.syncOrder,jdbcType=VARCHAR},
</if>
</set>
<where>
id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id,jdbcType=VARCHAR}
</foreach>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</update>
<insert id="batchInsertBuyerDetail" parameterType="com.dxhy.order.baseservice.module.buyer.model.BuyerEntityDetail" useGeneratedKeys="true" keyProperty="consumerId">
<bind name="dataType" value="${dataType}"/>
INSERT INTO buyer_manage_info_detail (
buyer_manage_id,bank_name,bank_account,address,phone,default_mark,create_user,update_user,create_time,update_time
) values
<foreach collection="buyerEntityDetails" item="buyerDetail" index="index" separator=",">
<!--<if test="consumerId != null">-->
<!--#{consumerId,jdbcType=VARCHAR},-->
<!--</if>-->
(#{buyerDetail.buyerManageId,jdbcType=VARCHAR},
#{buyerDetail.bankName,jdbcType=VARCHAR},
#{buyerDetail.bankAccount,jdbcType=VARCHAR},
#{buyerDetail.address,jdbcType=VARCHAR},
#{buyerDetail.phone,jdbcType=VARCHAR},
#{buyerDetail.defaultMark,jdbcType=VARCHAR},
#{buyerDetail.createUser,jdbcType=VARCHAR},
#{buyerDetail.updateUser,jdbcType=VARCHAR},
now(),
now())
</foreach>
</insert>
<delete id="deleteBuyerDetail">
DELETE FROM buyer_manage_info_detail where buyer_manage_id = #{buyerManageId,jdbcType=VARCHAR}
</delete>
<delete id="batchDeleteBuyerDetail">
DELETE FROM buyer_manage_info_detail where buyer_manage_id in
<foreach collection="buyerManageIds" item="buyerManageId" open="(" separator="," close=")">
#{buyerManageId,jdbcType=VARCHAR}
</foreach>
</delete>
<!-- 插入数据-->
<insert id="insertBuyer" parameterType="com.dxhy.order.baseservice.module.buyer.model.BuyerEntity">
<bind name="dataType" value="${dataType}"/>
INSERT INTO buyer_manage_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="taxpayerCode != null">
taxpayer_code,
</if>
<if test="purchaseName != null">
purchase_name,
</if>
<if test="address != null">
address,
</if>
<if test="phone != null">
phone,
</if>
<if test="bankOfDeposit != null">
bank_of_deposit,
</if>
<if test="bankNumber != null">
bank_number,
</if>
<if test="email != null">
email,
</if>
<if test="sjh != null">
sjh,
</if>
<if test="remarks != null">
remarks,
</if>
create_time,
modify_time,
<if test="createUserId != null">
create_user_id,
</if>
<if test="modifyUserId != null">
modify_user_id,
</if>
<if test="ghfQylx != null">
ghf_qylx,
</if>
<if test="xhfNsrsbh != null">
xhf_nsrsbh,
</if>
<if test="xhfMc != null">
xhf_mc,
</if>
<if test="buyerCode != null">
buyer_code,
</if>
<if test="invoiceName != null">
invoice_name,
</if>
<if test="invoiceTaxno != null">
invoice_taxno,
</if>
<if test="mdmMulticodeJson != null">
mdm_multicode_json,
</if>
<if test="status != null">
status,
</if>
<if test="syncOrder != null">
sync_order,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="taxpayerCode != null">
#{taxpayerCode,jdbcType=VARCHAR},
</if>
<if test="purchaseName != null">
#{purchaseName,jdbcType=VARCHAR},
</if>
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="bankOfDeposit != null">
#{bankOfDeposit,jdbcType=VARCHAR},
</if>
<if test="bankNumber != null">
#{bankNumber,jdbcType=VARCHAR},
</if>
<if test="email != null">
#{email,jdbcType=VARCHAR},
</if>
<if test="sjh != null">
#{sjh,jdbcType=VARCHAR},
</if>
<if test="remarks != null">
#{remarks,jdbcType=VARCHAR},
</if>
<if test="dataType == 1">
SYSDATE,
SYSDATE,
</if>
<if test="dataType == 0">
now(),
now(),
</if>
<if test="createUserId != null">
#{createUserId,jdbcType=VARCHAR},
</if>
<if test="modifyUserId != null">
#{modifyUserId,jdbcType=VARCHAR},
</if>
<if test="ghfQylx != null">
#{ghfQylx,jdbcType=VARCHAR},
</if>
<if test="xhfNsrsbh != null">
#{xhfNsrsbh,jdbcType=VARCHAR},
</if>
<if test="xhfMc != null">
#{xhfMc,jdbcType=VARCHAR},
</if>
<if test="buyerCode != null">
#{buyerCode,jdbcType=VARCHAR},
</if>
<if test="invoiceName != null">
#{invoiceName,jdbcType=VARCHAR},
</if>
<if test="invoiceTaxno != null">
#{invoiceTaxno,jdbcType=VARCHAR},
</if>
<if test="mdmMulticodeJson != null">
#{mdmMulticodeJson,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="syncOrder != null">
#{syncOrder,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<insert id="insertBuyerOnDuplicateKey" parameterType="com.dxhy.order.baseservice.module.buyer.model.BuyerEntity">
<bind name="dataType" value="${dataType}"/>
INSERT INTO buyer_manage_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="taxpayerCode != null">
taxpayer_code,
</if>
<if test="purchaseName != null">
purchase_name,
</if>
<if test="address != null">
address,
</if>
<if test="phone != null">
phone,
</if>
<if test="bankOfDeposit != null">
bank_of_deposit,
</if>
<if test="bankNumber != null">
bank_number,
</if>
<if test="email != null">
email,
</if>
<if test="sjh != null">
sjh,
</if>
<if test="remarks != null">
remarks,
</if>
create_time,
modify_time,
<if test="createUserId != null">
create_user_id,
</if>
<if test="modifyUserId != null">
modify_user_id,
</if>
<if test="ghfQylx != null">
ghf_qylx,
</if>
<if test="xhfNsrsbh != null">
xhf_nsrsbh,
</if>
<if test="xhfMc != null">
xhf_mc,
</if>
<if test="buyerCode != null">
buyer_code,
</if>
<if test="invoiceName != null">
invoice_name,
</if>
<if test="invoiceTaxno != null">
invoice_taxno,
</if>
<if test="mdmMulticodeJson != null">
mdm_multicode_json,
</if>
<if test="status != null">
status,
</if>
<if test="syncOrder != null">
sync_order,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> #{id,jdbcType=VARCHAR},
</if>
<if test="taxpayerCode != null"> #{taxpayerCode,jdbcType=VARCHAR},
</if>
<if test="purchaseName != null"> #{purchaseName,jdbcType=VARCHAR},
</if>
<if test="address != null"> #{address,jdbcType=VARCHAR},
</if>
<if test="phone != null"> #{phone,jdbcType=VARCHAR},
</if>
<if test="bankOfDeposit != null"> #{bankOfDeposit,jdbcType=VARCHAR},
</if>
<if test="bankNumber != null"> #{bankNumber,jdbcType=VARCHAR},
</if>
<if test="email != null"> #{email,jdbcType=VARCHAR},
</if>
<if test="sjh != null"> #{sjh,jdbcType=VARCHAR},
</if>
<if test="remarks != null"> #{remarks,jdbcType=VARCHAR},
</if>
<if test="dataType == 1">
SYSDATE,
SYSDATE,
</if>
<if test="dataType == 0">
now(),
now(),
</if>
<if test="createUserId != null"> #{createUserId,jdbcType=VARCHAR},
</if>
<if test="modifyUserId != null"> #{modifyUserId,jdbcType=VARCHAR},
</if>
<if test="ghfQylx != null"> #{ghfQylx,jdbcType=VARCHAR},
</if>
<if test="xhfNsrsbh != null"> #{xhfNsrsbh,jdbcType=VARCHAR},
</if>
<if test="xhfMc != null"> #{xhfMc,jdbcType=VARCHAR},
</if>
<if test="buyerCode != null"> #{buyerCode,jdbcType=VARCHAR},
</if>
<if test="invoiceName != null"> #{invoiceName,jdbcType=VARCHAR},
</if>
<if test="invoiceTaxno != null"> #{invoiceTaxno,jdbcType=VARCHAR},
</if>
<if test="mdmMulticodeJson != null"> #{mdmMulticodeJson,jdbcType=VARCHAR},
</if>
<if test="status != null"> #{status,jdbcType=VARCHAR},
</if>
<if test="syncOrder != null">
#{syncOrder,jdbcType=VARCHAR},
</if>
</trim>
on duplicate key update
<if test="id != null">
id = VALUES(id),
</if>
<if test="taxpayerCode != null">
taxpayer_code = VALUES(taxpayer_code),
</if>
<if test="purchaseName != null">
purchase_name = VALUES(purchase_name),
</if>
<if test="address != null">
address = VALUES(address),
</if>
<if test="phone != null">
phone = VALUES(phone),
</if>
<if test="bankOfDeposit != null">
bank_of_deposit = VALUES(bank_of_deposit),
</if>
<if test="bankNumber != null">
bank_number = VALUES(bank_number),
</if>
<if test="email != null">
email = VALUES(email),
</if>
<if test="sjh != null">
sjh = VALUES(sjh),
</if>
<if test="remarks != null">
remarks = VALUES(remarks),
</if>
create_time = VALUES(create_time),
modify_time = VALUES(modify_time),
<if test="createUserId != null">
create_user_id = VALUES(create_user_id),
</if>
<if test="modifyUserId != null">
modify_user_id = VALUES(modify_user_id),
</if>
<if test="ghfQylx != null">
ghf_qylx = VALUES(ghf_qylx),
</if>
<if test="xhfNsrsbh != null">
xhf_nsrsbh = VALUES(xhf_nsrsbh),
</if>
<if test="xhfMc != null">
xhf_mc = VALUES(xhf_mc),
</if>
<if test="buyerCode != null">
buyer_code = VALUES(buyer_code),
</if>
<if test="invoiceName != null">
invoice_name = VALUES(invoice_name),
</if>
<if test="invoiceTaxno != null">
invoice_taxno = VALUES(invoice_taxno),
</if>
<if test="mdmMulticodeJson != null">
mdm_multicode_json = VALUES(mdm_multicode_json),
</if>
<if test="status != null">
status = VALUES(status)
</if>
<if test="syncOrder != null">
sync_order = VALUES(syncOrder)
</if>
</insert>
<insert id="insertBuyerByList">
INSERT INTO buyer_manage_info (
id,
taxpayer_code,
purchase_name,
address,
phone,
bank_of_deposit,
bank_number,
email,
sjh,
remarks,
create_time,
modify_time,
create_user_id,
modify_user_id,
ghf_qylx,
xhf_nsrsbh,
xhf_mc,
buyer_code,
invoice_name,
invoice_taxno,
mdm_multicode_json,
status,
sync_order
)
values
<foreach collection="list" item="item" index="index"
separator=",">
(
#{item.id,jdbcType=VARCHAR},
#{item.taxpayerCode,jdbcType=VARCHAR},
#{item.purchaseName,jdbcType=VARCHAR},
#{item.address,jdbcType=VARCHAR},
#{item.phone,jdbcType=VARCHAR},
#{item.bankOfDeposit,jdbcType=VARCHAR},
#{item.bankNumber,jdbcType=VARCHAR},
#{item.email,jdbcType=VARCHAR},
#{item.sjh,jdbcType=VARCHAR},
#{item.remarks,jdbcType=VARCHAR},
now(),
now(),
#{item.createUserId,jdbcType=VARCHAR},
#{item.modifyUserId,jdbcType=VARCHAR},
#{item.ghfQylx,jdbcType=VARCHAR},
#{item.xhfNsrsbh,jdbcType=VARCHAR},
#{item.xhfMc,jdbcType=VARCHAR},
#{item.buyerCode,jdbcType=VARCHAR},
#{item.invoiceName,jdbcType=VARCHAR},
#{item.invoiceTaxno,jdbcType=VARCHAR},
#{item.mdmMulticodeJson,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR},
#{item.syncOrder,jdbcType=VARCHAR},
)
</foreach>
</insert>
<select id="selectBuyerByName" parameterType="map" resultType="int">
<bind name="dataType" value="${dataType}"/>
SELECT
count(*)
FROM
buyer_manage_info
<where>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.purchaseName != null and map.purchaseName != ''">
AND purchase_name = #{map.purchaseName,jdbcType=VARCHAR}
</if>
<if test="map.taxpayerCode != null">
AND taxpayer_code = #{map.taxpayerCode,jdbcType=VARCHAR}
</if>
<if test="map.id!=null and map.id!=''">
AND id !=#{map.id,jdbcType=VARCHAR}
</if>
<if test="map.status!=null and map.status!=''">
AND status =#{map.status,jdbcType=VARCHAR}
</if>
</where>
</select>
<!--根据名称模糊查询 -->
<select id="selectBuyer" parameterType="String" resultMap="BaseResultMap">
<bind name="dataType" value="${dataType}"/>
SELECT
id,
taxpayer_code,
purchase_name,
address,
phone,
bank_of_deposit,
bank_number,
email,
sjh,
remarks,
create_user_id,
<if test="dataType == 0">
DATE_FORMAT(create_time,'%Y-%m-%d') as createTime,
DATE_FORMAT(modify_time,'%Y-%m-%d') as modifyTime,
</if>
<if test="dataType == 1">
to_char(create_time,'yyyy-MM-dd') as createTime,
to_char(modify_time,'yyyy-MM-dd') as modifyTime,
</if>
modify_user_id,
ghf_qylx,
status,
sync_order
FROM
buyer_manage_info
<where>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="buyerCode != null and buyerCode != ''">
and buyer_code = #{buyerCode,jdbcType=VARCHAR}
</if>
<if test="dataType == 0">
<if test="purchaseName != null and purchaseName != ''">
AND concat_ws(',',purchase_name,taxpayer_code) LIKE
CONCAT(CONCAT('%',#{purchaseName,jdbcType=VARCHAR}),'%')
limit 10
</if>
</if>
<if test="dataType == 1">
<if test="purchaseName != null and purchaseName != ''">
AND purchase_name || ',' || taxpayer_code LIKE '%' || #{purchaseName,jdbcType=VARCHAR} || '%'
and rownum &lt;=10
</if>
</if>
</where>
</select>
<select id="selectBuyerByCodeOrNameAndNsrsbh" resultMap="BaseResultMap">
<bind name="dataType" value="${dataType}"/>
SELECT
id,
taxpayer_code,
purchase_name,
address,
phone,
bank_of_deposit,
bank_number,
email,
sjh,
remarks,
create_user_id,
<if test="dataType == 0">
DATE_FORMAT(create_time,'%Y-%m-%d') as createTime,
DATE_FORMAT(modify_time,'%Y-%m-%d') as modifyTime,
</if>
<if test="dataType == 1">
to_char(create_time,'yyyy-MM-dd') as createTime,
to_char(modify_time,'yyyy-MM-dd') as modifyTime,
</if>
modify_user_id,
ghf_qylx,
status,
sync_order
FROM
buyer_manage_info
<where>
<if test="buyerCode != null and buyerCode != ''">
and buyer_code = #{buyerCode,jdbcType=VARCHAR}
</if>
<if test="buyerName != null and buyerName != ''">
and buyer_name = #{buyerName,jdbcType=VARCHAR}
</if>
<if test="nsrsbh != null and nsrsbh != ''">
and xhf_nsrsbh = #{nsrsbh,jdbcType=VARCHAR}
</if>
</where>
</select>
<delete id="deleteBuyerById" parameterType="String">
DELETE
FROM buyer_manage_info
WHERE id = #{id,jdbcType=VARCHAR}
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</delete>
<!-- add by ysy -->
<select id="selectBuyerByBuyerEntity" parameterType="java.lang.String" resultMap="BaseResultMap">
<bind name="dataType" value="${dataType}"/>
SELECT
id,
taxpayer_code,
purchase_name,
address,
phone,
bank_of_deposit,
bank_number,
email,
sjh,
remarks,
create_user_id,
<if test="dataType == 0">
DATE_FORMAT(create_time,'%Y-%m-%d') as createTime,
DATE_FORMAT(modify_time,'%Y-%m-%d') as modifyTime,
</if>
<if test="dataType == 1">
to_char(create_time,'yyyy-MM-dd') as createTime,
to_char(modify_time,'yyyy-MM-dd') as modifyTime,
</if>
modify_user_id,
ghf_qylx,
xhf_nsrsbh,
xhf_mc,
buyer_code,
status,
sync_order
FROM
buyer_manage_info
<where>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="buyer.purchaseName != null and buyer.purchaseName != ''">
and purchase_name = #{buyer.purchaseName,jdbcType=VARCHAR}
</if>
<if test="buyer.buyerCode != null and buyer.buyerCode != ''">
and buyer_code = #{buyer.buyerCode,jdbcType=VARCHAR}
</if>
<if test="buyer.taxpayerCode != null ">
and taxpayer_code = #{buyer.taxpayerCode,jdbcType=VARCHAR}
</if>
<if test="buyer.id != null and buyer.id != ''">
and id = #{buyer.id,jdbcType=VARCHAR}
</if>
<if test="buyer.status != null and buyer.status != ''">
and status = #{buyer.status,jdbcType=VARCHAR}
</if>
</where>
</select>
</mapper>