ChangePosFeeUtil.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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 SetHYFDeposit(string SnIds, string DepositId, string UserId = "0")
  285. {
  286. // string DepositId = "299";
  287. string check = RedisDbconn.Instance.Get<string>("SetHYFPosDepositWait:" + SnIds);
  288. if (!string.IsNullOrEmpty(check))
  289. {
  290. return "操作频繁,请稍后再试";
  291. }
  292. RedisDbconn.Instance.Set("SetHYFPosDepositWait:" + SnIds, SnIds);
  293. RedisDbconn.Instance.SetExpire("SetHYFPosDepositWait:" + SnIds, 10);
  294. Dictionary<string, object> Obj = new Dictionary<string, object>();
  295. string[] SnIdList = SnIds.Split(',');
  296. foreach (string PosSn in SnIdList)
  297. {
  298. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + PosSn + ":" + DepositId, "盒易付-设置押金-返回报文");
  299. string content = PublicImportDataService.Instance.BoxServiceFee(PosSn, DepositId, int.Parse(UserId));
  300. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "盒易付-设置押金-返回报文");
  301. if (content == "fail")
  302. {
  303. return "机具" + PosSn + "设置失败";
  304. }
  305. JsonData jsonObj = JsonMapper.ToObject(content);
  306. if (jsonObj["resultCode"].ToString() != "1")
  307. {
  308. return jsonObj["errorDesc"].ToString();
  309. }
  310. }
  311. return "设置成功";
  312. }
  313. #endregion
  314. #region POSP-设置押金
  315. public static string SetPosPDeposit(string SnIds, string DepositId)
  316. {
  317. string policy_code = "";
  318. string policy_name = "";
  319. if(DepositId == "0")
  320. {
  321. policy_code = "LKB_000";
  322. policy_name = "联客宝";
  323. }
  324. else if(DepositId == "99")
  325. {
  326. policy_code = "LKB_99";
  327. policy_name = "联客宝";
  328. }
  329. else if(DepositId == "199")
  330. {
  331. policy_code = "LKB_199";
  332. policy_name = "联客宝";
  333. }
  334. else if(DepositId == "299")
  335. {
  336. policy_code = "LKB_299";
  337. policy_name = "联客宝299押金";
  338. }
  339. string check = RedisDbconn.Instance.Get<string>("SetPosPDepositWait:" + SnIds);
  340. if (!string.IsNullOrEmpty(check))
  341. {
  342. return "操作频繁,请稍后再试";
  343. }
  344. RedisDbconn.Instance.Set("SetPosPDepositWait:" + SnIds, SnIds);
  345. RedisDbconn.Instance.SetExpire("SetPosPDepositWait:" + SnIds, 10);
  346. Dictionary<string, object> Obj = new Dictionary<string, object>();
  347. string[] SnIdList = SnIds.Split(',');
  348. foreach (string PosSn in SnIdList)
  349. {
  350. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + PosSn + ":" + DepositId, "POSP-设置押金-返回报文");
  351. List<string> PosList = new List<string>();
  352. PosList.Add(PosSn);
  353. string content = PublicImportDataService.Instance.PospServiceFee(PosList, policy_code, policy_name);
  354. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "POSP-设置押金-返回报文");
  355. if (content == "fail")
  356. {
  357. return "机具" + PosSn + "设置失败";
  358. }
  359. JsonData jsonObj = JsonMapper.ToObject(content);
  360. if (jsonObj["code"].ToString() != "200")
  361. {
  362. return "设置失败";
  363. }
  364. }
  365. return "设置成功";
  366. }
  367. #endregion
  368. #region 拉卡拉-设置押金
  369. public static string SetLKLDeposit(string SnIds, string DepositId, int BrandId)
  370. {
  371. string check = RedisDbconn.Instance.Get<string>("SetLKLPosDepositWait:" + SnIds);
  372. if (!string.IsNullOrEmpty(check))
  373. {
  374. return "操作频繁,请稍后再试";
  375. }
  376. RedisDbconn.Instance.Set("SetLKLPosDepositWait:" + SnIds, SnIds);
  377. RedisDbconn.Instance.SetExpire("SetLKLPosDepositWait:" + SnIds, 10);
  378. Dictionary<string, object> Obj = new Dictionary<string, object>();
  379. string[] SnIdList = SnIds.Split(',');
  380. foreach (string PosSn in SnIdList)
  381. {
  382. //判断是否存在关联数据
  383. string content = "";
  384. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + PosSn + ":" + DepositId, "拉卡拉-设置押金-返回报文");
  385. content = PublicImportDataService.Instance.LkLSetDeposit(PosSn, decimal.Parse(DepositId), BrandId);
  386. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "拉卡拉-设置押金-返回报文");
  387. if (content == "fail")
  388. {
  389. return "机具" + PosSn + "设置失败";
  390. }
  391. JsonData jsonObj = JsonMapper.ToObject(content);
  392. if (jsonObj["code"].ToString() != "000000")
  393. {
  394. return jsonObj["message"].ToString();
  395. }
  396. content = jsonObj["data"].ToString();
  397. content = PublicImportDataService.Instance.LklDecrypt(content);
  398. if (!content.ToLower().Contains("success"))
  399. {
  400. return content;
  401. }
  402. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "拉卡拉-设置押金-返回报文");
  403. }
  404. return "设置成功";
  405. }
  406. #endregion
  407. }
  408. }