package com.jsh.erp.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jsh.erp.datasource.dto.MaterialDto;
import com.jsh.erp.datasource.entities.Log;
import com.jsh.erp.datasource.entities.MaterialBatch;
import com.jsh.erp.datasource.entities.MaterialExtend;
import com.jsh.erp.datasource.vo.MaterialExtendVo4List;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

public interface MaterialExtendService extends IService<MaterialExtend> {
    MaterialExtend getMaterialExtend(long id)throws Exception;

    List<MaterialExtendVo4List> getDetailList(Long materialId);

    List<MaterialExtend> getListByMIds(List<Long> idList);

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    String saveDetails(List<MaterialExtend> materialExtends, String sortList, Long materialId, String type) throws Exception;

    /**
     *  添加商品子信息
     * @param materialExtend 商品子信息
     */
    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int insertMaterialExtend(MaterialExtend materialExtend)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int updateMaterialExtend(MaterialExtend materialExtend) throws Exception;

    int checkIsBarCodeExist(Long id, String barCode)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int deleteMaterialExtend(Long id, HttpServletRequest request)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int batchDeleteMaterialExtendByIds(String ids, HttpServletRequest request) throws Exception;

    int insertMaterialExtend(JSONObject obj, HttpServletRequest request) throws Exception;

    int updateMaterialExtend(JSONObject obj, HttpServletRequest request)throws Exception;

    List<MaterialExtend> getMaterialExtendByTenantAndTime(Long tenantId, Long lastTime, Long syncNum)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    Long selectIdByMaterialIdAndDefaultFlag(Long materialId, String defaultFlag);

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    Long selectIdByMaterialIdAndBarCode(Long materialId, String barCode);

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    List<MaterialExtend> getListByMaterialIdAndDefaultFlagAndBarCode(Long materialId, String defaultFlag, String barCode);

    MaterialExtend getInfoByBarCode(String barCode)throws Exception;

    int getCountByManyBarCodeWithoutUs(String manyBarCode, String barCode);

    MaterialExtend getInfoByBatchNumber(String batchNumber)throws Exception;

    /**
     * 根据商品条码集合查询商品id
     * @param barCodeList 商品条码
     */
    List<Long> selectIdsByBarCode(List<String> barCodeList);
}
