package cn.newfeifan.mall.module.distri.service.orderpercentage;

import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;

import java.util.*;

import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;

import cn.newfeifan.mall.module.distri.dal.mysql.orderpercentage.OrderPercentageMapper;


/**
 * 积分相关计算浮动百分比设置 Service 实现类
 *
 * @author 非繁人
 */
@Service
@Validated
public class OrderPercentageServiceImpl implements OrderPercentageService {

    @Resource
    private OrderPercentageMapper orderPercentageMapper;


    @Override
    public OrderPercentageDO queryStatus() {
        List<OrderPercentageDO> orderPercentageDOS = orderPercentageMapper.selectList(new LambdaQueryWrapperX<OrderPercentageDO>()
                .eqIfPresent(OrderPercentageDO::getStatus, 1));

        if (orderPercentageDOS.isEmpty()) {
            return null;
        }
        return orderPercentageDOS.get(0);
    }

}