package com.yc.ship.module.ota.service.distributor;

import com.yc.ship.framework.common.pojo.CommonResult;
import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.tenant.core.aop.TenantIgnore;
import com.yc.ship.module.ota.api.dto.DistributorRespDTO;
import com.yc.ship.module.ota.controller.admin.distributor.vo.*;
import com.yc.ship.module.ota.dal.dataobject.distributor.DistributorDO;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 分销商信息 Service 接口
 *
 * @author 管理员
 */
public interface DistributorService {

    /**
     * 创建分销商信息
     *
     * @param createReqVO 创建信息
     * @return 编号
     */
    Long createDistributor(@Valid DistributorSaveReqVO createReqVO);
    String createCardNo(Long id);
    DistributorImportRespVO importDistributorList(List<DistributorImportExcelVO> distributorImportExcelVOS);

    /**
     * 更新分销商信息
     *
     * @param updateReqVO 更新信息
     */
    void updateDistributor(@Valid DistributorSaveReqVO updateReqVO);

    void updatePassword(DistributorUpdatePasswordReqVO updateReqVO);

    /**
     * 删除分销商信息
     *
     * @param id 编号
     */
    void deleteDistributor(Long id);

    /**
     * 获得分销商信息
     *
     * @param id 编号
     * @return 分销商信息
     */
    DistributorDO getDistributor(Long id);
    DistributorDO getDistributorNew(Long id);

    DistributorDO getDistributorByName(String name);

    /**
     * 获得分销商信息分页
     *
     * @param pageReqVO 分页查询
     * @return 分销商信息分页
     */
    PageResult<DistributorDO> getDistributorPage(DistributorPageReqVO pageReqVO);

    List<DistributorDO> getSimpleList(DistributorListReqVO reqVO);

    void updateStatus(Long id, Integer status);

    List<Map> getOtcSimpleList(DistributorSaveReqVO params);

    boolean addBalance(Long id, BigDecimal money);

    boolean subSurplus(Long id, BigDecimal money);

    boolean subPayCredit(Long id, BigDecimal money);

    boolean addPayCredit(Long id, BigDecimal money);

    boolean addInventory(Long id, BigDecimal money);

    /**
     * 扣减定向库存余额
     * @param distributorId
     * @param money
     * @return
     */
    boolean subInventory(Long distributorId, BigDecimal money);

    CommonResult<DistributorRespDTO> getDistributorByAccountTenantId(Long accountTenantId);

    List<DistributorRespVO> getOtcDistributor(Integer type);

    List<DistributorDO> selectListByType(Integer type);


    List<DistributorDO> selectChildNo();

    List<DistributorRespVO> getOtcDistributor(Integer type, Long productId);

    /**
     * 扣减金额-并返回是否执行成功
     * @param distributorId OTA主键
     * @param money 扣除金额
     * @return 是否扣款成功
     * @throws Exception
     */
    boolean subBalance(Long distributorId, BigDecimal money);

    boolean addSurplus(Long distributorId, BigDecimal money);

    CommonResult<DistributorRespDTO> getDistributorByOtaAccount(String otaAccount, String typeCode);

    DistributorDO getDistributorById(Long id);

    DistributorDO getDistributorByLoginUser(String loginName);

    Long updateDistributorCard(Long distributorId, Integer mode, BigDecimal amount, Long userId, Long orderId, Long refundId);

    List<DistributorDO> getDistributorList(Collection<Long> ids);

    List<DistributorDO> getDistributorsByAccountTenantId(Long accountTenantId);

    LoginTypeRespVO getLoginType();

    DistributorRespVO queryDistributorMoneyTotal(Long distributorId);

    /**
     * 根据登录用户ID获取分销商信息
     * @param loginUserId 登录用户ID
     * @auth fly cloud
     * @return 分销商信息
     */
    DistributorDO getDistributorByLoginUserId(Long loginUserId);

    DistributorRespVO getADistributorById(Long id);
}
