package com.buy507.mall.portal.controller;

import com.buy507.mall.common.api.CommonResult;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wallet")
public class MyWalletController {

    @Autowired
    private MyWalletService myWalletService;

    /**
     * 获取现金余额和流水
     * @param userId
     * @return
     */
    @GetMapping("/balance")
    public CommonResult<WalletCashVo> getBalance(@RequestParam Long userId){
        WalletCashVo walletCashVo = myWalletService.getBalanceAndCashFlow(userId);
        return CommonResult.success(walletCashVo);
    }

    /**
     * 获取积分余额和流水
     * @param userId
     * @return
     */
    @GetMapping("/points")
    public CommonResult<WalletPointsVo> getIntegration(@RequestParam Long userId){
        WalletPointsVo walletPointsVo = myWalletService.getIntegrationAndPointsFlow(userId);
        return CommonResult.success(walletPointsVo);
    }
}
