Browse Source

修复设置订单当前返现金额异常

lcl 1 year ago
parent
commit
c4e9b8bf9b
1 changed files with 16 additions and 9 deletions
  1. 16 9
      AppStart/Helper/Profit/ProfitHelper.cs

+ 16 - 9
AppStart/Helper/Profit/ProfitHelper.cs

@@ -2114,17 +2114,24 @@ namespace MySystem
 
         public void SetDivi(string content)
         { 
-            JsonData jsonObj = JsonMapper.ToObject(content);
-            int orderId = int.Parse(jsonObj["OrderId"].ToString());
-            decimal diviAmt = int.Parse(jsonObj["DiviAmt"].ToString());
-            WebCMSEntities db = new WebCMSEntities();
-            ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == orderId);
-            if(order != null)
+            try
+            {
+                JsonData jsonObj = JsonMapper.ToObject(content);
+                int orderId = int.Parse(function.CheckInt(jsonObj["OrderId"].ToString()));
+                decimal diviAmt = decimal.Parse(function.CheckNum(jsonObj["DiviAmt"].ToString()));
+                WebCMSEntities db = new WebCMSEntities();
+                ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == orderId);
+                if(order != null)
+                {
+                    order.CurDivi = diviAmt;
+                    db.SaveChanges();
+                }
+                db.Dispose();
+            }
+            catch(Exception ex)
             {
-                order.CurDivi = diviAmt;
-                db.SaveChanges();
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "设置订单当前返现金额异常");
             }
-            db.Dispose();
         }
 
     }