package com.jsh.erp.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jsh.erp.datasource.entities.Supplier;
import com.jsh.erp.utils.BaseResponseInfo;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public interface SupplierService extends IService<Supplier> {
    Supplier getSupplier(long id)throws Exception;

    List<Supplier> getSupplierListByIds(String ids)throws Exception;

    List<Supplier> getSupplier()throws Exception;

    List<Supplier> select(String supplier, String type, String phonenum, String telephone) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int insertSupplier(JSONObject obj, HttpServletRequest request)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int updateSupplier(JSONObject obj, HttpServletRequest request)throws Exception;

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

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

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

    int checkIsNameExist(Long id, String name)throws Exception;

    int checkIsNameAndTypeExist(Long id, String name, String type)throws Exception;

    int checkIsTelephoneAndTypeExist(Long id, String telephone, String type);

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    void updateAdvanceIn(Long supplierId);

    List<Supplier> findBySelectCus()throws Exception;

    List<Supplier> findBySelectSup()throws Exception;

    List<Supplier> findBySelectRetail()throws Exception;

    List<Supplier> findById(Long supplierId)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int batchSetStatus(Boolean status, String ids)throws Exception;

    List<Supplier> findUserCustomer()throws Exception;

    List<Supplier> findByAll(String supplier, String type, String phonenum, String telephone) throws Exception;

    Map<String, Object> getBeginNeedByOrganId(Long organId) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    void importVendor(MultipartFile file, HttpServletRequest request) throws Exception;

    Integer parseIntegerFromExcel(String content);

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    void importCustomer(MultipartFile file, HttpServletRequest request) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    void importMember(MultipartFile file, HttpServletRequest request) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    BaseResponseInfo importExcel(List<Supplier> mList, String type, HttpServletRequest request) throws Exception;

    BigDecimal parseBigDecimalEx(String str)throws Exception;

    File exportExcel(List<Supplier> dataList, String type) throws Exception;

    File exportExcelVendorOrCustomer(List<Supplier> dataList, String type) throws Exception;

    String mapInvoiceType(String invoiceType);

    String mapSettlementMethod(String settlementMethod);

    void setUserCustomerPermission(HttpServletRequest request, Supplier supplier) throws Exception;

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

    /**
     * 根据类型 和 电话号码查询供应商/客户信息
     * @param type
     * @param telephone
     * @return
     */
    Supplier getSupplierByPhone(String type,String telephone );

    Supplier getCustomerByPhone(String telephone );

    // 创建新客户
    Supplier createCustomer(Supplier supplier);
}
