package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ShopMerchantCountMapper;
import com.gxwebsoft.shop.service.ShopMerchantCountService;
import com.gxwebsoft.shop.entity.ShopMerchantCount;
import com.gxwebsoft.shop.param.ShopMerchantCountParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 门店销售统计表Service实现
 *
 * @author 科技小王子
 * @since 2024-10-02 10:07:51
 */
@Service
public class ShopMerchantCountServiceImpl extends ServiceImpl<ShopMerchantCountMapper, ShopMerchantCount> implements ShopMerchantCountService {

    @Override
    public PageResult<ShopMerchantCount> pageRel(ShopMerchantCountParam param) {
        PageParam<ShopMerchantCount, ShopMerchantCountParam> page = new PageParam<>(param);
        page.setDefaultOrder("create_time desc");
        List<ShopMerchantCount> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<ShopMerchantCount> listRel(ShopMerchantCountParam param) {
        List<ShopMerchantCount> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<ShopMerchantCount, ShopMerchantCountParam> page = new PageParam<>();
        page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public ShopMerchantCount getByIdRel(Integer id) {
        ShopMerchantCountParam param = new ShopMerchantCountParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
