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


import com.neusoft.smart.pos.dto.payment.request.*;
import com.neusoft.smart.pos.dto.payment.response.*;
import com.neusoft.smart.pos.framework.dto.ResponseData;
import com.neusoft.smart.pos.payment.service.PayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "支付管理使用rest接口", description = "支付管理使用rest接口")
@RestController
@RequestMapping(path = "/pay")
public class PayController {

	@Autowired
	private PayService payService;


    @ApiOperation(value = "第三方支付单生成接口(支付二维码生成接口)", notes = "第三方支付单生成接口")
    @PostMapping("/generateOrder")
    public ResponseData<PostGenerateOrderResponse> generateOrder(@RequestBody PostGenerateOrderRequest generateOrderRequest) {
        return new ResponseData<>(payService.createPayOrder(generateOrderRequest));
    }

    @ApiOperation(value = "第三方支付单信息查询接口", notes = "根据商户号订单编号查询预付单信息方法")
    @PostMapping("/queryOrder")
    public ResponseData<PostQueryOrderResponse> queryOrder(@RequestBody PostQueryOrderRequest queryOrderRequest) {
        return new ResponseData<>(payService.queryOrder(queryOrderRequest));
    }

    @ApiOperation(value = "第三方支付单取消接口", notes = "根据商户号订单编号取消预付单信息方法")
    @PostMapping("/cancelOrder")
    public ResponseData<PostCancelOrderResponse> cancelOrder(@RequestBody PostCancelOrderRequest cannelOrderRequest) {
        return new ResponseData<>(payService.cancelOrder(cannelOrderRequest));
    }

    @ApiOperation(value = "第三方支付单退款申请接口", notes = "根据商户号订申请退款方法")
    @PostMapping("/refundOrder")
    public ResponseData<PostRefundOrderResponse> refundOrder(@RequestBody PostRefundOrderRequest refundOrderRequest) {
        return new ResponseData<>(payService.refundOrder(refundOrderRequest));
    }

    @ApiOperation(value = "第三方支付单撤销接口", notes = "根据商户号订单编号撤销预付单信息方法")
    @PostMapping("/reverseOrder")
    public ResponseData<PostReverseOrderResponse> reverseOrder(@RequestBody PostReverseOrderRequest reverseOrderRequest) {
        return new ResponseData<>(payService.reverseOrder(reverseOrderRequest));
    }
    
    
    @ApiOperation(value = "第三方人脸支付初始化接口", notes = "人脸支付初始化方法")
    @PostMapping("/initFacePay")
    public ResponseData<PostInitFacePayResponse> initFacePay(@RequestBody PostInitFacePayRequest initFacePayRequest){
        return new ResponseData<>(payService.initFacePay(initFacePayRequest));
    }
    
}
	