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 insert into credit_card_bill id, name, bill_date, credit_card_id, bill_date_period, bill_amount, create_by, create_time, update_by, update_time, del_flag, bill_state, remark, #{id}, #{name}, #{billDate}, #{creditCardId}, #{billDatePeriod}, #{billAmount}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{delFlag}, #{billState}, #{remark}, update credit_card_bill name = #{name}, bill_date = #{billDate}, credit_card_id = #{creditCardId}, bill_date_period = #{billDatePeriod}, bill_amount = #{billAmount}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, del_flag = #{delFlag}, bill_state = #{billState}, remark = #{remark}, where id = #{id} delete from credit_card_bill where id = #{id} delete from credit_card_bill where id in #{id} update credit_card_bill set del_flag='1' where id = #{id} update credit_card_bill set del_flag='1' where id in #{id}