TestHelper.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Linq;
  5. using System.Data;
  6. using MySystem;
  7. using MySystem.PxcModels;
  8. using Library;
  9. public class TestHelper
  10. {
  11. public readonly static TestHelper Instance = new TestHelper();
  12. private TestHelper()
  13. {
  14. }
  15. public void Start()
  16. {
  17. Thread th = new Thread(setLdFee);
  18. th.IsBackground = true;
  19. th.Start();
  20. }
  21. public void StartEverDay()
  22. {
  23. OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
  24. DateTime end = DateTime.Parse("2022-04-19 00:00:00");
  25. DateTime check = DateTime.Parse("2022-03-11");
  26. while (check <= end)
  27. {
  28. StatMerchantTrade(check.ToString("yyyy-MM-dd"));
  29. check = check.AddDays(1);
  30. }
  31. }
  32. private void StatMerchantTrade(string date)
  33. {
  34. function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "执行商户交易额日志");
  35. WebCMSEntities db = new WebCMSEntities();
  36. try
  37. {
  38. DataTable selfdt = OtherMySqlConn.dtable("select MerchantId,BrandId,DATE_FORMAT(CreateDate,'%Y-%m-%d') as TradeDate,sum(TradeAmount) as TradeAmount from TradeRecord group by MerchantId,BrandId,DATE_FORMAT(CreateDate,'%Y-%m-%d') order by MerchantId,BrandId,DATE_FORMAT(CreateDate,'%Y-%m-%d')");
  39. foreach (DataRow selfDr in selfdt.Rows)
  40. {
  41. int BrandId = int.Parse(selfDr["BrandId"].ToString());
  42. int MerchantId = int.Parse(selfDr["MerchantId"].ToString());
  43. string TradeDate = selfDr["TradeDate"].ToString();
  44. TradeDate = TradeDate.Replace("-", "");
  45. string TradeMonth = TradeDate.Substring(0, 6);
  46. decimal TradeAmount = decimal.Parse(selfDr["TradeAmount"].ToString());
  47. PosMerchantTradeSummay merStat = db.PosMerchantTradeSummay.FirstOrDefault(m => m.MerchantId == MerchantId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.BrandId == BrandId);
  48. if (merStat == null)
  49. {
  50. merStat = db.PosMerchantTradeSummay.Add(new PosMerchantTradeSummay()
  51. {
  52. MerchantId = MerchantId,
  53. TradeMonth = TradeMonth,
  54. TradeDate = TradeDate,
  55. BrandId = BrandId,
  56. }).Entity;
  57. db.SaveChanges();
  58. }
  59. merStat.TradeAmount += TradeAmount;
  60. db.SaveChanges();
  61. }
  62. }
  63. catch (Exception ex)
  64. {
  65. function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计商户的交易额");
  66. }
  67. db.Dispose();
  68. function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "执行商户交易额日志");
  69. }
  70. private void setLdFee()
  71. {
  72. // DataTable dt = CustomerSqlConn.dtable("select KqMerNo,BrandId from PosMerchantInfo where Id in (select BindMerchantId from PosMachinesTwo where BrandId in (10,11) and DownFeeFlag=1 and BindingTime<'2023-08-06 00:00:00')", "server=rm-2vcs4j67tla603c9d5o.mysql.cn-chengdu.rds.aliyuncs.com;port=3306;user=KxsProfitServer;password=FrW8ZfxlcaVdm1r0;database=KxsProfitServer;charset=utf8;");
  73. // foreach(DataRow dr in dt.Rows)
  74. // {
  75. // function.WriteLog(dr["KqMerNo"].ToString(), "临时设置联动费率日志");
  76. // string result = SetDepositPostService.Instance.LDFeeRate(dr["KqMerNo"].ToString(), "0.0063", int.Parse(dr["BrandId"].ToString()), 0);
  77. // function.WriteLog(result + "\n\n", "临时设置联动费率日志");
  78. // }
  79. // function.WriteLog("000006026200825805", "临时设置费率日志");
  80. // string result = SetDepositPostService.Instance.SetFeeForSft("40585414", "0.6300", "0");
  81. // function.WriteLog(result + "\n\n", "临时设置费率日志");
  82. // function.WriteLog("0000320226626450030145", "临时设置费率日志");
  83. // result = SetDepositPostService.Instance.LDFeeRate("110000004265069", "0.0063", 1, 3);
  84. // function.WriteLog(result + "\n\n", "临时设置费率日志");
  85. // function.WriteLog("0000320226624650409066", "临时设置费率日志");
  86. // result = SetDepositPostService.Instance.LDFeeRate("110000004842951", "0.0063", 1, 3);
  87. // function.WriteLog(result + "\n\n", "临时设置费率日志");
  88. // function.WriteLog("0000320226636450184893", "临时设置费率日志");
  89. // result = SetDepositPostService.Instance.LDFeeRate("110000004744970", "0.0063", 3, 0);
  90. // function.WriteLog(result + "\n\n", "临时设置费率日志");
  91. // function.WriteLog("0000320226636450180288", "临时设置费率日志");
  92. // result = SetDepositPostService.Instance.LDFeeRate("110000004760326", "0.0063", 3, 0);
  93. // function.WriteLog(result + "\n\n", "临时设置费率日志");
  94. // function.WriteLog("00003102702303069483466", "临时设置费率日志");
  95. // string result = SetDepositPostService.Instance.SetFee("M7000615224RVXMbk7", "00003102702303069483466", 0.63M, 300);
  96. // function.WriteLog(result + "\n\n", "临时设置费率日志");
  97. // function.WriteLog("00000302JBNL01471793", "临时设置费率日志");
  98. // result = SetDepositPostService.Instance.SetFee("M900065131JVMYUBl5", "00000302JBNL01471793", 0.63M, 0);
  99. // function.WriteLog(result + "\n\n", "临时设置费率日志");
  100. // return;
  101. bool op = true;
  102. while(op)
  103. {
  104. int page = int.Parse(function.CheckInt(function.ReadInstance("/TmpSetLdFee/page.txt")));
  105. if(page < 1) page = 50;
  106. int skip = (page - 1) * 100;
  107. DataTable dt = CustomerSqlConn.dtable("select KqMerNo,BrandId from PosMerchantInfo where Id in (select BindMerchantId from PosMachinesTwo where BrandId in (10,11) and DownFeeFlag=0 and BindingTime<'2023-08-06 00:00:00') limit " + skip + ",100", "server=rm-2vcs4j67tla603c9d5o.mysql.cn-chengdu.rds.aliyuncs.com;port=3306;user=KxsProfitServer;password=FrW8ZfxlcaVdm1r0;database=KxsProfitServer;charset=utf8;");
  108. if(dt.Rows.Count > 0)
  109. {
  110. foreach(DataRow dr in dt.Rows)
  111. {
  112. function.WriteLog(dr["KqMerNo"].ToString(), "临时设置联动费率日志");
  113. string result = SetDepositPostService.Instance.LDFeeRate(dr["KqMerNo"].ToString(), "0.0063", int.Parse(dr["BrandId"].ToString()), 3);
  114. function.WriteLog(result + "\n\n", "临时设置联动费率日志");
  115. }
  116. page += 1;
  117. function.WritePage("/TmpSetLdFee/", "page.txt", page.ToString());
  118. }
  119. else
  120. {
  121. op = false;
  122. function.WriteLog("执行结束\n\n", "临时设置联动费率日志");
  123. }
  124. dt.Dispose();
  125. dt.Clear();
  126. }
  127. }
  128. public void StartJk()
  129. {
  130. Thread th = new Thread(setJkFee);
  131. th.IsBackground = true;
  132. th.Start();
  133. }
  134. private void setJkFee()
  135. {
  136. bool op = true;
  137. while(op)
  138. {
  139. int page = int.Parse(function.CheckInt(function.ReadInstance("/TmpSetJkFee/page.txt")));
  140. if(page < 1) page = 1;
  141. int skip = (page - 1) * 100;
  142. DataTable dt = CustomerSqlConn.dtable("select KqMerNo,KqSnNo from PosMerchantInfo where Id in (select BindMerchantId from PosMachinesTwo where BrandId in (1,3) and (DownFeeFlag=1 or UpFeeFlag=0) and BindingState=1 and BindingTime<'" + DateTime.Now.AddDays(-90).ToString("yyyy-MM-dd HH:mm:ss") + "') limit " + skip + ",100", "server=rm-2vcs4j67tla603c9d5o.mysql.cn-chengdu.rds.aliyuncs.com;port=3306;user=KxsProfitServer;password=FrW8ZfxlcaVdm1r0;database=KxsProfitServer;charset=utf8;");
  143. if(dt.Rows.Count > 0)
  144. {
  145. foreach(DataRow dr in dt.Rows)
  146. {
  147. function.WriteLog(dr["KqMerNo"].ToString(), "临时设置金控费率日志");
  148. function.WriteLog(dr["KqSnNo"].ToString(), "临时设置金控费率日志");
  149. string merNo = dr["KqMerNo"].ToString();
  150. string sn = dr["KqSnNo"].ToString();
  151. string result = SetDepositPostService.Instance.SetFee(merNo, sn, 0.63M, 0);
  152. function.WriteLog(result + "\n\n", "临时设置金控费率日志");
  153. }
  154. page += 1;
  155. function.WritePage("/TmpSetJkFee/", "page.txt", page.ToString());
  156. }
  157. else
  158. {
  159. op = false;
  160. function.WriteLog("执行结束\n\n", "临时设置金控费率日志");
  161. }
  162. dt.Dispose();
  163. dt.Clear();
  164. }
  165. }
  166. public void StartSft()
  167. {
  168. Thread th = new Thread(setSftFee);
  169. th.IsBackground = true;
  170. th.Start();
  171. }
  172. private void setSftFee()
  173. {
  174. bool op = true;
  175. while(op)
  176. {
  177. int page = int.Parse(function.CheckInt(function.ReadInstance("/TmpSetSftFee/page.txt")));
  178. if(page < 1) page = 1;
  179. int skip = (page - 1) * 100;
  180. DataTable dt = CustomerSqlConn.dtable("select mer.KqMerNo,DownFeeFlag,UpFeeFlag from (select BindMerchantId,DownFeeFlag,UpFeeFlag from PosMachinesTwo where BrandId=7 and BindingState=1 and BindingTime<'" + DateTime.Now.AddDays(-90).ToString("yyyy-MM-dd HH:mm:ss") + "') tb left join PosMerchantInfo mer on tb.BindMerchantId=mer.Id limit " + skip + ",100", "server=rm-2vcs4j67tla603c9d5o.mysql.cn-chengdu.rds.aliyuncs.com;port=3306;user=KxsProfitServer;password=FrW8ZfxlcaVdm1r0;database=KxsProfitServer;charset=utf8;");
  181. if(dt.Rows.Count > 0)
  182. {
  183. foreach(DataRow dr in dt.Rows)
  184. {
  185. function.WriteLog(dr["KqMerNo"].ToString(), "临时设置盛付通费率日志");
  186. string merNo = dr["KqMerNo"].ToString();
  187. string DownFeeFlag = dr["DownFeeFlag"].ToString();
  188. string UpFeeFlag = dr["UpFeeFlag"].ToString();
  189. string addRate = "0";
  190. string Fee = "0.6300";
  191. if(UpFeeFlag == "1" && DownFeeFlag == "0")
  192. {
  193. addRate = "3";
  194. }
  195. string result = SetDepositPostService.Instance.SetFeeForSft(merNo, Fee, addRate);
  196. function.WriteLog(result + "\n\n", "临时设置盛付通费率日志");
  197. }
  198. page += 1;
  199. function.WritePage("/TmpSetSftFee/", "page.txt", page.ToString());
  200. }
  201. else
  202. {
  203. op = false;
  204. function.WriteLog("执行结束\n\n", "临时设置盛付通费率日志");
  205. }
  206. dt.Dispose();
  207. dt.Clear();
  208. }
  209. }
  210. }