package com.neusoft.smart.pos.gateway.controller;


import com.neusoft.smart.pos.dto.trade.request.GetDailyRequest;
import com.neusoft.smart.pos.dto.trade.request.GetPayTypeTradeSummaryRequest;
import com.neusoft.smart.pos.dto.trade.request.GetShopTradeSummaryRequest;
import com.neusoft.smart.pos.dto.trade.response.GetDailyResponse;
import com.neusoft.smart.pos.dto.trade.response.GetPayChannelSummaryForPosResponse;
import com.neusoft.smart.pos.dto.trade.response.GetPayTypeTradeSummaryResponse;
import com.neusoft.smart.pos.dto.trade.response.GetShopTradeSummaryResponse;
import com.neusoft.smart.pos.framework.dto.ResponseData;
import com.neusoft.smart.pos.gateway.service.TradeStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(value = "交易统计使用rest接口", description = "交易统计使用rest接口")
@RestController
@RequestMapping(path = "/unionService/tradeStatistics")
@Validated
public class TradeStatisticsController {

	@Autowired
	private TradeStatisticsService tradeStatisticsService;

	@ApiOperation(value = "交易日报统计接口", notes = "交易日报统计接口")
	@GetMapping("/daily")
	public ResponseData<GetDailyResponse> queryPayDaily(@Valid @ModelAttribute GetDailyRequest dailyRequest, BindingResult bindingResult) {
		return new ResponseData<>(tradeStatisticsService.queryPayDaily(dailyRequest));
	}

	@ApiOperation(value = "POS端日交易汇总查询接口", notes = "POS端日交易汇总查询接口")
	@GetMapping("/payChannelSummaryForPos")
	public ResponseData<GetPayChannelSummaryForPosResponse> queryPayChannelSummaryForPos(
			@RequestParam(value="serialNo",defaultValue = "") String serialNo
			, @RequestParam(value="dateTime",defaultValue = "") String dateTime
			, @RequestParam(value="endTime",defaultValue = "") String endTime
			, @RequestParam(value="startTime",defaultValue = "") String startTime
			, @RequestParam(value="timeMode",defaultValue = "2") String timeMode) {
		return new ResponseData<>(tradeStatisticsService.queryPayChannelSummaryForPos(serialNo,dateTime,endTime,startTime,timeMode));
	}

	@ApiOperation(value = "门店交易统计查询接口(交易统计接口)", notes = "门店交易统计查询接口(交易统计接口)")
	@GetMapping("/shopTradeSummary")
	public ResponseData<GetShopTradeSummaryResponse> queryShopTradeSummary(@Valid @ModelAttribute GetShopTradeSummaryRequest shopTradeSummaryRequest, BindingResult bindingResult) {
		return new ResponseData<>(tradeStatisticsService.queryShopTradeSummary(shopTradeSummaryRequest));
	}
	
	@ApiOperation(value = "门店交易统计查询接口(交易统计接口)", notes = "门店交易统计查询接口(交易统计接口)")
	@GetMapping("/payTypeTradeSummary")
	public ResponseData<GetPayTypeTradeSummaryResponse> queryPayTypeTradeSummary(@Valid @ModelAttribute GetPayTypeTradeSummaryRequest payTypeTradeSummaryRequest, BindingResult bindingResult) {
		return new ResponseData<>(tradeStatisticsService.queryPayTypeTradeSummary(payTypeTradeSummaryRequest));
	}
}
	