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

import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
import cn.newfeifan.mall.module.distri.dal.mysql.orderpercentage.OrderPercentageMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 积分相关计算浮动百分比设置 Service 实现类
 *
 * @author 非繁人
 */
@Service
@Validated
@Slf4j
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);
    }

}