ChangePosFeeUtil.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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. WebCMSEntities db = new WebCMSEntities();
  26. Dictionary<string, object> Obj = new Dictionary<string, object>();
  27. string[] SnIdList = SnIds.Split(',');
  28. foreach (string SnId in SnIdList)
  29. {
  30. int SnIdNum = int.Parse(SnId);
  31. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  32. if (pos == null)
  33. {
  34. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  35. }
  36. //判断是否存在关联数据
  37. string content = "";
  38. // PosMachineOther otherPos = db.PosMachineOther.FirstOrDefault(m => m.Id == pos.Id);
  39. // if(otherPos != null)
  40. // {
  41. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "金控-设置押金-返回报文");
  42. content = PublicImportDataService.Instance.LkbSetDeposit(pos.PosSn, decimal.Parse(DepositId));
  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.LkbDecrypt(content);
  55. JsonData contentObj = JsonMapper.ToObject(content);
  56. if (contentObj["respCode"].ToString() != "00")
  57. {
  58. return contentObj["respMsg"].ToString();
  59. }
  60. // }
  61. // else
  62. // {
  63. // function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "金控-设置押金-返回报文");
  64. // content = function.GetWebRequest("http://sp.kexiaoshuang.com/api/test/SetDeposit?sn=" + pos.PosSn + "&num=" + DepositId);
  65. // function.WriteLog(DateTime.Now.ToString() + "\n" + content, "金控-设置押金-返回报文");
  66. // if (content == "fail")
  67. // {
  68. // return "机具" + pos.PosSn + "设置失败";
  69. // }
  70. // JsonData jsonObj = JsonMapper.ToObject(content);
  71. // if (jsonObj["code"].ToString() != "000000")
  72. // {
  73. // return jsonObj["message"].ToString();
  74. // }
  75. // content = jsonObj["data"].ToString();
  76. // content = PublicImportDataService.Instance.Decrypt(content);
  77. // JsonData contentObj = JsonMapper.ToObject(content);
  78. // if (contentObj["respCode"].ToString() != "00")
  79. // {
  80. // return contentObj["respMsg"].ToString();
  81. // }
  82. // }
  83. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "金控-设置押金-返回报文");
  84. var BeforeDeposit = 0;
  85. if (string.IsNullOrEmpty(pos.PrizeParams))
  86. {
  87. BeforeDeposit = 299;
  88. }
  89. else
  90. {
  91. BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
  92. }
  93. decimal amount = decimal.Parse(DepositId);
  94. pos.PrizeParams = amount.ToString("f0");
  95. db.SaveChanges();
  96. //设置押金添加记录
  97. PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
  98. }
  99. db.Dispose();
  100. return "设置成功";
  101. }
  102. #endregion
  103. #region 开店宝-设置押金
  104. public static string SetKDBDeposit(string SnIds, string DepositId)
  105. {
  106. // string DepositId = "473";
  107. string check = RedisDbconn.Instance.Get<string>("SetKDBPosDepositWait:" + SnIds);
  108. if (!string.IsNullOrEmpty(check))
  109. {
  110. return "操作频繁,请稍后再试";
  111. }
  112. RedisDbconn.Instance.Set("SetKDBPosDepositWait:" + SnIds, SnIds);
  113. RedisDbconn.Instance.SetExpire("SetKDBPosDepositWait:" + SnIds, 10);
  114. WebCMSEntities db = new WebCMSEntities();
  115. string[] SnIdList = SnIds.Split(',');
  116. foreach (string SnId in SnIdList)
  117. {
  118. int SnIdNum = int.Parse(SnId);
  119. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  120. if (pos == null)
  121. {
  122. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  123. }
  124. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "开店宝-设置押金-返回报文");
  125. string content = PublicImportDataService.Instance.ModifyDeposit(pos.PosSn, DepositId);
  126. if (content == "fail")
  127. {
  128. return "机具" + pos.PosSn + "设置失败";
  129. }
  130. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "开店宝-设置押金-返回报文");
  131. var BeforeDeposit = 0;
  132. if (string.IsNullOrEmpty(pos.PrizeParams))
  133. {
  134. BeforeDeposit = 299;
  135. }
  136. else
  137. {
  138. BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
  139. }
  140. decimal amount = decimal.Parse(PublicImportDataService.Instance.GetDepositAmount(DepositId));
  141. pos.PrizeParams = amount.ToString("f0");
  142. db.SaveChanges();
  143. //设置押金添加记录
  144. PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
  145. }
  146. db.Dispose();
  147. return "设置成功";
  148. }
  149. #endregion
  150. #region 乐刷-设置押金
  151. public static string SetLSDeposit(string SnIds, string DepositId)
  152. {
  153. // string DepositId = "300";
  154. string check = RedisDbconn.Instance.Get<string>("SetLSPosDepositWait:" + SnIds);
  155. if (!string.IsNullOrEmpty(check))
  156. {
  157. return "操作频繁,请稍后再试";
  158. }
  159. RedisDbconn.Instance.Set("SetLSPosDepositWait:" + SnIds, SnIds);
  160. RedisDbconn.Instance.SetExpire("SetLSPosDepositWait:" + SnIds, 10);
  161. WebCMSEntities db = new WebCMSEntities();
  162. Dictionary<string, object> Obj = new Dictionary<string, object>();
  163. string[] SnIdList = SnIds.Split(',');
  164. foreach (string SnId in SnIdList)
  165. {
  166. int SnIdNum = int.Parse(SnId);
  167. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  168. if (pos == null)
  169. {
  170. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  171. }
  172. string OldId = "", NewId = "";
  173. if (DepositId == "100")
  174. {
  175. NewId = "704067039039856640";
  176. }
  177. else if (DepositId == "200")
  178. {
  179. NewId = "709820183485095936";
  180. }
  181. else if (DepositId == "300")
  182. {
  183. NewId = "709820390742437888";
  184. }
  185. string content = PublicImportDataService.Instance.QueryActiveForConfig(pos.PosSn, pos.BrandId);
  186. JsonData jsonObj = JsonMapper.ToObject(content);
  187. if (jsonObj["code"].ToString() == "0")
  188. {
  189. OldId = jsonObj["data"]["posMarket"]["id"].ToString();
  190. }
  191. jsonObj = JsonMapper.ToObject(content);
  192. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + OldId + ":" + NewId, "乐刷-设置押金-返回报文");
  193. content = PublicImportDataService.Instance.SetDepositForLS(pos.PosSn, OldId, NewId, pos.BrandId);
  194. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "乐刷-设置押金-返回报文");
  195. if (content == "fail")
  196. {
  197. return "机具" + pos.PosSn + "设置失败";
  198. }
  199. jsonObj = JsonMapper.ToObject(content);
  200. if (jsonObj["code"].ToString() != "0")
  201. {
  202. return jsonObj["msg"].ToString();
  203. }
  204. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "乐刷-设置押金-返回报文");
  205. var BeforeDeposit = 0;
  206. if (string.IsNullOrEmpty(pos.PrizeParams))
  207. {
  208. BeforeDeposit = 299;
  209. }
  210. else
  211. {
  212. BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
  213. }
  214. decimal amount = decimal.Parse(DepositId);
  215. if (pos.BrandId == 4 || pos.BrandId == 5)
  216. {
  217. amount -= 1;
  218. }
  219. pos.PrizeParams = amount.ToString("f0");
  220. db.SaveChanges();
  221. //设置押金添加记录
  222. PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
  223. }
  224. db.Dispose();
  225. return "设置成功";
  226. }
  227. #endregion
  228. #region 立刷-设置押金
  229. public static string SetLISDeposit(string SnIds, string DepositId)
  230. {
  231. // string DepositId = "249";
  232. string check = RedisDbconn.Instance.Get<string>("SetLISPosDepositWait:" + SnIds);
  233. if (!string.IsNullOrEmpty(check))
  234. {
  235. return "操作频繁,请稍后再试";
  236. }
  237. RedisDbconn.Instance.Set("SetLISPosDepositWait:" + SnIds, SnIds);
  238. RedisDbconn.Instance.SetExpire("SetLISPosDepositWait:" + SnIds, 10);
  239. WebCMSEntities db = new WebCMSEntities();
  240. Dictionary<string, object> Obj = new Dictionary<string, object>();
  241. string[] SnIdList = SnIds.Split(',');
  242. foreach (string SnId in SnIdList)
  243. {
  244. int SnIdNum = int.Parse(SnId);
  245. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  246. if (pos == null)
  247. {
  248. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  249. }
  250. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "立刷-设置押金-返回报文");
  251. string content = "";
  252. if(pos.BrandId == 6)
  253. {
  254. content = PublicImportDataService.Instance.SetLiSDeposit(pos.PosSn, int.Parse(DepositId));
  255. }
  256. else
  257. {
  258. content = PublicImportDataService.Instance.SetLiSWeDeposit(pos.PosSn, int.Parse(DepositId));
  259. }
  260. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "立刷-设置押金-返回报文");
  261. JsonData jsonObj = JsonMapper.ToObject(content);
  262. if (jsonObj["ret_code"].ToString() != "00")
  263. {
  264. return jsonObj["ret_msg"].ToString();
  265. }
  266. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "立刷-设置押金-返回报文");
  267. var BeforeDeposit = 0;
  268. if (string.IsNullOrEmpty(pos.PrizeParams))
  269. {
  270. BeforeDeposit = 299;
  271. }
  272. else
  273. {
  274. BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
  275. }
  276. pos.PrizeParams = DepositId;
  277. db.SaveChanges();
  278. //设置押金添加记录
  279. PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
  280. }
  281. db.Dispose();
  282. return "设置成功";
  283. }
  284. #endregion
  285. #region 盛付通-设置押金
  286. public static string SetSFTDeposit(string SnIds, string DepositId)
  287. {
  288. string check = RedisDbconn.Instance.Get<string>("SetSFTPosDepositWait:" + SnIds);
  289. if (!string.IsNullOrEmpty(check))
  290. {
  291. return "操作频繁,请稍后再试";
  292. }
  293. RedisDbconn.Instance.Set("SetSFTPosDepositWait:" + SnIds, SnIds);
  294. RedisDbconn.Instance.SetExpire("SetSFTPosDepositWait:" + SnIds, 10);
  295. Dictionary<string, object> Obj = new Dictionary<string, object>();
  296. WebCMSEntities db = new WebCMSEntities();
  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) ?? new PosMachinesTwo();
  302. if (!string.IsNullOrEmpty(pos.SeoKeyword))
  303. {
  304. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  305. }
  306. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "盛付通-设置押金-返回报文");
  307. string DepositIdString = DepositId;
  308. if(DepositIdString == "0") DepositIdString = "000";
  309. if(DepositId == "0")
  310. {
  311. PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId) ?? new PosMerchantInfo();
  312. if(!string.IsNullOrEmpty(merchant.KqMerNo))
  313. {
  314. string back = PublicImportDataService.Instance.SftSnBindOrUnbind(pos.PosSn, merchant.KqMerNo);
  315. function.WriteLog("back:" + back, "盛付通-设置押金-返回报文");
  316. }
  317. }
  318. string content = PublicImportDataService.Instance.SetDepositForSft(pos.PosSn, "2024POS" + DepositIdString);
  319. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "盛付通-设置押金-返回报文");
  320. JsonData jsonObj = JsonMapper.ToObject(content);
  321. if (jsonObj["respCode"].ToString() != "00")
  322. {
  323. return jsonObj["errorMsg"].ToString();
  324. }
  325. var BeforeDeposit = 0;
  326. if (string.IsNullOrEmpty(pos.PrizeParams))
  327. {
  328. BeforeDeposit = 299;
  329. }
  330. else
  331. {
  332. BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
  333. }
  334. pos.PrizeParams = DepositId.Replace("2024POS", "");
  335. db.SaveChanges();
  336. //设置押金添加记录
  337. PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
  338. }
  339. db.Dispose();
  340. return "设置成功";
  341. }
  342. #endregion
  343. #region 海科-设置押金
  344. public static string SetHKDeposit(string SnIds, string DepositId)
  345. {
  346. // string DepositId = "300";
  347. string check = RedisDbconn.Instance.Get<string>("SetHKPosDepositWait:" + SnIds);
  348. if (!string.IsNullOrEmpty(check))
  349. {
  350. return "操作频繁,请稍后再试";
  351. }
  352. RedisDbconn.Instance.Set("SetHKPosDepositWait:" + SnIds, SnIds);
  353. RedisDbconn.Instance.SetExpire("SetHkPosDepositWait:" + SnIds, 10);
  354. WebCMSEntities db = new WebCMSEntities();
  355. Dictionary<string, object> Obj = new Dictionary<string, object>();
  356. string[] SnIdList = SnIds.Split(',');
  357. foreach (string SnId in SnIdList)
  358. {
  359. int SnIdNum = int.Parse(SnId);
  360. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  361. if (pos == null)
  362. {
  363. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  364. }
  365. string OldId = "", NewId = "";
  366. if (DepositId == "100")
  367. {
  368. NewId = pos.BrandId == 8 ? "202207011718129" : "202207011718197";
  369. }
  370. else if (DepositId == "200")
  371. {
  372. NewId = pos.BrandId == 8 ? "747200504467566592" : "747199934126108672";
  373. }
  374. else if (DepositId == "300")
  375. {
  376. NewId = pos.BrandId == 8 ? "747193472108732416" : "747193820156276736";
  377. }
  378. string content = PublicImportDataService.Instance.QueryActiveForConfigHK(pos.PosSn, pos.BrandId);
  379. JsonData jsonObj = JsonMapper.ToObject(content);
  380. if (jsonObj["code"].ToString() == "0")
  381. {
  382. OldId = jsonObj["data"]["posMarket"]["id"].ToString();
  383. }
  384. jsonObj = JsonMapper.ToObject(content);
  385. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + OldId + ":" + NewId, "海科-设置押金-返回报文");
  386. content = PublicImportDataService.Instance.SetDepositForHK(pos.PosSn, OldId, NewId, pos.BrandId);
  387. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "海科-设置押金-返回报文");
  388. if (content == "fail")
  389. {
  390. return "机具" + pos.PosSn + "设置失败";
  391. }
  392. jsonObj = JsonMapper.ToObject(content);
  393. if (jsonObj["code"].ToString() != "0")
  394. {
  395. return jsonObj["msg"].ToString();
  396. }
  397. decimal amount = decimal.Parse(DepositId);
  398. var BeforeDeposit = 0;
  399. if (string.IsNullOrEmpty(pos.PrizeParams))
  400. {
  401. BeforeDeposit = 299;
  402. }
  403. else
  404. {
  405. BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
  406. }
  407. if (pos.BrandId == 8 || pos.BrandId == 9)
  408. {
  409. amount -= 1;
  410. }
  411. pos.PrizeParams = amount.ToString("f0");
  412. db.SaveChanges();
  413. //设置押金添加记录
  414. PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
  415. }
  416. db.Dispose();
  417. return "设置成功";
  418. }
  419. #endregion
  420. #region 联动-设置押金
  421. public static string SetLDDeposit(string SnIds, string DepositId)
  422. {
  423. // string DepositId = "299";
  424. string check = RedisDbconn.Instance.Get<string>("SetLDPosDepositWait:" + SnIds);
  425. if (!string.IsNullOrEmpty(check))
  426. {
  427. return "操作频繁,请稍后再试";
  428. }
  429. RedisDbconn.Instance.Set("SetLDPosDepositWait:" + SnIds, SnIds);
  430. RedisDbconn.Instance.SetExpire("SetLDPosDepositWait:" + SnIds, 10);
  431. Dictionary<string, object> Obj = new Dictionary<string, object>();
  432. WebCMSEntities db = new WebCMSEntities();
  433. string[] SnIdList = SnIds.Split(',');
  434. foreach (string SnId in SnIdList)
  435. {
  436. int SnIdNum = int.Parse(SnId);
  437. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  438. if (pos == null)
  439. {
  440. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  441. }
  442. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "联动-设置押金-返回报文");
  443. string content = PublicImportDataService.Instance.LDServiceFee(pos.PosSn, int.Parse(DepositId), pos.BrandId);
  444. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "联动-设置押金-返回报文");
  445. JsonData jsonObj = JsonMapper.ToObject(content);
  446. if (jsonObj["code"].ToString() != "000000")
  447. {
  448. return jsonObj["msg"].ToString();
  449. }
  450. var BeforeDeposit = 0;
  451. if (string.IsNullOrEmpty(pos.PrizeParams))
  452. {
  453. BeforeDeposit = 299;
  454. }
  455. else
  456. {
  457. BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
  458. }
  459. decimal amount = decimal.Parse(DepositId);
  460. pos.PrizeParams = amount.ToString("f0");
  461. db.SaveChanges();
  462. //设置押金添加记录
  463. PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
  464. }
  465. db.Dispose();
  466. return "设置成功";
  467. }
  468. #endregion
  469. #region 盒易付-设置押金
  470. public static string SetHYFDeposit(string SnIds, string DepositId)
  471. {
  472. // string DepositId = "299";
  473. string check = RedisDbconn.Instance.Get<string>("SetHYFPosDepositWait:" + SnIds);
  474. if (!string.IsNullOrEmpty(check))
  475. {
  476. return "操作频繁,请稍后再试";
  477. }
  478. RedisDbconn.Instance.Set("SetHYFPosDepositWait:" + SnIds, SnIds);
  479. RedisDbconn.Instance.SetExpire("SetHYFPosDepositWait:" + SnIds, 10);
  480. WebCMSEntities db = new WebCMSEntities();
  481. Dictionary<string, object> Obj = new Dictionary<string, object>();
  482. string[] SnIdList = SnIds.Split(',');
  483. foreach (string SnId in SnIdList)
  484. {
  485. int SnIdNum = int.Parse(SnId);
  486. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  487. if (pos == null)
  488. {
  489. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  490. }
  491. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "盒易付-设置押金-返回报文");
  492. string content = PublicImportDataService.Instance.BoxServiceFee(pos.PosSn, DepositId, pos.BuyUserId);
  493. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "盒易付-设置押金-返回报文");
  494. if (content == "fail")
  495. {
  496. return "机具" + pos.PosSn + "设置失败";
  497. }
  498. JsonData jsonObj = JsonMapper.ToObject(content);
  499. if (jsonObj["resultCode"].ToString() != "1")
  500. {
  501. return jsonObj["errorDesc"].ToString();
  502. }
  503. var BeforeDeposit = 0;
  504. if (string.IsNullOrEmpty(pos.PrizeParams))
  505. {
  506. BeforeDeposit = 299;
  507. }
  508. else
  509. {
  510. BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
  511. }
  512. decimal amount = decimal.Parse(DepositId);
  513. pos.PrizeParams = amount.ToString("f0");
  514. db.SaveChanges();
  515. //设置押金添加记录
  516. PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
  517. }
  518. db.Dispose();
  519. return "设置成功";
  520. }
  521. #endregion
  522. #region POSP-设置押金
  523. public static string SetPosPDeposit(string SnIds, string DepositId)
  524. {
  525. string policy_code = "";
  526. string policy_name = "";
  527. if(DepositId == "0")
  528. {
  529. policy_code = "LKB_000";
  530. policy_name = "联客宝";
  531. }
  532. else if(DepositId == "99")
  533. {
  534. policy_code = "LKB_99";
  535. policy_name = "联客宝";
  536. }
  537. else if(DepositId == "199")
  538. {
  539. policy_code = "LKB_199";
  540. policy_name = "联客宝";
  541. }
  542. else if(DepositId == "299")
  543. {
  544. policy_code = "LKB_299";
  545. policy_name = "联客宝299押金";
  546. }
  547. string check = RedisDbconn.Instance.Get<string>("SetPosPDepositWait:" + SnIds);
  548. if (!string.IsNullOrEmpty(check))
  549. {
  550. return "操作频繁,请稍后再试";
  551. }
  552. RedisDbconn.Instance.Set("SetPosPDepositWait:" + SnIds, SnIds);
  553. RedisDbconn.Instance.SetExpire("SetPosPDepositWait:" + SnIds, 10);
  554. WebCMSEntities db = new WebCMSEntities();
  555. Dictionary<string, object> Obj = new Dictionary<string, object>();
  556. string[] SnIdList = SnIds.Split(',');
  557. foreach (string SnId in SnIdList)
  558. {
  559. int SnIdNum = int.Parse(SnId);
  560. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  561. if (pos == null)
  562. {
  563. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  564. }
  565. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "POSP-设置押金-返回报文");
  566. List<string> PosList = new List<string>();
  567. PosList.Add(pos.PosSn);
  568. string content = PublicImportDataService.Instance.PospServiceFee(PosList, policy_code, policy_name);
  569. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "POSP-设置押金-返回报文");
  570. if (content == "fail")
  571. {
  572. return "机具" + pos.PosSn + "设置失败";
  573. }
  574. JsonData jsonObj = JsonMapper.ToObject(content);
  575. if (jsonObj["code"].ToString() != "200")
  576. {
  577. return "设置失败";
  578. }
  579. var BeforeDeposit = 0;
  580. if (string.IsNullOrEmpty(pos.PrizeParams))
  581. {
  582. BeforeDeposit = 299;
  583. }
  584. else
  585. {
  586. BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
  587. }
  588. decimal amount = decimal.Parse(DepositId);
  589. pos.PrizeParams = amount.ToString("f0");
  590. db.SaveChanges();
  591. //设置押金添加记录
  592. PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
  593. }
  594. db.Dispose();
  595. return "设置成功";
  596. }
  597. #endregion
  598. #region 拉卡拉-设置押金
  599. public static string SetLKLDeposit(string SnIds, string DepositId)
  600. {
  601. string check = RedisDbconn.Instance.Get<string>("SetLKLPosDepositWait:" + SnIds);
  602. if (!string.IsNullOrEmpty(check))
  603. {
  604. return "操作频繁,请稍后再试";
  605. }
  606. RedisDbconn.Instance.Set("SetLKLPosDepositWait:" + SnIds, SnIds);
  607. RedisDbconn.Instance.SetExpire("SetLKLPosDepositWait:" + SnIds, 10);
  608. WebCMSEntities db = new WebCMSEntities();
  609. Dictionary<string, object> Obj = new Dictionary<string, object>();
  610. string[] SnIdList = SnIds.Split(',');
  611. foreach (string SnId in SnIdList)
  612. {
  613. int SnIdNum = int.Parse(SnId);
  614. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
  615. if (pos == null)
  616. {
  617. return "机具" + pos.PosSn + "已设置押金,请勿重复设置";
  618. }
  619. //判断是否存在关联数据
  620. string content = "";
  621. function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "拉卡拉-设置押金-返回报文");
  622. content = PublicImportDataService.Instance.LkLSetDeposit(pos.PosSn, decimal.Parse(DepositId));
  623. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "拉卡拉-设置押金-返回报文");
  624. if (content == "fail")
  625. {
  626. return "机具" + pos.PosSn + "设置失败";
  627. }
  628. JsonData jsonObj = JsonMapper.ToObject(content);
  629. if (jsonObj["code"].ToString() != "000000")
  630. {
  631. return jsonObj["message"].ToString();
  632. }
  633. content = jsonObj["data"].ToString();
  634. content = PublicImportDataService.Instance.LklDecrypt(content);
  635. if (!content.ToLower().Contains("success"))
  636. {
  637. return content;
  638. }
  639. function.WriteLog(DateTime.Now.ToString() + "\n" + content, "拉卡拉-设置押金-返回报文");
  640. var BeforeDeposit = 0;
  641. if (string.IsNullOrEmpty(pos.PrizeParams))
  642. {
  643. BeforeDeposit = 299;
  644. }
  645. else
  646. {
  647. BeforeDeposit = (int)decimal.Parse(pos.PrizeParams);
  648. }
  649. decimal amount = decimal.Parse(DepositId);
  650. pos.PrizeParams = amount.ToString("f0");
  651. db.SaveChanges();
  652. //设置押金添加记录
  653. PublicFunction.MerchantDepositSet(pos.BrandId, pos.BuyUserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
  654. }
  655. db.Dispose();
  656. return "设置成功";
  657. }
  658. #endregion
  659. }
  660. }