浏览代码

Merge branch 'main' of http://47.109.31.237:13000/lichunlei/mp-main-v2 into DuGuYang

DuGuYang 1 年之前
父节点
当前提交
1fd38f9da2
共有 2 个文件被更改,包括 33 次插入7 次删除
  1. 9 2
      Controllers/HomeController.cs
  2. 24 5
      Util/HaoDa/ProfitHelper.cs

+ 9 - 2
Controllers/HomeController.cs

@@ -316,9 +316,16 @@ namespace MySystem.Controllers
                 List<ConsumerOrders> list = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId + "", 1, 100000);
                 ConsumerOrders check = list.FirstOrDefault(m => m.Id == order.Id);
                 bool op = db.ConsumerProfit.Any(m => m.OrderId == order.Id);
-                if(check == null && !op)
+                if(check == null)
                 {
-                    RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":List", order.Id.ToString());
+                    if(!op)
+                    {
+                        RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":List", order.Id.ToString());
+                    }
+                    else
+                    {
+                        RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
+                    }
                 }
                 db.Dispose();
             }

+ 24 - 5
Util/HaoDa/ProfitHelper.cs

@@ -156,15 +156,25 @@ namespace MySystem
                                                     
                                                     //聚合支付退款
                                                     bool BackStatus = false;
+
+                                                    //拆单算法
+                                                    int CheckTime = SplitOrder(suborder.PayMoney,subset.MinPayMoney);
+                                                    if(CheckTime > 0)
+                                                    {
+                                                        GetMoney = GetMoney * CheckTime;
+                                                        db.SaveChanges();
+                                                        CurDiviPersons -= CheckTime - 1;
+                                                    }
+
                                                     decimal RefundAmount = GetMoney * 100;
                                                     RefundAmount = Math.Round(RefundAmount, 2);
                                                     if(!orderids.Contains(suborder.Id))
                                                     {
                                                         function.WriteLog("请求退款接口", "返现逻辑日志");
                                                         string RefundNo = "HDTK" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
-                                                        var info = HaoDaHelper.Instance.AggregatedPayRefund(merchantAdd.OutMchtNo, merchantAdd.StoreNo, RefundNo, suborder.OrderNo, RefundAmount.ToString("f0"));
-                                                        if(info.Contains("\"resultCode\":\"1\"") && info.Contains("\"tradeStatus\":\"2\""))
-                                                        {
+                                                        // var info = HaoDaHelper.Instance.AggregatedPayRefund(merchantAdd.OutMchtNo, merchantAdd.StoreNo, RefundNo, suborder.OrderNo, RefundAmount.ToString("f0"));
+                                                        // if(info.Contains("\"resultCode\":\"1\"") && info.Contains("\"tradeStatus\":\"2\""))
+                                                        // {
                                                             db.ConsumerProfit.Add(new ConsumerProfit()
                                                             {
                                                                 CreateDate = DateTime.Now,
@@ -180,8 +190,8 @@ namespace MySystem
                                                             });
                                                             db.SaveChanges();
                                                             BackStatus = true;
-                                                        }
-                                                        function.WriteLog("接口返回:" + info, "返现逻辑日志");
+                                                        // }
+                                                        // function.WriteLog("接口返回:" + info, "返现逻辑日志");
                                                         orderids.Add(suborder.Id);
                                                     }
 
@@ -268,6 +278,15 @@ namespace MySystem
             db.Dispose();            
             function.WriteLog("结束返现:" + orderidstring + "\n\n\n", "返现逻辑日志");
         }
+
+        //拆单算法
+        private int SplitOrder(decimal OrderAmt, decimal MinMoney)
+        {
+            decimal percenter = OrderAmt/MinMoney;
+            int Times = int.Parse(percenter.ToString().Split('.')[0]);
+            if(Times < 1) Times = 1;
+            return Times;
+        }
         #endregion