Fcszfc.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. using CP.Common;
  2. using MC.ORM;
  3. using MySql.Data.MySqlClient;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace CP.Model
  10. {
  11. #region 深圳风采/福彩35选7
  12. [TableName("fcsz35x7"), PrimaryKey("id")]
  13. public class Fcszfc35x7Info
  14. {
  15. #region 属性
  16. /// <summary>
  17. /// 期数
  18. /// </summary>
  19. public int qi { get; set; }
  20. /// <summary>
  21. /// 第一个号码
  22. /// </summary>
  23. public int n1 { get; set; }
  24. /// <summary>
  25. /// 第二个号码
  26. /// </summary>
  27. public int n2 { get; set; }
  28. /// <summary>
  29. /// 第三个号码
  30. /// </summary>
  31. public int n3 { get; set; }
  32. /// <summary>
  33. /// 第四个号码
  34. /// </summary>
  35. public int n4 { get; set; }
  36. /// <summary>
  37. /// 第五个号码
  38. /// </summary>
  39. public int n5 { get; set; }
  40. /// <summary>
  41. /// 第六个号码
  42. /// </summary>
  43. public int n6 { get; set; }
  44. /// <summary>
  45. /// 第七个号码
  46. /// </summary>
  47. public int n7 { get; set; }
  48. /// <summary>
  49. /// 第八个号码
  50. /// </summary>
  51. public int n8 { get; set; }
  52. /// <summary>
  53. /// 和值
  54. /// </summary>
  55. public int hz { get; set; }
  56. /// <summary>
  57. /// 跨度
  58. /// </summary>
  59. public int kd { get; set; }
  60. /// <summary>
  61. /// AC值
  62. /// </summary>
  63. public int ac { get; set; }
  64. /// <summary>
  65. /// 星期几
  66. /// </summary>
  67. public int week { get; set; }
  68. /// <summary>
  69. /// 开奖日期
  70. /// </summary>
  71. public DateTime date { get; set; }
  72. /// <summary>
  73. /// 在列表中的排名..
  74. /// 用于遗漏计算.
  75. /// </summary>
  76. [Ignore]
  77. public int rank { get; set; }
  78. #endregion
  79. }
  80. #endregion
  81. #region 深圳风采/福彩35选7 完整模型
  82. /// <summary>
  83. /// 深圳风采/福彩35选7
  84. /// </summary>
  85. [TableName("fcsz35x7"), PrimaryKey("id")]
  86. public class Fcszfc35x7LongInfo : Fcszfc35x7Info
  87. {
  88. #region 属性
  89. /// <summary>
  90. /// 自动编号
  91. /// </summary>
  92. public int id { get; set; }
  93. /// <summary>
  94. /// 一等奖注数
  95. /// </summary>
  96. public string zj1 { get; set; }
  97. /// <summary>
  98. /// 一等奖金额
  99. /// </summary>
  100. public string jo1 { get; set; }
  101. /// <summary>
  102. /// 二等奖注数
  103. /// </summary>
  104. public string zj2 { get; set; }
  105. /// <summary>
  106. /// 二等奖金额
  107. /// </summary>
  108. public string jo2 { get; set; }
  109. /// <summary>
  110. /// 三等奖注数
  111. /// </summary>
  112. public string zj3 { get; set; }
  113. /// <summary>
  114. /// 三等奖金额
  115. /// </summary>
  116. public string jo3 { get; set; }
  117. /// <summary>
  118. /// 开奖详情json
  119. /// </summary>
  120. public string winbonus { set; get; }
  121. /// <summary>
  122. /// 添加时间
  123. /// </summary>
  124. public DateTime addtime { get; set; }
  125. /// <summary>
  126. /// 下期奖池
  127. /// </summary>
  128. public string nextmoney { get; set; }
  129. /// <summary>
  130. /// 当期投注金额
  131. /// </summary>
  132. public string tzmoney { get; set; }
  133. /// <summary>
  134. /// 是否复查开奖号
  135. /// </summary>
  136. public int ischeck { get; set; }
  137. /// <summary>
  138. /// 号码
  139. /// </summary>
  140. public string opencode { get; set; }
  141. /// <summary>
  142. /// 第1步(开奖号)状态 -1:未添加 2:完成 3:复查完成
  143. /// </summary>
  144. public int step1state { set; get; }
  145. /// <summary>
  146. /// 第2步(开奖详情)状态 -1:未添加 1:完成一半 2:完成 3:复查完成
  147. /// </summary>
  148. public int step2state { set; get; }
  149. [Ignore]
  150. public string isComplete
  151. {
  152. get
  153. {
  154. if (step2state == 3)
  155. return "<span style='color:green;'>是</span>";
  156. return "<span style='color:red;'>否</span>";
  157. }
  158. }
  159. #endregion
  160. }
  161. #endregion
  162. #region 35x7遗漏模型
  163. /// <summary>
  164. /// 35选7出号走势图上的遗漏模型
  165. /// </summary>
  166. public class Fcszfc35x7MissInfo
  167. {
  168. /// <summary>
  169. /// 名称
  170. /// </summary>
  171. public string name { get; set; }
  172. /// <summary>
  173. /// 号码遗漏
  174. /// </summary>
  175. public int[] ch { get; set; }
  176. }
  177. /// <summary>
  178. /// 和值遗漏模型
  179. /// </summary>
  180. public class Fcszfc35x7HzMissInfo
  181. {
  182. /// <summary>
  183. /// 名称
  184. /// </summary>
  185. public string name { get; set; }
  186. /// <summary>
  187. /// 和值
  188. /// </summary>
  189. public int[] hz { get; set; }
  190. /// <summary>
  191. /// 和值奇偶
  192. /// </summary>
  193. public int[] jo { get; set; }
  194. /// <summary>
  195. /// 和尾
  196. /// </summary>
  197. public int[] hw { get; set; }
  198. }
  199. /// <summary>
  200. /// 跨度值遗漏模型
  201. /// </summary>
  202. public class Fcszfc35x7KdMissInfo
  203. {
  204. /// <summary>
  205. /// 名称
  206. /// </summary>
  207. public string name { get; set; }
  208. /// <summary>
  209. /// 跨度
  210. /// </summary>
  211. public int[] kd { get; set; }
  212. /// <summary>
  213. ///跨度奇偶
  214. /// </summary>
  215. public int[] jo { get; set; }
  216. /// <summary>
  217. /// 跨度大小
  218. /// </summary>
  219. public int[] dx { get; set; }
  220. /// <summary>
  221. /// 跨度质合
  222. /// </summary>
  223. public int[] zh { get; set; }
  224. }
  225. #endregion
  226. /// <summary>
  227. /// 深圳风采35选7的数据库操作.
  228. /// </summary>
  229. public class Fcszfc35x7Data : DataConnect
  230. {
  231. /// <summary>
  232. /// 数据库中取出所有数据
  233. /// </summary>
  234. /// <returns></returns>
  235. public static List<Fcszfc35x7Info> GetFcszfc35x7List()
  236. {
  237. List<Fcszfc35x7Info> list = new List<Fcszfc35x7Info>();
  238. string sql = string.Format("order by qi asc");
  239. DataConnect dc = new DataConnect();
  240. list = dc.db.Fetch<Fcszfc35x7Info>(sql);
  241. if (list != null && list.Count > 0)
  242. {
  243. for (int i = 0; i < list.Count; i++)
  244. {
  245. list[i].rank = i + 1;
  246. }
  247. }
  248. return list;
  249. }
  250. #region 开奖公告相关方法
  251. /// <summary>
  252. /// 获取开奖列表
  253. /// </summary>
  254. /// <param name="n">条数</param>
  255. /// <param name="type">默认0只有开奖号数据 1 带有开机号 2 带有试机号</param>
  256. /// <returns></returns>
  257. public static List<Fcszfc35x7LongInfo> GetList(int n = 30, bool isall = false)
  258. {
  259. string sql = $"where n1 > -1 order by qi desc limit {n}";
  260. if (isall)
  261. {
  262. sql = $"where n1 > -1 order by qi desc";
  263. }
  264. using (Database db = new Database(mysql, MySqlClientFactory.Instance))
  265. {
  266. return db.Fetch<Fcszfc35x7LongInfo>(sql);
  267. }
  268. }
  269. /// <summary>
  270. /// 获取最新30条开奖信息
  271. /// </summary>
  272. /// <returns></returns>
  273. public static Fcszfc35x7LongInfo GetFcszfc35X7NewInfo()
  274. {
  275. string sql = string.Format("where n1>-1 order by qi desc limit 1 ");
  276. DataConnect dc = new DataConnect();
  277. return dc.db.SingleOrDefault<Fcszfc35x7LongInfo>(sql);
  278. }
  279. /// <summary>
  280. /// 获取最新30条开奖信息
  281. /// </summary>
  282. /// <returns></returns>
  283. public static List<Fcszfc35x7LongInfo> GetFcszfc35x7Top30(int n = 30)
  284. {
  285. string sql = string.Format($"order by qi desc limit {n}");
  286. DataConnect dc = new DataConnect();
  287. return dc.db.Fetch<Fcszfc35x7LongInfo>(sql);
  288. }
  289. #region 根据期数获取某期开奖信息
  290. public static Fcszfc35x7LongInfo GetFcszfc35x7InfoByQi(int qi)
  291. {
  292. string sql = string.Empty;
  293. if (qi == 0)
  294. sql = string.Format("order by qi desc limit 1");
  295. else
  296. sql = string.Format("where qi={0} limit 1", qi);
  297. DataConnect dc = new DataConnect();
  298. Fcszfc35x7LongInfo info = dc.db.SingleOrDefault<Fcszfc35x7LongInfo>(sql);
  299. return info;
  300. }
  301. #endregion
  302. #region 根据年份取出当年所有期数
  303. /// <summary>
  304. /// 根据年份取出当年所有期数
  305. /// </summary>
  306. /// <param name="year"></param>
  307. /// <returns></returns>
  308. public static List<int> GetFcszfc35x7QiListByYear(int year)
  309. {
  310. List<int> rlist = new List<int>();
  311. string sql = string.Format("where qi like '{0}%' order by qi desc", year);
  312. DataConnect dc = new DataConnect();
  313. var list = dc.db.Fetch<Fcszfc35x7Info>(sql);
  314. if (list != null && list.Count > 0)
  315. {
  316. for (int i = 0; i < list.Count; i++)
  317. {
  318. rlist.Add(list[i].qi);
  319. }
  320. }
  321. return rlist;
  322. }
  323. #endregion
  324. #endregion
  325. #region 开奖号抓取相关数据层方法
  326. private static readonly object _lock = new object();
  327. public static void Add(Fcszfc35x7LongInfo info)
  328. {
  329. if (info == null)
  330. return;
  331. if (info.qi <= 0)
  332. return;
  333. info.opencode = $"{info.n1:00},{info.n2:00},{info.n3:00},{info.n4:00},{info.n5:00},{info.n6:00},{info.n7:00}+{info.n8:00}";
  334. //和值
  335. info.hz = info.n1 + info.n2 + info.n3 + info.n4 + info.n5 + info.n6 + info.n7;
  336. //星期
  337. info.week = Utils.GetIntWeek(info.date.DayOfWeek.ToString());
  338. List<int> kjh = new List<int> { info.n1, info.n2, info.n3, info.n4, info.n5, info.n6, info.n7 };
  339. kjh.Sort();
  340. info.n1 = kjh[0];
  341. info.n2 = kjh[1];
  342. info.n3 = kjh[2];
  343. info.n4 = kjh[3];
  344. info.n5 = kjh[4];
  345. info.n6 = kjh[5];
  346. info.n7 = kjh[6];
  347. //AC值
  348. string[] kjhstr = { info.n1.ToString(), info.n2.ToString(), info.n3.ToString(), info.n4.ToString(), info.n5.ToString(), info.n6.ToString(), info.n7.ToString() };
  349. //检查开奖号是否有重复值
  350. int[] array = { info.n1, info.n2, info.n3, info.n4, info.n5, info.n6, info.n7 };
  351. info.ac = ToolUtils.GetAC(kjhstr);
  352. info.kd = info.n7 - info.n1;
  353. lock (_lock)
  354. {
  355. using (Database db = new Database(mysql, MySqlClientFactory.Instance))
  356. {
  357. if (db.Exists<Fcszfc35x7LongInfo>($"where qi={info.qi}"))
  358. return;
  359. db.Insert(info);
  360. try
  361. {
  362. //更新api
  363. DoHttpHelp.UpdateWebApi(DFEnum.fcsz35x7.ToString());
  364. }
  365. catch (Exception) { }
  366. }
  367. }
  368. }
  369. public static void Update(Fcszfc35x7LongInfo model)
  370. {
  371. if (model == null)
  372. return;
  373. using (Database db = new Database(mysql, MySqlClientFactory.Instance))
  374. {
  375. var entity = db.SingleOrDefault<Fcszfc35x7LongInfo>(model.id);
  376. db.Update(entity);
  377. }
  378. }
  379. public static Fcszfc35x7LongInfo GetLastOne()
  380. {
  381. using (Database db = new Database(mysql, MySqlClientFactory.Instance))
  382. {
  383. var entity = db.SingleOrDefault<Fcszfc35x7LongInfo>($"order by qi desc limit 1");
  384. return entity ?? new Fcszfc35x7LongInfo();
  385. }
  386. }
  387. #endregion
  388. }
  389. }