package com.buy507.mall.portal.dao;

import com.buy507.mall.portal.vo.TransactionCashVo;
import com.buy507.mall.portal.vo.TransactionPointsVo;
import com.buy507.mall.portal.vo.WalletCashVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

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

@Mapper
public interface MyWalletMapper {
    /**
     * 获取用户现金余额
     * @param userId
     * @return
     */
    @Select("SELECT balance FROM ums_member WHERE id = #{userId}")
    BigDecimal getBalance(Long userId);

    /**
     * 获取用户现金流水
     * @param userId
     * @return
     */
    @Select("SELECT revenue_amount, remarks, transfer_payment_time FROM ums_member_account_transaction " +
            "WHERE member_id = #{userId} And flow_type = 1  ORDER BY transfer_payment_time DESC")
    List<TransactionCashVo> getCashFlow(Long userId);

    /**
     * 获取用户积分余额
     * @param userId
     * @return
     */
    @Select("SELECT integration FROM ums_member WHERE id = #{userId}")
    Integer getIntegration(Long userId);

    /**
     * 获取用户积分流水
     * @param userId
     * @return
     */
    @Select("SELECT revenue_points, remarks, transfer_payment_time FROM ums_member_account_transaction " +
            "WHERE member_id = #{userId} And flow_type = 2  ORDER BY transfer_payment_time DESC")
    List<TransactionPointsVo> getPointsFlow(Long userId);
}
