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


import com.neusoft.smart.pos.dto.trade.request.GetBillDetailsRequest;
import com.neusoft.smart.pos.dto.trade.response.GetAcceptBillsResponse;
import com.neusoft.smart.pos.dto.trade.response.GetBillDetailsResponse;
import com.neusoft.smart.pos.dto.trade.response.GetNoAcceptBillsResponse;
import com.neusoft.smart.pos.framework.dto.ResponseData;
import com.neusoft.smart.pos.gateway.service.BillService;
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;
import java.util.List;

@Api(value = "账单管理使用rest接口", description = "账单管理使用rest接口")
@RestController
@RequestMapping(path = "/unionService/bill")
@Validated
public class BillController {

	@Autowired
	private BillService billService;
	
	@ApiOperation(value = "未归档账单数据查询使用接口", notes = "未归档账单数据查询使用方法")
	@GetMapping("/noAcceptBills")
	public ResponseData<GetNoAcceptBillsResponse> queryNoAcceptBills(@RequestParam(value="billNumber",defaultValue = "") String billNumber
			,@RequestParam(value="rebuild",defaultValue = "0") String rebuild){
		return new ResponseData<>(billService.queryNoAcceptBills(billNumber,rebuild));
	}
	
	@ApiOperation(value = "已归档账单数据查询使用接口", notes = "已归档账单数据查询使用方法")
	@GetMapping("/acceptBills")
	public ResponseData<GetAcceptBillsResponse> queryAcceptBills(
			@RequestParam(value = "shopIds",defaultValue = "") List<Integer> shopIds
			,@RequestParam(value="startTime",defaultValue = "") String startTime
			,@RequestParam(value="endTime",defaultValue = "") String endTime){
		return new ResponseData<>(billService.queryAcceptBills(shopIds,startTime,endTime));
	}
	
	@ApiOperation(value = "结算单详情数据查询使用接口", notes = "结算单详情数据查询使用方法")
	@GetMapping("/billDetails")
	public ResponseData<GetBillDetailsResponse> queryBillDetails(@Valid @ModelAttribute GetBillDetailsRequest billDetailsRequest, BindingResult bindingResult){
		return new ResponseData<>(billService.queryBillDetails(billDetailsRequest));
	}
}
	