/***********************************************************************
* Project: baifenBinfa
* ProjectName: 百分兵法管理系统
* Web: http://chuanyin.com
* Author:
* Email:
* CreateTime: 2024 03/02
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Auth.HttpContextUser;
using CoreCms.Net.Configuration;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Model.ViewModels.DTO;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Extensions;
using CoreCms.Net.Utility.Helper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
namespace CoreCms.Net.Web.WebApi.Controllers
{
///
/// 支付调用接口数据
///
[Route("api/[controller]/[action]")]
[ApiController]
public class PaymentsController : ControllerBase
{
private IHttpContextUser _user;
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
private readonly ICoreCmsPaymentsServices _paymentsServices;
///
/// 构造函数
///
///
///
///
public PaymentsController(IHttpContextUser user
, ICoreCmsBillPaymentsServices billPaymentsServices
, ICoreCmsPaymentsServices paymentsServices
)
{
_user = user;
_billPaymentsServices = billPaymentsServices;
_paymentsServices = paymentsServices;
}
//公共接口====================================================================================================
#region 获取支付方式列表==================================================
///
/// 获取支付方式列表
///
///
[HttpPost]
public async Task GetList()
{
var jm = new WebApiCallBack();
var list = await _paymentsServices.QueryListByClauseAsync(p => p.isEnable == true, p => p.sort, OrderByType.Asc);
jm.status = true;
jm.data = list;
return jm;
}
#endregion
//验证接口====================================================================================================
#region 支付确认页面取信息==================================================
///
/// 支付确认页面取信息
///
///
[HttpPost]
[Authorize]
public async Task CheckPay([FromBody] CheckPayPost entity)
{
var jm = new WebApiCallBack();
if (string.IsNullOrEmpty(entity.ids))
{
jm.msg = GlobalErrorCodeVars.Code13100;
return jm;
}
jm = await _billPaymentsServices.FormatPaymentRel(entity.ids, entity.paymentType, entity.@params);
return jm;
}
#endregion
#region 获取支付单详情==================================================
///
/// 获取支付单详情
///
///
[HttpPost]
[Authorize]
public async Task GetInfo([FromBody] FMStringId entity)
{
var jm = new WebApiCallBack();
if (string.IsNullOrEmpty(entity.id))
{
jm.msg = GlobalErrorCodeVars.Code13100;
return jm;
}
var userId = entity.data.ObjectToInt(0);
jm = await _billPaymentsServices.GetInfo(entity.id, userId);
return jm;
}
#endregion
}
}