Browse Source

预扣款-添加预扣款调整

lcl 1 year ago
parent
commit
3a221fcec4
2 changed files with 26 additions and 17 deletions
  1. BIN
      .DS_Store
  2. 26 17
      Areas/Api/Controllers/RadioCardController.cs

BIN
.DS_Store


+ 26 - 17
Areas/Api/Controllers/RadioCardController.cs

@@ -68,7 +68,7 @@ namespace MySystem.Areas.Api.Controllers.v1
         #endregion
 
         #region 预扣款-添加预扣款
-        // [Authorize]
+        [Route("/v1/kxsmain/tochargebackrecord/addtochargebackrecord")]
         public JsonResult AddToChargeBackRecord(string value)
         {
             // value = DesDecrypt(value);
@@ -85,23 +85,32 @@ namespace MySystem.Areas.Api.Controllers.v1
             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
+                bool check = maindb.ToChargeBackRecord.Any(m => m.Field1 == PosSn && m.ChargeType == 124);
+                if(!check)
                 {
-                    CreateDate = DateTime.Now,
-                    SeoTitle = SysUserName + "_" + SysRealName,
-                    SeoDescription = "循环过期(" + PosSn + ")",
-                    Remark = "循环过期(" + PosSn + ")",
-                    Field1 = PosSn,
-                    ChargeType = 124,
-                    Kind = 0,
-                    ChargeAmount = amount,
-                    UserId = pos.BuyUserId,
-                }).Entity;
-                maindb.SaveChanges();
+                    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;
+                    UserAccount account = maindb.UserAccount.FirstOrDefault(m => m.Id == pos.BuyUserId);
+                    if(account != null)
+                    {
+                        account.ToChargeAmount += amount;
+                    }
+                    maindb.SaveChanges();
+                }
                 return new AppResultJson() { Status = "1", Info = "成功", Data = Obj };
             }
             else