package com.bohuikeji.delivery.backstage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bohuikeji.delivery.backstage.entity.TCustomerTemplate;
import com.bohuikeji.delivery.backstage.mapper.TCustomerTemplateMapper;
import com.bohuikeji.delivery.backstage.service.ITCustomerTemplateService;
import com.bohuikeji.frame.module.admin.base.ServiceImplBase;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 客户计费模板定义表 服务实现类
 * </p>
 *
 * @author 10552
 * @since 2021-01-29
 */
@Service
public class TCustomerTemplateServiceImpl extends ServiceImplBase<TCustomerTemplateMapper, TCustomerTemplate> implements ITCustomerTemplateService {

    @Override
    public List<TCustomerTemplate> getListByGroup(String groupKey, Integer franId, String templateCode) {
        return list(new QueryWrapper<TCustomerTemplate>()
                .eq("fran_id",franId)
                .eq("template_code",templateCode)
                .eq("config_group",groupKey).orderByDesc("config_sort"));
    }

    @Override
    public TCustomerTemplate getConfigByKey(String configKey, Integer franId, String templateCode) {
        return getOne(new QueryWrapper<TCustomerTemplate>().eq("fran_id",franId).eq("template_code",templateCode).eq("config_key",configKey),false);
    }

    @Override
    public TCustomerTemplate getOpenConfigByCode(Object templateCode, String groupKey) {
        return getOne(new QueryWrapper<TCustomerTemplate>().eq("template_code",templateCode).eq("config_group",groupKey),false);
    }

    @Override
    public TCustomerTemplate getOpenConfigByCodetwo(Object templateCode, String groupKey,String confiogName) {
        return getOne(new QueryWrapper<TCustomerTemplate>().eq("template_code",templateCode).eq("config_name",confiogName).eq("config_group",groupKey),false);
    }

    @Override
    public List<TCustomerTemplate> getPremiumListByGroup(String groupKey, Integer franId, String templateCode) {
        return list(new QueryWrapper<TCustomerTemplate>()
                .eq("template_status","使用中")
                .eq("fran_id",franId)
                .eq("template_code",templateCode)
                .eq("config_group",groupKey).orderByDesc("config_sort"));
    }
}
