浏览代码

分账打日志

lichunlei 1 年之前
父节点
当前提交
c17c8ba70f
共有 1 个文件被更改,包括 12 次插入1 次删除
  1. 12 1
      AppStart/Helper/WeChatPayBackService.cs

+ 12 - 1
AppStart/Helper/WeChatPayBackService.cs

@@ -138,12 +138,17 @@ namespace MySystem
                     var list = db.ConsumerOrders.Select(m => new { m.Id, m.CreateDate, m.Status, m.IsAct, m.PayMode }).Where(m => m.Status == 1 && m.PayMode == 2 && m.IsAct == 1 && m.CreateDate < checkDate).OrderBy(m => m.Id).Take(10).ToList();
                     foreach(var sub in list)
                     {
+                        LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "微信分账队列异常");
+                        LogHelper.Instance.WriteLog("Id:" + sub.Id, "微信分账队列异常");
                         ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == sub.Id);
                         if(order != null)
                         {
                             order.Status = 2;
                             MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
                             MerchantParamSet set = db.MerchantParamSet.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantParamSet();
+                            LogHelper.Instance.WriteLog("IsAct:" + order.IsAct, "微信分账队列监听");
+                            LogHelper.Instance.WriteLog("PayMoney:" + order.PayMoney, "微信分账队列监听");
+                            LogHelper.Instance.WriteLog("MinPayMoney:" + set.MinPayMoney, "微信分账队列监听");
                             if(order.IsAct == 1 && order.PayMoney >= set.MinPayMoney)
                             {
                                 MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantAddInfo();
@@ -154,6 +159,7 @@ namespace MySystem
                                     merchant.Version = 1;
                                     db.SaveChanges();
                                 }
+                                LogHelper.Instance.WriteLog("准备分账", "微信分账队列监听");
                                 //发起分账
                                 decimal fee = order.PayMoney; //单位:分
                                 if(fee >= 1)
@@ -168,7 +174,11 @@ namespace MySystem
                                         amount = int.Parse(fee.ToString("f0")),  //分账金额
                                         description = "服务费",  //分账描述
                                     });
-                                    WeChatFunction.Instance.ProfitShare(merchantAdd.SubMchid, TradeNo, OrderNo, Receivers);
+                                    LogHelper.Instance.WriteLog("TradeNo:" + TradeNo, "微信分账队列监听");
+                                    LogHelper.Instance.WriteLog("OrderNo:" + OrderNo, "微信分账队列监听");
+                                    LogHelper.Instance.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(Receivers), "微信分账队列监听");
+                                    string ProfitShareResult = WeChatFunction.Instance.ProfitShare(merchantAdd.SubMchid, TradeNo, OrderNo, Receivers);
+                                    LogHelper.Instance.WriteLog("分账结果:" + ProfitShareResult, "微信分账队列监听");
 
                                     //开始监听分账状态
                                     Dictionary<string, object> req = new Dictionary<string, object>();
@@ -184,6 +194,7 @@ namespace MySystem
                                 }
                             }
                         }
+                        LogHelper.Instance.WriteLog("\n\n", "微信分账队列监听");
                     }
                     db.SaveChanges();
                     db.Dispose();