package com.fzm.mall.server.front.merchant.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzm.mall.server.front.asset.model.vo.BusinessVO;
import com.fzm.mall.server.front.merchant.model.Merchant;
import com.fzm.mall.server.front.merchant.mapper.MerchantMapper;
import com.fzm.mall.server.front.merchant.service.IMerchantService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.mall.server.front.redis.MerchantRedis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author tdz
 * @since 2021-03-02
 */
@Service
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> implements IMerchantService {

    @Autowired
    private  MerchantRedis merchantRedis;

    @Autowired
    private  MerchantMapper merchantMapper;

    @Override
    public Merchant info(String merchantId) {
        /*Merchant merchant = merchantRedis.getMerchant(merchantId);
        if (merchant != null) {
            return merchant;
        }*/
        QueryWrapper<Merchant> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("merchant_id", merchantId);
       /* merchant =
        if (merchant != null) {
            merchantRedis.setMerchant(merchantId, merchant);
        }*/
        return  getOne(queryWrapper);
    }

    @Override
    public BigDecimal getPrice(String coin) {
        return merchantMapper.getPrice(coin);
    }
}
