package com.fuint.repository.mapper;

import com.fuint.repository.bean.MemberTopBean;
import com.fuint.repository.model.MtUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

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

/**
 * 会员个人信息 Mapper 接口
 *
 * Created by FSQ
 * CopyRight https://www.fuint.cn
 */
public interface MtUserMapper extends BaseMapper<MtUser> {

    List<MtUser> queryMemberByMobile(@Param("merchantId") Long merchantId, @Param("mobile") String mobile);

    List<MtUser> queryMemberByName(@Param("merchantId") Long merchantId, @Param("name") String name);

    MtUser queryMemberByOpenId(@Param("merchantId") Long merchantId, @Param("openId") String openId);

    List<MtUser> findMembersByUserNo(@Param("merchantId") Long merchantId, @Param("userNo") String userNo);

    void updateActiveTime(@Param("userId") Long userId, @Param("updateTime") Date updateTime);

    void updateUserBalance(@Param("merchantId") Long merchantId, @Param("userIds") List<Long> userIds, @Param("amount") BigDecimal amount);

    void resetMobile(@Param("mobile") String mobile, @Param("userId") Long userId);

    Long getUserCount(@Param("merchantId") Long merchantId);

    Long getStoreUserCount(@Param("storeId") Long storeId);

    Long getUserCountByTime(@Param("merchantId") Long merchantId, @Param("beginTime") Date beginTime, @Param("endTime") Date endTime);

    Long getStoreUserCountByTime(@Param("storeId") Long storeId, @Param("beginTime") Date beginTime, @Param("endTime") Date endTime);

    List<MemberTopBean> getMemberConsumeTopList(@Param("merchantId") Long merchantId, @Param("storeId") Long storeId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<Long> getUserIdList(@Param("merchantId") Long merchantId, @Param("storeId") Long storeId);

    List<MtUser> searchMembers(@Param("merchantId") Long merchantId, @Param("keyword") String keyword);

}
