From 4cb523bee320f335100c63df4c8f51ed09fca9eb Mon Sep 17 00:00:00 2001
From: lingling <kety1122@163.com>
Date: 星期四, 20 三月 2025 16:47:07 +0800
Subject: [PATCH] Merge branch 'master' of http://120.26.58.240:8888/r/LifePaymentApi

---
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs |   76 +++++++++++++++++++++++++-------------
 1 files changed, 50 insertions(+), 26 deletions(-)

diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index eb4913d..037418e 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -21,6 +21,8 @@
 using ZeroD.Util;
 using Alipay.EasySDK.Payment.Common.Models;
 using static LifePayment.Domain.Shared.LifePaymentConstant;
+using ZeroD.Util.Fadd;
+using Nest;
 
 namespace LifePayment.Application;
 
@@ -167,7 +169,8 @@
     {
         return await _channelFilter.GetChannelLifePayUserFilter(_lifePayUserRepository).Where(x => x.IsDeleted == false)
             .WhereIf(!string.IsNullOrEmpty(input.QueryCondition), x => x.PhoneNumber.Contains(input.QueryCondition) || x.Name.Contains(input.QueryCondition))
-            .WhereIf(input.CreationTime.HasValue, x => x.CreationTime.ToString("yyyy-MM-dd") == input.CreationTime.Value.ToString("yyyy-MM-dd"))
+            .WhereIf(input.CreationTimeBegin.HasValue, x => x.CreationTime >= input.CreationTimeBegin)
+            .WhereIf(input.CreationTimeEnd.HasValue, x => x.CreationTime <= input.CreationTimeEnd)
                                             .Select(x =>
                                                    new UserListOutput()
                                                    {
@@ -266,31 +269,50 @@
 
     public async Task<LifePayOrderOutput> GetLifePayOrderDetail(string orderNo)
     {
-        var result = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo)
-                                            .Select(x =>
-                                                    new LifePayOrderOutput
-                                                    {
-                                                        DiscountAmount = x.DiscountAmount,
-                                                        FinishTime = x.FinishTime,
-                                                        Id = x.Id,
-                                                        LifePayOrderStatus = x.LifePayOrderStatus,
-                                                        LifePayOrderType = x.LifePayOrderType,
-                                                        LifePayType = x.LifePayType,
-                                                        OrderNo = x.OrderNo,
-                                                        PayAmount = x.PayAmount,
-                                                        RechargeAmount = x.RechargeAmount,
-                                                        PayStatus = x.PayStatus,
-                                                        PayTime = x.PayTime,
-                                                        OrderParamDetailJsonStr = x.OrderParamDetailJsonStr,
-                                                        RefundCredentialsImgUrl = x.RefundCredentialsImgUrl.GetOssPath(),
-                                                        CreationTime = x.CreationTime,
-                                                        RefundCheckRemark = x.RefundCheckRemark,
-                                                        RefundApplyRemark = x.RefundApplyRemark,
-                                                        RefundTime = x.RefundTime,
-                                                        ACOOLYOrderNo = x.ACOOLYOrderNo,
-                                                    })
-                                            .FirstOrDefaultAsync();
-        CheckExtensions.IfTrueThrowUserFriendlyException(result == null, "璁㈠崟涓嶅瓨鍦�");
+        var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
+        var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
+        var channle = await _lifePayChannlesRep.FirstOrDefaultAsync(r => r.ChannlesNum == order.ChannelId);
+        var premium = await _lifePayPremiumRepository.Where(x => x.IsDeleted == false && x.PremiumType == order.LifePayType).FirstOrDefaultAsync();
+        CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
+        var user = await _lifePayUserRepository.FirstOrDefaultAsync(x => x.Id == order.UserId);
+        
+        var channlesRakePrice = (order.PayAmount - (order.PlatformDeductionAmount == null ? 0 : order.PlatformDeductionAmount)) * channle.ChannlesRakeRate / 100;
+        var result = new LifePayOrderOutput()
+                {
+            UserName = user.Name,
+            UserPhoneNumber = user.PhoneNumber,
+            DiscountAmount = order.DiscountAmount,
+            FinishTime = order.FinishTime,
+            Id = order.Id,
+            OutOrderNo = order.OutOrderNo,
+            LifePayChannle = channle.ChannlesName,
+            LifePayOrderStatus = order.LifePayOrderStatus,
+            LifePayOrderType = order.LifePayOrderType,
+            LifePayType = order.LifePayType,
+            OrderNo = order.OrderNo,
+            PayAmount = order.PayAmount,
+            RechargeAmount = order.RechargeAmount,
+            PayStatus = order.PayStatus,
+            PayTime = order.PayTime,
+            OrderParamDetailJsonStr = order.OrderParamDetailJsonStr,
+            RefundCredentialsImgUrl = order.RefundCredentialsImgUrl.GetOssPath(),
+            CreationTime = order.CreationTime,
+            RefundCheckRemark = order.RefundCheckRemark,
+            RefundApplyRemark = order.RefundApplyRemark,
+            RefundTime = order.RefundTime,
+            ACOOLYOrderNo = order.ACOOLYOrderNo,
+            LifePayRefundStatus = order.LifePayRefundStatus,
+            ActualRechargeAmount = order.ActualRechargeAmount,
+            RefundPrice = order.RefundPrice,
+            PlatformRate = platformRate.Rate,
+            PlatformPrice = order.PlatformDeductionAmount,
+            ChannleRate = channle.ChannlesRate,
+            ChannlesRakeRate = channle.ChannlesRakeRate,
+            ChannlesRakePrice = channlesRakePrice.HasValue ? 0 : Math.Round(channlesRakePrice.Value, 2),
+            PremiumRate = premium == null ? 0 : premium.Rate,
+            PremiumPrice = premium == null ? 0 : Math.Round(order.PayAmount * premium.Rate, 2),
+            Profit = (order.PayAmount - order.PlatformDeductionAmount) * (1.00m - channle.ChannlesRakeRate / 100) - (premium == null ? 0 : Math.Round(order.PayAmount * premium.Rate, 2))
+        };
 
         return result;
     }
@@ -908,10 +930,12 @@
                 OpenId = openid
             }
         };
+        Logger.LogError("璋冪敤璇锋眰锛�" + req.ToJson());
         var timestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
         string nonce = Guid.NewGuid().ToString();
 
         var res = await _wxPayApi.PayTransactionsJsAPI(req);
+        Logger.LogError("璋冪敤缁撴灉锛�" + res.ToJson());
         string package = "prepay_id=" + res.PrepayId;
         ModelPaymentMiniPay info = new ModelPaymentMiniPay();
         if (res != null)

--
Gitblit v1.9.1