123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <?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.huiju.estateagents.property.dao.BillInvoiceMapper">
- <sql id="Base_Column_List" >
- id, org_id, bill_id, building_owner_info_id, ta_user_id, bill_invoice_explain,
- pay_price, bill_statement_id, bill_status, pay_name, pay_date, create_user, create_date,
- update_user, update_date, pay_type
- </sql>
- <select id="selectBillInvoice" resultType="com.huiju.estateagents.property.model.BillInvoice">
-
- SELECT
- tpi.*,
- tboi.owner_name as ownerName,
- tpro.phase_name as phase,
- tpro.building_name as building,
- tpro.unit_name as unit,
- tpro.name as roomNo,
- tpbo.order_bumber as billStatement,
- (SELECT user_name from ta_user tu WHERE tu.user_id = tpi.create_user) as createUserName,
- (SELECT user_name from ta_user tu WHERE tu.user_id = tpi.update_user) as updateUserName
- FROM
- tp_bill_invoice tpi
- LEFT JOIN tp_room_no tpro ON tpi.room_no_id = tpro.id
- LEFT JOIN tp_bill_order tpbo ON tpi.id = tpbo.tp_bill_invoice_id
- LEFT JOIN tp_building_owner_info tboi ON tpi.building_owner_info_id = tboi.id
- <where>
- <trim prefixOverrides="and | or">
- <if test="map.phase != null and map.phase != ''">
- AND tpro.phase_id = #{map.phase}
- </if>
- <if test="map.building != null and map.building != ''">
- AND tpro.building_id = #{map.building}
- </if>
- <if test="map.unit != null and map.unit != ''">
- AND tpro.unit_id = #{map.unit}
- </if>
- <if test="map.roomNo != null and map.roomNo != ''">
- AND tpro.room_no_id = #{map.roomNo}
- </if>
- <if test="map.ownerName != null and map.ownerName != ''">
- AND tboi.owner_name like CONCAT('%',#{map.ownerName},'%')
- </if>
- <if test="map.billStatus != null">
- AND tpi.bill_status = #{map.billStatus}
- </if>
- <if test="map.payName != null and map.payName != ''">
- AND tpi.pay_name like CONCAT('%',#{map.payName}, '%')
- </if>
- <if test="map.billId != null">
- AND tpi.bill_id = #{map.billId}
- </if>
- <if test="map.orgId != null">
- AND tpi.org_id = #{map.orgId}
- </if>
- AND tpi.status = 1
- </trim>
- </where>
- order by tpi.id DESC
-
- </select>
-
- <select id="selectBillInvoiceTemp" resultType="com.huiju.estateagents.property.model.BillInvoice">
-
- SELECT
- tpi.*,
- tboi.owner_name as ownerName,
- tprn.phase_name as phase,
- tprn.building_name as building,
- tprn.unit_name as unit,
- tprn.name as roomNo
- FROM
- tp_bill_invoice tpi
- LEFT JOIN tp_room_no tprn ON tpi.room_no_id = tprn.id
- LEFT JOIN tp_building_owner_info tboi ON tpi.bill_statement_id = tboi.id
- <where>
- <trim prefixOverrides="and | or">
- <if test="map.billId != null">
- AND tpi.bill_id = #{map.billId}
- </if>
- <if test="map.orgId != null">
- AND tpi.org_id = #{map.orgId}
- </if>
- AND tpi.status = 0
- </trim>
- </where>
- order by tpi.create_date DESC
- </select>
-
- <select id="selectBillInvoiceEffective" resultType="com.huiju.estateagents.property.model.BillInvoice">
-
- SELECT
- tpi.*,
- tboi.owner_name as ownerName,
- tpro.phase_name as phase,
- tpro.building_name as building,
- tpro.unit_name as unit,
- tpro.name as roomNo,
- tpbo.order_bumber as billStatement,
- (SELECT user_name from ta_user tu WHERE tu.user_id = tpi.create_user) as createUserName,
- (SELECT user_name from ta_user tu WHERE tu.user_id = tpi.update_user) as updateUserName
- FROM
- tp_bill_invoice tpi
- LEFT JOIN tp_room_no tpro ON tpi.room_no_id = tpro.id
- LEFT JOIN tp_bill_order tpbo ON tpi.id = tpbo.tp_bill_invoice_id
- LEFT JOIN tp_building_owner_info tboi ON tpi.building_owner_info_id = tboi.id
- <where>
- <trim prefixOverrides="and | or">
- <if test="map.billId != null">
- AND tpi.bill_id = #{map.billId}
- </if>
- <if test="map.orgId != null">
- AND tpi.org_id = #{map.orgId}
- </if>
- AND tpi.status = 1
- </trim>
- </where>
- order by tpi.create_date DESC
- </select>
-
- <select id="getPriceCount" resultType="map">
- SELECT
- sum( pay_price ) AS totalPrice,
- org_id AS orgId
- FROM
- tp_bill_invoice
- WHERE
- `status` = 1
- AND bill_status = 1
- GROUP BY
- org_id
- </select>
-
- <select id="getBillsList" resultType="map">
- SELECT
- i.id,
- i.bill_invoice_explain as billInvoiceExplain,
- b.is_ticket as isTicket,
- i.pay_price AS payPrice,
- i.ta_user_id AS taUserId,
- i.bill_status AS billStatus,
- b.bill_name AS billName,
- b.bill_explain AS billExplain,
- b.end_date AS endDate,
- b.create_date AS createDate,
- i.out_trade_no AS outTradeNo
- FROM
- tp_bill_invoice i
- LEFT JOIN tp_bill b ON b.id = i.bill_id
- AND b.org_id = #{orgId,jdbcType=INTEGER}
- WHERE
- i.org_id = #{orgId,jdbcType=INTEGER}
- <if test="payType == 0">
- AND i.bill_status = 0
- </if>
- <if test="payType == 1">
- AND (i.bill_status = 1 or i.bill_status = 2)
- </if>
- and i.status=1
- AND i.room_no_id in (SELECT room_no_id
- from ta_user_verify WHERE person_id = #{personId}
- <!-- and role_id = 1-->
- <if test="taUserVerifyId != null">
- AND id = #{taUserVerifyId}
- </if>
- )
- </select>
-
- <select id="getBillInvoiceDetail" resultType="map">
- SELECT
- i.id,
- i.bill_invoice_explain AS billInvoiceExplain,
- b.is_ticket as isTicket,
- i.pay_price AS payPrice,
- i.pay_date as payDate,
- i.ta_user_id AS taUserId,
- i.bill_status AS billStatus,
- b.bill_name AS billName,
- b.bill_explain AS billExplain,
- b.end_date AS endDate,
- s.id AS billStatementId,
- s.pay_name AS payName,
- s.pay_remark AS payRemark,
- s.pay_type AS payType,
- s.create_time AS createTime,
- i.out_trade_no AS outTradeNo
- FROM
- tp_bill_invoice i
- LEFT JOIN tp_bill b ON b.id = i.bill_id
- AND b.org_id = #{orgId,jdbcType=INTEGER}
- LEFT JOIN tp_bill_statement s ON i.bill_statement_id = s.id
- AND s.org_id = #{orgId,jdbcType=INTEGER}
- WHERE
- i.id = #{billInvoiceId,jdbcType=INTEGER}
- AND i.org_id = #{orgId,jdbcType=INTEGER}
- </select>
-
- <select id="selectByIdAndroomNoId" resultType="com.huiju.estateagents.property.model.BillInvoice" >
- SELECT
- t.id,
- t.org_id AS orgId,
- t.bill_id AS billId,
- t.building_owner_info_id AS buildingOwnerInfoId,
- t.ta_user_id AS taUserId,
- t.bill_invoice_explain AS billInvoiceExplain,
- t.pay_price AS payPrice,
- t.bill_statement_id AS billStatementId,
- t.bill_status AS billStatus,
- t.pay_name AS payName,
- t.out_trade_no AS outTradeNo,
- b.bill_name as billName
- FROM
- tp_bill_invoice t
- LEFT JOIN tp_bill b ON t.bill_id = b.id and b.org_id = #{orgId,jdbcType=INTEGER}
- where t.id = #{id,jdbcType=INTEGER}
- and t.org_id = #{orgId,jdbcType=INTEGER}
- and t.status = 1
- and t.room_no_id = #{roomNoId,jdbcType=INTEGER}
- </select>
-
- <select id="selectByOutTradeNo" resultType="com.huiju.estateagents.property.model.BillInvoice" >
- SELECT
- t.id,
- t.org_id AS orgId,
- t.bill_id AS billId,
- t.building_owner_info_id AS buildingOwnerInfoId,
- t.ta_user_id AS taUserId,
- t.bill_invoice_explain AS billInvoiceExplain,
- t.pay_price AS payPrice,
- t.bill_statement_id AS billStatementId,
- t.bill_status AS billStatus,
- t.pay_name AS payName,
- t.out_trade_no AS outTradeNo,
- b.bill_name as billName
- FROM
- tp_bill_invoice t
- LEFT JOIN tp_bill b ON t.bill_id = b.id
- where t.out_trade_no = #{outTradeNo,jdbcType=VARCHAR}
- and t.status = 1
- </select>
-
- <select id="selectByBuildingOwnerInfoId" parameterType="integer" resultType="com.huiju.estateagents.property.model.BillInvoice" >
- select
- <include refid="Base_Column_List"/>
- from tp_bill_invoice
- where bill_statement_id = #{buildingOwnerInfoId,jdbcType=INTEGER}
- </select>
-
- <update id="updateBeach" parameterType="map" >
- update tp_bill_invoice
- set ta_user_id = #{map.taUserId}
- where id in
- <foreach collection="map.list" item="item" index="index" separator="," open="(" close=")">
- #{item.id}
- </foreach>
- </update>
- </mapper>
|