package com.trs.ggzyexchange.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.trs.ggzyexchange.entity.CqSwBargainResult;
import com.trs.ggzyexchange.entity.TenderDetailsVo;
import com.trs.ggzyexchange.mapper.CqSwBargainResultMapper;
import com.trs.ggzyexchange.service.CqSwBargainResultService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 交易结果信息 服务实现类
 * </p>
 *
 * @author trs
 * @since 2023-03-03
 */
@Service
public class CqSwBargainResultServiceImpl extends ServiceImpl<CqSwBargainResultMapper, CqSwBargainResult> implements CqSwBargainResultService {

    @Autowired
    private CqSwBargainResultMapper cqSwBargainResultMapper;

    @Override
    public IPage<TenderDetailsVo> queryCqSwBargainResultAllList(Page<CqSwBargainResult> page) {
        return cqSwBargainResultMapper.queryCqSwBargainResultAllList(page);
    }

    @Override
    public Long maxDataTimeStamp() {
        Long aLong = cqSwBargainResultMapper.maxDataTimeStamp();
        try{
            if(!ObjectUtils.isEmpty(aLong)){
                if(aLong != 0){
                    String sLong = ((aLong+"").substring(0,8)) + "000000";
                    aLong = Long.parseLong(sLong);
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return aLong;
    }

    @Override
    public IPage<TenderDetailsVo> queryCqSwBargainResultAllListByTime(Page<CqSwBargainResult> page, Long time) {
        return cqSwBargainResultMapper.queryCqSwBargainResultAllListByTime(page,time);
    }

    @Override
    public int countByRegionCodeAndTime(String region_code, Long resultStartTimeYyyyMMdd, Long resultEndTimeYyyyMMdd) {
        return cqSwBargainResultMapper.countByRegionCodeAndTime(region_code,resultStartTimeYyyyMMdd,resultEndTimeYyyyMMdd);
    }

    @Override
    public int countByRegionCode(String areaCode) {
        return cqSwBargainResultMapper.countByRegionCode(areaCode);
    }

    @Override
    public CqSwBargainResult getSumMoneyByRegionCode(String areaCode) {
        return cqSwBargainResultMapper.getSumMoneyByRegionCode(areaCode);
    }

    // String resultStartTime, String resultEndTime
    @Override
    public CqSwBargainResult getSumMoneyByRegionCodeAndTime(String regionCode, String resultStartTime, String resultEndTime) {
        return cqSwBargainResultMapper.getSumMoneyByRegionCodeAndTime(regionCode,resultStartTime,resultEndTime);
    }


}
