package cn.pluss.platform.merchantIncome;

import cn.pluss.platform.api.PageInfo;
import cn.pluss.platform.dto.LeshuaBillsDTO;
import cn.pluss.platform.entity.MakeMoney;
import cn.pluss.platform.entity.MerchantIncome;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.mapper.MerchantIncomeMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

public interface MerchantIncomeService extends IService<MerchantIncome> {

    default MerchantIncome queryMerchantIncome(MerchantIncome merchantIncome) {
        return getBaseMapper().selectOne(new QueryWrapper<>(merchantIncome));
    }

    default void saveMerchantIncome(MerchantIncome merchantIncome) {
        getBaseMapper().insert(merchantIncome);
    }

    default void updateMerchantIncome(MerchantIncome merchantIncome) {
        getBaseMapper().updateById(merchantIncome);
    }

    default void deleteMerchantIncome(MerchantIncome merchantIncome) {
        getBaseMapper().deleteById(merchantIncome.getId());
    }

    default List<MerchantIncome> queryMerchantIncomePage(Map map) {
        return ((MerchantIncomeMapper)getBaseMapper()).queryMerchantIncomePage(map);
    }

    default Integer queryMerchantIncomePageCount(Map map) {
        return ((MerchantIncomeMapper)getBaseMapper()).queryMerchantIncomePageCount(map);
    }

    /**
     * 查询乐刷打款账单
     *
     * @param leshuaBillsDTO
     * @return
     */
    PageInfo<MakeMoney> queryLeshuaBills(LeshuaBillsDTO leshuaBillsDTO) throws ParseException;

    /**
     * 查询余额, 按天获取
     *
     * @param merchantCode 商户code
     * @param startTime    开始时间，年月日
     * @param endTime      结束时间，年月日
     */
    Map<String, Object> queryTotalEnterFee(String merchantCode, String startTime, String endTime);


    /**
     * 查询商家最后的五条收入记录
     * @return
     */
    List<MerchantIncome> queryLastFiveMerchantIncome2(UserApp userApp);
}

