package com.jxy.order.mapper;

import com.jxy.common.datasource.annotation.Master;
import com.jxy.order.dto.AddCreditOrderDto;
import com.jxy.order.dto.UserAccountDto;
import com.jxy.order.entity.AddCreditOrder;
import com.jxy.order.entity.AddressInfo;
import com.jxy.order.entity.UserAddress;
import com.jxy.order.entity.UserBalance;
import com.jxy.order.vo.HandleAddCreditOrderVo;
import com.jxy.order.vo.OrderStatusVo;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

@Master
public interface OrderMapper{


    public int checkTxidIfExist(@Param("txid") String txid);

    public UserAddress getAddressByUserId(@Param("userId") long userId);

    public Long getUserIdByEmail(@Param("email") String email);


    public int getAddressNoUsedCount();


    public int batchInsertTotalAddress(List<String> list);

    public int batchInsertBSCTotalAddress(List<String> list);

    public int batchInsertTRXTotalAddress(List<String> list);

    /**
     * 用户收款地址信息入库  原则上不调用
     * @param dto
     * @return
     */
    public int insertAddressAndUserId(@Param("dto") UserAddress dto);

    public String getAddressNoUse(@Param("table") String table);

    public boolean updateAddressToUse(@Param("address") String address,@Param("table") String table);

    /**
     * 充值订单信息记录
     * @param dto
     * @return
     */
    public boolean insertAddCreditOrder(@Param("dto") AddCreditOrder dto);

    public boolean insertUserAccount(@Param("dto") UserAccountDto dto);

    public UserAccountDto getUserAccountByUserId(@Param("userId") Long userId);

    public boolean updateUserAccount(@Param("dto") UserAccountDto dto, @Param("usdt") BigDecimal usdt, @Param("usdc") BigDecimal usdc, @Param("busd") BigDecimal busd);

    public boolean insertUserBalance(@Param("dto") UserBalance dto);

    /**
     *根据状态、地址获取所有系统充值订单
     */
    public List<AddCreditOrderDto> getAddCreditOrderByStatus(@Param("vo") OrderStatusVo vo);


    /**
     *获取超时未处理的充值订单列表
     */
    public List<AddCreditOrder> getExpireNoHandleAddCreditOrder();

    /**
     *获取所有地址
     */
    public List<AddressInfo> getAllAddress(@Param("status") Integer status);

    /**
     *根据用户id获取用户所有系统充值订单
     * @param userId
     * @return
     */
    public  List<AddCreditOrder> getAddCreditOrderByUserId(@Param("userId") Long userId,@Param("status") Integer status);

    /**
     *根据订单id获取充值订单详情
     * @param id
     * @return
     */
    public AddCreditOrder getAddCreditOrderById(@Param("id") Long id);

    public AddCreditOrder getAddCreditOrderByOrderIdAndUserId(@Param("orderId") Long orderId,@Param("userId") Long userId);

    public int updateOrderStatusById(@Param("vo") HandleAddCreditOrderVo vo);

    public int updateOrdersById(@Param("vo") HandleAddCreditOrderVo vo);

}
