package com.zhongshu.card.server.core.controller.openAPI.order;

import com.github.microservice.net.ResultContent;
import com.github.microservice.staticVariable.OpenApiMark;
import com.zhongshu.card.client.openApi.model.ExpenseFlowOpenApiModel;
import com.zhongshu.card.client.openApi.model.order.MarkPaidParam;
import com.zhongshu.card.client.openApi.model.order.OrderCreateParam;
import com.zhongshu.card.client.openApi.params.ExpenseFlowOpenApiSearch;
import com.zhongshu.card.client.openApi.params.OrderNoParam;
import com.zhongshu.card.client.openApi.params.PaymentNoParam;
import com.zhongshu.card.server.core.service.openAPI.order.OrderOpenApiService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author TRX
 * @date 2024/6/5
 */
@RestController
@RequestMapping("/" + OpenApiMark.fullCardOpenAPI + "/v1/orderManager")
@Tag(name = "openAPI-订单管理")
public class ExpenseFlowOpenApiController {

    @Autowired
    private OrderOpenApiService expenseFlowOpenApiService;

    @Operation(summary = "创建订单", description = "创建订单")
    @RequestMapping(value = {"createOrder"}, method = {RequestMethod.POST})
    public ResultContent createOrder(@RequestBody OrderCreateParam param) {
        return expenseFlowOpenApiService.createOrder(param);
    }

    @Operation(summary = "订单列表-分页查询", description = "订单列表-分页查询")
    @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
    public ResultContent<Page<ExpenseFlowOpenApiModel>> page(@RequestBody ExpenseFlowOpenApiSearch param) {
        return expenseFlowOpenApiService.page(param);
    }

    @Operation(summary = "订单详情（支付订单号）", description = "订单详情")
    @RequestMapping(value = {"getDetailByPaymentNo"}, method = {RequestMethod.POST})
    public ResultContent<ExpenseFlowOpenApiModel> getDetailByPaymentNo(@RequestBody PaymentNoParam param) {
        return expenseFlowOpenApiService.getDetailByPaymentNo(param);
    }

    @Operation(summary = "订单详情(订单号查询)", description = "订单详情")
    @RequestMapping(value = {"getDetailByOrderNo"}, method = {RequestMethod.POST})
    public ResultContent<ExpenseFlowOpenApiModel> getDetailByOrderNo(@RequestBody OrderNoParam param) {
        return expenseFlowOpenApiService.getDetailByOrderNo(param);
    }

    @Operation(summary = "关闭订单(支付订单号)", description = "关闭订单")
    @RequestMapping(value = {"closeOrderByPaymentNo"}, method = {RequestMethod.POST})
    public ResultContent closeOrderByPaymentNo(@RequestBody PaymentNoParam param) {
        return expenseFlowOpenApiService.closeOrderByPaymentNo(param);
    }

    @Operation(summary = "关闭订单(订单号)", description = "关闭订单")
    @RequestMapping(value = {"closeOrderByOrderNo"}, method = {RequestMethod.POST})
    public ResultContent closeOrderByOrderNo(@RequestBody OrderNoParam param) {
        return expenseFlowOpenApiService.closeOrderByOrderNo(param);
    }

    @Operation(summary = "标记订单已支付(订单号)", description = "标记订单已支付")
    @RequestMapping(value = {"markOrderPaid"}, method = {RequestMethod.POST})
    public ResultContent markOrderPaid(@RequestBody MarkPaidParam param) {
        return expenseFlowOpenApiService.markOrderPaid(param);
    }

}
