package com.buy507.mall.portal.controller;

import com.buy507.mall.common.api.CommonResult;
import com.buy507.mall.portal.domain.WithdrawApplyParam;
import com.buy507.mall.portal.service.MyWalletService;
import com.buy507.mall.portal.service.UmsMemberService;
import com.buy507.mall.portal.vo.WalletCashVo;
import com.buy507.mall.portal.vo.WalletPointsVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

    @Autowired
    private MyWalletService myWalletService;

    @Autowired
    private UmsMemberService memberService;


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


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

    @ApiOperation("会员提现申请")
    @PostMapping(value = "/withdraw")
    public CommonResult withdrawApply(@RequestBody WithdrawApplyParam applyParam) {
        return memberService.withdrawApply(applyParam);
    }
}
