ChangePosFeeUtil.cs 25 KB

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