package com.miaxis.app.controller.extension;

import com.miaxis.common.constant.Constants;
import com.miaxis.common.core.controller.BaseController;
import com.miaxis.common.core.domain.Response;
import com.miaxis.common.core.domain.entity.UserInfo;
import com.miaxis.common.core.page.ResponsePageInfo;
import com.miaxis.common.utils.SecurityUtils;
import com.miaxis.extension.service.IWxExtensionIncomeService;
import com.miaxis.extension.vo.ExtensionIncomeVo;
import com.miaxis.extension.vo.WxGzhExtensionIncomeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wwl
 * @version 1.0
 * @date 2021/11/29 15:58
 */
@RestController
@RequestMapping(Constants.STUDENT_PREFIX + "/extension/income")
@Api(tags={"【H5-分成收益】"})
@AllArgsConstructor
public class WxExtensionIncomeController extends BaseController {

    private final IWxExtensionIncomeService extensionIncomeService;

    /**
     * 查询收益列表
     */
    @GetMapping(value = "/extensionIncomeList")
    @ApiOperation("查询收益列表")
    @ApiImplicitParam(name = "nickName", value = "微信昵称", dataType = "string", required = false)
    public ResponsePageInfo<WxGzhExtensionIncomeVo> extensionIncomeList(String nickName) {
        UserInfo userInfo = SecurityUtils.getLoginUser().getStudent();
        startPage();
        List<WxGzhExtensionIncomeVo> incomeDtos = extensionIncomeService.extensionIncomeList(userInfo.getOpenid(),nickName);
        return toResponsePageInfo(incomeDtos);
    }


    /**
     * 查询收益金额（总金额、已提现金额、未提现金额）
     */
    @GetMapping(value = "/extensionIncomePrice")
    @ApiOperation("查询收益金额（总金额、已提现金额、未提现金额）")
    public Response<ExtensionIncomeVo> extensionIncomePrice() {
        UserInfo userInfo = SecurityUtils.getLoginUser().getStudent();
        ExtensionIncomeVo incomePrice = extensionIncomeService.extensionIncomePrice(userInfo.getOpenid());
        return Response.success(incomePrice);
    }



}
