package com.yiqi.recharge.mapper;

import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yiqi.common.core.domain.PageVO;
import com.yiqi.recharge.domain.dto.BillMstrQueryDTO;
import com.yiqi.recharge.domain.dto.RechargeBalanceCountDTO;
import com.yiqi.recharge.domain.dto.RechargeCardBillMstrQueryDTO;
import com.yiqi.recharge.domain.dto.RechargePasswordCardQueryDTO;
import com.yiqi.recharge.domain.dto.weapp.WeAppCardRecordByCardDTO;
import com.yiqi.recharge.domain.dto.weapp.WeAppCardRecordByUserDTO;
import com.yiqi.recharge.domain.vo.RechargeBalanceCountVO;
import com.yiqi.recharge.domain.vo.RechargeCardBillMstrQueryVO;
import com.yiqi.recharge.domain.vo.RechargePasswordCardQueryVO;
import com.yiqi.recharge.domain.vo.StoreCardStatisticsVO;
import com.yiqi.recharge.domain.vo.weapp.WeAppCardsInfoVO;
import com.yiqi.recharge.domain.vo.weapp.WeAppCardsUseRecordsVO;
import org.apache.ibatis.annotations.Mapper;
import com.yiqi.recharge.domain.RechargePasswordCard;
import org.apache.ibatis.annotations.Param;

/**
 * 密码充值卡管理Mapper接口
 *
 * @author xiaohei
 * @date 2023-08-29
 */
@Mapper
public interface RechargePasswordCardMapper extends BaseMapper<RechargePasswordCard> {

    public List<RechargePasswordCardQueryVO> selectUserRechargePasswordCardList(@Param("pageVO") PageVO pageVO, @Param("appUserId") long appUserId);

    public int countRechargePasswordCardList(@Param("pageVO") PageVO pageVO, @Param("appUserId") long appUserId);

    public RechargePasswordCard selectTotalBalanceGroupByAppUser(@Param("appUserId") Long appUserId, @Param("orderType") String orderType);

    public List<RechargeBalanceCountVO> findUserPageByBalance(@Param("rechargeBalanceCountDTO") RechargeBalanceCountDTO rechargeBalanceCountDTO, @Param("sourceType") String sourceType, @Param("orgId") Long orgId);

    public int findUserPageByBalanceCount(@Param("rechargeBalanceCountDTO") RechargeBalanceCountDTO rechargeBalanceCountDTO, @Param("sourceType") String sourceType, @Param("orgId") Long orgId);

    public List<RechargeCardBillMstrQueryVO> getCardBillMstrInfoById(RechargeCardBillMstrQueryDTO rechargeCardBillMstrQueryDTO);

    public List<RechargeCardBillMstrQueryVO> getBillMstrInfoList(@Param("billMstrQueryDTO") BillMstrQueryDTO billMstrQueryDTO, @Param("orgId") Long orgId, @Param("sourceType") String sourceType);

    public int countBillMstrInfoList(@Param("billMstrQueryDTO") BillMstrQueryDTO billMstrQueryDTO, @Param("orgId") Long orgId, @Param("sourceType") String sourceType);

    public List<RechargeBalanceCountVO> getBalanceCountListByUserIdList(@Param("userIdList") List<Long> userIdList, @Param("expireDate") Date expireDate);

    /**
     * 查询密码充值卡管理
     *
     * @param id 密码充值卡管理主键
     * @return 密码充值卡管理
     */
    public RechargePasswordCard selectRechargePasswordCardById(Long id);

    /**
     * 查询密码充值卡管理列表
     *
     * @param rechargePasswordCardQueryDTO 密码充值卡管理
     * @return 密码充值卡管理集合
     */
    public List<RechargePasswordCardQueryVO> selectRechargePasswordCardList(RechargePasswordCardQueryDTO rechargePasswordCardQueryDTO);

    /**
     * 删除密码充值卡管理
     *
     * @param id 密码充值卡管理主键
     * @return 结果
     */
    public int deleteRechargePasswordCardById(Long id);

    /**
     * 批量删除密码充值卡管理
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteRechargePasswordCardByIds(Long[] ids);

    /**
     * 按客户获取充值卡信息
     */
    public List<WeAppCardsInfoVO> getPasswordCardsInfoByAppUserId(WeAppCardRecordByUserDTO weAppCardRecordByUserDTO);

    /**
     * 按充值卡查消费记录
     */
    public WeAppCardsUseRecordsVO getUseRecordsByCardId(WeAppCardRecordByCardDTO weAppCardRecordByCardDTO);

    /**
     * 根据订单号查询充值卡
     *
     * @param orderNo
     * @return
     */
    RechargePasswordCard selectRechargePasswordCardByOrderNo(String orderNo);

    /**
     * 根据用户id查询会员卡数量
     *
     * @param appUserId
     * @return
     */
    Long getCountyByAppUserId(Long appUserId);

    /**
     * 根据用户id查询会员卡
     * @param appUserId
     * @param buyGoodsType
     * @return
     */
    List<RechargePasswordCard> selectRechargePasswordCardListByAppUserIdAndBuyGoodsType(@Param("appUserId") Long appUserId, @Param("buyGoodsType") String buyGoodsType);

    /**
     * 根据充值单号查询充值卡
     * @param cardSn
     * @return
     */
    RechargePasswordCard selectRechargePasswordCardBySn(String cardSn);

    /**
     * 分页查询门店会员卡统计
     */
    List<StoreCardStatisticsVO> selectStoreCardStatisticsPage(
            @Param("storeId") Long storeId,
            @Param("beginTime") Date beginTime,
            @Param("endTime") Date endTime,
            @Param("startRow") int startRow,
            @Param("pageSize") int pageSize
    );

}
