package com.red.circle.wallet.inner.service.freight;

import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.wallet.inner.model.cmd.AddFreightBalanceRunningWaterCmd;
import com.red.circle.wallet.inner.model.cmd.FreightAgentReviewCmd;
import com.red.circle.wallet.inner.model.cmd.FreightBalanceCmd;
import com.red.circle.wallet.inner.model.cmd.FreightBalanceRunningWaterCmd;
import com.red.circle.wallet.inner.model.cmd.UpdateFreightBalanceInfoCmd;
import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd;
import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExportQryCmd;
import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterPageQryCmd;
import com.red.circle.wallet.inner.model.cmd.UserFreightSellerCmd;
import com.red.circle.wallet.inner.model.cmd.UserFreightSellerPageQryCmd;
import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQryCmd;
import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO;
import com.red.circle.wallet.inner.model.dto.UserFreightBalanceRunningWaterDTO;
import com.red.circle.wallet.inner.model.dto.UserFreightSellerDTO;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 货运代理金币.
 *
 * @author pengliang on 2023/8/18
 */
public interface FreightGoldClientService {

  /**
   * 改变余额.
   */
  void changeBalance(FreightBalanceRunningWaterCmd cmd);

  /**
   * 获取余额.
   */
  BigDecimal getBalance(Long userId);

  /**
   * 插入流水
   */
  void addRunningWater(AddFreightBalanceRunningWaterCmd cmd);

  /**
   * 是否存在货运账户.
   *
   * @param userId 用户id
   * @return true 存在，false 不存在
   */
  boolean existsBalance(Long userId);

  boolean existsRecord(String txId);

  /**
   * 是否为货运代理角色
   *
   * @param userId 用户id
   * @return true是
   */
  Boolean checkFreightAgent(Long userId);

  /**
   * 是否为超级货运代理角色
   */
  Boolean checkSuperFreightAgent(Long userId);

  PageResult<UserFreightBalanceDTO> pageFreight(UserFreightBalancePageQryCmd query);

  UserFreightBalanceDTO getFreightBalance(Long userId);

  UserFreightBalanceDTO getByUserId(Long userId);

  UserFreightBalanceDTO getFreightBalanceById(Long id);

  boolean updateFreightBalance(FreightBalanceCmd cmd);

   Boolean updateSellerQuantity(UserFreightSellerCmd param);

  void deleteFreightBalance(Long userId);

  /**
   * 删除记录
   */
  void deleteFreightBalanceRunningWater(Long userId);

  boolean decrCandyBalance(SysOriginPlatformEnum sysOrigin, Long userId,
      BigDecimal quantity);

  Map<Long, Long> mapSellerQuantityByFreightIds(Set<Long> freightIds);

  boolean existsSeller(Long userId);

  boolean incrCandyBalance(SysOriginPlatformEnum sysOrigin, Long userId, BigDecimal quantity);

  void addFreightAgentReview(FreightAgentReviewCmd cmd);

  PageResult<UserFreightBalanceRunningWaterDTO> pageRunningWater(
      UserFreightBalanceRunningWaterPageQryCmd query);

  PageResult<UserFreightBalanceRunningWaterDTO> pageFreightSellerRunningWater(
      UserFreightSellerRunningWaterPageQryCmd query);

  List<UserFreightBalanceRunningWaterDTO> listExportBalanceRunningWater(
      UserFreightBalanceRunningWaterExportQryCmd query);

  PageResult<UserFreightSellerDTO> pageFreightSeller(UserFreightSellerPageQryCmd query);

  void removeFreightSeller(Long id);

  /**
   * 更新货运代理账户信息（国家和联系方式）.
   */
  Boolean updateFreightBalanceInfo(UpdateFreightBalanceInfoCmd cmd);

  /**
   * 批量查询用户交易次数（type=1的记录数）.
   */
  Map<Long, Long> mapTransactionCountByUserIds(Set<Long> userIds);

  /**
   * 查询用户指定时间和类型的总金额.
   */
  BigDecimal getTotalAmountByCondition(Long userId, String startTime, String endTime, String rechargeType);
}
