PublicChangePosFee.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Data;
  5. using System.Text.RegularExpressions;
  6. using MySystem.Models;
  7. using Library;
  8. using NPOI.SS.UserModel;
  9. using NPOI.XSSF.UserModel;
  10. using Microsoft.AspNetCore.Mvc;
  11. using System.IO;
  12. using LitJson;
  13. /// <summary>
  14. /// 设置机具服务费
  15. /// </summary>
  16. namespace MySystem
  17. {
  18. public class PublicChangePosFee
  19. {
  20. public WebCMSEntities db = new WebCMSEntities();
  21. #region 金控-设置押金
  22. public string SetJKDeposit(string SnIds)
  23. {
  24. string check = RedisDbconn.Instance.Get<string>("SetJKPosDepositWait:" + SnIds);
  25. if (!string.IsNullOrEmpty(check))
  26. {
  27. return "操作频繁,请稍后再试";
  28. }
  29. RedisDbconn.Instance.Set("SetJKPosDepositWait:" + SnIds, SnIds);
  30. RedisDbconn.Instance.SetExpire("SetJKPosDepositWait:" + SnIds, 120);
  31. Dictionary<string, object> Obj = new Dictionary<string, object>();
  32. string[] SnIdList = SnIds.Split(',');
  33. foreach (string SnId in SnIdList)
  34. {
  35. int SnIdNum = int.Parse(SnId);
  36. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  37. if (pos == null)
  38. {
  39. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  40. }
  41. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + "299", "金控-设置押金-返回报文");
  42. string content = function.GetWebRequest("http://sp.kexiaoshuang.com/api/test/SetDeposit?sn=" + pos.PosSn + "&num=" + "299");
  43. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "金控-设置押金-返回报文");
  44. if (content == "fail")
  45. {
  46. return "机具" + pos.PosSn + "设置失败";
  47. }
  48. JsonData jsonObj = JsonMapper.ToObject(content);
  49. if (jsonObj["code"].ToString() != "000000")
  50. {
  51. return jsonObj["message"].ToString();
  52. }
  53. content = jsonObj["data"].ToString();
  54. content = PublicImportDataService.Instance.Decrypt(content);
  55. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "金控-设置押金-返回报文");
  56. JsonData contentObj = JsonMapper.ToObject(content);
  57. if (contentObj["respCode"].ToString() != "00")
  58. {
  59. return contentObj["respMsg"].ToString();
  60. }
  61. var BeforeDeposit = 0;
  62. if (string.IsNullOrEmpty(pos.PrizeParams))
  63. {
  64. BeforeDeposit = 299;
  65. }
  66. else
  67. {
  68. BeforeDeposit = int.Parse(pos.PrizeParams);
  69. }
  70. decimal amount = decimal.Parse("199");
  71. pos.PrizeParams = amount.ToString("f0");
  72. db.SaveChanges();
  73. }
  74. return "设置成功";
  75. }
  76. #endregion
  77. #region 开店宝-设置押金
  78. public string SetKDBDeposit(string SnIds)
  79. {
  80. string check = RedisDbconn.Instance.Get<string>("SetKDBPosDepositWait:" + SnIds);
  81. if (!string.IsNullOrEmpty(check))
  82. {
  83. return "操作频繁,请稍后再试";
  84. }
  85. RedisDbconn.Instance.Set("SetKDBPosDepositWait:" + SnIds, SnIds);
  86. RedisDbconn.Instance.SetExpire("SetKDBPosDepositWait:" + SnIds, 120);
  87. string[] SnIdList = SnIds.Split(',');
  88. foreach (string SnId in SnIdList)
  89. {
  90. int SnIdNum = int.Parse(SnId);
  91. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  92. if (pos == null)
  93. {
  94. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  95. }
  96. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + "299", "开店宝-设置押金-返回报文");
  97. string content = PublicImportDataService.Instance.ModifyDeposit(pos.PosSn, "299");
  98. if (content == "fail")
  99. {
  100. return "机具" + pos.PosSn + "设置失败";
  101. }
  102. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "开店宝-设置押金-返回报文");
  103. var BeforeDeposit = 0;
  104. if (string.IsNullOrEmpty(pos.PrizeParams))
  105. {
  106. BeforeDeposit = 299;
  107. }
  108. else
  109. {
  110. BeforeDeposit = int.Parse(pos.PrizeParams);
  111. }
  112. decimal amount = decimal.Parse(PublicImportDataService.Instance.GetDepositAmount("299"));
  113. pos.PrizeParams = amount.ToString("f0");
  114. db.SaveChanges();
  115. }
  116. return "设置成功";
  117. }
  118. #endregion
  119. #region 乐刷-设置押金
  120. public string SetLSDeposit(string SnIds, string DepositId = "300")
  121. {
  122. string check = RedisDbconn.Instance.Get<string>("SetLSPosDepositWait:" + SnIds);
  123. if (!string.IsNullOrEmpty(check))
  124. {
  125. return "操作频繁,请稍后再试";
  126. }
  127. RedisDbconn.Instance.Set("SetLSPosDepositWait:" + SnIds, SnIds);
  128. RedisDbconn.Instance.SetExpire("SetLSPosDepositWait:" + SnIds, 120);
  129. Dictionary<string, object> Obj = new Dictionary<string, object>();
  130. string[] SnIdList = SnIds.Split(',');
  131. foreach (string SnId in SnIdList)
  132. {
  133. int SnIdNum = int.Parse(SnId);
  134. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  135. if (pos == null)
  136. {
  137. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  138. }
  139. string OldId = "", NewId = "";
  140. if (DepositId == "100")
  141. {
  142. NewId = "704067039039856640";
  143. }
  144. else if (DepositId == "200")
  145. {
  146. NewId = "709820183485095936";
  147. }
  148. else if (DepositId == "300")
  149. {
  150. NewId = "709820390742437888";
  151. }
  152. string content = PublicImportDataService.Instance.QueryActiveForConfig(pos.PosSn, pos.BrandId);
  153. JsonData jsonObj = JsonMapper.ToObject(content);
  154. if (jsonObj["code"].ToString() == "0")
  155. {
  156. OldId = jsonObj["data"]["posMarket"]["id"].ToString();
  157. }
  158. jsonObj = JsonMapper.ToObject(content);
  159. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + OldId + ":" + NewId, "乐刷-设置押金-返回报文");
  160. content = PublicImportDataService.Instance.SetDepositForLS(pos.PosSn, OldId, NewId, pos.BrandId);
  161. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "乐刷-设置押金-返回报文");
  162. if (content == "fail")
  163. {
  164. return "机具" + pos.PosSn + "设置失败";
  165. }
  166. jsonObj = JsonMapper.ToObject(content);
  167. if (jsonObj["code"].ToString() != "0")
  168. {
  169. return jsonObj["msg"].ToString();
  170. }
  171. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "乐刷-设置押金-返回报文");
  172. var BeforeDeposit = 0;
  173. if (string.IsNullOrEmpty(pos.PrizeParams))
  174. {
  175. BeforeDeposit = 299;
  176. }
  177. else
  178. {
  179. BeforeDeposit = int.Parse(pos.PrizeParams);
  180. }
  181. decimal amount = decimal.Parse(DepositId);
  182. if (pos.BrandId == 4 || pos.BrandId == 5)
  183. {
  184. amount -= 1;
  185. }
  186. pos.PrizeParams = amount.ToString("f0");
  187. db.SaveChanges();
  188. }
  189. return "设置成功";
  190. }
  191. #endregion
  192. #region 立刷-设置押金
  193. public string SetLISDeposit(string SnIds, string DepositId = "249")
  194. {
  195. string check = RedisDbconn.Instance.Get<string>("SetLISPosDepositWait:" + SnIds);
  196. if (!string.IsNullOrEmpty(check))
  197. {
  198. return "操作频繁,请稍后再试";
  199. }
  200. RedisDbconn.Instance.Set("SetLISPosDepositWait:" + SnIds, SnIds);
  201. RedisDbconn.Instance.SetExpire("SetLISPosDepositWait:" + SnIds, 120);
  202. Dictionary<string, object> Obj = new Dictionary<string, object>();
  203. string[] SnIdList = SnIds.Split(',');
  204. foreach (string SnId in SnIdList)
  205. {
  206. int SnIdNum = int.Parse(SnId);
  207. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  208. if (pos == null)
  209. {
  210. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  211. }
  212. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "立刷-设置押金-返回报文");
  213. string content = PublicImportDataService.Instance.SetLiSDeposit(pos.PosSn, int.Parse(DepositId));
  214. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "立刷-设置押金-返回报文");
  215. JsonData jsonObj = JsonMapper.ToObject(content);
  216. if (jsonObj["ret_code"].ToString() != "00")
  217. {
  218. return jsonObj["ret_msg"].ToString();
  219. }
  220. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "立刷-设置押金-返回报文");
  221. var BeforeDeposit = 0;
  222. if (string.IsNullOrEmpty(pos.PrizeParams))
  223. {
  224. if (RelationClass.GetKqProductBrandInfo(pos.BrandId) == "立刷云电签")
  225. {
  226. BeforeDeposit = 249;
  227. }
  228. else
  229. {
  230. BeforeDeposit = 299;
  231. }
  232. }
  233. else
  234. {
  235. BeforeDeposit = int.Parse(pos.PrizeParams);
  236. }
  237. pos.PrizeParams = DepositId;
  238. db.SaveChanges();
  239. }
  240. return "设置成功";
  241. }
  242. #endregion
  243. #region 盛付通-设置押金
  244. public string SetSFTDeposit(string SnIds, string DepositId)
  245. {
  246. string check = RedisDbconn.Instance.Get<string>("SetSFTPosDepositWait:" + SnIds);
  247. if (!string.IsNullOrEmpty(check))
  248. {
  249. return "操作频繁,请稍后再试";
  250. }
  251. RedisDbconn.Instance.Set("SetSFTPosDepositWait:" + SnIds, SnIds);
  252. RedisDbconn.Instance.SetExpire("SetSFTPosDepositWait:" + SnIds, 120);
  253. Dictionary<string, object> Obj = new Dictionary<string, object>();
  254. string[] SnIdList = SnIds.Split(',');
  255. foreach (string SnId in SnIdList)
  256. {
  257. int SnIdNum = int.Parse(SnId);
  258. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  259. if (pos == null)
  260. {
  261. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  262. }
  263. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "盛付通-设置押金-返回报文");
  264. string content = PublicImportDataService.Instance.SetDepositForSft(pos.PosSn, DepositId);
  265. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "盛付通-设置押金-返回报文");
  266. JsonData jsonObj = JsonMapper.ToObject(content);
  267. if (jsonObj["respCode"].ToString() != "00")
  268. {
  269. return jsonObj["errorMsg"].ToString();
  270. }
  271. var BeforeDeposit = 0;
  272. if (string.IsNullOrEmpty(pos.PrizeParams))
  273. {
  274. BeforeDeposit = 299;
  275. }
  276. else
  277. {
  278. BeforeDeposit = int.Parse(pos.PrizeParams);
  279. }
  280. pos.PrizeParams = DepositId.Replace("2021POS", "");
  281. db.SaveChanges();
  282. }
  283. return "设置成功";
  284. }
  285. #endregion
  286. #region 海科-设置押金
  287. public string SetHKDeposit(string SnIds, string DepositId = "300")
  288. {
  289. string check = RedisDbconn.Instance.Get<string>("SetHKPosDepositWait:" + SnIds);
  290. if (!string.IsNullOrEmpty(check))
  291. {
  292. return "操作频繁,请稍后再试";
  293. }
  294. RedisDbconn.Instance.Set("SetHKPosDepositWait:" + SnIds, SnIds);
  295. RedisDbconn.Instance.SetExpire("SetHkPosDepositWait:" + SnIds, 120);
  296. Dictionary<string, object> Obj = new Dictionary<string, object>();
  297. string[] SnIdList = SnIds.Split(',');
  298. foreach (string SnId in SnIdList)
  299. {
  300. int SnIdNum = int.Parse(SnId);
  301. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  302. if (pos == null)
  303. {
  304. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  305. }
  306. string OldId = "", NewId = "";
  307. if (DepositId == "100")
  308. {
  309. NewId = pos.BrandId == 8 ? "202207011718129" : "202207011718197";
  310. }
  311. else if (DepositId == "200")
  312. {
  313. NewId = pos.BrandId == 8 ? "747200504467566592" : "747199934126108672";
  314. }
  315. else if (DepositId == "300")
  316. {
  317. NewId = pos.BrandId == 8 ? "747193472108732416" : "747193820156276736";
  318. }
  319. string content = PublicImportDataService.Instance.QueryActiveForConfigHK(pos.PosSn, pos.BrandId);
  320. JsonData jsonObj = JsonMapper.ToObject(content);
  321. if (jsonObj["code"].ToString() == "0")
  322. {
  323. OldId = jsonObj["data"]["posMarket"]["id"].ToString();
  324. }
  325. jsonObj = JsonMapper.ToObject(content);
  326. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + OldId + ":" + NewId, "海科-设置押金-返回报文");
  327. content = PublicImportDataService.Instance.SetDepositForHK(pos.PosSn, OldId, NewId, pos.BrandId);
  328. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "海科-设置押金-返回报文");
  329. if (content == "fail")
  330. {
  331. return "机具" + pos.PosSn + "设置失败";
  332. }
  333. jsonObj = JsonMapper.ToObject(content);
  334. if (jsonObj["code"].ToString() != "0")
  335. {
  336. return jsonObj["msg"].ToString();
  337. }
  338. decimal amount = decimal.Parse(DepositId);
  339. var BeforeDeposit = 0;
  340. if (string.IsNullOrEmpty(pos.PrizeParams))
  341. {
  342. BeforeDeposit = 299;
  343. }
  344. else
  345. {
  346. BeforeDeposit = int.Parse(pos.PrizeParams);
  347. }
  348. if (pos.BrandId == 8 || pos.BrandId == 9)
  349. {
  350. amount -= 1;
  351. }
  352. pos.PrizeParams = amount.ToString("f0");
  353. db.SaveChanges();
  354. }
  355. return "设置成功";
  356. }
  357. #endregion
  358. #region 联动-设置押金
  359. public string SetLDDeposit(string SnIds, string DepositId = "299")
  360. {
  361. string check = RedisDbconn.Instance.Get<string>("SetLDPosDepositWait:" + SnIds);
  362. if (!string.IsNullOrEmpty(check))
  363. {
  364. return "操作频繁,请稍后再试";
  365. }
  366. RedisDbconn.Instance.Set("SetLDPosDepositWait:" + SnIds, SnIds);
  367. RedisDbconn.Instance.SetExpire("SetLDPosDepositWait:" + SnIds, 120);
  368. Dictionary<string, object> Obj = new Dictionary<string, object>();
  369. string[] SnIdList = SnIds.Split(',');
  370. foreach (string SnId in SnIdList)
  371. {
  372. int SnIdNum = int.Parse(SnId);
  373. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  374. if (pos == null)
  375. {
  376. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  377. }
  378. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "联动-设置押金-返回报文");
  379. string content = PublicImportDataService.Instance.LDServiceFee(pos.PosSn, int.Parse(DepositId), pos.BrandId);
  380. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "联动-设置押金-返回报文");
  381. JsonData jsonObj = JsonMapper.ToObject(content);
  382. if (jsonObj["code"].ToString() != "000000")
  383. {
  384. return jsonObj["msg"].ToString();
  385. }
  386. var BeforeDeposit = 0;
  387. if (string.IsNullOrEmpty(pos.PrizeParams))
  388. {
  389. BeforeDeposit = 299;
  390. }
  391. else
  392. {
  393. BeforeDeposit = int.Parse(pos.PrizeParams);
  394. }
  395. decimal amount = decimal.Parse(DepositId);
  396. pos.PrizeParams = amount.ToString("f0");
  397. db.SaveChanges();
  398. }
  399. return "设置成功";
  400. }
  401. #endregion
  402. #region 盒易付-设置押金
  403. public string SetHYFDeposit(string SnIds, string DepositId = "299")
  404. {
  405. string check = RedisDbconn.Instance.Get<string>("SetHYFPosDepositWait:" + SnIds);
  406. if (!string.IsNullOrEmpty(check))
  407. {
  408. return "操作频繁,请稍后再试";
  409. }
  410. RedisDbconn.Instance.Set("SetHYFPosDepositWait:" + SnIds, SnIds);
  411. RedisDbconn.Instance.SetExpire("SetHYFPosDepositWait:" + SnIds, 120);
  412. Dictionary<string, object> Obj = new Dictionary<string, object>();
  413. string[] SnIdList = SnIds.Split(',');
  414. foreach (string SnId in SnIdList)
  415. {
  416. int SnIdNum = int.Parse(SnId);
  417. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  418. if (pos == null)
  419. {
  420. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  421. }
  422. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "盒易付-设置押金-返回报文");
  423. string content = PublicImportDataService.Instance.BoxServiceFee(pos.PosSn, DepositId);
  424. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "盒易付-设置押金-返回报文");
  425. if (content == "fail")
  426. {
  427. return "机具" + pos.PosSn + "设置失败";
  428. }
  429. JsonData jsonObj = JsonMapper.ToObject(content);
  430. if (jsonObj["resultCode"].ToString() != "1")
  431. {
  432. return jsonObj["errorDesc"].ToString();
  433. }
  434. var BeforeDeposit = 0;
  435. if (string.IsNullOrEmpty(pos.PrizeParams))
  436. {
  437. BeforeDeposit = 299;
  438. }
  439. else
  440. {
  441. BeforeDeposit = int.Parse(pos.PrizeParams);
  442. }
  443. decimal amount = decimal.Parse(DepositId);
  444. pos.PrizeParams = amount.ToString("f0");
  445. db.SaveChanges();
  446. }
  447. return "设置成功";
  448. }
  449. #endregion
  450. #region
  451. public string SeeInfo(string Brand)
  452. {
  453. var info = "";
  454. //KDB
  455. info = PublicImportDataService.Instance.GetPolicyList();
  456. return info;
  457. }
  458. #endregion
  459. }
  460. }