package cn.wisenergy.web.admin.controller.app;

import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.AccountInfo;
import cn.wisenergy.model.app.User;
import cn.wisenergy.model.dto.AccountInfoQuery;
import cn.wisenergy.service.app.AccountService;
import cn.wisenergy.service.app.DayTaskService;
import cn.wisenergy.web.common.BaseController;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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.RestController;

/**
 * @author 86187
 */
@Api(tags = "账户管理")
@RestController
@RequestMapping("/account")
@Slf4j
public class AccountController extends BaseController {
    @Autowired
    private AccountService accountService;

    @Autowired
    private DayTaskService dayTaskService;

    @ApiOperation(value = "获取账户信息", notes = "获取账户信息", httpMethod = "GET")
    @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String")
    @GetMapping("/getByUserId")
    public R<AccountInfo> getByUserId(String userId) {
        return accountService.getByUserId(userId);
    }


    @ApiOperation(value = "获取账户分页列表", notes = "获取账户分页列表", httpMethod = "GET")
    @ApiImplicitParam(name = "query", value = "查询条件", dataType = "AccountInfoQuery")
    @GetMapping("/getList")
    public R<PageInfo<AccountInfo>> getList(AccountInfoQuery query) {
        return accountService.getList(query);
    }

    /***********************************************测试日定时任务***************************/

    @ApiOperation(value = "订单佣金", notes = "订单佣金", httpMethod = "GET")
    @GetMapping("/orderRebate")
    public R<Boolean> orderRebate() {
        return dayTaskService.orderRebate();
    }


    @ApiOperation(value = "月度肥料", notes = "月度肥料", httpMethod = "GET")
    @GetMapping("/monthManure")
    public R<Boolean> monthManure() {
        return dayTaskService.performanceCount();
    }

    @ApiOperation(value = "最大进步奖", notes = "最大进步奖", httpMethod = "GET")
    @GetMapping("/growAward")
    public R<Boolean> growAward() {
        return dayTaskService.progressPrizeCount();
    }
}
