From f8e21d7b31d7690e17f5980aeb5763036dda99f0 Mon Sep 17 00:00:00 2001
From: liushijie <lslola@126.com>
Date: 星期四, 27 三月 2025 09:12:14 +0800
Subject: [PATCH] fix bug

---
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs |   95 +++++++++++++++++++++++------------------------
 1 files changed, 47 insertions(+), 48 deletions(-)

diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index 405d11c..ef50008 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -263,19 +263,19 @@
                             from b in temp.DefaultIfEmpty()
                             select new LifePayOrderListOutput
                             {
-                                DiscountAmount = a.DiscountAmount,
+                                DiscountAmount = a.DiscountAmount ?? 0,
                                 FinishTime = a.FinishTime,
                                 Id = a.Id,
-                                LifePayOrderStatus = a.LifePayOrderStatus,
+                                LifePayOrderStatus = a.LifePayOrderStatus?? 0,
                                 LifePayOrderType = a.LifePayOrderType,
                                 LifePayType = a.LifePayType,
                                 OrderNo = a.OrderNo,
-                                PayAmount = a.PayAmount,
+                                PayAmount = a.PayAmount ?? 0,
                                 PhoneNumber = a.PhoneNumber,
-                                RechargeAmount = a.RechargeAmount,
+                                RechargeAmount = a.RechargeAmount??0,
                                 UserId = a.UserId,
                                 OutOrderNo = a.OutOrderNo,
-                                PayStatus = a.PayStatus,
+                                PayStatus = a.PayStatus?? 0,
                                 PayTime = a.PayTime,
                                 ACOOLYOrderNo = a.ACOOLYOrderNo,
                                 RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(),
@@ -319,19 +319,19 @@
                             from b in temp.DefaultIfEmpty()
                             select new LifePayOrderListOutput
                             {
-                                DiscountAmount = a.DiscountAmount,
+                                DiscountAmount = a.DiscountAmount ?? 0,
                                 FinishTime = a.FinishTime,
                                 Id = a.Id,
-                                LifePayOrderStatus = a.LifePayOrderStatus,
+                                LifePayOrderStatus = a.LifePayOrderStatus ?? 0,
                                 LifePayOrderType = a.LifePayOrderType,
                                 LifePayType = a.LifePayType,
                                 OrderNo = a.OrderNo,
-                                PayAmount = a.PayAmount,
+                                PayAmount = a.PayAmount ?? 0,
                                 PhoneNumber = a.PhoneNumber,
-                                RechargeAmount = a.RechargeAmount,
+                                RechargeAmount = a.RechargeAmount ?? 0,
                                 UserId = a.UserId,
                                 OutOrderNo = a.OutOrderNo,
-                                PayStatus = a.PayStatus,
+                                PayStatus = a.PayStatus ?? 0,
                                 PayTime = a.PayTime,
                                 ACOOLYOrderNo = a.ACOOLYOrderNo,
                                 RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(),
@@ -403,25 +403,24 @@
         CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
         var user = await _lifePayUserRepository.FirstOrDefaultAsync(x => x.Id == order.UserId);
         CheckExtensions.IfTrueThrowUserFriendlyException(user == null, "鐢ㄦ埛涓嶅瓨鍦�");
-        var orderpirce = await GetOrderPrice(order.RechargeAmount, order.PayAmount, order.PlatformRate ?? 0, order.ChannleRate ?? 0, order.ChannlesRakeRate ?? 0, order.PremiumRate ?? 0);
-
+        var orderpirce = await GetOrderPrice(order.RechargeAmount ?? 0, order.PayAmount ?? 0, order.PlatformRate ?? 0, order.ChannleRate ?? 0, order.ChannlesRakeRate ?? 0, order.PremiumRate ?? 0);
 
         var result = new LifePayOrderOutput()
         {
             UserName = user.Name,
             UserPhoneNumber = user.PhoneNumber,
-            DiscountAmount = order.DiscountAmount,
+            DiscountAmount = order.DiscountAmount ?? 0,
             FinishTime = order.FinishTime,
             Id = order.Id,
             OutOrderNo = order.OutOrderNo,
             LifePayChannle = channle.ChannlesName,
-            Status = order.LifePayOrderStatus,
+            Status = order.LifePayOrderStatus ?? 0,
             LifePayOrderType = order.LifePayOrderType,
             LifePayType = order.LifePayType,
             OrderNo = order.OrderNo,
-            PayAmount = order.PayAmount,
-            RechargeAmount = order.RechargeAmount,
-            PayStatus = order.PayStatus,
+            PayAmount = order.PayAmount ?? 0,
+            RechargeAmount = order.RechargeAmount ?? 0,
+            PayStatus = order.PayStatus ?? 0,
             PayTime = order.PayTime,
             OrderParamDetailJsonStr = order.OrderParamDetailJsonStr,
             RefundCredentialsImgUrl = order.RefundCredentialsImgUrl.GetOssPath(),
@@ -463,18 +462,18 @@
         {
             UserName = user.Name,
             UserPhoneNumber = user.PhoneNumber,
-            DiscountAmount = order.DiscountAmount,
+            DiscountAmount = order.DiscountAmount ?? 0,
             FinishTime = order.FinishTime,
             Id = order.Id,
             OutOrderNo = order.OutOrderNo,
             LifePayChannle = channle.ChannlesName,
-            Status = order.LifePayOrderStatus,
+            Status = order.LifePayOrderStatus ?? 0,
             LifePayOrderType = order.LifePayOrderType,
             LifePayType = order.LifePayType,
             OrderNo = order.OrderNo,
-            PayAmount = order.PayAmount,
-            RechargeAmount = order.RechargeAmount,
-            PayStatus = order.PayStatus,
+            PayAmount = order.PayAmount ?? 0,
+            RechargeAmount = order.RechargeAmount ?? 0,
+            PayStatus = order.PayStatus ?? 0,
             PayTime = order.PayTime,
             RefundCredentialsImgUrl = order.RefundCredentialsImgUrl.GetOssPath(),
             CreationTime = order.CreationTime,
@@ -519,16 +518,16 @@
                                             .Select(x =>
                                                     new UserLifePayOrderOutput
                                                     {
-                                                        DiscountAmount = x.DiscountAmount,
+                                                        DiscountAmount = x.DiscountAmount ?? 0,
                                                         FinishTime = x.FinishTime,
                                                         Id = x.Id,
-                                                        LifePayOrderStatus = x.LifePayOrderStatus,
+                                                        LifePayOrderStatus = x.LifePayOrderStatus ?? 0,
                                                         LifePayOrderType = x.LifePayOrderType,
                                                         LifePayType = x.LifePayType,
                                                         OrderNo = x.OrderNo,
-                                                        PayAmount = x.PayAmount,
-                                                        RechargeAmount = x.RechargeAmount,
-                                                        PayStatus = x.PayStatus,
+                                                        PayAmount = x.PayAmount ?? 0,
+                                                        RechargeAmount = x.RechargeAmount ?? 0,
+                                                        PayStatus = x.PayStatus ?? 0,
                                                         PayTime = x.PayTime,
                                                         OrderParamDetailJsonStr = x.OrderParamDetailJsonStr,
                                                         RefundCredentialsImgUrl = x.RefundCredentialsImgUrl.GetOssPath(),
@@ -550,16 +549,16 @@
                                             .Select(x =>
                                                     new UserLifePayOrderOutput
                                                     {
-                                                        DiscountAmount = x.DiscountAmount,
+                                                        DiscountAmount = x.DiscountAmount ?? 0,
                                                         FinishTime = x.FinishTime,
                                                         Id = x.Id,
-                                                        LifePayOrderStatus = x.LifePayOrderStatus,
+                                                        LifePayOrderStatus = x.LifePayOrderStatus?? 0 ,
                                                         LifePayOrderType = x.LifePayOrderType,
                                                         LifePayType = x.LifePayType,
                                                         OrderNo = x.OrderNo,
-                                                        PayAmount = x.PayAmount,
-                                                        RechargeAmount = x.RechargeAmount,
-                                                        PayStatus = x.PayStatus,
+                                                        PayAmount = x.PayAmount ?? 0,
+                                                        RechargeAmount = x.RechargeAmount ?? 0,
+                                                        PayStatus = x.PayStatus ?? 0,
                                                         PayTime = x.PayTime,
                                                         OrderParamDetailJsonStr = x.OrderParamDetailJsonStr,
                                                         RefundCredentialsImgUrl = x.RefundCredentialsImgUrl.GetOssPath(),
@@ -585,7 +584,7 @@
     public async Task<LifePayStatusEnum> GetPayStatusByOrderNo(string orderNo)
     {
         return await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo)
-                                            .Select(x => x.PayStatus)
+                                            .Select(x => x.PayStatus ?? 0)
                                             .FirstOrDefaultAsync();
     }
 
@@ -641,7 +640,7 @@
                                                         OrderNo = x.OrderNo,
                                                         RefundCheckRemark = x.RefundCheckRemark,
                                                         RefundApplyRemark = x.RefundApplyRemark,
-                                                        LifePayOrderStatus = x.LifePayOrderStatus,
+                                                        LifePayOrderStatus = x.LifePayOrderStatus ?? 0,
                                                     }).FirstOrDefaultAsync();
 
         CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "鏈壘鍒拌鍗曚俊鎭�");
@@ -1015,10 +1014,10 @@
 
 #if DEBUG
         //var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, 0.01m, ip, input.H5Type);
-        var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, order.PayAmount, ip, input.H5Type);
+        var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, order.PayAmount ?? 0, ip, input.H5Type);
 #else
       //var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, 0.01m, ip, input.H5Type);
-        var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, order.PayAmount, ip, input.H5Type);
+        var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, order.PayAmount??0, ip, input.H5Type);
 #endif
 
         return payUrl;
