package com.buy507.mall.portal.service.impl;

import com.buy507.mall.portal.dao.MyWalletMapper;
import com.buy507.mall.portal.service.MyWalletService;
import com.buy507.mall.portal.vo.WalletCashVo;
import com.buy507.mall.portal.vo.WalletPointsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MyWalletServiceImpl implements MyWalletService {

    @Autowired
    private MyWalletMapper myWalletMapper;

    /**
     * 获取现金余额和流水
     * @param userId
     * @return
     */
    @Override
    public WalletCashVo getBalanceAndCashFlow(Long userId) {

        WalletCashVo walletCashVo = new WalletCashVo();
        //获取现金余额
        walletCashVo.setBalance(myWalletMapper.getBalance(userId));
        //获取现金流水
        walletCashVo.setCashVoList(myWalletMapper.getCashFlow(userId));

        return walletCashVo;
    }

    /**
     * 获取积分余额和流水
     * @param userId
     * @return
     */
    @Override
    public WalletPointsVo getIntegrationAndPointsFlow(Long userId) {
        WalletPointsVo walletPointsVo = new WalletPointsVo();

        //获取积分余额
        walletPointsVo.setIntegration(myWalletMapper.getIntegration(userId));
        //获取积分流水
        walletPointsVo.setPointsVoList(myWalletMapper.getPointsFlow(userId));

        return walletPointsVo;
    }
}
