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


import com.neusoft.smart.pos.constants.DictionaryConstant;
import com.neusoft.smart.pos.dto.trade.request.GetMemberOrderDetailsRequest;
import com.neusoft.smart.pos.dto.trade.request.GetShopOrderDetailsRequest;
import com.neusoft.smart.pos.dto.trade.request.GetShopOrderSummaryRequest;
import com.neusoft.smart.pos.dto.trade.response.GetShopOrderDetailsResponse;
import com.neusoft.smart.pos.dto.trade.response.GetShopOrderSummaryResponse;
import com.neusoft.smart.pos.framework.bean.PaginationExtendBean;
import com.neusoft.smart.pos.framework.dto.ResponseData;
import com.neusoft.smart.pos.gateway.service.OrderStatisticsService;
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.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(value = "订单统计使用rest接口", description = "订单统计使用rest接口")
@RestController
@RequestMapping(path = "/unionService/orderStatistics")
@Validated
public class OrderStatisticsController {

	@Autowired
	private OrderStatisticsService orderStatisticsService;

	@ApiOperation(value = "门店订单汇总查询接口(订单管理页面接口)", notes = "门店订单汇总查询接口(订单管理页面接口)")
	@GetMapping("/shopOrderSummary")
	public ResponseData<PaginationExtendBean<GetShopOrderSummaryResponse>> queryShopOrderSummary(@Valid @ModelAttribute GetShopOrderSummaryRequest shopOrderSummaryRequest, BindingResult bindingResult) {
		return new ResponseData<>(orderStatisticsService.queryShopOrderSummary(shopOrderSummaryRequest));
	}

	@ApiOperation(value = "门店订单详情统计查询接口(门店订单详情页面接口)", notes = "门店订单详情统计查询接口(门店订单详情页面接口)")
	@GetMapping("/shopOrderDetails")
	public ResponseData<GetShopOrderDetailsResponse> queryShopOrderDetails(@Valid @ModelAttribute GetShopOrderDetailsRequest shopOrderDetailsRequest, BindingResult bindingResult) {
		return new ResponseData<>(orderStatisticsService.queryShopOrderDetails(shopOrderDetailsRequest));
	}

	@ApiOperation(value = "员工订单详情统计查询接口(门店订单详情页面接口)", notes = "门店订单详情统计查询接口(门店订单详情页面接口)")
	@GetMapping("/memberOrderDetails")
	public ResponseData<GetShopOrderDetailsResponse> queryMemberOrderDetails(@Valid @ModelAttribute GetMemberOrderDetailsRequest memberOrderDetailsRequest, BindingResult bindingResult) {
		return new ResponseData<>(orderStatisticsService.queryMemberOrderDetails(memberOrderDetailsRequest));
	}

	@ApiOperation(value = "门店充值订单列表统计查询接口", notes = "门店充值订单列表统计查询接口")
	@GetMapping("/shopRechargeOrderDetails")
	public ResponseData<GetShopOrderDetailsResponse> queryShopRechargeOrderDetails(@Valid @ModelAttribute GetShopOrderDetailsRequest shopOrderDetailsRequest, BindingResult bindingResult) {
		shopOrderDetailsRequest.setOrderType(DictionaryConstant.ORDER_TYPE_HYCZ.getCode());
		return new ResponseData<>(orderStatisticsService.queryShopOrderDetails(shopOrderDetailsRequest));
	}
}
	