zhengyuxuan
2025-04-02 95fe2c54a45fae507247eb92c8f60af9c892159f
LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
@@ -1,4 +1,8 @@
using LifePayment.Application.Contracts;
using Alipay.AopSdk.F2FPay.Model;
using LifePayment.Application.Contracts;
using LifePayment.Application.LifePay;
using LifePayment.Domain;
using LifePayment.Domain.Common;
using LifePayment.Domain.Shared;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -22,17 +26,23 @@
        private readonly ILifePayService _lifePayService;
        private readonly IStatisticsService _statisticsService;
        private readonly IWebClientInfoProvider _webClientInfoProvider;
        private readonly ICommonService _commonService;
        private readonly ILifePayOrderService _lifePayOrderService;
        private readonly ILogger<LifePayController> _logger;
        public LifePayController(
              ILifePayService lifePayService,
              IStatisticsService statisticsService,
              IWebClientInfoProvider webClientInfoProvider
            , ILogger<LifePayController> logger
              IWebClientInfoProvider webClientInfoProvider,
              ICommonService commonService,
              ILifePayOrderService lifePayOrderService,
              ILogger<LifePayController> logger
              )
        {
            _lifePayService = lifePayService;
            _statisticsService = statisticsService;
            _webClientInfoProvider = webClientInfoProvider;
            _commonService = commonService;
            _lifePayOrderService = lifePayOrderService;
            _logger = logger;
        }
@@ -41,12 +51,49 @@
        /// <summary>
        /// 获取顶部统计数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [HttpPost]
        [AllowAnonymous]
        public async Task<TopStatisticsOutput> GetTopStatistics()
        public async Task<TopStatisticsOutput> GetTopStatistics(TopStatisticsInput input)
        {
            return await _statisticsService.GetTopStatistics();
            return await _statisticsService.GetTopStatistics(input.ChannleList);
        }
        /// <summary>
        /// 获取30日收款统计
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<ReceiptsListOutPut> GetReceiptsList(TopStatisticsInput input)
        {
            return await _statisticsService.GetReceiptsList(input.ChannleList);
        }
        /// <summary>
        /// 渠道数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<ChannelDataListOutPut> GetChannelDataList(TopStatisticsInput input)
        {
            return await _statisticsService.GetChannelDataList(input.ChannleList);
        }
        /// <summary>
        /// 30日佣金列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<ChannlesRakeListOutPut> GetChannlesRakeList(TopStatisticsInput input)
        {
            return await _statisticsService.GetChannlesRakeList(input.ChannleList);
        }
        /// <summary>
@@ -153,9 +200,8 @@
        /// 获取渠道折扣
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [HttpPost]
        [AllowAnonymous]
        [ChannelFilter]
        public async Task<ChannelRateOutput> GetChannelRate(ChannelsBaseInput input)
        {
            return await _lifePayService.GetChannelRate(input);
@@ -183,6 +229,16 @@
            return await _lifePayService.GetIntroInfo(type);
        }
        /// <summary>
        /// 获取在线客服
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<string> GetOnlineService()
        {
            return await _commonService.GetOnlineService();
        }
        /// <summary>
        /// 获取用户分页数据
