687 lines
27 KiB
XML
Raw Normal View History

2021-12-21 11:49:15 +08:00
<?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.xhpc.invoice.mapper.XhpcInvoiceMapper">
<resultMap id="BaseResultMap" type="com.xhpc.invoice.pojo.XhpcInvoice">
<id column="invoice_id" jdbcType="BIGINT" property="invoiceId"/>
<result column="receive_email" jdbcType="VARCHAR" property="receiveEmail"/>
<result column="title_type" jdbcType="INTEGER" property="titleType"/>
<result column="title_content" jdbcType="VARCHAR" property="titleContent"/>
<result column="duty_number" jdbcType="VARCHAR" property="dutyNumber"/>
<result column="invoice_content" jdbcType="VARCHAR" property="invoiceContent"/>
<result column="invoice_money" jdbcType="DECIMAL" property="invoiceMoney"/>
<result column="invoice_order_eletric_total_money" jdbcType="DECIMAL" property="invoiceOrderEletricTotalMoney"/>
<result column="invoice_order_service_total_money" jdbcType="DECIMAL" property="invoiceOrderServiceTotalMoney"/>
<result column="firm_address" jdbcType="VARCHAR" property="firmAddress"/>
<result column="firm_phone" jdbcType="VARCHAR" property="firmPhone"/>
<result column="firm_bank" jdbcType="VARCHAR" property="firmBank"/>
<result column="firm_bank_account" jdbcType="VARCHAR" property="firmBankAccount"/>
<result column="is_show_date" jdbcType="INTEGER" property="isShowDate"/>
<result column="user_notes" jdbcType="VARCHAR" property="userNotes"/>
<result column="creator_id" jdbcType="BIGINT" property="creatorId"/>
<result column="creator_type" jdbcType="INTEGER" property="creatorType"/>
<result column="creator" jdbcType="VARCHAR" property="creator"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="invoicing_time" jdbcType="TIMESTAMP" property="invoicingTime"/>
<result column="drawer" jdbcType="VARCHAR" property="drawer"/>
<result column="finance_notes" jdbcType="VARCHAR" property="financeNotes"/>
<result column="electric_invoice_url" jdbcType="VARCHAR" property="electricInvoiceUrl"/>
<result column="updator" jdbcType="BIGINT" property="updator"/>
<result column="update_time" jdbcType="DATE" property="updateTime"/>
<result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
</resultMap>
2021-12-21 11:49:15 +08:00
<sql id="Base_Column_List">
`invoice_id`
,
`receive_email`,
`title_type`,
`title_content`,
`duty_number`,
`invoice_content`,
`invoice_money`,
`invoice_order_eletric_total_money`,
`invoice_order_service_total_money`,
`firm_address`,
`firm_phone`,
`firm_bank`,
`firm_bank_account`,
`is_show_date`,
`user_notes`,
`creator_id`,
`creator_type`,
`creator`,
`create_time`,
`status`,
`invoicing_time`,
`drawer`,
`finance_notes`,
`electric_invoice_url`,
`updator`,
`update_time`,
`is_read`,
`del_flag`
2021-12-21 11:49:15 +08:00
</sql>
2021-12-21 11:49:15 +08:00
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from xhpc_invoice
where invoice_id = #{invoiceId,jdbcType=BIGINT} and del_flag is null;
</select>
<select id="selectAllInvoiceOrdersByCondition" resultMap="BaseResultMap">
SELECT
invoice_id,
creator,
creator_type,
invoice_money,
status,
create_time,
invoicing_time,
drawer
FROM
xhpc_invoice
<where>
del_flag IS NULL
<if test="creator!=null">
and creator = #{creator}
</if>
<if test="creatorType!=null">
and creatorType = #{creatorType}
</if>
<if test="status!=null">
and status = #{status}
</if>
<if test="startCreatorTime!=null">
and create_time &gt;= #{startCreatorTime}
</if>
<if test="endCreatorTime!=null">
and create_time &lt;= #{endCreatorTime}
</if>
<if test="startInvoicingTime!=null">
and invoicing_time &gt;= #{startInvoicingTime}
</if>
<if test="endInvoicingTime!=null">
and invoicing_time &lt;= #{endInvoicingTime}
</if>
</where>
LIMIT #{currentPage},#{items}
</select>
<select id="sumItemsInvoice" resultType="java.lang.Long">
SELECT
count(invoice_id)
FROM
xhpc_invoice
<where>
del_flag IS NULL
<if test="creator!=null">
and creator = #{creator}
</if>
<if test="creatorType!=null">
and creatorType = #{creatorType}
</if>
<if test="status!=null">
and status = #{status}
</if>
<if test="startCreatorTime!=null">
and create_time &gt;= #{startCreatorTime}
</if>
<if test="endCreatorTime!=null">
and create_time &lt;= #{endCreatorTime}
</if>
<if test="startInvoicingTime!=null">
and invoicing_time &gt;= #{startInvoicingTime}
</if>
<if test="endInvoicingTime!=null">
and invoicing_time &lt;= #{endInvoicingTime}
</if>
</where>
</select>
<select id="allInvoicedMoney" resultType="java.math.BigDecimal">
SELECT sum(invoice_money)
FROM xhpc_invoice
WHERE del_flag IS NULL
AND `status` = 1
</select>
<select id="allNotInvoicedMoney" resultType="java.math.BigDecimal">
SELECT sum(invoice_money)
FROM xhpc_invoice
WHERE del_flag IS NULL
AND `status` = 0
</select>
<select id="selectInvoiceTitleInfo" resultMap="BaseResultMap">
SELECT title_content,
duty_number
FROM `xhpc_invoice`
WHERE title_content LIKE concat("%", #{firmName}, "%")
GROUP BY title_content LIMIT 0,3
</select>
<select id="selectUserLastInputInvoiceInfo" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM `xhpc_invoice`
WHERE creator_id = #{creatorId}
AND creator_type = #{creatorType}
ORDER BY invoice_id DESC LIMIT 0,1
</select>
<select id="findInvoicesByCreatorIdAndCreatorType" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM xhpc_invoice
WHERE del_flag IS NULL
AND creator_id = #{creatorId}
AND creator_type = #{creatorType}
LIMIT #{currentPage}, #{items}
</select>
<select id="getUserInvoiceItemsByCreatorIdAndCreatorType" resultType="java.lang.Long">
SELECT count(invoice_id)
FROM xhpc_invoice
WHERE del_flag IS NULL
AND creator_id = #{creatorId}
AND creator_type = #{creatorType}
</select>
<select id="findNotReadCount" resultType="java.lang.Long">
SELECT count(invoice_id)
FROM xhpc_invoice
WHERE del_flag IS NULL
AND is_read = 0
AND creator_id = #{creatorId}
AND creator_type = #{creatorType}
</select>
2021-12-21 11:49:15 +08:00
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from xhpc_invoice
where invoice_id = #{invoiceId,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="invoice_id" keyProperty="invoiceId" parameterType="com.xhpc.invoice.pojo.XhpcInvoice"
useGeneratedKeys="true">
insert into xhpc_invoice (receive_email, title_type, title_content,
duty_number, invoice_content, invoice_money,
invoice_order_eletric_total_money, invoice_order_service_total_money,
firm_address, firm_phone, firm_bank,
firm_bank_account, is_show_date, user_notes,
creator_id, creator_type, creator,
create_time, `status`, invoicing_time,
drawer, finance_notes, electric_invoice_url,
updator, update_time, del_flag)
values (#{receiveEmail,jdbcType=VARCHAR}, #{titleType,jdbcType=INTEGER}, #{titleContent,jdbcType=VARCHAR},
#{dutyNumber,jdbcType=VARCHAR}, #{invoiceContent,jdbcType=VARCHAR}, #{invoiceMoney,jdbcType=DECIMAL},
#{invoiceOrderEletricTotalMoney,jdbcType=DECIMAL}, #{invoiceOrderServiceTotalMoney,jdbcType=DECIMAL},
#{firmAddress,jdbcType=VARCHAR}, #{firmPhone,jdbcType=VARCHAR}, #{firmBank,jdbcType=VARCHAR},
#{firmBankAccount,jdbcType=VARCHAR}, #{isShowDate,jdbcType=INTEGER}, #{userNotes,jdbcType=VARCHAR},
#{creatorId,jdbcType=BIGINT}, #{creatorType,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, #{invoicingTime,jdbcType=TIMESTAMP},
#{drawer,jdbcType=VARCHAR}, #{financeNotes,jdbcType=VARCHAR}, #{electricInvoiceUrl,jdbcType=VARCHAR},
#{updator,jdbcType=BIGINT}, #{updateTime,jdbcType=DATE}, #{delFlag,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="invoice_id" keyProperty="invoiceId"
parameterType="com.xhpc.invoice.pojo.XhpcInvoice" useGeneratedKeys="true">
insert into xhpc_invoice
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="receiveEmail != null">
receive_email,
</if>
<if test="titleType != null">
title_type,
</if>
<if test="titleContent != null">
title_content,
</if>
<if test="dutyNumber != null">
duty_number,
</if>
<if test="invoiceContent != null">
invoice_content,
</if>
<if test="invoiceMoney != null">
invoice_money,
</if>
<if test="invoiceOrderEletricTotalMoney != null">
invoice_order_eletric_total_money,
</if>
<if test="invoiceOrderServiceTotalMoney != null">
invoice_order_service_total_money,
</if>
<if test="firmAddress != null">
firm_address,
</if>
<if test="firmPhone != null">
firm_phone,
</if>
<if test="firmBank != null">
firm_bank,
</if>
<if test="firmBankAccount != null">
firm_bank_account,
</if>
<if test="isShowDate != null">
is_show_date,
</if>
<if test="userNotes != null">
user_notes,
</if>
<if test="creatorId != null">
creator_id,
</if>
<if test="creatorType != null">
creator_type,
</if>
<if test="creator != null">
creator,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="status != null">
`status`,
</if>
<if test="invoicingTime != null">
invoicing_time,
</if>
<if test="drawer != null">
drawer,
</if>
<if test="financeNotes != null">
finance_notes,
</if>
<if test="electricInvoiceUrl != null">
electric_invoice_url,
</if>
<if test="updator != null">
updator,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="delFlag != null">
del_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="receiveEmail != null">
#{receiveEmail,jdbcType=VARCHAR},
</if>
<if test="titleType != null">
#{titleType,jdbcType=INTEGER},
</if>
<if test="titleContent != null">
#{titleContent,jdbcType=VARCHAR},
</if>
<if test="dutyNumber != null">
#{dutyNumber,jdbcType=VARCHAR},
</if>
<if test="invoiceContent != null">
#{invoiceContent,jdbcType=VARCHAR},
</if>
<if test="invoiceMoney != null">
#{invoiceMoney,jdbcType=DECIMAL},
</if>
<if test="invoiceOrderEletricTotalMoney != null">
#{invoiceOrderEletricTotalMoney,jdbcType=DECIMAL},
</if>
<if test="invoiceOrderServiceTotalMoney != null">
#{invoiceOrderServiceTotalMoney,jdbcType=DECIMAL},
</if>
<if test="firmAddress != null">
#{firmAddress,jdbcType=VARCHAR},
</if>
<if test="firmPhone != null">
#{firmPhone,jdbcType=VARCHAR},
</if>
<if test="firmBank != null">
#{firmBank,jdbcType=VARCHAR},
</if>
<if test="firmBankAccount != null">
#{firmBankAccount,jdbcType=VARCHAR},
</if>
<if test="isShowDate != null">
#{isShowDate,jdbcType=INTEGER},
</if>
<if test="userNotes != null">
#{userNotes,jdbcType=VARCHAR},
</if>
<if test="creatorId != null">
#{creatorId,jdbcType=BIGINT},
</if>
<if test="creatorType != null">
#{creatorType,jdbcType=INTEGER},
</if>
<if test="creator != null">
#{creator,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="invoicingTime != null">
#{invoicingTime,jdbcType=TIMESTAMP},
</if>
<if test="drawer != null">
#{drawer,jdbcType=VARCHAR},
</if>
<if test="financeNotes != null">
#{financeNotes,jdbcType=VARCHAR},
</if>
<if test="electricInvoiceUrl != null">
#{electricInvoiceUrl,jdbcType=VARCHAR},
</if>
<if test="updator != null">
#{updator,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=DATE},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=INTEGER},
</if>
</trim>
</insert>
<insert id="insertSelectiveAndReturnId" parameterType="com.xhpc.invoice.pojo.XhpcInvoice"
keyProperty="invoiceId">
insert into xhpc_invoice
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="receiveEmail != null">
receive_email,
</if>
<if test="titleType != null">
title_type,
</if>
<if test="titleContent != null">
title_content,
</if>
<if test="dutyNumber != null">
duty_number,
</if>
<if test="invoiceContent != null">
invoice_content,
</if>
<if test="invoiceMoney != null">
invoice_money,
</if>
<if test="invoiceOrderEletricTotalMoney != null">
invoice_order_eletric_total_money,
</if>
<if test="invoiceOrderServiceTotalMoney != null">
invoice_order_service_total_money,
</if>
<if test="firmAddress != null">
firm_address,
</if>
<if test="firmPhone != null">
firm_phone,
</if>
<if test="firmBank != null">
firm_bank,
</if>
<if test="firmBankAccount != null">
firm_bank_account,
</if>
<if test="isShowDate != null">
is_show_date,
</if>
<if test="userNotes != null">
user_notes,
</if>
<if test="creatorId != null">
creator_id,
</if>
<if test="creatorType != null">
creator_type,
</if>
<if test="creator != null">
creator,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="status != null">
`status`,
</if>
<if test="invoicingTime != null">
invoicing_time,
</if>
<if test="drawer != null">
drawer,
</if>
<if test="financeNotes != null">
finance_notes,
</if>
<if test="electricInvoiceUrl != null">
electric_invoice_url,
</if>
<if test="updator != null">
updator,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="delFlag != null">
del_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="receiveEmail != null">
#{receiveEmail,jdbcType=VARCHAR},
</if>
<if test="titleType != null">
#{titleType,jdbcType=INTEGER},
</if>
<if test="titleContent != null">
#{titleContent,jdbcType=VARCHAR},
</if>
<if test="dutyNumber != null">
#{dutyNumber,jdbcType=VARCHAR},
</if>
<if test="invoiceContent != null">
#{invoiceContent,jdbcType=VARCHAR},
</if>
<if test="invoiceMoney != null">
#{invoiceMoney,jdbcType=DECIMAL},
</if>
<if test="invoiceOrderEletricTotalMoney != null">
#{invoiceOrderEletricTotalMoney,jdbcType=DECIMAL},
</if>
<if test="invoiceOrderServiceTotalMoney != null">
#{invoiceOrderServiceTotalMoney,jdbcType=DECIMAL},
</if>
<if test="firmAddress != null">
#{firmAddress,jdbcType=VARCHAR},
</if>
<if test="firmPhone != null">
#{firmPhone,jdbcType=VARCHAR},
</if>
<if test="firmBank != null">
#{firmBank,jdbcType=VARCHAR},
</if>
<if test="firmBankAccount != null">
#{firmBankAccount,jdbcType=VARCHAR},
</if>
<if test="isShowDate != null">
#{isShowDate,jdbcType=INTEGER},
</if>
<if test="userNotes != null">
#{userNotes,jdbcType=VARCHAR},
</if>
<if test="creatorId != null">
#{creatorId,jdbcType=BIGINT},
</if>
<if test="creatorType != null">
#{creatorType,jdbcType=INTEGER},
</if>
<if test="creator != null">
#{creator,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="invoicingTime != null">
#{invoicingTime,jdbcType=TIMESTAMP},
</if>
<if test="drawer != null">
#{drawer,jdbcType=VARCHAR},
</if>
<if test="financeNotes != null">
#{financeNotes,jdbcType=VARCHAR},
</if>
<if test="electricInvoiceUrl != null">
#{electricInvoiceUrl,jdbcType=VARCHAR},
</if>
<if test="updator != null">
#{updator,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=DATE},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=INTEGER},
</if>
</trim>
</insert>
2021-12-21 11:49:15 +08:00
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.invoice.pojo.XhpcInvoice">
update xhpc_invoice
<set>
<if test="receiveEmail != null">
receive_email = #{receiveEmail,jdbcType=VARCHAR},
</if>
<if test="titleType != null">
title_type = #{titleType,jdbcType=INTEGER},
</if>
<if test="titleContent != null">
title_content = #{titleContent,jdbcType=VARCHAR},
</if>
<if test="dutyNumber != null">
duty_number = #{dutyNumber,jdbcType=VARCHAR},
</if>
<if test="invoiceContent != null">
invoice_content = #{invoiceContent,jdbcType=VARCHAR},
</if>
<if test="invoiceMoney != null">
invoice_money = #{invoiceMoney,jdbcType=DECIMAL},
</if>
<if test="invoiceOrderEletricTotalMoney != null">
invoice_order_eletric_total_money = #{invoiceOrderEletricTotalMoney,jdbcType=DECIMAL},
</if>
<if test="invoiceOrderServiceTotalMoney != null">
invoice_order_service_total_money = #{invoiceOrderServiceTotalMoney,jdbcType=DECIMAL},
</if>
<if test="firmAddress != null">
firm_address = #{firmAddress,jdbcType=VARCHAR},
</if>
<if test="firmPhone != null">
firm_phone = #{firmPhone,jdbcType=VARCHAR},
</if>
<if test="firmBank != null">
firm_bank = #{firmBank,jdbcType=VARCHAR},
</if>
<if test="firmBankAccount != null">
firm_bank_account = #{firmBankAccount,jdbcType=VARCHAR},
</if>
<if test="isShowDate != null">
is_show_date = #{isShowDate,jdbcType=INTEGER},
</if>
<if test="userNotes != null">
user_notes = #{userNotes,jdbcType=VARCHAR},
</if>
<if test="creatorId != null">
creator_id = #{creatorId,jdbcType=BIGINT},
</if>
<if test="creatorType != null">
creator_type = #{creatorType,jdbcType=INTEGER},
</if>
<if test="creator != null">
creator = #{creator,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
`status` = #{status,jdbcType=INTEGER},
</if>
<if test="invoicingTime != null">
invoicing_time = #{invoicingTime,jdbcType=TIMESTAMP},
</if>
<if test="drawer != null">
drawer = #{drawer,jdbcType=VARCHAR},
</if>
<if test="financeNotes != null">
finance_notes = #{financeNotes,jdbcType=VARCHAR},
</if>
<if test="electricInvoiceUrl != null">
electric_invoice_url = #{electricInvoiceUrl,jdbcType=VARCHAR},
</if>
<if test="updator != null">
updator = #{updator,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=DATE},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=INTEGER},
</if>
</set>
where invoice_id = #{invoiceId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.xhpc.invoice.pojo.XhpcInvoice">
update xhpc_invoice
set receive_email = #{receiveEmail,jdbcType=VARCHAR},
title_type = #{titleType,jdbcType=INTEGER},
title_content = #{titleContent,jdbcType=VARCHAR},
duty_number = #{dutyNumber,jdbcType=VARCHAR},
invoice_content = #{invoiceContent,jdbcType=VARCHAR},
invoice_money = #{invoiceMoney,jdbcType=DECIMAL},
invoice_order_eletric_total_money = #{invoiceOrderEletricTotalMoney,jdbcType=DECIMAL},
invoice_order_service_total_money = #{invoiceOrderServiceTotalMoney,jdbcType=DECIMAL},
firm_address = #{firmAddress,jdbcType=VARCHAR},
firm_phone = #{firmPhone,jdbcType=VARCHAR},
firm_bank = #{firmBank,jdbcType=VARCHAR},
firm_bank_account = #{firmBankAccount,jdbcType=VARCHAR},
is_show_date = #{isShowDate,jdbcType=INTEGER},
user_notes = #{userNotes,jdbcType=VARCHAR},
creator_id = #{creatorId,jdbcType=BIGINT},
creator_type = #{creatorType,jdbcType=INTEGER},
creator = #{creator,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
`status` = #{status,jdbcType=INTEGER},
invoicing_time = #{invoicingTime,jdbcType=TIMESTAMP},
drawer = #{drawer,jdbcType=VARCHAR},
finance_notes = #{financeNotes,jdbcType=VARCHAR},
electric_invoice_url = #{electricInvoiceUrl,jdbcType=VARCHAR},
updator = #{updator,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=DATE},
del_flag = #{delFlag,jdbcType=INTEGER}
where invoice_id = #{invoiceId,jdbcType=BIGINT}
</update>
<update id="invoiceToUser">
UPDATE xhpc_invoice
SET finance_notes = #{financeNotes},
invoicing_time = #{invoicingTime},
electric_invoice_url = #{eletricInvoiceUrl},
`status` = #{status},
drawer = #{drawer},
is_read = 0
WHERE invoice_id = #{invoiceId};
</update>
<update id="failInvoiceToUser">
UPDATE xhpc_invoice
SET finance_notes = #{financeNotes},
invoicing_time = #{invoicingTime},
electric_invoice_url = #{eletricInvoiceUrl},
`status` = #{status},
drawer = #{drawer} is_read = 0
WHERE invoice_id = #{invoiceId}
</update>
<update id="updateByInvoiceId">
UPDATE xhpc_invoice
SET is_read = 1
WHERE del_flag IS NULL
AND invoice_id = #{invoiceId}
</update>
2021-12-21 11:49:15 +08:00
</mapper>