package com.hzs.system.config.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.constant.CacheConstants;
import com.hzs.common.core.constant.SystemFieldConstants;
import com.hzs.common.core.enums.EYesNo;
import com.hzs.common.core.service.RedisService;
import com.hzs.common.core.utils.DateUtils;
import com.hzs.common.domain.system.base.BdCurrency;
import com.hzs.common.domain.system.config.BdShare;
import com.hzs.system.config.mapper.BdShareMapper;
import com.hzs.system.config.service.IBdShareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 分红配置 服务实现类
 * </p>
 *
 * @author zhangjing
 * @since 2022-09-22
 */
@Service
public class BdShareServiceImpl extends ServiceImpl<BdShareMapper, BdShare> implements IBdShareService {

    private RedisService redisService;

    @Autowired
    public void setRedisService(RedisService redisService) {
        this.redisService = redisService;
    }
    /**
     * @description: 根据分红pkid查询分配配置
     * @author: zhang jing
     * @date: 2022/9/28 15:20
     * @param: [id, pkCountry]
     * @return: com.hzs.common.domain.system.config.BdShare
     **/
    @Override
    public BdShare getBdShareById(Integer id) {
        BdShare share = redisService.getCacheObject(CacheConstants.BD_SHARE + id);
        if(null == share){
            QueryWrapper<BdShare> queryWrapper = new QueryWrapper();
            queryWrapper.eq("PK_ID",id);
            share = baseMapper.selectOne(queryWrapper);
            if(null != share){
                redisService.setCacheObject(CacheConstants.BD_SHARE + id, share);
            }
        }
        return share;
    }
}
