package com.hzs.sale.postage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.constant.CacheConstants;
import com.hzs.common.core.constant.Constants;
import com.hzs.common.core.service.RedisService;
import com.hzs.common.domain.sale.postage.BdPostageDetail;
import com.hzs.sale.postage.mapper.BdPostageDetailMapper;
import com.hzs.sale.postage.service.IBdPostageDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 * 邮费详情设置 服务实现类
 * </p>
 *
 * @author hzs
 * @since 2022-08-29
 */
@Service
public class BdPostageDetailServiceImpl extends ServiceImpl<BdPostageDetailMapper, BdPostageDetail> implements IBdPostageDetailService {

    private RedisService redisService;

    @Autowired
    public void setRedisService(RedisService redisService) {
        this.redisService = redisService;
    }

    @Override
    public List<BdPostageDetail> getPostageDetail(Integer tranType, Integer pkPostage) {
//        List<BdPostageDetail> bdPostageDetailList = redisService.getCacheList(CacheConstants.BD_POSTAGE_DETAIL + tranType + pkPostage);
//        if (bdPostageDetailList == null || bdPostageDetailList.size() == 0) {
//            bdPostageDetailList = baseMapper.queryPostageDetail(tranType, pkPostage);
//            if (bdPostageDetailList.size() > 0) {
//                redisService.setCacheList(CacheConstants.BD_POSTAGE_DETAIL + tranType + pkPostage, bdPostageDetailList);
//                redisService.expire(CacheConstants.BD_POSTAGE_DETAIL + tranType + pkPostage, Constants.TIMEOUT_DAY, TimeUnit.DAYS);
//            }
//        }
        return baseMapper.queryPostageDetail(tranType, pkPostage);
    }

    @Override
    public List<BdPostageDetail> queryPostageDetail(Integer tranType) {
        return baseMapper.queryPostageDetail(tranType, null);
    }
}
