package com.xingxi.master.merchant.service.impl;

import com.xingxi.common.core.text.Convert;
import com.xingxi.common.utils.DateUtils;
import com.xingxi.common.utils.ShiroUtils;
import com.xingxi.master.merchant.domain.MerchantProd;
import com.xingxi.master.merchant.mapper.MerchantProdMapper;
import com.xingxi.master.merchant.service.IMerchantProdService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 店铺商品Service业务层处理
 *
 * @author xingxi
 * @date 2025-03-06
 */
@Service
public class MerchantProdServiceImpl implements IMerchantProdService {
    @Resource
    private MerchantProdMapper merchantProdMapper;

    /**
     * 查询店铺商品
     *
     * @param mercProdId 店铺商品主键
     * @return 店铺商品
     */
    @Override
    public MerchantProd selectMerchantProdByMercProdId(Long mercProdId) {
        return merchantProdMapper.selectMerchantProdByMercProdId(mercProdId);
    }

    /**
     * 查询店铺商品列表
     *
     * @param merchantProd 店铺商品
     * @return 店铺商品
     */
    @Override
    public List<MerchantProd> selectMerchantProdList(MerchantProd merchantProd) {
        return merchantProdMapper.selectMerchantProdList(merchantProd);
    }

    /**
     * 新增店铺商品
     *
     * @param merchantProd 店铺商品
     * @return 结果
     */
    @Override
    public int insertMerchantProd(MerchantProd merchantProd) {
        merchantProd.setCreateUser(ShiroUtils.getLoginName());
        merchantProd.setCreateTime(DateUtils.getNowDate());
        return merchantProdMapper.insertMerchantProd(merchantProd);
    }

    /**
     * 新增店铺商品
     *
     * @param merchantProdList 店铺商品
     * @return 结果
     */
    @Override
    public int batchInsertMerchantProd(List<MerchantProd> merchantProdList) {
        return merchantProdMapper.batchInsertMerchantProd(merchantProdList);
    }

    /**
     * 修改店铺商品
     *
     * @param merchantProd 店铺商品
     * @return 结果
     */
    @Override
    public int updateMerchantProd(MerchantProd merchantProd) {
        merchantProd.setUpdateTime(DateUtils.getNowDate());
        return merchantProdMapper.updateMerchantProd(merchantProd);
    }

    /**
     * 批量删除店铺商品
     *
     * @param mercProdIds 需要删除的店铺商品主键
     * @return 结果
     */
    @Override
    public int deleteMerchantProdByMercProdIds(String mercProdIds) {
        return merchantProdMapper.deleteMerchantProdByMercProdIds(Convert.toStrArray(mercProdIds));
    }

    /**
     * 删除店铺商品信息
     *
     * @param mercProdId 店铺商品主键
     * @return 结果
     */
    @Override
    public int deleteMerchantProdByMercProdId(Long mercProdId) {
        return merchantProdMapper.deleteMerchantProdByMercProdId(mercProdId);
    }

    /**
     * 逻辑删除店铺商品
     *
     * @param mercProdId 店铺商品主键
     * @return 结果
     */
    @Override
    public int logicDeleteMerchantProdByMercProdId(Long mercProdId) {
        return merchantProdMapper.logicDeleteMerchantProdByMercProdId(mercProdId);
    }

    /**
     * 逻辑批量删除店铺商品
     *
     * @param mercProdIds 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int logicDeleteMerchantProdByMercProdIds(String[] mercProdIds) {
        return merchantProdMapper.logicDeleteMerchantProdByMercProdIds(mercProdIds);
    }

    /**
     * 逻辑批量删除店铺商品
     *
     * @param merchantProd 店铺商品
     * @return 结果
     */
    @Override
    public int logicDeleteMerchantProdByCondition(MerchantProd merchantProd) {
        return merchantProdMapper.logicDeleteMerchantProdByCondition(merchantProd);
    }
}
