123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <?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.njyunzhi.invoice.mapper.TaInvoiceDetailMapper">
-
- <insert id="createBatch">
-
- INSERT INTO ta_invoice_detail_tpl (
- `detail_id`,
- `invoice_id`,
- `invoice_person_id`,
- `person_id`,
- `person_name`,
- `invoice_org_id`,
- `invoice_org_name`,
- `org_id`,
- `org_name`,
- `tax_no`,
- `address`,
- `phone`,
- `bank_id`,
- `bank_name`,
- `card_no`,
- `invoice_item_tpl_id`,
- `item_name`,
- `charge`,
- `merge_remark`,
- `stay_remark`,
- `status`,
- `create_date`
- ) SELECT
- UUID_SHORT( ),
- t.invoice_id,
- t.invoice_person_id,
- NULL,
- t.`name`,
- t.invoice_org_id,
- t.org_name,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- 1,
- now( )
- FROM
- ta_invoice_person t
- WHERE
- t.invoice_id = #{invoiceId}
- AND t.`status` > -1
- </insert>
- <update id="updatePerson">
- UPDATE ta_invoice_detail t
- SET t.person_id = #{personId}
- WHERE
- t.invoice_id = #{invoiceId}
- AND t.invoice_person_id = #{invoicePersonId}
- </update>
- <delete id="removeTplById">
- DELETE FROM ta_invoice_detail_tpl
- WHERE detail_id = #{id}
- </delete>
- <select id="getByPerson" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
- SELECT
- *
- FROM
- ta_invoice_detail t
- WHERE
- t.invoice_id = #{invoiceId}
- AND t.person_id = #{personId}
- AND t.`status` = 1
- </select>
-
- <sql id="getInvoiceDetail">
- SELECT
- t.`detail_id`,
- t.`invoice_id`,
- t.`invoice_person_id`,
- t.`person_id`,
- t.`person_name`,
- t.`invoice_org_id`,
- t.`invoice_org_name`,
- t.`org_id`,
- t.`org_name`,
- t.`tax_no`,
- t.`address`,
- t.`phone`,
- t.`bank_id`,
- t.`bank_name`,
- t.`card_no`,
- s.`invoice_item_id`,
- s.`name` AS item_name,
- s.`charge`,
- t.`merge_remark`,
- t.`stay_remark`,
- t.`mail_user`,
- t.`mail_phone`,
- t.`mail_address`,
- t.`status`,
- t.`create_date`,
- t.`is_need_lodging`,
- t.`room_code`
- FROM
- ta_invoice_detail t
- INNER JOIN ta_invoice_item s ON t.invoice_id = s.invoice_id AND t.invoice_person_id = s.invoice_person_id
- </sql>
-
- <select id="getListByMainId" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
- <include refid="getInvoiceDetail"></include>
- WHERE
- t.`status` = 1
- AND t.invoice_id = #{invoiceId}
- ORDER BY
- t.org_name ASC,
- t.person_name ASC,
- s.`name` ASC
- </select>
- <select id="getTplPageBy" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
- SELECT
- t.`invoice_person_id`,
- t.`person_id`,
- t.`invoice_org_id`,
- t.`name` AS `person_name`,
- t.`phone`,
- t.`status`,
- t.`create_date`,
- t.`invoice_id`,
- t.`org_name` AS invoice_org_name,
- s.`invoice_item_id`,
- s.`name` AS item_name,
- s.`charge`
- FROM
- ta_invoice_person t
- INNER JOIN ta_invoice_item s ON t.invoice_person_id = s.invoice_person_id
- WHERE
- t.invoice_id = #{invoiceId}
- AND t.`status` > -1
- AND s.`status` > -1
- ORDER BY
- t.org_name ASC,
- t.`name` ASC,
- s.`name` ASC
- </select>
- <select id="getPersonPage" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
- SELECT
- t.*,
- s.`name` as invoice_name
- FROM
- ta_invoice_detail t
- INNER JOIN ta_invoice_fill s ON s.invoice_id = t.invoice_id
- WHERE
- t.`status` = 1
- <if test="invoiceId != null and invoiceId != ''">
- AND t.invoice_id = #{invoiceId}
- </if>
- <if test="personId != null and personId != ''">
- AND t.person_id = #{personId}
- </if>
- <if test="personName != null and personName != ''">
- AND t.person_name LIKE CONCAT( '%', #{personName}, '%' )
- </if>
- GROUP BY
- t.person_id
- ORDER BY
- t.org_name ASC,
- t.person_name ASC
- </select>
- <select id="getTplByPerson" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
- SELECT
- t.`invoice_person_id`,
- t.`person_id`,
- t.`invoice_org_id`,
- t.`name` AS `person_name`,
- t.`phone`,
- t.`status`,
- t.`create_date`,
- t.`invoice_id`,
- t.`org_name` AS invoice_org_name
- FROM
- ta_invoice_person t
- WHERE
- t.invoice_id = #{invoiceId}
- AND t.`invoice_person_id` = #{invoicePersonId}
- AND t.`status` > -1
- ORDER BY
- t.org_name ASC,
- t.`name` ASC
- </select>
- <select id="getPageBy" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
- <include refid="getInvoiceDetail"></include>
- WHERE
- t.`status` = 1
- AND t.invoice_id = #{invoiceId}
- <if test="orgName != null and orgName != ''">
- AND t.org_name LIKE CONCAT( '%', #{orgName}, '%' )
- </if>
- <if test="personName != null and personName != ''">
- AND t.person_name LIKE CONCAT( '%', #{personName}, '%' )
- </if>
- ORDER BY
- t.org_name ASC,
- t.person_name ASC,
- s.`name` ASC
- </select>
- </mapper>
|