package com.ywt.alipaympapi.controller;

import com.ywt.model.PageVO;
import com.ywt.model.ResponseVO;
import com.ywt.request.pay.*;
import com.ywt.response.pay.*;
import com.ywt.alipaympapi.service.IsvPayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Desc
 */
@RestController
@Slf4j
public class TradeController {

    @Autowired
    private IsvPayService isvPayService;

    /**
     * 指定医院订单列表
     *
     * @param request
     * @return
     */
    @PostMapping("miniProRequest.pay.payHistory")
    public ResponseVO<PageVO<PayHistoryResponseData>> queryPayHistory(PayHistoryRequest request) {
        PageVO<PayHistoryResponseData> data = isvPayService.queryPayHistory(request);

        return ResponseVO.success(data);

    }

    /**
     * 订单详情
     *
     * @param request
     * @return
     */
    @PostMapping("miniProRequest.pay.payDetail")
    public ResponseVO<PayDetailResponseData> queryPayDetail(PayDetailRequest request) {
        return ResponseVO.success(isvPayService.queryPayDetail(request));
    }


    /**
     * 订单自费方式预结算查询
     *
     * @param request
     * @return
     */
    @PostMapping("miniProRequest.pay.computeSelfPaidOrder")
    public ResponseVO<ComputeSelfPaidOrderResponseData> computeSelfPaidOrder(ComputeSelfPaidOrderRequest request) {
        return ResponseVO.success(isvPayService.computeSelfPaidOrder(request));
    }

    /**
     * 订单医保方式预结算查询
     *
     * @param request
     * @return
     */
    @PostMapping("miniProRequest.pay.computeMedicarePayOrder")
    public ResponseVO<ComputeMedicarePayOrderResponseData> computeMedicarePayOrder(ComputeMedicarePayOrderRequest request) {
        return ResponseVO.success(isvPayService.computeMedicarePayOrder(request));
    }

    /**
     * 商家支付订单号获取(订单支付,自费/医保)
     *
     * @param request
     * @return
     */
    @PostMapping("miniProRequest.pay.tradeNoForOrder")
    public ResponseVO<TradeNoForOrderResponseData> tradeNoForOrder(TradeNoForOrderRequest request) {
        return ResponseVO.success(isvPayService.tradeNoForOrder(request));
    }

    /**
     * 商家订单号获取
     *
     * @param request
     * @return
     */
    @PostMapping("miniProRequest.pay.tradeNoQuery")
    public ResponseVO<TradeNoResponseData> queryTradeNo(OutTradeNoRequest request) {

        return ResponseVO.success(isvPayService.queryTradeNo(request));
    }

    /**
     * 支付结果通知
     *
     * @param request
     * @return
     */
    @PostMapping("miniProRequest.pay.tradeResult")
    public ResponseVO<TradeResultResponseData> informTradeResult(TradeResultRequest request) {
        TradeResultResponseData data = isvPayService.informTradeResult(request);
        return ResponseVO.success(data);
    }
}
