DuGuYang 3 лет назад
Родитель
Сommit
ac93157fde
1 измененных файлов с 298 добавлено и 166 удалено
  1. 298 166
      AppStart/PublicChangePosFee.cs

+ 298 - 166
AppStart/PublicChangePosFee.cs

@@ -1,172 +1,304 @@
-// using System;
-// using System.Collections.Generic;
-// using System.Linq;
-// using System.Data;
-// using System.Text.RegularExpressions;
-// using MySystem.Models;
-// using Library;
-// using NPOI.SS.UserModel;
-// using NPOI.XSSF.UserModel;
-// using Microsoft.AspNetCore.Mvc;
-// using System.IO;
-// using LitJson;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Data;
+using System.Text.RegularExpressions;
+using MySystem.Models;
+using Library;
+using NPOI.SS.UserModel;
+using NPOI.XSSF.UserModel;
+using Microsoft.AspNetCore.Mvc;
+using System.IO;
+using LitJson;
+/// <summary>
+/// 设置机具服务费
+/// </summary>
 
-// namespace MySystem
-// {
-//     public class PublicChangePosFee
-//     {
-//         public WebCMSEntities db = new WebCMSEntities();
-//         public BsModels.WebCMSEntities bsdb = new BsModels.WebCMSEntities();
-//         public OpModels.WebCMSEntities opdb = new OpModels.WebCMSEntities();
+namespace MySystem
+{
+    public class PublicChangePosFee
+    {
+        public WebCMSEntities db = new WebCMSEntities();
+        public BsModels.WebCMSEntities bsdb = new BsModels.WebCMSEntities();
+        public OpModels.WebCMSEntities opdb = new OpModels.WebCMSEntities();
 
-//         #region 金控-设置押金
-//         public string SetJKDeposit(string SnIds)
-//         {
-//             string check = RedisDbconn.Instance.Get<string>("SetDepositWait:" + SnIds);
-//             if (!string.IsNullOrEmpty(check))
-//             {
-//                 return "操作频繁,请稍后再试";
-//             }
-//             RedisDbconn.Instance.Set("SetDepositWait:" + SnIds, SnIds);
-//             RedisDbconn.Instance.SetExpire("SetDepositWait:" + SnIds, 120);
-//             Dictionary<string, object> Obj = new Dictionary<string, object>();
-//             string[] SnIdList = SnIds.Split(',');
-//             foreach (string SnId in SnIdList)
-//             {
-//                 int SnIdNum = int.Parse(SnId);
-//                 PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.UserId == UserId && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
-//                 if (pos == null)
-//                 {
-//                     return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
-//                 }
-//                 function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "金控-设置押金-返回报文");
-//                 string content = function.GetWebRequest("http://sp.kexiaoshuang.com/api/test/SetDeposit?sn=" + pos.PosSn + "&num=" + DepositId); //PublicImportDataService.Instance.SetDeposit(pos.PosSn, decimal.Parse(DepositId));
-//                 function.WriteLog(DateTime.Now.ToString() + "\n" + content, "金控-设置押金-返回报文");
-//                 if (content == "fail")
-//                 {
-//                     return Json(new AppResultJson() { Status = "-1", Info = "机具" + pos.PosSn + "设置失败" });
-//                 }
-//                 JsonData jsonObj = JsonMapper.ToObject(content);
-//                 if (jsonObj["code"].ToString() != "000000")
-//                 {
-//                     return Json(new AppResultJson() { Status = "-1", Info = jsonObj["message"].ToString() });
-//                 }
-//                 content = jsonObj["data"].ToString();
-//                 content = PublicImportDataService.Instance.Decrypt(content);
-//                 function.WriteLog(DateTime.Now.ToString() + "\n" + content, "金控-设置押金-返回报文");
-//                 JsonData contentObj = JsonMapper.ToObject(content);
-//                 if (contentObj["respCode"].ToString() != "00")
-//                 {
-//                     return Json(new AppResultJson() { Status = "-1", Info = contentObj["respMsg"].ToString() });
-//                 }
-//                 var BeforeDeposit = 0;
-//                 if (string.IsNullOrEmpty(pos.PrizeParams))
-//                 {
-//                     if (RelationClass.GetKqProductBrandInfo(pos.BrandId) == "立刷云电签")
-//                     {
-//                         BeforeDeposit = 249;
-//                     }
-//                     else
-//                     {
-//                         BeforeDeposit = 299;
-//                     }
-//                 }
-//                 else
-//                 {
-//                     BeforeDeposit = int.Parse(pos.PrizeParams);
-//                 }
-//                 decimal amount = decimal.Parse(DepositId);
-//                 pos.PrizeParams = amount.ToString("f0");
-//                 maindb.SaveChanges();
+        #region 金控-设置押金
+        public string SetJKDeposit(string SnIds, string DepositId)
+        {
+            string check = RedisDbconn.Instance.Get<string>("SetDepositWait:" + SnIds);
+            if (!string.IsNullOrEmpty(check))
+            {
+                return "操作频繁,请稍后再试";
+            }
+            RedisDbconn.Instance.Set("SetDepositWait:" + SnIds, SnIds);
+            RedisDbconn.Instance.SetExpire("SetDepositWait:" + SnIds, 120);
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            string[] SnIdList = SnIds.Split(',');
+            foreach (string SnId in SnIdList)
+            {
+                int SnIdNum = int.Parse(SnId);
+                PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
+                if (pos == null)
+                {
+                    return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
+                }
+                function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + "199", "金控-设置押金-返回报文");
+                string content = function.GetWebRequest("http://sp.kexiaoshuang.com/api/test/SetDeposit?sn=" + pos.PosSn + "&num=" + "199");
+                function.WriteLog(DateTime.Now.ToString() + "\n" + content, "金控-设置押金-返回报文");
+                if (content == "fail")
+                {
+                    return "机具" + pos.PosSn + "设置失败";
+                }
+                JsonData jsonObj = JsonMapper.ToObject(content);
+                if (jsonObj["code"].ToString() != "000000")
+                {
+                    return jsonObj["message"].ToString();
+                }
+                content = jsonObj["data"].ToString();
+                content = PublicImportDataService.Instance.Decrypt(content);
+                function.WriteLog(DateTime.Now.ToString() + "\n" + content, "金控-设置押金-返回报文");
+                JsonData contentObj = JsonMapper.ToObject(content);
+                if (contentObj["respCode"].ToString() != "00")
+                {
+                    return contentObj["respMsg"].ToString();
+                }
+                var BeforeDeposit = 0;
+                if (string.IsNullOrEmpty(pos.PrizeParams))
+                {
+                    if (RelationClass.GetKqProductBrandInfo(pos.BrandId) == "立刷云电签")
+                    {
+                        BeforeDeposit = 249;
+                    }
+                    else
+                    {
+                        BeforeDeposit = 299;
+                    }
+                }
+                else
+                {
+                    BeforeDeposit = int.Parse(pos.PrizeParams);
+                }
+                decimal amount = decimal.Parse("199");
+                pos.PrizeParams = amount.ToString("f0");
+                db.SaveChanges();
+            }
+            return "设置成功";
+        }
+        #endregion
 
-//                 //设置押金添加记录
-//                 PublicFunction.MerchantDepositSet(pos.BrandId, UserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
-//             }
-//             return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
-//         }
-//         #endregion
 
-//         #region 海科-设置押金
-//         public string SetHKDeposit(string SnIds)
-//         {
-//             string check = RedisDbconn.Instance.Get<string>("SetHkPosDepositWait:" + SnIds);
-//             if (!string.IsNullOrEmpty(check))
-//             {
-//                 return "操作频繁,请稍后再试";
-//             }
-//             RedisDbconn.Instance.Set("SetHkPosDepositWait:" + SnIds, SnIds);
-//             RedisDbconn.Instance.SetExpire("SetHkPosDepositWait:" + SnIds, 120);
-//             string DepositId = "300"; //押金Id
-//             Dictionary<string, object> Obj = new Dictionary<string, object>();
-//             string[] SnIdList = SnIds.Split(',');
-//             foreach (string SnId in SnIdList)
-//             {
-//                 int SnIdNum = int.Parse(SnId);
-//                 PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
-//                 if (pos == null)
-//                 {
-//                     return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
-//                 }
-//                 string OldId = "", NewId = "";
-//                 if (DepositId == "100")
-//                 {
-//                     NewId = pos.BrandId == 8 ? "202207011718129" : "202207011718197";
-//                 }
-//                 else if (DepositId == "200")
-//                 {
-//                     NewId = pos.BrandId == 8 ? "747200504467566592" : "747199934126108672";
-//                 }
-//                 else if (DepositId == "300")
-//                 {
-//                     NewId = pos.BrandId == 8 ? "747193472108732416" : "747193820156276736";
-//                 }
-//                 string content = PublicImportDataService.Instance.QueryActiveForConfigHK(pos.PosSn, pos.BrandId);
-//                 JsonData jsonObj = JsonMapper.ToObject(content);
-//                 if (jsonObj["code"].ToString() == "0")
-//                 {
-//                     OldId = jsonObj["data"]["posMarket"]["id"].ToString();
-//                 }
-//                 jsonObj = JsonMapper.ToObject(content);
-//                 function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + OldId + ":" + NewId, "海科-设置押金-返回报文");
-//                 content = PublicImportDataService.Instance.SetDepositForHK(pos.PosSn, OldId, NewId, pos.BrandId);
-//                 function.WriteLog(DateTime.Now.ToString() + "\n" + content, "海科-设置押金-返回报文");
-//                 if (content == "fail")
-//                 {
-//                     return "机具" + pos.PosSn + "设置失败";
-//                 }
-//                 jsonObj = JsonMapper.ToObject(content);
-//                 if (jsonObj["code"].ToString() != "0")
-//                 {
-//                     return jsonObj["msg"].ToString();
-//                 }
-//                 decimal amount = decimal.Parse(DepositId);
-//                 var BeforeDeposit = 0;
-//                 if (string.IsNullOrEmpty(pos.PrizeParams))
-//                 {
-//                     if (RelationClass.GetKqProductBrandInfo(pos.BrandId) == "立刷云电签")
-//                     {
-//                         BeforeDeposit = 249;
-//                     }
-//                     else
-//                     {
-//                         BeforeDeposit = 299;
-//                     }
-//                 }
-//                 else
-//                 {
-//                     BeforeDeposit = int.Parse(pos.PrizeParams);
-//                 }
-//                 if (pos.BrandId == 8 || pos.BrandId == 9)
-//                 {
-//                     amount -= 1;
-//                 }
-//                 pos.PrizeParams = amount.ToString("f0");
-//                 db.SaveChanges();
 
-//             }
-//             return "设置成功";
-//         }
-//         #endregion
+        
+        #region 开店宝-设置押金
+        public string SetKDBDeposit(string SnIds, string DepositId)
+        {
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            string[] SnIdList = SnIds.Split(',');
+            foreach (string SnId in SnIdList)
+            {
+                int SnIdNum = int.Parse(SnId);
+                PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
+                if (pos == null)
+                {
+                    return"机具" + pos.PosSn + "已设置押金,请勿重复设置";
+                }
+                function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + "299", "开店宝-设置押金-返回报文");
+                string content = PublicImportDataService.Instance.ModifyDeposit(pos.PosSn, "299");
+                if (content == "fail")
+                { 
+                    return"机具" + pos.PosSn + "设置失败";
+                }
+                function.WriteLog(DateTime.Now.ToString() + "\n" + content, "开店宝-设置押金-返回报文");
 
-//     }
-// }
+                var BeforeDeposit = 0;
+                if (string.IsNullOrEmpty(pos.PrizeParams))
+                {
+                    if (RelationClass.GetKqProductBrandInfo(pos.BrandId) == "立刷云电签")
+                    {
+                        BeforeDeposit = 249;
+                    }
+                    else
+                    {
+                        BeforeDeposit = 299;
+                    }
+                }
+                else
+                {
+                    BeforeDeposit = int.Parse(pos.PrizeParams);
+                }
+                decimal amount = decimal.Parse(PublicImportDataService.Instance.GetDepositAmount("299"));
+                pos.PrizeParams = amount.ToString("f0");
+                db.SaveChanges();
+            }
+            return "设置成功";
+        }
+        #endregion
+
+
+
+        #region 乐刷-设置押金
+        public string SetDeposit(string SnIds, string DepositId)
+        {
+            string check = RedisDbconn.Instance.Get<string>("SetLsPosDepositWait:" + SnIds);
+            if (!string.IsNullOrEmpty(check))
+            { 
+                return "操作频繁,请稍后再试";
+            }
+            RedisDbconn.Instance.Set("SetLsPosDepositWait:" + SnIds, SnIds);
+            RedisDbconn.Instance.SetExpire("SetLsPosDepositWait:" + SnIds, 120);
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            string[] SnIdList = SnIds.Split(',');
+            foreach (string SnId in SnIdList)
+            {
+                int SnIdNum = int.Parse(SnId);
+                PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
+                if (pos == null)
+                {
+                    return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
+                }
+                string OldId = "", NewId = "";
+                if (DepositId == "100")
+                {
+                    NewId = "704067039039856640";
+                }
+                else if (DepositId == "200")
+                {
+                    NewId = "709820183485095936";
+                }
+                else if (DepositId == "300")
+                {
+                    NewId = "709820390742437888";
+                }
+                string content = PublicImportDataService.Instance.QueryActiveForConfig(pos.PosSn, pos.BrandId);
+                JsonData jsonObj = JsonMapper.ToObject(content);
+                if (jsonObj["code"].ToString() == "0")
+                {
+                    OldId = jsonObj["data"]["posMarket"]["id"].ToString();
+                }
+                jsonObj = JsonMapper.ToObject(content);
+                function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + OldId + ":" + NewId, "乐刷-设置押金-返回报文");
+                content = PublicImportDataService.Instance.SetDepositForLS(pos.PosSn, OldId, NewId, pos.BrandId);
+                function.WriteLog(DateTime.Now.ToString() + "\n" + content, "乐刷-设置押金-返回报文");
+                if (content == "fail")
+                { 
+                    return "机具" + pos.PosSn + "设置失败";
+                }
+                jsonObj = JsonMapper.ToObject(content);
+                if (jsonObj["code"].ToString() != "0")
+                { 
+                    return jsonObj["msg"].ToString();
+                }
+                function.WriteLog(DateTime.Now.ToString() + "\n" + content, "乐刷-设置押金-返回报文");
+                var BeforeDeposit = 0;
+                if (string.IsNullOrEmpty(pos.PrizeParams))
+                {
+                    if (RelationClass.GetKqProductBrandInfo(pos.BrandId) == "立刷云电签")
+                    {
+                        BeforeDeposit = 249;
+                    }
+                    else
+                    {
+                        BeforeDeposit = 299;
+                    }
+                }
+                else
+                {
+                    BeforeDeposit = int.Parse(pos.PrizeParams);
+                }
+                decimal amount = decimal.Parse(DepositId);
+                if (pos.BrandId == 4 || pos.BrandId == 5)
+                {
+                    amount -= 1;
+                }
+                pos.PrizeParams = amount.ToString("f0");
+                db.SaveChanges();
+            }
+            return "设置成功";
+        }
+        #endregion
+
+
+
+        #region 海科-设置押金
+        public string SetHKDeposit(string SnIds, string DepositId)
+        {
+            string check = RedisDbconn.Instance.Get<string>("SetHkPosDepositWait:" + SnIds);
+            if (!string.IsNullOrEmpty(check))
+            {
+                return "操作频繁,请稍后再试";
+            }
+            RedisDbconn.Instance.Set("SetHkPosDepositWait:" + SnIds, SnIds);
+            RedisDbconn.Instance.SetExpire("SetHkPosDepositWait:" + SnIds, 120);
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            string[] SnIdList = SnIds.Split(',');
+            foreach (string SnId in SnIdList)
+            {
+                int SnIdNum = int.Parse(SnId);
+                PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
+                if (pos == null)
+                {
+                    return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
+                }
+                string OldId = "", NewId = "";
+                if (DepositId == "100")
+                {
+                    NewId = pos.BrandId == 8 ? "202207011718129" : "202207011718197";
+                }
+                else if (DepositId == "200")
+                {
+                    NewId = pos.BrandId == 8 ? "747200504467566592" : "747199934126108672";
+                }
+                else if (DepositId == "300")
+                {
+                    NewId = pos.BrandId == 8 ? "747193472108732416" : "747193820156276736";
+                }
+                string content = PublicImportDataService.Instance.QueryActiveForConfigHK(pos.PosSn, pos.BrandId);
+                JsonData jsonObj = JsonMapper.ToObject(content);
+                if (jsonObj["code"].ToString() == "0")
+                {
+                    OldId = jsonObj["data"]["posMarket"]["id"].ToString();
+                }
+                jsonObj = JsonMapper.ToObject(content);
+                function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + OldId + ":" + NewId, "海科-设置押金-返回报文");
+                content = PublicImportDataService.Instance.SetDepositForHK(pos.PosSn, OldId, NewId, pos.BrandId);
+                function.WriteLog(DateTime.Now.ToString() + "\n" + content, "海科-设置押金-返回报文");
+                if (content == "fail")
+                {
+                    return "机具" + pos.PosSn + "设置失败";
+                }
+                jsonObj = JsonMapper.ToObject(content);
+                if (jsonObj["code"].ToString() != "0")
+                {
+                    return jsonObj["msg"].ToString();
+                }
+                decimal amount = decimal.Parse(DepositId);
+                var BeforeDeposit = 0;
+                if (string.IsNullOrEmpty(pos.PrizeParams))
+                {
+                    if (RelationClass.GetKqProductBrandInfo(pos.BrandId) == "立刷云电签")
+                    {
+                        BeforeDeposit = 249;
+                    }
+                    else
+                    {
+                        BeforeDeposit = 299;
+                    }
+                }
+                else
+                {
+                    BeforeDeposit = int.Parse(pos.PrizeParams);
+                }
+                if (pos.BrandId == 8 || pos.BrandId == 9)
+                {
+                    amount -= 1;
+                }
+                pos.PrizeParams = amount.ToString("f0");
+                db.SaveChanges();
+
+            }
+            return "设置成功";
+        }
+        #endregion
+
+    }
+}