package cn.pluss.platform.mapper;

import cn.pluss.platform.entity.UserIntegral;
import cn.pluss.platform.other.JfShopIntegral;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

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

/**
 * <p>
 * 用户积分详情表 Mapper 接口
 * </p>
 *
 * @author crystal
 * @since 2022-05-17
 */
public interface UserIntegralMapper extends BaseMapper<UserIntegral> {

    /**
     * 查询积分详情
     * @param userId
     * @param type
     * @return
     */
    List<JfShopIntegral> list(@Param("userId") String userId, @Param("type") String type);

    /**
     * 统计积分总额
     * @param userId
     * @return
     */
    BigDecimal getCountIntegral(@Param("userId") Serializable userId,@Param("date") String date, @Param("auditDate") String auditDate);

    default BigDecimal getCountIntegral(@Param("userId") Serializable userId){
        return getCountIntegral(userId,null,null);
    }

    Page<UserIntegral> pageInfo(Page<UserIntegral> page, @Param("entity") UserIntegral query);

    @Select("SELECT * FROM tb_pluss_user_integral WHERE orderNumber = #{orderNumber}")
    UserIntegral getByOrderNumber(String orderNumber);
}
