package vip.xiaonuo.risk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import vip.xiaonuo.risk.entity.RiskContract;
import vip.xiaonuo.risk.mapper.RiskContractMapper;
import vip.xiaonuo.risk.param.RiskContractParam;
import vip.xiaonuo.risk.service.IRiskContractService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 风控款到发货逾期 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-12-11
 */
@Service
public class RiskContractServiceImpl extends ServiceImpl<RiskContractMapper, RiskContract> implements IRiskContractService {

    @Autowired
    private RiskContractMapper contractMapper;

    @Override
    public Page<RiskContract> listPage(RiskContractParam contractParam) {
        String orgId = contractParam.getOrgId();
        Page<RiskContract> page = new Page<>(contractParam.getPageNum(), contractParam.getPageSize());
        QueryWrapper<RiskContract> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId);
        queryWrapper.orderByDesc("end_time");
        return contractMapper.selectPage(page, queryWrapper);
    }
}
