package com.iformall.controller;

import com.iformall.common.ResultData;
import com.iformall.service.WxMerchantTradeDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;

@RestController
@RequestMapping("/api/wxMerchantTradeDaily")
@Api(description = "解单相关接口")
public class WxMerchantTradeDailyController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxMerchantTradeDailyService wxMerchantTradeDailyService;


    @ApiOperation("获得当日解单")
    @GetMapping("/getVolume")
    public ResultData getVolume() {
        return wxMerchantTradeDailyService.getVolume(getUser().getId());
    }

    @ApiOperation("获得近7日解单")
    @GetMapping("/getVolumeOfWeek")
    public ResultData getVolumeOfWeek() {
        return wxMerchantTradeDailyService.getVolumeOfWeek(getUser().getId());
    }

    @ApiOperation("上报每日解单")
    @GetMapping("/reportDailyVolume")
    @ApiImplicitParam(name = "volume", value = "总金额（分）", dataType = "Integer", paramType = "query", required = true)
    public ResultData saveDailyTradingVolume(Integer volume) {
        return wxMerchantTradeDailyService.saveDailyTradingVolume(getUser().getId(), volume);
    }


}