@@ -1063,7 +1062,7 @@
 
         //  var result = await PayTransactionsJsAPI(input.OpenId, input.Attach,  order.PayAmount, input.OrderNo, desc);
 
-        var result = await PayTransactionsJsAPI(input.OpenId, input.PayAppId, input.Attach, order.PayAmount, input.OrderNo, desc);
+        var result = await PayTransactionsJsAPI(input.OpenId, input.PayAppId, input.Attach, order.PayAmount ?? 0, input.OrderNo, desc);
         return result;
         //var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, 0.01m, ip, input.H5Type);
         //var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, order.PayAmount, ip, input.H5Type);
@@ -1387,7 +1386,7 @@
 
         if (input.LifePayRefundType == LifePayRefundTypeEnum.鍏ㄩ閫�娆�)
         {
-            input.RefundPrice = order.PayAmount;
+            input.RefundPrice = order.PayAmount ?? 0;
         }
 
         if (order.LifePayOrderStatus != LifePayOrderStatusEnum.寰呴��娆� || order.PayStatus != LifePayStatusEnum.宸叉敮浠� || order.LifePayRefundStatus != LifePayRefundStatusEnum.寰呴��娆�)
@@ -2026,19 +2025,19 @@
                       from b in temp.DefaultIfEmpty()
                       select new LifePayOrderListOutput
                       {
-                          DiscountAmount = a.DiscountAmount,
+                          DiscountAmount = a.DiscountAmount ?? 0,
                           FinishTime = a.FinishTime,
                           Id = a.Id,
-                          LifePayOrderStatus = a.LifePayOrderStatus,
+                          LifePayOrderStatus = a.LifePayOrderStatus ?? 0,
                           LifePayOrderType = a.LifePayOrderType,
                           LifePayType = a.LifePayType,
                           OrderNo = a.OrderNo,
-                          PayAmount = a.PayAmount,
+                          PayAmount = a.PayAmount ?? 0,
                           PhoneNumber = a.PhoneNumber,
-                          RechargeAmount = a.RechargeAmount,
+                          RechargeAmount = a.RechargeAmount ?? 0,
                           UserId = a.UserId,
                           OutOrderNo = a.OutOrderNo,
-                          PayStatus = a.PayStatus,
+                          PayStatus = a.PayStatus ?? 0,
                           PayTime = a.PayTime,
                           ACOOLYOrderNo = a.ACOOLYOrderNo,
                           RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(),
@@ -2077,19 +2076,19 @@
                       from b in temp.DefaultIfEmpty()
                       select new LifePayOrderListOutput
                       {
-                          DiscountAmount = a.DiscountAmount,
+                          DiscountAmount = a.DiscountAmount ?? 0,
                           FinishTime = a.FinishTime,
                           Id = a.Id,
-                          LifePayOrderStatus = a.LifePayOrderStatus,
+                          LifePayOrderStatus = a.LifePayOrderStatus ?? 0,
                           LifePayOrderType = a.LifePayOrderType,
                           LifePayType = a.LifePayType,
                           OrderNo = a.OrderNo,
-                          PayAmount = a.PayAmount,
+                          PayAmount = a.PayAmount ?? 0,
                           PhoneNumber = a.PhoneNumber,
-                          RechargeAmount = a.RechargeAmount,
+                          RechargeAmount = a.RechargeAmount ?? 0,
                           UserId = a.UserId,
                           OutOrderNo = a.OutOrderNo,
-                          PayStatus = a.PayStatus,
+                          PayStatus = a.PayStatus ?? 0,
                           PayTime = a.PayTime,
                           ACOOLYOrderNo = a.ACOOLYOrderNo,
                           RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(),

--
Gitblit v1.9.1