@@ -413,7 +469,178 @@
            return data;
        }
        /// <summary>
        /// 获取消费流水分页数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageOutput<LifePayConsumptionListOutput>> GetLifePayConsumptionPage(LifePayConsumptionPageInput input)
        {
            return await _lifePayOrderService.GetLifePayConsumptionPage(input);
        }
        /// <summary>
        /// 获取充值流水分页数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageOutput<LifePayRechargeReceiptsListOutput>> GetLifePayRechargeReceiptsPage(LifePayRechargeReceiptsPageInput input)
        {
            return await _lifePayOrderService.GetLifePayRechargeReceiptsPage(input);
        }
        /// <summary>
        /// 获取渠道分佣分页列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageOutput<LifePayChannlesRakeListOutput>> GetLifePayChannlesRakePage(LifePayChannlesRakePageInput input)
        {
            return await _lifePayOrderService.GetLifePayChannlesRakePage(input);
        }
        /// <summary>
        /// 导出渠道分佣Excel
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> GetLifePayChannlesRakePageExport(LifePayChannlesRakePageInput input)
        {
            var data = await _lifePayOrderService.GetLifePayChannlesRakePageExport(input);
            if (data.Any())
            {
                var bytes = ExcelHelper.ListToByteForExcel(data, "xlsx");
                return File(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "渠道分佣" + ".xlsx");
            }
            return Json(default);
        }
        /// <summary>
        /// 获取收支流水分页数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageOutput<LifePayExpensesReceiptsListOutput>> GetLifePayExpensesReceiptsPage(LifePayExpensesReceiptsPageInput input)
        {
            return await _lifePayOrderService.GetLifePayExpensesReceiptsPage(input);
        }
        /// <summary>
        /// 查询支付宝支付订单信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<Alipay.EasySDK.Payment.Common.Models.AlipayTradeQueryResponse> QueryAlipayTrade(OrderInQuiryInput input)
        {
            var res = await _lifePayService.QueryAlipayTrade(input);
            //await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput()
            //{
            //    OrderNo = input.OutTradeNo,
            //    OutOrderNo = res.TradeNo,
            //    LifePayType = LifePayTypeEnum.AliPay,
            //    ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses,
            //    Amount = Convert.ToDecimal(res.ReceiptAmount)
            //});
            return res;
        }
        /// <summary>
        /// 查询支付宝退款订单信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<Alipay.EasySDK.Payment.Common.Models.AlipayTradeFastpayRefundQueryResponse> QueryAlipayTradeRefund(OrderInQuiryInput input)
        {
            return await _lifePayService.QueryAlipayTradeRefund(input);
        }
        /// <summary>
        /// 查询微信退款信息
        /// </summary>
        /// <param name="outTradeNo"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<WxPayDomesticRefundsQueryReponse> WxPayDomesticRefundsQuery(string outTradeNo)
        {
            var res = await _lifePayService.WxPayDomesticRefundsQuery(outTradeNo);
            if (res.Code == WxpayResultCode.Success)
            {
                await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput()
                {
                    OrderNo = res.OutTradeNo,
                    OutRefundNo = res.RefundId,
                    OutOrderNo = res.TransactionId,
                    LifePayType = LifePayTypeEnum.WxPay,
                    ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses,
                    Amount = Convert.ToDecimal(res.Amount.Total)
                });
            }
            return res;
        }
        /// <summary>
        /// 查询微信订单信息
        /// </summary>
        /// <param name="outTradeNo"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<WxPayTradeQueryReponse> WxPayTradeQuery(string outTradeNo)
        {
            var res = await _lifePayService.WxPayTradeQuery(outTradeNo);
            await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput()
            {
                OrderNo = res.OutTradeNo,
                OutOrderNo = res.TransactionId,
                LifePayType = LifePayTypeEnum.WxPay,
                ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses,
                Amount = Convert.ToDecimal(res.Amount.Total)
            });
            return res;
        }
        /// <summary>
        /// 同步订单收支信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task GetAllLifePayExpensesReceipts()
        {
            await _lifePayOrderService.GetAllLifePayExpensesReceipts();
        }
        /// <summary>
        /// 同步订单
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task GetAllChannlesRake()
        {
            await _lifePayOrderService.GetAllChannlesRake();
        }
        /// <summary>
        /// 统计交易流水
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task GetAllLifePayConsumption()
        {
            await _lifePayOrderService.GetAllLifePayConsumption();
        }
        #endregion
        #region 操作
@@ -455,6 +682,17 @@
        public async Task<CreateLifePayOrderOutput> CreateLifePayGasOrder(CreateLifePayOrderInput<LifeGasData> input)
        {
            return await _lifePayService.CreateLifePayGasOrder(input);
        }
        /// <summary>
        /// 修改实际到账金额
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateLifePayOrderActualReceivedAmount(UpdateLifePayOrderInput input)
        {
            return await _lifePayService.UpdateLifePayOrderActualReceivedAmount(input);
        }
        /// <summary>
@@ -586,6 +824,30 @@
        }
        /// <summary>
        /// 在线客服配置
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateOnlineService(OnlineServiceInput input)
        {
            await _commonService.UpdateOnlineService(input);
            return Constant.SUCCESS;
        }
        /// <summary>
        /// 上传充值流水
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddUpdatePayRechargeReceipts(AddUpdatePayRechargeReceiptsInput input)
        {
            await _lifePayOrderService.AddUpdatePayRechargeReceipts(input);
            return Constant.SUCCESS;
        }
        /// <summary>
        /// 设置生活缴费支付类型
        /// </summary>
        /// <param name="input"></param>