package com.ytpm.controller;

import com.ytpm.agent.param.AdRecordListParam;
import com.ytpm.agent.param.AuditUserParam;
import com.ytpm.agent.param.DitchListForIosParam;
import com.ytpm.agent.view.AgentDitchView;
import com.ytpm.agent.view.AgentUserInfo;
import com.ytpm.app.param.YtAppUserListParam;
import com.ytpm.app.view.AppUserStaticsView;
import com.ytpm.app.view.YtAppUserListView;
import com.ytpm.app.view.YtUserEcpmListView;
import com.ytpm.app.view.YtUserEcpmStatisticView;
import com.ytpm.general.Result;
import com.ytpm.general.ResultTable;
import com.ytpm.service.YtAppUserService;
import com.ytpm.utils.FeignClientInvoker;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

@Api(tags = "APP应用管理模块")
@RestController
@RequestMapping("/appUser")
public class YtAppUserController {

    @Resource
    private YtAppUserService appUserService;

    /**
     * 查询App用户列表
     * @param param 列表入参
     * @return 分页列表
     */
    @PostMapping("/getUserList")
    @ApiOperation(value = "查询App用户列表")
    public ResultTable<YtAppUserListView> selectAppUserList(@RequestBody YtAppUserListParam param, @AuthenticationPrincipal AgentUserInfo userInfo) {
        return appUserService.selectAppUserList(param, userInfo);
    }

    @PostMapping("/getRevenueByTime")
    @ApiOperation(value = "根据时间获取收益")
    public Result<BigDecimal> getRevenueByTime(@RequestBody YtAppUserListParam param, @AuthenticationPrincipal AgentUserInfo userInfo) {
        return appUserService.getRevenueByTime(param, userInfo.getUserId());
    }

    /**
     * 查询用户广告数据统计列表
     */
    @GetMapping("/staticList")
    @ApiOperation(value = "查询用户广告数据统计列表")
    public ResultTable<AppUserStaticsView> staticList(){
        return appUserService.staticList();
    }

    /**
     * 查询用户的ecpm
     */
    @PostMapping("/ecpm")
    @ApiOperation(value = "查询用户ecpm数据")
    public ResultTable<YtUserEcpmListView> ecpmList(@RequestBody AdRecordListParam param){
        return appUserService.ecpmList(param);
    }

    @PostMapping("/ecpm/statistic")
    @ApiOperation(value = "统计用户ecpm数据")
    public Result<YtUserEcpmStatisticView> ecpmStatistic(@RequestBody AdRecordListParam param){
        return appUserService.ecpmStatistic(param);
    }

    /**
     * 批量审核
     */
    @PostMapping("/batchAudit")
    @ApiOperation(value = "批量审核用户")
    public Result<String> batchAudit(@RequestBody AuditUserParam auditParam){
        return appUserService.batchAudit(auditParam);
    }
}
