package cn.pluss.platform.mapper;

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

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import cn.pluss.platform.entity.MerchantMenber;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface MerchantMenberMapper extends BaseMapper<MerchantMenber> {

    MerchantMenber queryMerchantMenber(MerchantMenber merchantMenber);

    List<MerchantMenber> queryMerchantMenberList(MerchantMenber merchantMenber);

    void saveMerchantMenber(MerchantMenber merchantMenber);

    void updateMerchantMenber(MerchantMenber merchantMenber);

    void deleteMerchantMenber(MerchantMenber merchantMenber);

    List<MerchantMenber> queryMerchantMenberPage(Map map);

    Integer queryMerchantMenberPageCount(Map map);

    void saveMerchantMenberBatch(List<MerchantMenber> merchantMenberList);
    
    Double queryMerchantMenberTotalRechargeFee(Map map);
    
    Double queryMerchantMenberUsableRechargeFee(Map map);
    
    Integer queryMerchantMenberNumByTime(Map map);
    
    
    /**
     * 
     * queryMerchantRecharge:(查询商户的账单). <br/> 
     * 
     * @author Administrator 
     * @param merchantCode
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param orderType 0：会员消费，1：会员充值'
     * @return 
     * @since JDK 1.8
     */
    Double queryMerchantMemberBill(@Param(value = "rechargeType") String rechargeType, @Param(value = "orderType") String orderType, @Param(value = "merchantCode") String merchantCode, @Param(value = "startTime") String startTime, @Param(value = "endTime") String endTime);
    
    /**
     * 
     * queryMerchantGiveMoney:(赠送返现金额). <br/> 
     * 
     * @author Administrator 
     * @param merchantCode
     * @return 
     * @since JDK 1.8
     */
    Double queryMerchantGiveMoney(@Param(value = "merchantCode") String merchantCode);
    
    /**
     * 
     * manageQueryMerchantMenberPage:(manage). <br/> 
     * 
     * @author Administrator 
     * @param map
     * @return 
     * @since JDK 1.8
     */
    List<MerchantMenber> manageQueryMerchantMenberPage(Map map);

    List<MerchantMenber> manageQueryMerchantNoMenberPage(Map map);
    /**
     * 
     * manageQueryMerchantMenberPageCount:(这里用一句话描述这个方法的作用). <br/> 
     * 
     * @author Administrator 
     * @param map
     * @return 
     * @since JDK 1.8
     */
    Integer manageQueryMerchantMenberPageCount(Map map);

    Integer manageQueryMerchantNoMenberPageCount(Map map);

    List<MerchantMenber> manageMerchantMenberSum(Map<String, Object> newMemberMap);

    /**
     * 关联分页查询会员卡列表
     * @param page
     * @param menber
     * @return
     */
    Page<MerchantMenber> pageJoinData(@Param("page") Page<MerchantMenber> page, @Param("menber")MerchantMenber menber);

    /**
     * 根据unionId 修改openid
     * @date: 2021/12/9 18:00
     */
    @Update("UPDATE tb_pluss_merchant_menber SET openid = #{openId} WHERE unionId = #{unionId}")
    void updateByUnionId(@Param("openId") String openId,@Param("unionId") String unionId);

    /**
     * 根据会员卡号获取会员卡信息
     * @param cardNo
     * @return
     */
    @Select("SELECT * FROM tb_pluss_merchant_menber WHERE cardNo = #{cardNo}")
    MerchantMenber getByCardNo(String cardNo);
}

