/*
 * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.distribution.comment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.common.config.Constant;
import com.yami.shop.distribution.comment.dao.DistributionWithdrawCashSetMapper;
import com.yami.shop.distribution.comment.model.DistributionWithdrawCashSet;
import com.yami.shop.distribution.comment.service.DistributionWithdrawCashSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * 提现设置
 *
 * @author xwc
 * @date 2019-04-13 15:45:12
 */
@Service
public class DistributionWithdrawCashSetServiceImpl extends ServiceImpl<DistributionWithdrawCashSetMapper, DistributionWithdrawCashSet> implements DistributionWithdrawCashSetService {

    @Autowired
    private DistributionWithdrawCashSetMapper distributionWithdrawCashSetMapper;

    @Override
    @Cacheable(cacheNames = "DistributionWithdrawCashSet", key = "'0'")
    public DistributionWithdrawCashSet getByShopId() {
        DistributionWithdrawCashSet distributionWithdrawCashSet = distributionWithdrawCashSetMapper.selectOne(new LambdaQueryWrapper<DistributionWithdrawCashSet>()
                .eq(DistributionWithdrawCashSet::getShopId, Constant.PLATFORM_SHOP_ID)
        );
//        if(distributionWithdrawCashSet == null){
//            return  createInitialDistributionWithdrawCash(shopId);
//        }
        return distributionWithdrawCashSet;
    }

//    @Override
//    public DistributionWithdrawCashSet createInitialDistributionWithdrawCash(Long shopId) {
//        DistributionWithdrawCashSet distributionWithdrawCashSet = new DistributionWithdrawCashSet();
//        distributionWithdrawCashSet.setShopId(shopId);
////        distributionWithdrawCashSet.setSettlementTime(0);
////        distributionWithdrawCashSet.setSettlementMode(0);
////        distributionWithdrawCashSet.setSettlementAutoSet(0);
//        distributionWithdrawCashSet.setFrequency(-1);
//        distributionWithdrawCashSet.setAmountMin(0.0);
//        distributionWithdrawCashSet.setAmountMax(1000.0);
////        distributionWithdrawCashSet.setModeOfPayment(0);
//        distributionWithdrawCashSetMapper.insert(distributionWithdrawCashSet);
//        return distributionWithdrawCashSet;
//    }

    @Override
    @CacheEvict(cacheNames = "DistributionWithdrawCashSet", key = "'0'")
    public void removeCacheByShopId(Long shopId) {

    }


}
