Explorar o código

添加取消返现和回复返现接口

lcl hai 1 ano
pai
achega
35ad772512
Modificáronse 2 ficheiros con 75 adicións e 0 borrados
  1. 68 0
      Areas/Api/Controllers/Main/ConsumerOrdersController.cs
  2. 7 0
      Util/RedisDbconn.cs

+ 68 - 0
Areas/Api/Controllers/Main/ConsumerOrdersController.cs

@@ -167,5 +167,73 @@ namespace MySystem.Areas.Api.Controllers.v1
         }
         #endregion
 
+
+
+        #region 经营数据-统计数据-经营详情-取消返现
+        // [Authorize]
+        public JsonResult CancelDivi(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            AppResultJson result = CancelDiviDo(value);
+            return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
+        }
+        private AppResultJson CancelDiviDo(string value)
+        {
+            JsonData data = JsonMapper.ToObject(value);
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            int Id = int.Parse(function.CheckInt(data["id"].ToString()));
+            ConsumerOrders order = maindb.ConsumerOrders.FirstOrDefault(m => m.Id == Id);
+            if(order != null)
+            {
+                List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId);
+                if(suborders.Count > 0)
+                {
+                    ConsumerOrders suborder = suborders.FirstOrDefault(m => m.Id == Id);
+                    if(suborder != null)
+                    {
+                        order.CurDivi = suborder.CurDivi;
+                        maindb.SaveChanges();
+                        RedisDbconn.Instance.RemoveFromList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, suborder);
+                        return new AppResultJson() { Status = "1", Info = "", Data = Obj };
+                    }
+                }
+            }
+            return new AppResultJson() { Status = "-1", Info = "取消失败", Data = Obj };
+        }
+        #endregion
+
+        #region 经营数据-统计数据-经营详情-恢复返现
+        // [Authorize]
+        public JsonResult RestoreDivi(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            AppResultJson result = RestoreDiviDo(value);
+            return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
+        }
+        private AppResultJson RestoreDiviDo(string value)
+        {
+            JsonData data = JsonMapper.ToObject(value);
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            int Id = int.Parse(function.CheckInt(data["id"].ToString()));
+            ConsumerOrders order = maindb.ConsumerOrders.FirstOrDefault(m => m.Id == Id);
+            if(order != null)
+            {
+                List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId);
+                if(suborders.Count > 0)
+                {
+                    ConsumerOrders suborder = suborders.FirstOrDefault(m => m.Id == Id);
+                    if(suborder == null)
+                    {
+                        RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, order);
+                    }
+                    return new AppResultJson() { Status = "1", Info = "", Data = Obj };
+                }
+            }
+            return new AppResultJson() { Status = "-1", Info = "恢复失败", Data = Obj };
+        }
+        #endregion
+
     }
 }

+ 7 - 0
Util/RedisDbconn.cs

@@ -146,6 +146,13 @@ namespace MySystem
         }
         #endregion
 
+        #region 移除列表
+        public long RemoveFromList(string key, object value, int count = 1)
+        {            
+            return csredis.LRem(key, count, value);
+        }
+        #endregion
+
         #region 添加排序列表对象
         public long AddSort(string key, object value, decimal score)
         {