TmpService.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. using System;
  2. using System.Collections.Generic;
  3. using Library;
  4. using LitJson;
  5. using System.Linq;
  6. using System.Data;
  7. using System.Threading;
  8. using MySystem.JavaProductModels;
  9. namespace MySystem
  10. {
  11. public class TmpService
  12. {
  13. public readonly static TmpService Instance = new TmpService();
  14. private TmpService()
  15. { }
  16. public void Start()
  17. {
  18. Thread th = new Thread(poscheck);
  19. th.IsBackground = true;
  20. th.Start();
  21. }
  22. private void SetLkbDeposit()
  23. {
  24. while (true)
  25. {
  26. try
  27. {
  28. string content = RedisDbconn.Instance.RPop<string>("SetLkbDepositQueue");
  29. if (!string.IsNullOrEmpty(content))
  30. {
  31. string[] data = content.Split('|');
  32. PublicImportDataService.Instance.LkbSetDeposit(data[0], decimal.Parse(data[1]));
  33. }
  34. else
  35. {
  36. Thread.Sleep(2000);
  37. }
  38. }
  39. catch (Exception ex)
  40. {
  41. Utils.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "商城订单余额支付异常");
  42. Thread.Sleep(2000);
  43. }
  44. }
  45. }
  46. public void dosomething()
  47. {
  48. string content = function.ReadInstance("jk299.txt");
  49. string[] SnNos = content.Split('\n');
  50. int count = SnNos.Length;
  51. int index = 0;
  52. foreach(string SnNo in SnNos)
  53. {
  54. index += 1;
  55. PublicImportDataService.Instance.LkbSetDeposit(SnNo, 299);
  56. function.WritePage("/look/", "progress.txt", index + "/" + count);
  57. function.WritePage("/look/", "sn.txt", SnNo);
  58. Thread.Sleep(100);
  59. }
  60. content = function.ReadInstance("jk0.txt");
  61. SnNos = content.Split('\n');
  62. count = SnNos.Length;
  63. index = 0;
  64. foreach(string SnNo in SnNos)
  65. {
  66. index += 1;
  67. PublicImportDataService.Instance.LkbSetDeposit(SnNo, 0);
  68. function.WritePage("/look/", "progress.txt", index + "/" + count);
  69. function.WritePage("/look/", "sn.txt", SnNo);
  70. Thread.Sleep(100);
  71. }
  72. }
  73. public void poscheck()
  74. {
  75. if(RedisDbconn.Instance.Get<string>("TmpService_poscheck_flag3") == "1")
  76. {
  77. return;
  78. }
  79. RedisDbconn.Instance.Set("TmpService_poscheck_flag3", "1");
  80. WebCMSEntities db = new WebCMSEntities();
  81. try
  82. {
  83. List<string> poslist = new List<string>();
  84. List<int> merids = new List<int>();
  85. List<string> mernos = new List<string>();
  86. //金控
  87. // poslist = function.ReadInstance("tmpdata/jk.txt").Replace("\r", "").Split('\n').ToList();
  88. // foreach(string pos in poslist)
  89. // {
  90. // string result = PublicImportDataService.Instance.LkbSetFee(pos, 2.99M, 300);
  91. // function.WriteLog(pos + "\n" + result + "\n\n", "tmp金控临时费率");
  92. // Thread.Sleep(500);
  93. // }
  94. // //盛付通
  95. // poslist = function.ReadInstance("tmpdata/1.txt").Replace("\r", "").Split('\n').ToList();
  96. // List<string> without1 = function.ReadInstance("tmpdata/sft1.txt").Replace("\r", "").Split('\n').ToList();
  97. // List<string> without2 = function.ReadInstance("tmpdata/sft2.txt").Replace("\r", "").Split('\n').ToList();
  98. // List<string> without3 = function.ReadInstance("tmpdata/11.txt").Replace("\r", "").Split('\n').ToList();
  99. // function.WriteLog(poslist.Count.ToString(), "tmp盛付通临时费率");
  100. // merids = db.KxsMachine.Where(m => poslist.Contains(m.PosSn) && !without1.Contains(m.PosSn) && !without2.Contains(m.PosSn) && !without3.Contains(m.PosSn) && m.BrandId == 7 && m.MerchantId > 0).ToList().Select(m => m.MerchantId).ToList();
  101. // function.WriteLog(merids.Count.ToString(), "tmp盛付通临时费率");
  102. // mernos = db.KxsMerchant.Where(m => merids.Contains(m.Id)).ToList().Select(m => m.MerchantNo).ToList();
  103. // function.WriteLog(mernos.Count.ToString(), "tmp盛付通临时费率");
  104. // foreach(string merno in mernos)
  105. // {
  106. // if(int.Parse(DateTime.Now.ToString("HHmm")) < 2100)
  107. // {
  108. // string result = SetDepositPostService.Instance.SetFeeForSft(merno, "0.6500", "3");
  109. // function.WriteLog(merno + "\n" + DateTime.Now.ToString() + "\n" + result + "\n\n", "tmp盛付通临时费率");
  110. // Thread.Sleep(500);
  111. // }
  112. // else
  113. // {
  114. // function.WriteLog(merno, "tmp盛付通临时费率POSN");
  115. // }
  116. // }
  117. // List<string> list = function.ReadInstance("tmpdata/sft3.txt").Replace("\r", "").Split('\n').ToList();
  118. // foreach(string merno in list)
  119. // {
  120. // string result = SetDepositPostService.Instance.SetFeeForSft(merno, "0.6500", "3");
  121. // function.WriteLog(merno + "\n" + DateTime.Now.ToString() + "\n" + result + "\n\n", "tmp盛付通临时费率");
  122. // Thread.Sleep(500);
  123. // }
  124. // poslist = function.ReadInstance("tmpdata/sft1.txt").Replace("\r", "").Split('\n').ToList();
  125. // function.WriteLog(poslist.Count.ToString(), "tmp盛付通临时费率");
  126. // merids = db.KxsMachine.Where(m => poslist.Contains(m.PosSn) && m.BrandId == 7 && m.MerchantId > 0).ToList().Select(m => m.MerchantId).ToList();
  127. // function.WriteLog(merids.Count.ToString(), "tmp盛付通临时费率");
  128. // mernos = db.KxsMerchant.Where(m => merids.Contains(m.Id)).ToList().Select(m => m.MerchantNo).ToList();
  129. // function.WriteLog(mernos.Count.ToString(), "tmp盛付通临时费率");
  130. // foreach(string merno in mernos)
  131. // {
  132. // string result = SetDepositPostService.Instance.SetFeeForSft(merno, "0.6300", "0");
  133. // function.WriteLog(merno + "\n" + result + "\n\n", "tmp盛付通临时费率");
  134. // Thread.Sleep(500);
  135. // }
  136. // poslist = function.ReadInstance("tmpdata/sft2.txt").Replace("\r", "").Split('\n').ToList();
  137. // function.WriteLog(poslist.Count.ToString(), "tmp盛付通临时费率");
  138. // merids = db.KxsMachine.Where(m => poslist.Contains(m.PosSn) && m.BrandId == 7 && m.MerchantId > 0).ToList().Select(m => m.MerchantId).ToList();
  139. // function.WriteLog(merids.Count.ToString(), "tmp盛付通临时费率");
  140. // mernos = db.KxsMerchant.Where(m => merids.Contains(m.Id)).ToList().Select(m => m.MerchantNo).ToList();
  141. // function.WriteLog(mernos.Count.ToString(), "tmp盛付通临时费率");
  142. // foreach(string merno in mernos)
  143. // {
  144. // string result = SetDepositPostService.Instance.SetFeeForSft(merno, "0.6000", "0");
  145. // function.WriteLog(merno + "\n" + result + "\n\n", "tmp盛付通临时费率");
  146. // Thread.Sleep(500);
  147. // }
  148. //来客吧电签
  149. // poslist = function.ReadInstance("tmpdata/lkbdq.txt").Split('\n').ToList();
  150. // merids = db.KxsMachine.Where(m => poslist.Contains(m.PosSn) && m.BrandId == 15 && m.MerchantId > 0).ToList().Select(m => m.MerchantId).ToList();
  151. // mernos = db.KxsMerchant.Where(m => merids.Contains(m.Id)).ToList().Select(m => m.MerchantNo).ToList();
  152. // foreach(string merno in poslist)
  153. // {
  154. // List<string> mernoList = new List<string>();
  155. // mernoList.Add(merno);
  156. // string result = PublicImportDataService.Instance.PospFee(mernoList, "LKB_0.65+3", "联客宝0.65+3");
  157. // function.WriteLog(merno + "\n" + result + "\n\n", "tmp来客吧电签临时费率");
  158. // Thread.Sleep(500);
  159. // }
  160. // poslist = function.ReadInstance("tmpdata/lkbdq0.txt").Split('\n').ToList();
  161. // merids = db.KxsMachine.Where(m => poslist.Contains(m.PosSn) && m.BrandId == 15 && m.MerchantId > 0).ToList().Select(m => m.MerchantId).ToList();
  162. // mernos = db.KxsMerchant.Where(m => merids.Contains(m.Id)).ToList().Select(m => m.MerchantNo).ToList();
  163. // foreach(string merno in poslist)
  164. // {
  165. // List<string> mernoList = new List<string>();
  166. // mernoList.Add(merno);
  167. // string result = PublicImportDataService.Instance.PospFee(mernoList, "LKB_0.65", "联客宝0.65");
  168. // function.WriteLog(merno + "\n" + result + "\n\n", "tmp来客吧电签临时费率0");
  169. // Thread.Sleep(500);
  170. // }
  171. // //联动电签
  172. // poslist = function.ReadInstance("tmpdata/3.txt").Split('\n').ToList();
  173. // merids = db.KxsMachine.Where(m => poslist.Contains(m.PosSn) && m.BrandId == 10 && m.MerchantId > 0).ToList().Select(m => m.MerchantId).ToList();
  174. // mernos = db.KxsMerchant.Where(m => merids.Contains(m.Id)).ToList().Select(m => m.MerchantNo).ToList();
  175. // foreach(string merno in mernos)
  176. // {
  177. // string result = SetDepositPostService.Instance.LDFeeRate(merno, "0.0065", 10, 3);
  178. // function.WriteLog(merno + "\n" + result + "\n\n", "tmp联动电签临时费率");
  179. // Thread.Sleep(500);
  180. // }
  181. // //联动大POS
  182. // poslist = function.ReadInstance("tmpdata/4.txt").Split('\n').ToList();
  183. // merids = db.KxsMachine.Where(m => poslist.Contains(m.PosSn) && m.BrandId == 11 && m.MerchantId > 0).ToList().Select(m => m.MerchantId).ToList();
  184. // mernos = db.KxsMerchant.Where(m => merids.Contains(m.Id)).ToList().Select(m => m.MerchantNo).ToList();
  185. // foreach(string merno in mernos)
  186. // {
  187. // string result = SetDepositPostService.Instance.LDFeeRate(merno, "0.0065", 11, 3);
  188. // function.WriteLog(merno + "\n" + result + "\n\n", "tmp联动大POS临时费率");
  189. // Thread.Sleep(500);
  190. // }
  191. //立刷微电签
  192. poslist = function.ReadInstance("tmpdata/lswdq.txt").Split('\n').ToList();
  193. var poses = db.KxsMachine.Where(m => poslist.Contains(m.PosSn) && m.BrandId == 22 && m.MerchantId > 0).ToList();
  194. merids = poses.Select(m => m.MerchantId).ToList();
  195. var mers = db.KxsMerchant.Where(m => merids.Contains(m.Id)).ToList();
  196. foreach(var pos in poses)
  197. {
  198. var mer = mers.FirstOrDefault(m => m.Id == pos.MerchantId);
  199. if(mer != null)
  200. {
  201. // string result = PublicImportDataService.Instance.SetLiSWeFee(pos.PosSn, mer.MerchantNo, "0.63", "300");
  202. string result = PublicImportDataService.Instance.SetLiSWeFee(pos.PosSn, mer.MerchantNo, "0.63", "0");
  203. function.WriteLog(pos.PosSn + "\n" + mer.MerchantNo + "\n" + result + "\n\n", "tmp立刷微电签临时费率");
  204. Thread.Sleep(500);
  205. }
  206. }
  207. //立刷微智能
  208. poslist = function.ReadInstance("tmpdata/liwzn.txt").Replace("\r", "").Split('\n').ToList();
  209. foreach(string pos in poslist)
  210. {
  211. string[] parts = pos.Split('|');
  212. string result = PublicImportDataService.Instance.SetLiSWeFee(parts[0], parts[1], "0.63", "0");
  213. function.WriteLog(parts[0] + "\n" + parts[1] + "\n" + result + "\n\n", "tmp立刷微智能临时费率");
  214. Thread.Sleep(1500);
  215. }
  216. //联动力POS
  217. // mernos = function.ReadInstance("tmpdata/zzb.txt").Replace("\r", "").Split('\n').ToList();
  218. // foreach(string merno in mernos)
  219. // {
  220. // // string content = SetDepositPostService.Instance.LDZZBFeeRate(merno, 0.68M, 3);
  221. // string content = SetDepositPostService.Instance.LDZZBFeeRate(merno, 0.68M, 0);
  222. // if(content.Contains("encryptKey"))
  223. // {
  224. // JsonData jsonObj = JsonMapper.ToObject(content);
  225. // string aesKey = jsonObj["encryptKey"].ToString();
  226. // aesKey = SetDepositPostService.Instance.LDZZBDecrypt(aesKey);
  227. // content += SetDepositPostService.Instance.AesDecrypt(jsonObj["data"].ToString(), aesKey);
  228. // }
  229. // function.WriteLog(merno + "\n" + content + "\n\n", "tmp联动力POS临时费率");
  230. // Thread.Sleep(1000);
  231. // }
  232. //盒易付
  233. // mernos = function.ReadInstance("tmpdata/hyf.txt").Replace("\r", "").Split('\n').ToList();
  234. // foreach(string merno in mernos)
  235. // {
  236. // string content = SetDepositPostService.Instance.BoxFee(merno, "0.65");
  237. // function.WriteLog(merno + "\n" + content + "\n\n", "tmp盒易付临时费率");
  238. // Thread.Sleep(1000);
  239. // }
  240. //批量查询立刷费率
  241. // poslist = function.ReadInstance("tmpdata/lishua.txt").Split('\n').ToList();
  242. // foreach(var pos in poslist)
  243. // {
  244. // string rateNum = "0";
  245. // string feeNum = "0";
  246. // string[] data = pos.Split('|');
  247. // string content = PublicImportDataService.Instance.QueryLiSDeposit(data[1], "");
  248. // JsonData jsonObj = JsonMapper.ToObject(content);
  249. // if(jsonObj["ret_code"].ToString() == "00")
  250. // {
  251. // JsonData feeList = jsonObj["feeList"];
  252. // foreach (JsonData fee in feeList)
  253. // {
  254. // string feeCalcType = fee["feeCalcType"].ToString();
  255. // if(feeCalcType == "M5" || feeCalcType == "T0")
  256. // {
  257. // string rate = fee["rate"].ToString();
  258. // if(feeCalcType == "M5")
  259. // {
  260. // rateNum = rate;
  261. // }
  262. // else if(feeCalcType == "T0")
  263. // {
  264. // feeNum = rate;
  265. // }
  266. // }
  267. // }
  268. // function.WriteLog("" + data[0] + "|" + data[1] + "|" + rateNum + "|" + feeNum, "tmp立刷费率批量查询");
  269. // }
  270. // else
  271. // {
  272. // function.WriteLog("" + data[0] + "|" + data[1] + "|" + content, "tmp立刷费率批量查询");
  273. // }
  274. // }
  275. }
  276. catch(Exception ex)
  277. {
  278. function.WriteLog(ex.ToString() + "\n\n", "tmp临时费率异常");
  279. }
  280. db.Dispose();
  281. }
  282. }
  283. }