HomeController.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. using Common;
  2. using KJH55128_Rec.Business;
  3. using KJH55128_Rec.Business.TJ;
  4. using KJH55128_Rec.Business.TrendChart;
  5. using KJH55128_Rec.Util;
  6. using KJH55128_Rec.ViewModels;
  7. using Models;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Web;
  12. using System.Web.Mvc;
  13. using static Common.HongKongHelper;
  14. namespace KJH55128_Rec.Controllers
  15. {
  16. public class HomeController : Controller
  17. {
  18. public ActionResult Mindex()
  19. {
  20. return Redirect("/index.html");
  21. }
  22. [Route("index.html")]
  23. public ActionResult Index()
  24. {
  25. List<string> types = TJApiBLL.GetHomeTypes();
  26. List<LotteryData> list = KJApiBLL.GetLotteryAdTJ(types);
  27. return View(list);
  28. }
  29. /// <summary>
  30. /// 历史开奖
  31. /// </summary>
  32. /// <param name="type"></param>
  33. /// <returns></returns>
  34. //[Route("kjls/{area}/{type}.html")]
  35. //[Route("kjls/{area}/{type}/{date}.html")]
  36. [Route("kjls/{strparams}.html")]
  37. public ActionResult KJXQ(string strparams)
  38. {
  39. string area = "", type = "", date = "";
  40. string[] arrs = strparams.Split('-');
  41. if (arrs.Length > 0)
  42. {
  43. area = ValidationTools.CheckStr(arrs[0], "gpc", 5);
  44. type = ValidationTools.CheckStr(arrs[1], "fc3d", 20);
  45. if (arrs.Length == 3)
  46. {
  47. date = ValidationTools.CheckStr(arrs[2], null, 15);
  48. }
  49. }
  50. string code = EnumHelper.GETEnumTypeByText<SCCLottery>(type);
  51. type = EnumHelper.GETEnumTypeByText<SCCLottery>(type);
  52. LotteryData data = KJApiBLL.GetLotteryAdTJ(type);
  53. if (type == "DF_SMHLHC_HongKong")
  54. {
  55. var newBall = GetHongKongLotteryAttr(data.RedBall.ToList());
  56. ViewBag.newBall = newBall;
  57. ViewBag.bs = BoSeDict;
  58. ViewBag.sx = ShengXiaoDict;
  59. ViewBag.wx = WuXingDict;
  60. }
  61. ViewBag.area = area;
  62. if (!string.IsNullOrWhiteSpace(date))
  63. {
  64. try
  65. {
  66. date = DateTime.ParseExact(date, "yyyyMMdd", null).ToString("yyyy-MM-dd");
  67. ViewBag.date = date;
  68. }
  69. catch
  70. {
  71. if (date.IndexOf("y") != -1)
  72. {
  73. ViewBag.year = ValidationTools.CheckInt(date.Substring(1, date.Length - 1), 2000, (DateTime.Now.Year + 1));
  74. }
  75. if (date.IndexOf("q") != -1)
  76. {
  77. ViewBag.qs = ValidationTools.CheckInt(date.Substring(1, date.Length - 1), 0, 9999999);
  78. }
  79. if (date.IndexOf("n") != -1)
  80. {
  81. ViewBag.num = ValidationTools.CheckInt(date.Substring(1, date.Length - 1), 29, 121);
  82. }
  83. }
  84. }
  85. int value = -1;
  86. try
  87. {
  88. value = (int)Enum.Parse(typeof(EnumZXCid), type);
  89. ZXViewModel temp = new ZXViewModel();
  90. temp = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.Contains("基本") && d.Name.IndexOf("手机") == -1);
  91. if (temp == null)
  92. {
  93. ViewBag.zsSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.IndexOf("手机") == -1).Url;
  94. }
  95. else
  96. {
  97. ViewBag.zsSrc = temp.Url;
  98. }
  99. ViewBag.toolSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.工具).FirstOrDefault().Url;
  100. }
  101. catch
  102. {
  103. }
  104. string TDKType = EnumHelper.GetSCCLotteryTDKTypeName((SCCLottery)Enum.Parse(typeof(SCCLottery), code));
  105. ViewBag.tdk = KJApiBLL.GetTDK(TDKType);
  106. return View(data);
  107. }
  108. /// <summary>
  109. /// 开机号
  110. /// </summary>
  111. /// <returns></returns>
  112. //[Route("kjh/{type}.html")]
  113. //[Route("kjh/{type}/{param}.html")]
  114. //[Route("kjh/{type}/{param}/{term}.html")]
  115. [Route("kjh/{strparams}.html")]
  116. public ActionResult KJH(string strparams)
  117. {
  118. string type = "", param = "", complex = "";
  119. int term = 0;
  120. string[] arrs = strparams.Split('-');
  121. if (arrs.Length > 0)
  122. {
  123. type = ValidationTools.CheckStr(arrs[0], "fc3d", 5);
  124. if (arrs.Length == 2)
  125. {
  126. param = ValidationTools.CheckStr(arrs[1], null, 20);
  127. }
  128. if (arrs.Length == 3)
  129. {
  130. param = ValidationTools.CheckStr(arrs[1], null, 20);
  131. complex = ValidationTools.CheckStr(arrs[2], null, 15);
  132. }
  133. }
  134. ViewBag.code = type;
  135. ViewBag.term = 30;
  136. KJiHdescribe kJiHdescribe = new KJiHdescribe();
  137. if (type == "fc3d")
  138. {
  139. ViewBag.desc = kJiHdescribe.GetValueByKey(SCCLottery.QG_FC3D.ToString() + "-" + KJDdescribeType.What);
  140. }
  141. if (type == "ssq")
  142. {
  143. ViewBag.desc = kJiHdescribe.GetValueByKey(SCCLottery.QG_FCSSQ.ToString() + "-" + KJDdescribeType.What);
  144. }
  145. if (type == "pl3")
  146. {
  147. ViewBag.desc = kJiHdescribe.GetValueByKey(SCCLottery.QG_TCP3.ToString() + "-" + KJDdescribeType.What);
  148. }
  149. if (type == "dlt")
  150. {
  151. ViewBag.desc = kJiHdescribe.GetValueByKey(SCCLottery.QG_TCDLT.ToString() + "-" + KJDdescribeType.What);
  152. }
  153. type = EnumHelper.GETEnumTypeByText<SCCLottery>(type);
  154. List<LotteryKaiJiHaoAdShijihaoHModel> data = new List<LotteryKaiJiHaoAdShijihaoHModel>();
  155. if (string.IsNullOrWhiteSpace(param))
  156. {
  157. //var firstmodel = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, "Term", null, 5, true).FirstOrDefault();
  158. data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, "Term", null, 20, true);
  159. }
  160. else
  161. {
  162. Dictionary<string, object> dict2 = null;
  163. if (param.IndexOf("y") != -1)
  164. {
  165. int year = 0;
  166. year = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 2000, (DateTime.Now.Year + 1));
  167. dict2 = new Dictionary<string, object>();
  168. dict2["MinYear"] = year;
  169. dict2["MaxYear"] = year + 1;
  170. //data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, null, dict2, 0, true);
  171. }
  172. else if (param.IndexOf("n") != -1)
  173. {
  174. term = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 29, 121);
  175. ViewBag.term = term;
  176. dict2 = new Dictionary<string, object>();
  177. dict2["Num"] = term;
  178. //data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, "Term", dict2, term, true);
  179. }
  180. else if (param.IndexOf("q") != -1)
  181. {
  182. int qs = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 0, 9999999);
  183. dict2 = new Dictionary<string, object>();
  184. dict2["Num"] = qs;
  185. //data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, null, dict2, 0, true);
  186. }
  187. else
  188. {
  189. dict2 = new Dictionary<string, object>();
  190. int s_qs = ValidationTools.CheckInt(param, 0, 9999999);
  191. int e_qs = ValidationTools.CheckInt(complex, 0, 9999999);
  192. if (s_qs > e_qs)
  193. {
  194. int temp = e_qs;
  195. e_qs = s_qs;
  196. s_qs = temp;
  197. }
  198. dict2["MinTerm"] = s_qs;
  199. dict2["MaxTerm"] = e_qs;
  200. //data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, null, dict2, 0, true);
  201. }
  202. data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, "Term", dict2, term, true);
  203. }
  204. int value = -1;
  205. try
  206. {
  207. value = (int)Enum.Parse(typeof(EnumZXCid), type);
  208. ZXViewModel temp = new ZXViewModel();
  209. temp = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.Contains("基本") && d.Name.IndexOf("手机") == -1);
  210. if (temp == null)
  211. {
  212. ViewBag.zsSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.IndexOf("手机") == -1).Url;
  213. }
  214. else
  215. {
  216. ViewBag.zsSrc = temp.Url;
  217. }
  218. ViewBag.toolSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.工具).FirstOrDefault().Url;
  219. }
  220. catch
  221. {
  222. }
  223. return View(data);
  224. }
  225. /// <summary>
  226. /// 试机号
  227. /// </summary>
  228. /// <returns></returns>
  229. //[Route("sjh/{type}.html")]
  230. //[Route("sjh/{type}/{param}.html")]
  231. //[Route("sjh/{type}/{param}/{term}.html")]
  232. [Route("sjh/{strparams}.html")]
  233. public ActionResult SJH(string strparams)
  234. {
  235. string type = "", param = "", complex = "";
  236. int term = 0;
  237. string[] arrs = strparams.Split('-');
  238. if (arrs.Length > 0)
  239. {
  240. type = ValidationTools.CheckStr(arrs[0], "fc3d", 5);
  241. if (arrs.Length == 2)
  242. {
  243. param = ValidationTools.CheckStr(arrs[1], null, 20);
  244. }
  245. if (arrs.Length == 3)
  246. {
  247. param = ValidationTools.CheckStr(arrs[1], null, 20);
  248. complex = ValidationTools.CheckStr(arrs[2], null, 15);
  249. }
  250. }
  251. ViewBag.code = type;
  252. ViewBag.term = 30;
  253. type = EnumHelper.GETEnumTypeByText<SCCLottery>(type);
  254. List<LotteryKaiJiHaoAdShijihaoHModel> data = new List<LotteryKaiJiHaoAdShijihaoHModel>();
  255. if (string.IsNullOrWhiteSpace(param))
  256. {
  257. data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, "Term", null, 20, true);
  258. }
  259. else
  260. {
  261. Dictionary<string, object> dict2 = null;
  262. if (param.IndexOf("y") != -1)
  263. {
  264. int year = 0;
  265. year = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 2000, (DateTime.Now.Year + 1));
  266. dict2 = new Dictionary<string, object>();
  267. dict2["MinYear"] = year;
  268. dict2["MaxYear"] = year + 1;
  269. //data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, null, dict2, 0, true);
  270. }
  271. else if (param.IndexOf("n") != -1)
  272. {
  273. term = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 29, 121);
  274. ViewBag.term = term;
  275. dict2 = new Dictionary<string, object>();
  276. dict2["Num"] = term;
  277. //data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, "Term", dict2, term, true);
  278. }
  279. else if (param.IndexOf("q") != -1)
  280. {
  281. int qs = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 0, 9999999);
  282. dict2 = new Dictionary<string, object>();
  283. dict2["Num"] = qs;
  284. //data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, null, dict2, 0, true);
  285. }
  286. else
  287. {
  288. dict2 = new Dictionary<string, object>();
  289. int s_qs = ValidationTools.CheckInt(param, 0, 9999999);
  290. int e_qs = ValidationTools.CheckInt(complex, 0, 9999999);
  291. if (s_qs > e_qs)
  292. {
  293. int temp = e_qs;
  294. e_qs = s_qs;
  295. s_qs = temp;
  296. }
  297. dict2["MinTerm"] = s_qs;
  298. dict2["MaxTerm"] = e_qs;
  299. //data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, null, dict2, 0, true);
  300. }
  301. data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, "Term", dict2, term, true);
  302. }
  303. int value = -1;
  304. try
  305. {
  306. value = (int)Enum.Parse(typeof(EnumZXCid), type);
  307. ZXViewModel temp = new ZXViewModel();
  308. temp = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.Contains("基本") && d.Name.IndexOf("手机") == -1);
  309. if (temp == null)
  310. {
  311. ViewBag.zsSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.IndexOf("手机") == -1).Url;
  312. }
  313. else
  314. {
  315. ViewBag.zsSrc = temp.Url;
  316. }
  317. ViewBag.toolSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.工具).FirstOrDefault().Url;
  318. }
  319. catch
  320. {
  321. }
  322. return View(data);
  323. }
  324. /// <summary>
  325. /// 全国彩
  326. /// </summary>
  327. /// <returns></returns>
  328. [Route("qgc.html")]
  329. public ActionResult QGC()
  330. {
  331. //string id = TJApiBLL.GetBaseItemLottery().FirstOrDefault(d => d.Value == "QGC").Key;
  332. List<string> types = TJApiBLL.GetShowHomeTypes("QGC");
  333. List<LotteryData> datalist = KJApiBLL.GetLotteryAdTJ(types);
  334. return View(datalist);
  335. }
  336. /// <summary>
  337. /// 地方彩
  338. /// </summary>
  339. /// <returns></returns>
  340. [Route("dfc.html")]
  341. public ActionResult DFC()
  342. {
  343. //string id = TJApiBLL.GetBaseItemLottery().FirstOrDefault(d => d.Value == "DFC").Key;
  344. List<string> types = TJApiBLL.GetShowHomeTypes("DFC");
  345. List<LotteryData> datalist = KJApiBLL.GetLotteryAdTJ(types);
  346. if (types.Where(a => a == "DF_SMHLHC_HongKong").ToList().Count == 1)
  347. {
  348. var data = datalist.Where(a => a.LotteryType == "DF_SMHLHC_HongKong").FirstOrDefault();
  349. if (data != null)
  350. {
  351. var newBall = GetHongKongLotteryAttr(data.RedBall.ToList());
  352. ViewBag.newBall = newBall;
  353. }
  354. }
  355. return View(datalist);
  356. }
  357. /// <summary>
  358. /// 高频彩
  359. /// </summary>
  360. /// <returns></returns>
  361. [Route("gpc.html")]
  362. public ActionResult GPC()
  363. {
  364. //string id = TJApiBLL.GetBaseItemLottery().FirstOrDefault(d => d.Value == "GPC11X5").Key;
  365. List<string> types = TJApiBLL.GetShowHomeTypes("GPC11X5");
  366. List<LotteryData> datalist = KJApiBLL.GetLotteryAdTJ(types);
  367. return View(datalist);
  368. }
  369. /// <summary>
  370. /// 开奖详情
  371. /// </summary>
  372. /// <returns></returns>
  373. //[Route("kjxq/{area}/{type}.html")]
  374. //[Route("kjxq/{area}/{type}/{num}.html")]
  375. [Route("kjxq/{strparams}.html")]
  376. public ActionResult KJDetail(string strparams)
  377. {
  378. string area = "", type = "", num = "";
  379. string[] arrs = strparams.Split('-');
  380. if (arrs.Length > 0)
  381. {
  382. area = ValidationTools.CheckStr(arrs[0], "gpc", 5);
  383. type = ValidationTools.CheckStr(arrs[1], "fc3d", 20);
  384. if (arrs.Length == 3)
  385. {
  386. num = ValidationTools.CheckStr(arrs[2], null, 15);
  387. }
  388. }
  389. try
  390. {
  391. string code = EnumHelper.GETEnumTypeByText<SCCLottery>(type);
  392. LotteryData data = new LotteryData();
  393. LotterySupply lottsumodel = new LotterySupply();
  394. ViewBag.area = area;
  395. if (!string.IsNullOrWhiteSpace(num))
  396. {
  397. int intnum = 0;
  398. int.TryParse(num, out intnum);
  399. Dictionary<string, object> dict = new Dictionary<string, object>();
  400. dict["Num"] = intnum;
  401. LotteryViewModel temp = KJApiBLL.GetLotteryList(code, 0, 0, null, dict).FirstOrDefault(); //查期号
  402. data.OpenTime = temp.OpenTime;
  403. data.LotteryName = temp.LotteryName;
  404. data.Term = temp.LotteryName;
  405. data.LotteryText = type;
  406. data.MoneyPond = temp.MoneyPond;
  407. data.MoneyCount = temp.MoneyCount;
  408. data.RedBall = temp.RedBall;
  409. data.BlueBall = temp.BlueBall;
  410. data.Term = intnum.ToString();
  411. data.LotteryType = temp.LotteryType;
  412. data.KJTime = temp.KJTime;
  413. lottsumodel.hezhi = temp.hezhi;
  414. lottsumodel.daxiaobi = temp.daxiao;
  415. lottsumodel.jioubi = temp.jio;
  416. if (temp.Details != null && temp.Details.Count > 0)
  417. {
  418. for (int i = 0; i < temp.Details.Count; i++)
  419. {
  420. data.Details.Add(new LotteryDetail(temp.Details[i].Label, temp.Details[i].Value));
  421. }
  422. }
  423. if (temp.Results != null && temp.Results.Count > 0)
  424. {
  425. data.ResultsList = new List<LotteryResults>();
  426. for (int i = 0; i < temp.Results.Count; i++)
  427. {
  428. data.ResultsList.Add(new LotteryResults(temp.Results[i].LevelName, temp.Results[i].Count, temp.Results[i].Money));
  429. }
  430. }
  431. }
  432. else
  433. {
  434. data = KJApiBLL.GetLotteryAdTJ(code);
  435. //和值 奇偶比 大小比;
  436. if (data.Details.Select(w => w.Label).ToList().Contains("大小比"))
  437. {
  438. lottsumodel.daxiaobi = data.Details.FirstOrDefault(w => w.Label == "大小比").Value.ToString();
  439. }
  440. if (data.Details.Select(w => w.Label).ToList().Contains("奇偶比"))
  441. {
  442. lottsumodel.jioubi = data.Details.FirstOrDefault(w => w.Label == "奇偶比").Value.ToString();
  443. }
  444. if (data.Details.Select(w => w.Label).ToList().Contains("和值"))
  445. {
  446. lottsumodel.hezhi = data.Details.FirstOrDefault(w => w.Label == "和值").Value.ToString();
  447. }
  448. }
  449. int value = -1;
  450. try
  451. {
  452. value = (int)Enum.Parse(typeof(EnumZXCid), code);
  453. ZXViewModel temp = new ZXViewModel();
  454. temp = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.Contains("基本") && d.Name.IndexOf("手机") == -1);
  455. if (temp == null)
  456. {
  457. lottsumodel.zsurl = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.IndexOf("手机") == -1).Url;
  458. }
  459. else
  460. {
  461. lottsumodel.zsurl = temp.Url;
  462. }
  463. lottsumodel.gjurl = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.工具).FirstOrDefault().Url;
  464. }
  465. catch (Exception e)
  466. {
  467. Console.Write(e);
  468. }
  469. ViewBag.lotterysu = lottsumodel;
  470. string TDKType = EnumHelper.GetSCCLotteryTDKTypeName((SCCLottery)Enum.Parse(typeof(SCCLottery), code));
  471. ViewBag.tdk=KJApiBLL.GetTDK(TDKType);
  472. string type1 = EnumHelper.GETEnumTypeByText<SCCLottery>(type);
  473. if (type1 == "DF_SMHLHC_HongKong")
  474. {
  475. var newBall = GetHongKongLotteryAttr(data.RedBall.ToList());
  476. ViewBag.newBall = newBall;
  477. ViewBag.bs = BoSeDict;
  478. ViewBag.sx = ShengXiaoDict;
  479. ViewBag.wx = WuXingDict;
  480. }
  481. return View(data);
  482. }
  483. catch (Exception ee)
  484. {
  485. return Redirect("/");
  486. }
  487. }
  488. }
  489. }