216 lines
9.5 KiB
XML
216 lines
9.5 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.intc.invest.mapper.CreditCardBillMapper">
|
|
|
|
<resultMap type="CreditCardBillVo" id="CreditCardBillResult">
|
|
<result property="id" column="id" />
|
|
<result property="name" column="name" />
|
|
<result property="billDate" column="bill_date" />
|
|
<result property="creditCardId" column="credit_card_id" />
|
|
<result property="billDatePeriod" column="bill_date_period" />
|
|
<result property="billAmount" column="bill_amount" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="delFlag" column="del_flag" />
|
|
<result property="billState" column="bill_state" />
|
|
<result property="bankName" column="bank_name" />
|
|
<result property="bankCode" column="bank_code" />
|
|
<result property="remark" column="remark" />
|
|
<result property="posCount" column="pos_count" />
|
|
<result property="dailyExpensesCount" column="daily_expenses_count" />
|
|
<result property="availableLimit" column="available_limit" />
|
|
<result property="payDate" column="pay_date" />
|
|
<result property="recentDealTime" column="recent_deal_time" />
|
|
</resultMap>
|
|
|
|
<sql id="selectCreditCardBillVo">
|
|
select
|
|
a.id,
|
|
a.name,
|
|
a.bill_date,
|
|
a.credit_card_id,
|
|
a.bill_date_period,
|
|
a.bill_amount,
|
|
a.create_by,
|
|
a.create_time,
|
|
a.update_by,
|
|
a.update_time,
|
|
a.del_flag,
|
|
a.bill_state,
|
|
a.remark,
|
|
bc."name" as bank_name,
|
|
bc.pay_date,
|
|
bc.code as bank_code,
|
|
a2.available_limit,
|
|
(
|
|
select
|
|
count(*)
|
|
from
|
|
accounts_deal_record adr
|
|
where
|
|
adr.account_id = a.credit_card_id
|
|
and adr.deal_type = '2'
|
|
and to_char(adr.create_time,
|
|
'yyyy-MM-dd')>= split_part(a.bill_date_period,
|
|
'~',
|
|
1)
|
|
and split_part(a.bill_date_period,
|
|
'~',
|
|
2)>= to_char(adr.create_time,
|
|
'yyyy-MM-dd')
|
|
and adr.deal_category = '5'
|
|
and adr.del_flag = '0'
|
|
) as pos_count,
|
|
(
|
|
select
|
|
count(*)
|
|
from
|
|
accounts_deal_record adr
|
|
where
|
|
adr.account_id = a.credit_card_id
|
|
and adr.deal_type = '2'
|
|
and to_char(adr.create_time,
|
|
'yyyy-MM-dd')>= split_part(a.bill_date_period,
|
|
'~',
|
|
1)
|
|
and split_part(a.bill_date_period,
|
|
'~',
|
|
2)>= to_char(adr.create_time,
|
|
'yyyy-MM-dd')
|
|
and adr.deal_category = '1'
|
|
and adr.del_flag = '0'
|
|
) as daily_expenses_count,
|
|
(
|
|
select
|
|
create_time
|
|
from
|
|
accounts_deal_record adr
|
|
where
|
|
adr.account_id = a.credit_card_id
|
|
and to_char(adr.create_time,
|
|
'yyyy-MM-dd')>= split_part(a.bill_date_period,
|
|
'~',
|
|
1)
|
|
and split_part(a.bill_date_period,
|
|
'~',
|
|
2)>= to_char(adr.create_time,
|
|
'yyyy-MM-dd')
|
|
and adr.del_flag = '0'
|
|
order by
|
|
adr.create_time desc
|
|
limit 1
|
|
) as recent_deal_time
|
|
from
|
|
credit_card_bill a
|
|
left join bank_card_lend bc on
|
|
bc.id = a.credit_card_id
|
|
left join accounts a2 on
|
|
a2.id = a.credit_card_id
|
|
</sql>
|
|
|
|
<select id="selectCreditCardBillList" parameterType="CreditCardBillDto" resultMap="CreditCardBillResult">
|
|
<include refid="selectCreditCardBillVo"/>
|
|
<where>
|
|
a.del_flag='0'
|
|
<if test="name != null and name != ''"> and a.name like '%'|| #{name}||'%'</if>
|
|
<if test="creditCardId != null "> and a.credit_card_id = #{creditCardId}</if>
|
|
<if test="billState != null and billState != ''"> and a.bill_state = #{billState}</if>
|
|
<if test="startMonth!=null and startMonth !=''">
|
|
and to_char(a.bill_date, 'yyyy-MM')>=#{startMonth}
|
|
</if>
|
|
<if test="endMonth!=null and endMonth !=''">
|
|
and #{endMonth}>=to_char(a.bill_date, 'yyyy-MM')
|
|
</if>
|
|
<if test="billDate!=null and billDate !=''">
|
|
and #{billDate}=to_char(a.bill_date, 'yyyy-MM-dd')
|
|
</if>
|
|
</where>
|
|
<!-- 数据范围过滤 -->
|
|
${params.dataScope}
|
|
order by a.bill_date desc,a.create_time desc
|
|
</select>
|
|
|
|
<select id="selectCreditCardBillById" parameterType="Long" resultMap="CreditCardBillResult">
|
|
<include refid="selectCreditCardBillVo"/>
|
|
where a.id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertCreditCardBill" parameterType="CreditCardBill">
|
|
insert into credit_card_bill
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">id,</if>
|
|
<if test="name != null">name,</if>
|
|
<if test="billDate != null">bill_date,</if>
|
|
<if test="creditCardId != null">credit_card_id,</if>
|
|
<if test="billDatePeriod != null">bill_date_period,</if>
|
|
<if test="billAmount != null">bill_amount,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="delFlag != null">del_flag,</if>
|
|
<if test="billState != null">bill_state,</if>
|
|
<if test="remark != null">remark,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">#{id},</if>
|
|
<if test="name != null">#{name},</if>
|
|
<if test="billDate != null">#{billDate},</if>
|
|
<if test="creditCardId != null">#{creditCardId},</if>
|
|
<if test="billDatePeriod != null">#{billDatePeriod},</if>
|
|
<if test="billAmount != null">#{billAmount},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="delFlag != null">#{delFlag},</if>
|
|
<if test="billState != null">#{billState},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateCreditCardBill" parameterType="CreditCardBill">
|
|
update credit_card_bill
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="name != null">name = #{name},</if>
|
|
<if test="billDate != null">bill_date = #{billDate},</if>
|
|
<if test="creditCardId != null">credit_card_id = #{creditCardId},</if>
|
|
<if test="billDatePeriod != null">bill_date_period = #{billDatePeriod},</if>
|
|
<if test="billAmount != null">bill_amount = #{billAmount},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
|
<if test="billState != null">bill_state = #{billState},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteCreditCardBillById" parameterType="Long">
|
|
delete from credit_card_bill where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteCreditCardBillByIds" parameterType="String">
|
|
delete from credit_card_bill where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
<update id="removeCreditCardBillById" parameterType="Long">
|
|
update credit_card_bill set del_flag='1' where id = #{id}
|
|
</update>
|
|
|
|
<update id="removeCreditCardBillByIds" parameterType="String">
|
|
update credit_card_bill set del_flag='1' where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
</mapper>
|