using LifePayment.Application.Contracts; using LifePayment.Domain; using LifePayment.Domain.Shared; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.WebClientInfo; using Volo.Abp.EventBus.Distributed; using Volo.Abp.Identity; using Volo.Abp.Uow; using ZeroD.Util; using ZeroD.Util.Fadd; using LifePayment.Application.Contracts; namespace LifePayment.HttpApi { [Route("api/[controller]/[action]")] [ApiController] [Authorize] public class LifePayController : AbpController { private readonly ILifePayService _lifePayService; private readonly IWebClientInfoProvider _webClientInfoProvider; public LifePayController( ILifePayService lifePayService, IWebClientInfoProvider webClientInfoProvider ) { _lifePayService = lifePayService; _webClientInfoProvider = webClientInfoProvider; } #region 查询 /// /// 获取电费面值 /// /// [HttpGet] [AllowAnonymous] public async Task GetElectricParValue() { return await _lifePayService.GetElectricParValue(); } /// /// 获取电费充值区域 /// /// [HttpGet] [AllowAnonymous] public async Task GetElectricSupportArea() { var aresResult = await _lifePayService.GetElectricSupportArea(); var parValues = await _lifePayService.GetElectricParValue(); foreach(var item in aresResult.ElectricAreaList) { var paritem = parValues.ElectricParValue.Where(r=>r.AreaName == item.CityName).FirstOrDefault(); if(paritem != null) { item.ElectricType = paritem.ElectricType; item.ParValue = paritem.ParValue; item.Rate = paritem.Rate; } } return aresResult; } /// /// 获取话费面值 /// /// [HttpGet] [AllowAnonymous] public async Task GetPhoneParValue() { return await _lifePayService.GetPhoneParValue(); } /// /// 获取折扣 /// /// [HttpGet] [AllowAnonymous] public async Task> GetRate() { return await _lifePayService.GetRate(); } /// /// 获取用户分页数据 /// /// /// [HttpPost] public async Task> GetUserPage(PageInput input) { return await _lifePayService.GetUserPage(input); } /// /// 获取订单分页数据 /// /// /// [HttpPost] public async Task> GetLifePayOrderPage(QueryLifePayOrderListInput input) { return await _lifePayService.GetLifePayOrderPage(input); } /// /// 获取我的订单分页数据 /// /// /// [HttpPost] [AllowAnonymous] public async Task> GetUserLifePayOrderPage(QueryLifePayOrderListInput input) { return await _lifePayService.GetUserLifePayOrderPage(input); } /// /// 根据订单号获取支付状态 /// /// /// [HttpGet] [AllowAnonymous] public async Task GetPayStatusByOrderNo(string orderNo) { return await _lifePayService.GetPayStatusByOrderNo(orderNo); } #endregion #region 操作 /// /// 创建生活缴费话费订单 /// /// /// [HttpPost] [AllowAnonymous] public async Task CreateLifePayPhoneOrder(CreateLifePayOrderInput input) { return await _lifePayService.CreateLifePayPhoneOrder(input); } /// /// 创建生活缴费电费订单 /// /// /// [HttpPost] [AllowAnonymous] public async Task CreateLifePayElectricOrder(CreateLifePayOrderInput input) { return await _lifePayService.CreateLifePayElectricOrder(input); } /// /// 退款生活缴费订单 /// /// /// /// [HttpPost] public async Task RefundLifePayOrder(RefundLifePayOrderInput input) { await _lifePayService.RefundLifePayOrder(input); return Constant.SUCCESS; } /// /// 设置生活缴费支付类型 /// /// /// [HttpPost] [AllowAnonymous] public async Task SetLifePayOrderPayType(SetLifePayOrderPayTypeInput input) { return await _lifePayService.SetLifePayOrderPayType(input, _webClientInfoProvider.ClientIpAddress); } /// /// 获取微信支付的JSAPI /// /// /// [HttpPost] [AllowAnonymous] public async Task GetPayOrderForJsAPI(GetPayOrderForJsAPIInput input) { return await _lifePayService.GetPayOrderForJsAPI(input, _webClientInfoProvider.ClientIpAddress); } #endregion } }