package cn.pluss.platform.mapper;

import java.util.List;
import java.util.Map;

import cn.pluss.platform.entity.MerchantProfit;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import cn.pluss.platform.entity.Fans;
import cn.pluss.platform.vo.FansConsumVO;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface FansMapper {

    List<Fans> selectGroupData(@Param("lastMerchantCodeList") List<String> lastMerchantCodeList);

    Fans queryFans(Fans fans);

    List<Fans> queryFansList(Fans fans);

    void saveFans(Fans fans);

    void updateFans(Fans fans);

    void deleteFans(Fans fans);

    List<Fans> queryFansPage(Map map);

    Integer queryFansPageCount(Map map);

    Integer queryFansNoPageCount(Map map);

    void saveFansBatch(List<Fans> fansList);

    Double sumConsumMoneyByMerchantCode(Map map);

    /**
     * queryNowDateFansList:(获取当天粉丝的集合). <br/>
     *
     * @return
     * @author Administrator
     * @since JDK 1.8
     */
    List<Fans> queryNowDateFansList(Map map);


    List<Fans> queryFansPageManage(Map map);

    Integer queryFansPageCountManage(Map map);

    /**
     * queryLastFansByUserId:(查询某一粉丝最后一次消费的时间). <br/>
     *
     * @param userId
     * @return
     * @author Administrator
     * @since JDK 1.8
     */
    Fans queryLastFansByUserId(@Param(value = "userId") String userId);

    /**
     * queryFansConsumPage:(最新粉丝分润记录查询). <br/>
     *
     * @param map
     * @return
     * @author Administrator
     * @since JDK 1.8
     */
    List<FansConsumVO> queryFansConsumPage(Map<String, Object> map);

    List<FansConsumVO> queryFansNoConsumPage(Map<String, Object> map);

    /**
     * queryFansConsumPageCount:(最新粉丝分润记录统计). <br/>
     *
     * @param map
     * @return
     * @author Administrator
     * @since JDK 1.8
     */
    Integer queryFansConsumPageCount(Map<String, Object> map);

    Integer queryFansNoConsumPageCount(Map<String, Object> map);

    Double queryFansSumConsumMoney(Map<String, Object> map);

    Double queryFansSumShareMoney(Map<String, Object> map);

    /**
     * 返回今日粉丝奖励总数
     *
     * @param fans
     * @return
     */
    Double queryFansTodayCount(Fans fans);

    @Select("SELECT * FROM tb_pluss_fans WHERE orderNumber = #{orderNumber} FOR UPDATE ")
    Fans getByLockOrderNumber(String orderNumber);
}

