using CloudGaming.Api.Base;
using CloudGaming.Code.Mall;
using CloudGaming.DtoModel.JY;
using CloudGaming.DtoModel.Mall;

using HuanMeng.DotNetCore.Base;

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

using Newtonsoft.Json;

namespace CloudGaming.Api.Controllers;


/// <summary>
/// 
/// </summary>
public class PaymentController : CloudGamingControllerBase
{
    public PaymentController(IServiceProvider _serviceProvider) : base(_serviceProvider)
    {
    }

    /// <summary>
    /// 创建订单
    /// </summary>
    /// <param name="intentOrder"></param>
    /// <returns></returns>
    [HttpPost]
    [Authorize]
    public async Task<IntentOrderDto> CreateOrder([FromBody] IntentOrderRequest intentOrder)
    {
        OrderBLL orderBLL = new OrderBLL(ServiceProvider);
        return await orderBLL.CreateOrder(intentOrder.PaymentMethod, intentOrder.ProductId);
    }


    /// <summary>
    /// 获取订单状态
    /// </summary>
    /// <param name="orderId"></param>
    /// <returns></returns>
    [HttpGet]
    [Authorize]
    public async Task<BaseResponse<bool>> GetOrderRewardsInfo(string orderId)
    {
    
        OrderBLL orderBLL = new OrderBLL(ServiceProvider);
        return await orderBLL.GetOrderRewardsInfo(orderId);
    }
}
