浏览代码

预扣款-添加预扣款打日志

lcl 1 年之前
父节点
当前提交
54fcc4cdda
共有 1 个文件被更改,包括 45 次插入1 次删除
  1. 45 1
      Areas/Api/Controllers/RadioCardController.cs

+ 45 - 1
Areas/Api/Controllers/RadioCardController.cs

@@ -64,6 +64,50 @@ namespace MySystem.Areas.Api.Controllers.v1
             obj.Add("data", data);
             return obj;
         }
-        #endregion        
+        #endregion
+
+        #region 预扣款-添加预扣款
+        // [Authorize]
+        public JsonResult AddToChargeBackRecord(string value)
+        {
+            // value = DesDecrypt(value);
+            function.WriteLog(DateTime.Now.ToString() + "\n" + value + "\n\n", "预扣款-添加预扣款");
+            JsonData data = JsonMapper.ToObject(value);
+            AppResultJson result = AddToChargeBackRecordDo(value);
+            return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
+        }
+        private AppResultJson AddToChargeBackRecordDo(string value)
+        {
+            JsonData data = JsonMapper.ToObject(value);
+            string PosSn = data["PosSn"].ToString(); //机具SN
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            var pos = maindb.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn && m.Status > -1) ?? new PosMachinesTwo();
+            if (pos.Id > 0)
+            {
+                var brand = maindb.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new KqProducts();
+                var amount = 0.00M;
+                if (brand.Kind == 1) amount = 200;
+                if (brand.Kind == 2) amount = 300;
+                var ToChargeBackRecord = maindb.ToChargeBackRecord.Add(new ToChargeBackRecord
+                {
+                    CreateDate = DateTime.Now,
+                    SeoTitle = SysUserName + "_" + SysRealName,
+                    SeoDescription = "循环过期(" + PosSn + ")",
+                    Remark = "循环过期(" + PosSn + ")",
+                    Field1 = PosSn,
+                    ChargeType = 124,
+                    Kind = 0,
+                    ChargeAmount = amount,
+                    UserId = pos.BuyUserId,
+                }).Entity;
+                maindb.SaveChanges();
+                return new AppResultJson() { Status = "1", Info = "成功", Data = Obj };
+            }
+            else
+            {
+                return new AppResultJson() { Status = "-1", Info = "机具不存在", Data = Obj };
+            }
+        }
+        #endregion
     }
 }