package cn.ysk.cashier.mybatis.service.impl;

import cn.ysk.cashier.mybatis.entity.TbShopUserFlow;
import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper;
import cn.ysk.cashier.mybatis.service.TbShopUserFlowService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.*;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author GYJ
 */
@Service
public class TbShopUserFlowServiceImpl extends ServiceImpl<TbShopUserFlowMapper, TbShopUserFlow> implements TbShopUserFlowService {
    @Override
    public BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime) {
        return baseMapper.sumUserFlowAmountByConditions(shopId, startTime, endTime);
    }

    @Override
    public IPage<Map<String, Object>> selectByUserId(Integer userId, Integer page, Integer pageSize) {

        QueryWrapper<TbShopUserFlow> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("shop_user_id",userId);

        List<OrderItem> orders=new ArrayList<>();
        OrderItem orderItem=new OrderItem();
        orderItem.setColumn("id");
        orderItem.setAsc(false);
        orders.add(orderItem);
        Page page1=new Page<>(page,pageSize);
        page1.setOrders(orders);
        return baseMapper.selectMapsPage(page1,queryWrapper);
    }

    @Override
    public Integer selectCountByUserId(Integer userId) {
        return null;
    }


}
