package org.dromara.zhishu.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.dromara.zhishu.domain.RunningTask;
import org.dromara.zhishu.domain.dto.ErpGoodsDto;
import org.dromara.zhishu.domain.dto.RunningTaskShopGoodsDto;
import org.dromara.zhishu.domain.dto.SuccessDataItemDto;
import org.dromara.zhishu.domain.dto.SuccessDataKfz;
import org.dromara.zhishu.domain.vo.RunningTaskNumVo;

import java.util.List;
import java.util.Map;

/**
 * 执行的任务Service接口
 *
 * @author yxy
 * @date 2025-8-5
 */
public interface IRunningTaskByShopService {


    List<Map> selectGetShopGoodsList(String tableName,String isOnsale,String isbn,String priceDown,String priceUp,String startDate,String endDate, Long pageNum, Long pageSize,String goodsName,String stockDown,String stockUp,String trilateralId,String goodsCode,String skuCode);

    int selectGetShopGoodsListCount(String tableName,String isOnsale,String isbn,String priceDown,String priceUp,String startDate,String endDate,String goodsName,String stockDown,String stockUp,String trilateralId,String goodsCode,String skuCode);

    List<Map> selectGetShopGoodsListByDto(RunningTaskShopGoodsDto runningTaskShopGoodsDto);


    /**
     * 查询重复数据根据 isbn和价格
     * @param tableName
     * @param isbn
     * @return
     */
    int selectNumByIsbn(String tableName, String isbn);

    int selectGetShopGoodsNum(String tableName,String isOnSale,String isbn,String priceDown,String priceUp,String startDate,String endDate,String goodsName,String stockDown,String stockUp,String trilateralId,String goodsCode,String skuCode);

    int delShopGoods(String tableName,String isOnSale,String isbn,String priceDown,String priceUp,String startDate,String endDate);

    int selectByTrilateralId(String tableName,String trilateralId);

    RunningTask selectVoByTrilateralId(String tableName,String trilateralId);

    String selectLastFinishTime(String tableName);

    List<RunningTask> selectByIsbn(String tableName,String isbn);

    List<RunningTaskNumVo> selectTaskShopNum(String tableName,Long taskId);

    int selectGetShopGoodsNumByTasKId(String tableName, String taskId);

    String selectStatus(String tableName);


    /**
     * 不分页查询重复数据
     * @param tableName
     * @return
     */
    List<SuccessDataItemDto> selectRepeatNoPage(String tableName);


    List<SuccessDataItemDto> selectShopGoodsList(ErpGoodsDto erpGoodsDto);

    /**
     * kfz专用导出店铺商品数据
     * @param erpGoodsDto
     * @return
     */
    List<SuccessDataKfz> selectKfzShopGoodsList(ErpGoodsDto erpGoodsDto);

    /**
     * 分页查询重复数据
     * @param tableName
     * @param pageNum
     * @param pageSize
     * @return
     */
    Page<SuccessDataItemDto> selectRepeat(String tableName, Long pageNum, Long pageSize);

    // 检查表是否存在
    int checkTableExists(String tableName);

    // 创建表
    void createTable(String tableName);

    // 插入数据
    void insert(String tableName, RunningTask task);

    //修改语句
    void update(String tableName, RunningTask task);

    void batchInsert(String tableName, List<RunningTask> list);


    void updateStatus(String tableName);

    void deleteAll(String tableName);

    void deleteByStatus(String tableName,String status);

    void deleteByTaskId(String tableName,String taskId);

    void deleteByGoodsId(String tableName,String goodsId);

    List<SuccessDataItemDto> selectOnSaleGoodsId(String tableName);

    List<SuccessDataItemDto> selectByGoodsId(String tableName, String trilateralId);

    void updateSuccessDataById( String tableName,  String id, String successDataJsonStr);

    List<Map> getShopGoodsList(String tableName);

    Integer getShopGoodsTotalNum(String tableName);

    Integer getShopGoodsTotalNumByTaskId(String tableName,Long taskId);

    // Mapper接口
      Map<String, Boolean> batchCheckGoodsIdExists(String tableName, List<String> goodsIds);

    Map<String, Object> selectTodayGoods(List<String> shopId);

     Map<String, Object> selectTodaySales(List<String> shopId);
    List<Map> selectGetShopGoodsListAll(String tableName,String isOnsale, Long pageNum, Long pageSize);
    Integer countAll(String tableName);

    /**
     * 批量查询goods_id是否存在，返回存在的goods_id列表
     * @param tableName
     * @param goodsIds
     * @return
     */
    List<Long> batchSelectExistsByGoodsIds(String tableName,List<Long> goodsIds);
}
