package com.kxs.stat.biz.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kxs.stat.biz.constant.enums.TotalTypeEnum;
import com.kxs.stat.biz.mapper.KxsLkbTradeMapper;
import com.kxs.stat.api.model.KxsLkbTrade;
import com.kxs.stat.biz.service.KxsLkbTradeService;
import org.springframework.stereotype.Service;

/**
 * 来客吧交易统计总表(KxsLkbTrade)表服务实现类
 *
 * @author 系统
 * @since 2024-05-09 13:59:07
 */
@Service("kxsLkbTradeService")
public class KxsLkbTradeServiceImpl extends ServiceImpl<KxsLkbTradeMapper, KxsLkbTrade> implements KxsLkbTradeService {

    @Override
    public KxsLkbTrade getLkbTradeAmt(KxsLkbTrade param) {


        return baseMapper.selectOne(Wrappers.<KxsLkbTrade>query()
                        .select("SUM(trade_amt) as trade_amt", "SUM(act_trade_amt) as act_trade_amt", "user_id", "total_type")
                .eq("user_id", param.getUserId())
                .eq("total_type", TotalTypeEnum.TEAM.getType())
                .eq(param.getTradeMonth() != null, "trade_month", param.getTradeMonth())
                .eq(param.getTradeDate() != null, "trade_date", param.getTradeDate()));
    }
}

