package com.ssm.manage.dao.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ssm.core.impl.BaseDaoImpl;
import com.ssm.manage.dao.SsmRefundRechargeDao;
import com.ssm.manage.entity.RefundOrderList;
import com.ssm.manage.entity.RefundRecharge;
import com.ssm.manage.mapper.RefundRechargeMapper;
import com.ssm.manage.query.RefundOrderResquest;
import com.ssm.manage.query.RefundRechargeRequest;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Component
public class SsmRefundRechargeDaoImpl extends BaseDaoImpl<RefundRecharge> implements SsmRefundRechargeDao {
    @Autowired
    private RefundRechargeMapper mapper;

    @Override
    public RefundRechargeMapper getMapper() {
        return mapper;
    }

    @Override
    public PageInfo<RefundRecharge> selectPage(RefundRechargeRequest refundRechargeRequest) {
        Example example = new Example(RefundRecharge.class);
        Example.Criteria criteria = example.createCriteria();
        if (StringUtils.isNotBlank(refundRechargeRequest.getRefundNum())){
            criteria.andEqualTo("refundNum",refundRechargeRequest.getRefundNum());
        }
//        if (null != refundRechargeRequest.getStoreId()){
//            criteria.andEqualTo("storeId",refundRechargeRequest.getStoreId());
//        }
        if (null != refundRechargeRequest.getRefundDate()){
            criteria.andLike("refundDate", refundRechargeRequest.getRefundDate() + "%");
        }
        PageHelper.startPage(refundRechargeRequest.getPageNum(), refundRechargeRequest.getPageSize(), refundRechargeRequest.getOrderAndSort());
        List<RefundRecharge> list = selectByExample(example);
        PageInfo<RefundRecharge> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<RefundRecharge> selectList(RefundOrderResquest refundOrderResquest) {
        return mapper.selectList(refundOrderResquest);
    }

    @Override
    public List<RefundRecharge> selectLists(RefundOrderResquest refundOrderResquest) {
        return mapper.selectList(refundOrderResquest);
    }

    @Override
    public List<RefundRecharge> selectListschia(RefundOrderResquest refundOrderResquest) {
        return mapper.selectListschia(refundOrderResquest);
    }
}
