62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using HuanMeng.DotNetCore.Base;
|
|
using HuanMeng.MiaoYu.Code.Order;
|
|
using HuanMeng.MiaoYu.Model.Dto.Order;
|
|
using HuanMeng.MiaoYu.WebApi.Base;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace HuanMeng.MiaoYu.WebApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 订单
|
|
/// </summary>
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
|
|
public class PaymentController : MiaoYuControllerBase
|
|
{
|
|
public PaymentController(IServiceProvider _serviceProvider) : base(_serviceProvider)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建订单
|
|
/// </summary>
|
|
/// <param name="intentOrder"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<BaseResponse<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]
|
|
public async Task<BaseResponse<bool>> GetOrderRewardsInfo(string orderId)
|
|
{
|
|
OrderBLL orderBLL = new OrderBLL(ServiceProvider);
|
|
return await orderBLL.GetOrderRewardsInfo(orderId);
|
|
}
|
|
/// <summary>
|
|
/// 购买商城物品
|
|
/// </summary>
|
|
/// <param name="buyProductRequest"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<BaseResponse<bool>> BuyProduct([FromBody] BuyProductRequest buyProductRequest)
|
|
{
|
|
OrderBLL orderBLL = new OrderBLL(ServiceProvider);
|
|
return await orderBLL.BuyProduct(buyProductRequest.ProductId, buyProductRequest.BuyCount ?? 1);
|
|
}
|
|
|
|
}
|
|
}
|