package com.sqx.modules.app.controller.app;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.app.dao.UserDao;
import com.sqx.modules.app.entity.UserEntity;
import com.sqx.modules.app.service.UserMoneyService;
import com.sqx.modules.sys.controller.AbstractController;
import com.sqx.modules.sys.entity.SysUserEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/app/userMoney")
@Api(tags={"用户端-钱包"})
public class AppUserMoneyController extends AbstractController {

    @Autowired
    private UserMoneyService userMoneyService;
    @Autowired
    private UserDao userDao;

    @GetMapping("/selectMyMoney")
    @Login
    @ApiOperation("我的钱包余额")
    public Result selectMyMoney(@RequestAttribute Long userId) {
        return Result.success().put("data", userMoneyService.selectUserMoneyByUserId(userId));
    }



    /**
     * 我的收益
     */
    @GetMapping("/selectMyProfit")
    @Login
    @ApiOperation("我的收益")
    public Result selectMyProfit(@RequestAttribute Long userId) {
        return Result.success().put("data", userMoneyService.selectMyProfit(userId));
    }

    /**
     * 余额明细
     */
    @GetMapping("/balanceDetailed")
    @Login
    @ApiOperation("余额明细")
    public Result balanceDetailed(@RequestAttribute Long userId, Integer page, Integer limit, Integer classify) {

        return userMoneyService.balanceDetailed(userId, page, limit, classify);
    }


    /**
     * 收益明细
     */
    @GetMapping("/profitDetailed")
    @Login
    @ApiOperation("收益明细")
    public Result profitDetailed(@RequestAttribute Long userId, Long page, Long limit) {
        if (page != null || limit != null) {
            return Result.error("分页条件为空");
        } else {
            IPage ipage = new Page(page, limit);
            return Result.success().put("data", userMoneyService.profitDetailed(userId, ipage));
        }
    }



}
