ChangePosFeeUtil.cs 21 KB

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