Browse Source

待返现金额不满1分的订单,直接出局,并且不影响返现人数

lcl 1 year ago
parent
commit
6821e4283f
1 changed files with 12 additions and 4 deletions
  1. 12 4
      AppStart/Helper/Profit/ProfitHelper.cs

+ 12 - 4
AppStart/Helper/Profit/ProfitHelper.cs

@@ -212,6 +212,7 @@ namespace MySystem
                             if (IsAll == 0 && PayMoney >= MinPayMoney && GetPercent < 1)
                             {
                                 decimal DiviMoney = PayMoney * (1 - GetPercent - cusumerFeePercent - profitPercent);
+                                DiviMoney = Math.Round(DiviMoney, 2);
                                 if (DiviMoney > 0)
                                 {
                                     order.ReturnFlag = 1;
@@ -242,17 +243,17 @@ namespace MySystem
 
                                     // 减去自己付的订单
                                     // CurDiviPersons = CurDiviPersons - 1;
-                                    int OutCount = 0; // 出局人数
                                     List<int> orderids = new List<int>();
                                     while (CurDiviPersons > 0)
                                     {
                                         ConsumerOrders suborder = RedisDbconn.Instance.RPopLPush<ConsumerOrders>("ConsumerOrders:Divi:" + PayMode + ":" + MerchantId, "ConsumerOrders:Divi:" + PayMode + ":" + MerchantId);
                                         if (suborder != null)
                                         {
+                                            decimal TmpCurDivi = suborder.CurDivi;
                                             MerchantParamSet subset = Newtonsoft.Json.JsonConvert.DeserializeObject<MerchantParamSet>(order.SeoDescription);
                                             int subProfitDays = subset.ProfitDays; //分红期限(天)
                                             bool IsOut = suborder.UpdateDate.Value.AddDays(subProfitDays) < DateTime.Now ? true : false;
-                                            if (suborder.CurDivi < suborder.MaxDivi && !IsOut)
+                                            if (suborder.CurDivi < suborder.MaxDivi && suborder.MaxDivi - suborder.CurDivi >= 0.01M && !IsOut)
                                             {
                                                 //如果没过期并且当前退款金额没超过最大退款金额,就执行
                                                 decimal GetMoney = suborder.MaxDivi - suborder.CurDivi;
@@ -267,7 +268,6 @@ namespace MySystem
                                                 }
                                                 if (GetMoney > minProfit)
                                                 {
-                                                    decimal TmpCurDivi = suborder.CurDivi;
                                                     suborder.CurDivi += GetMoney;
                                                     if (DiffMoney > 0)
                                                     {
@@ -324,7 +324,6 @@ namespace MySystem
                                                             editOrder.CurDivi = editOrder.MaxDivi;
                                                             db.SaveChanges();
                                                         }
-                                                        OutCount += 1;
                                                     }
                                                     RedisDbconn.Instance.AddList("ConsumerOrdersSetDivi", "{\"OrderId\":\"" + suborder.Id + "\",\"DiviAmt\":\"" + suborder.CurDivi + "\"}");
                                                 }
@@ -332,6 +331,15 @@ namespace MySystem
                                             else
                                             { 
                                                 //否者计算人数不计入退款名额
+                                                suborder.CurDivi = TmpCurDivi;
+                                                RedisDbconn.Instance.RemoveFromList("ConsumerOrders:Divi:" + PayMode + ":" + MerchantId, suborder);                                                        
+                                                ConsumerOrders editOrder = db.ConsumerOrders.FirstOrDefault(m => m.Id == suborder.Id);
+                                                if (editOrder != null)
+                                                {
+                                                    editOrder.ReturnFlag = 0;
+                                                    editOrder.CurDivi = editOrder.MaxDivi;
+                                                    db.SaveChanges();
+                                                }
                                                 CurDiviPersons += 1;
                                             }
                                         }