package com.clx.performance.mapper.loan;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.model.loan.OwnerLoanRecord;
import com.clx.performance.param.pc.loan.carrier.PageOwnerLoanRecordOfOwner;
import com.clx.performance.sqlProvider.loan.OwnerLoanRecordSqlProvider;
import com.clx.performance.vo.pc.loan.carrier.OwnerLoanRecordVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

/**
 * @author kavin
 * Date 2024-01-20
 * Time 17:05
 */
public interface OwnerLoanRecordMapper extends BaseMapper<OwnerLoanRecord> {

    /**
     * @see OwnerLoanRecordSqlProvider#pageByParam(Page, PageOwnerLoanRecordOfOwner)
     */
    @SelectProvider(type = OwnerLoanRecordSqlProvider.class, method = "pageByParam")
    IPage<OwnerLoanRecordVO> pageByParam(@Param("page") Page<OwnerLoanRecordVO> page, @Param("param") PageOwnerLoanRecordOfOwner param);


    @Update("update owner_loan_record set loan_residue_balance = loan_residue_balance + #{account.loanResidueBalance}" +
           ",modified_time=#{now}"
            + "where id = #{account.id} and modified_time = #{account.modifiedTime}"
    )
    Integer updateCasLoanRecord(@Param("account") OwnerLoanRecord update, @Param("now") String nowStr);
}
