123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707 |
- using Library;
- using System.Collections.Generic;
- using System;
- using System.Linq;
- using LitJson;
- using MySystem.PxcModels;
- namespace MySystem
- {
- /// <summary>
- /// 调整机具服务费工具类
- /// </summary>
- public class ChangePosFeeUtil
- {
- #region 金控-设置押金
- public static string SetJKDeposit(string SnIds, string DepositId)
- {
- // string DepositId = "299";
- string check = RedisDbconn.Instance.Get<string>("SetJKPosDepositWait:" + SnIds);
- if (!string.IsNullOrEmpty(check))
- {
- return "操作频繁,请稍后再试";
- }
- RedisDbconn.Instance.Set("SetJKPosDepositWait:" + SnIds, SnIds);
- RedisDbconn.Instance.SetExpire("SetJKPosDepositWait:" + SnIds, 10);
- WebCMSEntities db = new WebCMSEntities();
- 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 content = "";
- // PosMachineOther otherPos = db.PosMachineOther.FirstOrDefault(m => m.Id == pos.Id);
- // if(otherPos != null)
- // {
- function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "金控-设置押金-返回报文");
- content = PublicImportDataService.Instance.LkbSetDeposit(pos.PosSn, decimal.Parse(DepositId));
- 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.LkbDecrypt(content);
- JsonData contentObj = JsonMapper.ToObject(content);
- if (contentObj["respCode"].ToString() != "00")
- {
- return contentObj["respMsg"].ToString();
- }
- // }
- // else
- // {
- // function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "金控-设置押金-返回报文");
- // content = function.GetWebRequest("http://sp.kexiaoshuang.com/api/test/SetDeposit?sn=" + pos.PosSn + "&num=" + DepositId);
- // 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);
- // JsonData contentObj = JsonMapper.ToObject(content);
- // if (contentObj["respCode"].ToString() != "00")
- // {
- // return contentObj["respMsg"].ToString();
- // }
- // }
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "金控-设置押金-返回报文");
- var BeforeDeposit = 0;
- if (string.IsNullOrEmpty(pos.PrizeParams))
- {
- BeforeDeposit = 299;
- }
- else
- {
- BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
- }
- decimal amount = decimal.Parse(DepositId);
- pos.PrizeParams = amount.ToString("f0");
- db.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- db.Dispose();
- return "设置成功";
- }
- #endregion
- #region 开店宝-设置押金
- public static string SetKDBDeposit(string SnIds, string DepositId)
- {
- // string DepositId = "473";
- string check = RedisDbconn.Instance.Get<string>("SetKDBPosDepositWait:" + SnIds);
- if (!string.IsNullOrEmpty(check))
- {
- return "操作频繁,请稍后再试";
- }
- RedisDbconn.Instance.Set("SetKDBPosDepositWait:" + SnIds, SnIds);
- RedisDbconn.Instance.SetExpire("SetKDBPosDepositWait:" + SnIds, 10);
- WebCMSEntities db = new WebCMSEntities();
- 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 + ":" + DepositId, "开店宝-设置押金-返回报文");
- string content = PublicImportDataService.Instance.ModifyDeposit(pos.PosSn, DepositId);
- if (content == "fail")
- {
- return "机具" + pos.PosSn + "设置失败";
- }
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "开店宝-设置押金-返回报文");
- var BeforeDeposit = 0;
- if (string.IsNullOrEmpty(pos.PrizeParams))
- {
- BeforeDeposit = 299;
- }
- else
- {
- BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
- }
- decimal amount = decimal.Parse(PublicImportDataService.Instance.GetDepositAmount(DepositId));
- pos.PrizeParams = amount.ToString("f0");
- db.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- db.Dispose();
- return "设置成功";
- }
- #endregion
- #region 乐刷-设置押金
- public static string SetLSDeposit(string SnIds, string DepositId)
- {
- // string DepositId = "300";
- string check = RedisDbconn.Instance.Get<string>("SetLSPosDepositWait:" + SnIds);
- if (!string.IsNullOrEmpty(check))
- {
- return "操作频繁,请稍后再试";
- }
- RedisDbconn.Instance.Set("SetLSPosDepositWait:" + SnIds, SnIds);
- RedisDbconn.Instance.SetExpire("SetLSPosDepositWait:" + SnIds, 10);
- WebCMSEntities db = new WebCMSEntities();
- 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))
- {
- BeforeDeposit = 299;
- }
- else
- {
- BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
- }
- decimal amount = decimal.Parse(DepositId);
- if (pos.BrandId == 4 || pos.BrandId == 5)
- {
- amount -= 1;
- }
- pos.PrizeParams = amount.ToString("f0");
- db.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- db.Dispose();
- return "设置成功";
- }
- #endregion
- #region 立刷-设置押金
- public static string SetLISDeposit(string SnIds, string DepositId)
- {
- // string DepositId = "249";
- string check = RedisDbconn.Instance.Get<string>("SetLISPosDepositWait:" + SnIds);
- if (!string.IsNullOrEmpty(check))
- {
- return "操作频繁,请稍后再试";
- }
- RedisDbconn.Instance.Set("SetLISPosDepositWait:" + SnIds, SnIds);
- RedisDbconn.Instance.SetExpire("SetLISPosDepositWait:" + SnIds, 10);
- WebCMSEntities db = new WebCMSEntities();
- 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 + ":" + DepositId, "立刷-设置押金-返回报文");
- string content = "";
- if(pos.BrandId == 6)
- {
- content = PublicImportDataService.Instance.SetLiSDeposit(pos.PosSn, int.Parse(DepositId));
- }
- else
- {
- content = PublicImportDataService.Instance.SetLiSWeDeposit(pos.PosSn, int.Parse(DepositId));
- }
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "立刷-设置押金-返回报文");
- JsonData jsonObj = JsonMapper.ToObject(content);
- if (jsonObj["ret_code"].ToString() != "00")
- {
- return jsonObj["ret_msg"].ToString();
- }
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "立刷-设置押金-返回报文");
- var BeforeDeposit = 0;
- if (string.IsNullOrEmpty(pos.PrizeParams))
- {
- BeforeDeposit = 299;
- }
- else
- {
- BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
- }
- pos.PrizeParams = DepositId;
- db.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- db.Dispose();
- return "设置成功";
- }
- #endregion
- #region 盛付通-设置押金
- public static string SetSFTDeposit(string SnIds, string DepositId)
- {
- string check = RedisDbconn.Instance.Get<string>("SetSFTPosDepositWait:" + SnIds);
- if (!string.IsNullOrEmpty(check))
- {
- return "操作频繁,请稍后再试";
- }
- RedisDbconn.Instance.Set("SetSFTPosDepositWait:" + SnIds, SnIds);
- RedisDbconn.Instance.SetExpire("SetSFTPosDepositWait:" + SnIds, 10);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- WebCMSEntities db = new WebCMSEntities();
- string[] SnIdList = SnIds.Split(',');
- foreach (string SnId in SnIdList)
- {
- int SnIdNum = int.Parse(SnId);
- PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum) ?? new PosMachinesTwo();
- if (!string.IsNullOrEmpty(pos.SeoKeyword))
- {
- return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
- }
- function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "盛付通-设置押金-返回报文");
- string DepositIdString = DepositId;
- if(DepositIdString == "0") DepositIdString = "000";
- if(DepositId == "0")
- {
- PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId) ?? new PosMerchantInfo();
- if(!string.IsNullOrEmpty(merchant.KqMerNo))
- {
- string back = PublicImportDataService.Instance.SftSnBindOrUnbind(pos.PosSn, merchant.KqMerNo);
- function.WriteLog("back:" + back, "盛付通-设置押金-返回报文");
- }
- }
- string content = PublicImportDataService.Instance.SetDepositForSft(pos.PosSn, "2024POS" + DepositIdString);
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "盛付通-设置押金-返回报文");
- JsonData jsonObj = JsonMapper.ToObject(content);
- if (jsonObj["respCode"].ToString() != "00")
- {
- return jsonObj["errorMsg"].ToString();
- }
- var BeforeDeposit = 0;
- if (string.IsNullOrEmpty(pos.PrizeParams))
- {
- BeforeDeposit = 299;
- }
- else
- {
- BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
- }
- pos.PrizeParams = DepositId.Replace("2024POS", "");
- db.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- db.Dispose();
- return "设置成功";
- }
- #endregion
- #region 海科-设置押金
- public static string SetHKDeposit(string SnIds, string DepositId)
- {
- // string DepositId = "300";
- string check = RedisDbconn.Instance.Get<string>("SetHKPosDepositWait:" + SnIds);
- if (!string.IsNullOrEmpty(check))
- {
- return "操作频繁,请稍后再试";
- }
- RedisDbconn.Instance.Set("SetHKPosDepositWait:" + SnIds, SnIds);
- RedisDbconn.Instance.SetExpire("SetHkPosDepositWait:" + SnIds, 10);
- WebCMSEntities db = new WebCMSEntities();
- 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))
- {
- BeforeDeposit = 299;
- }
- else
- {
- BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
- }
- if (pos.BrandId == 8 || pos.BrandId == 9)
- {
- amount -= 1;
- }
- pos.PrizeParams = amount.ToString("f0");
- db.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- db.Dispose();
- return "设置成功";
- }
- #endregion
- #region 联动-设置押金
- public static string SetLDDeposit(string SnIds, string DepositId)
- {
- // string DepositId = "299";
- string check = RedisDbconn.Instance.Get<string>("SetLDPosDepositWait:" + SnIds);
- if (!string.IsNullOrEmpty(check))
- {
- return "操作频繁,请稍后再试";
- }
- RedisDbconn.Instance.Set("SetLDPosDepositWait:" + SnIds, SnIds);
- RedisDbconn.Instance.SetExpire("SetLDPosDepositWait:" + SnIds, 10);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- WebCMSEntities db = new WebCMSEntities();
- 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 + ":" + DepositId, "联动-设置押金-返回报文");
- string content = PublicImportDataService.Instance.LDServiceFee(pos.PosSn, int.Parse(DepositId), pos.BrandId);
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "联动-设置押金-返回报文");
- JsonData jsonObj = JsonMapper.ToObject(content);
- if (jsonObj["code"].ToString() != "000000")
- {
- return jsonObj["msg"].ToString();
- }
- var BeforeDeposit = 0;
- if (string.IsNullOrEmpty(pos.PrizeParams))
- {
- BeforeDeposit = 299;
- }
- else
- {
- BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
- }
- decimal amount = decimal.Parse(DepositId);
- pos.PrizeParams = amount.ToString("f0");
- db.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- db.Dispose();
- return "设置成功";
- }
- #endregion
- #region 盒易付-设置押金
- public static string SetHYFDeposit(string SnIds, string DepositId)
- {
- // string DepositId = "299";
- string check = RedisDbconn.Instance.Get<string>("SetHYFPosDepositWait:" + SnIds);
- if (!string.IsNullOrEmpty(check))
- {
- return "操作频繁,请稍后再试";
- }
- RedisDbconn.Instance.Set("SetHYFPosDepositWait:" + SnIds, SnIds);
- RedisDbconn.Instance.SetExpire("SetHYFPosDepositWait:" + SnIds, 10);
- WebCMSEntities db = new WebCMSEntities();
- 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 + ":" + DepositId, "盒易付-设置押金-返回报文");
- string content = PublicImportDataService.Instance.BoxServiceFee(pos.PosSn, DepositId, pos.BuyUserId);
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "盒易付-设置押金-返回报文");
- if (content == "fail")
- {
- return "机具" + pos.PosSn + "设置失败";
- }
- JsonData jsonObj = JsonMapper.ToObject(content);
- if (jsonObj["resultCode"].ToString() != "1")
- {
- return jsonObj["errorDesc"].ToString();
- }
- var BeforeDeposit = 0;
- if (string.IsNullOrEmpty(pos.PrizeParams))
- {
- BeforeDeposit = 299;
- }
- else
- {
- BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
- }
- decimal amount = decimal.Parse(DepositId);
- pos.PrizeParams = amount.ToString("f0");
- db.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- db.Dispose();
- return "设置成功";
- }
- #endregion
- #region POSP-设置押金
- public static string SetPosPDeposit(string SnIds, string DepositId)
- {
- string policy_code = "";
- string policy_name = "";
- if(DepositId == "0")
- {
- policy_code = "LKB_000";
- policy_name = "联客宝";
- }
- else if(DepositId == "99")
- {
- policy_code = "LKB_99";
- policy_name = "联客宝";
- }
- else if(DepositId == "199")
- {
- policy_code = "LKB_199";
- policy_name = "联客宝";
- }
- else if(DepositId == "299")
- {
- policy_code = "LKB_299";
- policy_name = "联客宝299押金";
- }
- string check = RedisDbconn.Instance.Get<string>("SetPosPDepositWait:" + SnIds);
- if (!string.IsNullOrEmpty(check))
- {
- return "操作频繁,请稍后再试";
- }
- RedisDbconn.Instance.Set("SetPosPDepositWait:" + SnIds, SnIds);
- RedisDbconn.Instance.SetExpire("SetPosPDepositWait:" + SnIds, 10);
- WebCMSEntities db = new WebCMSEntities();
- 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 + ":" + DepositId, "POSP-设置押金-返回报文");
- List<string> PosList = new List<string>();
- PosList.Add(pos.PosSn);
- string content = PublicImportDataService.Instance.PospServiceFee(PosList, policy_code, policy_name);
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "POSP-设置押金-返回报文");
- if (content == "fail")
- {
- return "机具" + pos.PosSn + "设置失败";
- }
- JsonData jsonObj = JsonMapper.ToObject(content);
- if (jsonObj["code"].ToString() != "200")
- {
- return "设置失败";
- }
- var BeforeDeposit = 0;
- if (string.IsNullOrEmpty(pos.PrizeParams))
- {
- BeforeDeposit = 299;
- }
- else
- {
- BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
- }
- decimal amount = decimal.Parse(DepositId);
- pos.PrizeParams = amount.ToString("f0");
- db.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- db.Dispose();
- return "设置成功";
- }
- #endregion
-
-
-
- #region 拉卡拉-设置押金
- public static string SetLKLDeposit(string SnIds, string DepositId)
- {
- string check = RedisDbconn.Instance.Get<string>("SetLKLPosDepositWait:" + SnIds);
- if (!string.IsNullOrEmpty(check))
- {
- return "操作频繁,请稍后再试";
- }
- RedisDbconn.Instance.Set("SetLKLPosDepositWait:" + SnIds, SnIds);
- RedisDbconn.Instance.SetExpire("SetLKLPosDepositWait:" + SnIds, 10);
- WebCMSEntities db = new WebCMSEntities();
- 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 content = "";
- function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "拉卡拉-设置押金-返回报文");
- content = PublicImportDataService.Instance.LkLSetDeposit(pos.PosSn, decimal.Parse(DepositId));
- 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.LklDecrypt(content);
- if (!content.ToLower().Contains("success"))
- {
- return content;
- }
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "拉卡拉-设置押金-返回报文");
- var BeforeDeposit = 0;
- if (string.IsNullOrEmpty(pos.PrizeParams))
- {
- BeforeDeposit = 299;
- }
- else
- {
- BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
- }
- decimal amount = decimal.Parse(DepositId);
- pos.PrizeParams = amount.ToString("f0");
- db.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- db.Dispose();
- return "设置成功";
- }
- #endregion
-
-
-
-
-
- }
- }
|