package com.starry.admin.modules.clerk.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.modules.clerk.mapper.PlayClerkWagesDetailsInfoMapper;
import com.starry.admin.modules.clerk.module.entity.PlayClerkWagesDetailsInfoEntity;
import com.starry.admin.modules.clerk.service.IPlayClerkWagesDetailsInfoService;
import com.starry.common.utils.IdUtils;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 店员工资明细信息Service业务层处理
 *
 * @author admin
 * @since 2024-05-31
 */
@Service
public class PlayClerkWagesDetailsInfoServiceImpl
        extends
            ServiceImpl<PlayClerkWagesDetailsInfoMapper, PlayClerkWagesDetailsInfoEntity>
        implements
            IPlayClerkWagesDetailsInfoService {
    @Resource
    private PlayClerkWagesDetailsInfoMapper playClerkWagesDetailsInfoMapper;

    @Override
    public PlayClerkWagesDetailsInfoEntity selectByClerkIdAndWagesId(String wagesId, String clerkId) {
        LambdaQueryWrapper<PlayClerkWagesDetailsInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(PlayClerkWagesDetailsInfoEntity::getWagesId, wagesId);
        lambdaQueryWrapper.eq(PlayClerkWagesDetailsInfoEntity::getClerkId, clerkId);
        return this.baseMapper.selectOne(lambdaQueryWrapper);
    }

    @Override
    public PlayClerkWagesDetailsInfoEntity selectByOrderId(String orderId) {
        LambdaQueryWrapper<PlayClerkWagesDetailsInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(PlayClerkWagesDetailsInfoEntity::getOrderId, orderId);
        return this.baseMapper.selectOne(lambdaQueryWrapper);
    }

    /**
     * 查询店员工资明细信息
     *
     * @param id
     *            店员工资明细信息主键
     * @return 店员工资明细信息
     */
    @Override
    public PlayClerkWagesDetailsInfoEntity selectPlayClerkWagesDetailsInfoById(String id) {
        return this.baseMapper.selectById(id);
    }

    @Override
    public List<PlayClerkWagesDetailsInfoEntity> selectByWagesId(String wagesId) {
        LambdaQueryWrapper<PlayClerkWagesDetailsInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(PlayClerkWagesDetailsInfoEntity::getWagesId, wagesId);
        return this.baseMapper.selectList(lambdaQueryWrapper);
    }

    /**
     * 查询店员工资明细信息列表
     *
     * @param playClerkWagesDetailsInfo
     *            店员工资明细信息
     * @return 店员工资明细信息
     */
    @Override
    public IPage<PlayClerkWagesDetailsInfoEntity> selectPlayClerkWagesDetailsInfoByPage(
            PlayClerkWagesDetailsInfoEntity playClerkWagesDetailsInfo) {
        Page<PlayClerkWagesDetailsInfoEntity> page = new Page<>(1, 10);
        return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
    }

    /**
     * 新增店员工资明细信息
     *
     * @param playClerkWagesDetailsInfo
     *            店员工资明细信息
     * @return 结果
     */
    @Override
    public boolean create(PlayClerkWagesDetailsInfoEntity playClerkWagesDetailsInfo) {
        if (StrUtil.isBlankIfStr(playClerkWagesDetailsInfo.getId())) {
            playClerkWagesDetailsInfo.setId(IdUtils.getUuid());
        }
        return save(playClerkWagesDetailsInfo);
    }

    /**
     * 修改店员工资明细信息
     *
     * @param playClerkWagesDetailsInfo
     *            店员工资明细信息
     * @return 结果
     */
    @Override
    public boolean update(PlayClerkWagesDetailsInfoEntity playClerkWagesDetailsInfo) {
        return updateById(playClerkWagesDetailsInfo);
    }

    /**
     * 批量删除店员工资明细信息
     *
     * @param ids
     *            需要删除的店员工资明细信息主键
     * @return 结果
     */
    @Override
    public int deletePlayClerkWagesDetailsInfoByIds(String[] ids) {
        return playClerkWagesDetailsInfoMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除店员工资明细信息信息
     *
     * @param id
     *            店员工资明细信息主键
     * @return 结果
     */
    @Override
    public int deletePlayClerkWagesDetailsInfoById(String id) {
        return playClerkWagesDetailsInfoMapper.deleteById(id);
    }
}
