TemplateController.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. using Common;
  2. using KJH55128_Rec.Business;
  3. using KJH55128_Rec.Business.TJ;
  4. using KJH55128_Rec.Business.TrendChart;
  5. using KJH55128_Rec.ViewModels;
  6. using Models;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace KJH55128_Rec.Controllers
  13. {
  14. public class TemplateController : Controller
  15. {
  16. ////高频彩11x5部分区分
  17. //private List<string> dfclottery = new List<string>()
  18. //{ "jiangsu11x5","heilongjiang11x5","guangdong11x5","hebei11x5","liaoning11x5",
  19. // "jiangxi11x5","jilin11x5","shandong11x5","yunnan11x5","zhejiang11x5"};
  20. //高频彩11x5部分区分
  21. private List<string> dfclottery = new List<string>()
  22. { "GP_11x5_JiangSu","GP_11x5_HeiLongJiang","GP_11x5_GuangDong","GP_11x5_HeBei","GP_11x5_LiaoNing",
  23. "GP_11x5_JiangXi","GP_11x5_JiLin","GP_11x5_ShanDong","GP_11x5_YunNan","GP_11x5_ZheJiang"};
  24. /// <summary>
  25. /// 全国彩开奖table
  26. /// </summary>
  27. /// <returns></returns>
  28. public PartialViewResult _qgc(string type)
  29. {
  30. ViewBag.lottery = type;
  31. List<LotteryViewModel> data = KJApiBLL.GetLotteryList(type, 0, 0, "Term", null, 10, true);// 查倒数
  32. return PartialView(data);
  33. }
  34. /// <summary>
  35. /// 地方彩开奖table
  36. /// </summary>
  37. /// <returns></returns>
  38. public PartialViewResult _dfc(string type)
  39. {
  40. ViewBag.lottery = type;
  41. List<LotteryViewModel> data = KJApiBLL.GetLotteryList(type, 0, 0, "Term", null, 10, true);// 查倒数
  42. return PartialView(data);
  43. }
  44. #region 高频彩
  45. /// <summary>
  46. /// 高频彩11x5开奖table
  47. /// </summary>
  48. /// <param name="type"></param>
  49. /// <returns></returns>
  50. public PartialViewResult _gpc11x5(string type, string date)
  51. {
  52. ViewBag.Dispaly = getDfcIsDisplay(type);
  53. List<LotteryViewModel> data = new List<LotteryViewModel>();
  54. if (string.IsNullOrWhiteSpace(date))
  55. {
  56. data = KJApiBLL.GetLotteryList(type, 1, 0, null, null, 0, true);// 查天数
  57. }
  58. else
  59. {
  60. Dictionary<string, object> dict2 = null;
  61. dict2["MinDate"] = date + " 00:00:00";
  62. dict2["MaxDate"] = date + " 23:59:59";
  63. data = KJApiBLL.GetLotteryList(type, 0, 0, null, dict2, 0, true);
  64. }
  65. return PartialView(data);
  66. }
  67. /// <summary>
  68. /// 高频彩快3开奖table
  69. /// </summary>
  70. /// <param name="type"></param>
  71. /// <returns></returns>
  72. public PartialViewResult _gpck3(string type, string date)
  73. {
  74. List<LotteryViewModel> data = new List<LotteryViewModel>();
  75. if (string.IsNullOrWhiteSpace(date))
  76. {
  77. data = KJApiBLL.GetLotteryList(type, 1, 0, null, null, 0, true);// 查天数
  78. }
  79. else
  80. {
  81. Dictionary<string, object> dict2 = null;
  82. dict2["MinDate"] = date + " 00:00:00";
  83. dict2["MaxDate"] = date + " 23:59:59";
  84. data = KJApiBLL.GetLotteryList(type, 0, 0, null, dict2, 0, true);
  85. }
  86. return PartialView(data);
  87. }
  88. /// <summary>
  89. /// 高频彩快12开奖table
  90. /// </summary>
  91. /// <param name="type"></param>
  92. /// <returns></returns>
  93. public PartialViewResult _gpckl12(string type, string date)
  94. {
  95. List<LotteryViewModel> data = new List<LotteryViewModel>();
  96. if (string.IsNullOrWhiteSpace(date))
  97. {
  98. data = KJApiBLL.GetLotteryList(type, 1, 0, null, null, 0, true);// 查天数
  99. }
  100. else
  101. {
  102. Dictionary<string, object> dict2 = null;
  103. dict2["MinDate"] = date + " 00:00:00";
  104. dict2["MaxDate"] = date + " 23:59:59";
  105. data = KJApiBLL.GetLotteryList(type, 0, 0, null, dict2, 0, true);
  106. }
  107. return PartialView(data);
  108. }
  109. /// <summary>
  110. /// 高频彩快乐十分开奖table
  111. /// </summary>
  112. /// <param name="type"></param>
  113. /// <returns></returns>
  114. public PartialViewResult _gpcklsf(string type, string date)
  115. {
  116. ViewBag.lottery = type;
  117. List<LotteryViewModel> data = new List<LotteryViewModel>();
  118. if (string.IsNullOrWhiteSpace(date))
  119. {
  120. data = KJApiBLL.GetLotteryList(type, 1, 0, null, null, 0, true);// 查天数
  121. }
  122. else
  123. {
  124. Dictionary<string, object> dict2 = null;
  125. dict2["MinDate"] = date + " 00:00:00";
  126. dict2["MaxDate"] = date + " 23:59:59";
  127. data = KJApiBLL.GetLotteryList(type, 0, 0, null, dict2, 0, true);
  128. }
  129. return PartialView(data);
  130. }
  131. /// <summary>
  132. /// 高频彩时时彩table
  133. /// </summary>
  134. /// <param name="type"></param>
  135. /// <returns></returns>
  136. public PartialViewResult _gpcssc(string type, string date)
  137. {
  138. ViewBag.lottery = type;
  139. List<LotteryViewModel> data = KJApiBLL.GetLotteryList(type, 1, 0, null, null, 0, true);// 查天数
  140. return PartialView(data);
  141. }
  142. /// <summary>
  143. /// 高频彩其他table
  144. /// </summary>
  145. /// <param name="type"></param>
  146. /// <returns></returns>
  147. public PartialViewResult _gpcqt(string type, string date)
  148. {
  149. ViewBag.lottery = type;
  150. List<LotteryViewModel> data = KJApiBLL.GetLotteryList(type, 1, 0, null, null, 0, true);// 查天数
  151. return PartialView(data);
  152. }
  153. #endregion
  154. /// <summary>
  155. /// 控制高频彩11x5部分区分模板的单元格
  156. /// </summary>
  157. /// <param name="type"></param>
  158. /// <returns></returns>
  159. private bool getDfcIsDisplay(string type)
  160. {
  161. return dfclottery.FindIndex(d => d == type) > -1;
  162. }
  163. /// <summary>
  164. /// 返回彩种的历史记录table分页
  165. /// </summary>
  166. /// <param name="tablename">模板名</param>
  167. /// <param name="lotterytype">彩种名</param>
  168. /// <param name="day">多少天以内</param>
  169. /// <param name="num"></param>
  170. /// <param name="order"></param>
  171. /// <param name="param"></param>
  172. /// <param name="count">倒数多少条</param>
  173. /// <returns></returns>
  174. public PartialViewResult _getTable(string tablename = "", string lotterytype = "",
  175. int day = 1, int num = 0, string date = "", int year = 0,string qs="")
  176. {
  177. //lotterytype = EnumHelper.GETEnumTypeByText<SCCLottery>(lotterytype);
  178. ViewBag.lottery = lotterytype;
  179. ViewBag.Dispaly = getDfcIsDisplay(lotterytype);
  180. string param = null;
  181. Dictionary<string, object> dict2 = null;
  182. if (tablename.IndexOf("qgc") != -1 || tablename.IndexOf("dfc") != -1)
  183. {
  184. //全国彩地方彩
  185. if (num == 0 && day == 1&& year == 0 && string.IsNullOrWhiteSpace(qs))//初始化
  186. {
  187. day = 0;
  188. num = 20;
  189. param = "Term";
  190. }
  191. else
  192. {
  193. day = 0;
  194. param = "Term";
  195. }
  196. if (year != 0)
  197. {
  198. dict2 = new Dictionary<string, object>();
  199. dict2["MinYear"] = year;
  200. dict2["MaxYear"] = (year + 1);
  201. }
  202. if (!string.IsNullOrWhiteSpace(qs))
  203. {
  204. dict2 = new Dictionary<string, object>();
  205. dict2["Num"] = qs;
  206. }
  207. try
  208. {
  209. int value = -1;
  210. value = (int)Enum.Parse(typeof(EnumZXCid), lotterytype);
  211. ZXViewModel temp = new ZXViewModel();
  212. temp = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.Contains("基本") && d.Name.IndexOf("手机") == -1);
  213. if (temp == null)
  214. {
  215. ViewBag.zsSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.IndexOf("手机") == -1).Url;
  216. }
  217. else
  218. {
  219. ViewBag.zsSrc = temp.Url;
  220. }
  221. }
  222. catch
  223. {
  224. }
  225. }
  226. else
  227. {
  228. //高频彩
  229. if (!string.IsNullOrWhiteSpace(date))
  230. {
  231. //date = DateTime.ParseExact(date, "yyyyMMdd", null).ToString("yyyy-MM-dd");
  232. dict2 = new Dictionary<string, object>();
  233. dict2["MinDate"] = date + " 00:00:00";
  234. dict2["MaxDate"] = date + " 23:59:59";
  235. day = 0;
  236. }
  237. }
  238. List<LotteryViewModel> data = KJApiBLL.GetLotteryList(lotterytype, day, 0, param, dict2, num, true);
  239. return PartialView(tablename, data);
  240. }
  241. /// <summary>
  242. /// 返回彩种的历史记录table接口
  243. /// </summary>
  244. /// <param name="tablename">模板名</param>
  245. /// <param name="lotterytype">彩种名</param>
  246. /// <param name="day">多少天以内</param>
  247. /// <param name="num"></param>
  248. /// <param name="order"></param>
  249. /// <param name="param"></param>
  250. /// <param name="count">倒数多少条</param>
  251. /// <returns></returns>
  252. [HttpPost]
  253. public PartialViewResult _getTables(string tablename = "", string lotterytype = "", int day = 1, int num = 0,
  254. string minDate = "", string maxDate = "")
  255. {
  256. //lotterytype = EnumHelper.GETEnumTypeByText<SCCLottery>(lotterytype);
  257. ViewBag.lottery = lotterytype;
  258. ViewBag.Dispaly = getDfcIsDisplay(lotterytype);
  259. string param = null;
  260. if (num > 0)
  261. {
  262. param = "Term";
  263. }
  264. Dictionary<string, object> dict2 = null;
  265. if (!string.IsNullOrWhiteSpace(minDate) || !string.IsNullOrWhiteSpace(maxDate))
  266. {
  267. dict2 = new Dictionary<string, object>();
  268. dict2["MinDate"] = minDate;
  269. dict2["MaxDate"] = maxDate;
  270. }
  271. List<LotteryViewModel> data = KJApiBLL.GetLotteryList(lotterytype, day, 0, param, dict2, num, true);
  272. try
  273. {
  274. int value = -1;
  275. value = (int)Enum.Parse(typeof(EnumZXCid), lotterytype);
  276. ZXViewModel temp = new ZXViewModel();
  277. temp = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.Contains("基本") && d.Name.IndexOf("手机") == -1);
  278. if (temp == null)
  279. {
  280. ViewBag.zsSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.IndexOf("手机") == -1).Url;
  281. }
  282. else {
  283. ViewBag.zsSrc = temp.Url;
  284. }
  285. }
  286. catch
  287. {
  288. }
  289. return PartialView(tablename, data);
  290. }
  291. /// <summary>
  292. /// 获取开奖数据
  293. /// </summary>
  294. /// <param name="lotterytype"></param>
  295. /// <returns></returns>
  296. [HttpPost]
  297. public JsonResult _getKjData(string lotterytype = "")
  298. {
  299. //lotterytype = EnumHelper.GETEnumTypeByText<SCCLottery>(lotterytype);
  300. if (!string.IsNullOrWhiteSpace(lotterytype))
  301. {
  302. LotteryData data = KJApiBLL.GetLotteryAdTJ(lotterytype);
  303. return Json(data, JsonRequestBehavior.AllowGet);
  304. }
  305. else
  306. {
  307. return Json(new { msg = "lotterytype 参数传值有误" }, JsonRequestBehavior.AllowGet);
  308. }
  309. }
  310. /// <summary>
  311. /// 开机号、试机号年份、近10期切换
  312. /// </summary>
  313. /// <param name="lotterytype"></param>
  314. /// <param name="type"></param>
  315. /// <param name="term"></param>
  316. /// <param name="minYear"></param>
  317. /// <param name="maxYear"></param>
  318. /// <returns></returns>
  319. [HttpPost]
  320. public PartialViewResult _getKJHorSJHTable(string lotterytype, string type = "kjh", int term = 0, string minTerm = "", string maxTerm = "", string minYear = "", string maxYear = "")
  321. {
  322. if (!string.IsNullOrWhiteSpace(lotterytype))
  323. {
  324. lotterytype = EnumHelper.GETEnumTypeByText<SCCLottery>(lotterytype);
  325. Dictionary<string, object> dict2 = null;
  326. string param = null;
  327. if (term > 0)
  328. {
  329. param = "Term";
  330. }
  331. if (!string.IsNullOrWhiteSpace(minYear) || !string.IsNullOrWhiteSpace(maxYear))
  332. {
  333. dict2 = new Dictionary<string, object>();
  334. dict2["MinYear"] = minYear;
  335. dict2["MaxYear"] = maxYear;
  336. }
  337. if (!string.IsNullOrWhiteSpace(minTerm) || !string.IsNullOrWhiteSpace(maxTerm))
  338. {
  339. dict2 = new Dictionary<string, object>();
  340. dict2["MinTerm"] = minTerm;
  341. dict2["MaxTerm"] = maxTerm;
  342. }
  343. List<LotteryKaiJiHaoAdShijihaoHModel> data = null;
  344. if (type == "kjh")
  345. {
  346. data = KJApiBLL.GetLotteryListKaiJiHao(lotterytype, 0, 0, param, dict2, term, true);
  347. return PartialView("_kjhTable", data);
  348. }
  349. else
  350. {
  351. data = KJApiBLL.GetLotteryListShiJiHao(lotterytype, 0, 0, param, dict2, term, true);
  352. return PartialView("_sjhTable", data);
  353. }
  354. }
  355. else
  356. {
  357. return PartialView("/Shared/Error");
  358. }
  359. }
  360. /// <summary>
  361. /// 开机号||试机号按期号查询
  362. /// </summary>
  363. /// <param name="lotterytype"></param>
  364. /// <param name="type"></param>
  365. /// <param name="qs"></param>
  366. /// <returns></returns>
  367. [HttpPost]
  368. public JsonResult _getKJHorSJHDataByTerm(string lotterytype = "fc3d", string type = "kjh", string qs = "")
  369. {
  370. try
  371. {
  372. if (!string.IsNullOrWhiteSpace(lotterytype))
  373. {
  374. lotterytype = EnumHelper.GETEnumTypeByText<SCCLottery>(lotterytype);
  375. Dictionary<string, object> dict2 = null;
  376. if (!string.IsNullOrWhiteSpace(qs))
  377. {
  378. dict2 = new Dictionary<string, object>();
  379. dict2["Num"] = qs;
  380. }
  381. KaiJiHaoAdShijihaoHModel data = null;
  382. if (type == "kjh")
  383. {
  384. data = KJApiBLL.GetLotteryListKaiJiHao(lotterytype, 0, 0, null, dict2, 0, true)[0].Kaijianghao;
  385. }
  386. else
  387. {
  388. data = KJApiBLL.GetLotteryListShiJiHao(lotterytype, 0, 0, null, dict2, 0, true)[0].Shijihao;
  389. }
  390. return Json(data, JsonRequestBehavior.AllowGet);
  391. }
  392. else
  393. {
  394. return Json(new { msg = "lotterytype 参数传值有误" }, JsonRequestBehavior.AllowGet);
  395. }
  396. }
  397. catch (Exception ee)
  398. {
  399. return null;
  400. }
  401. }
  402. /// <summary>
  403. /// 高频彩页面展示彩种切换接口
  404. /// </summary>
  405. /// <param name="types"></param>
  406. /// <returns></returns>
  407. public PartialViewResult _getNavLotteryTable(string id)
  408. {
  409. //id = TJApiBLL.GetBaseItemLottery().FirstOrDefault(d => d.ItemCode == id).ItemId;
  410. List<string> types = TJApiBLL.GetShowHomeTypes(id);
  411. List<LotteryData> datalist = KJApiBLL.GetLotteryAdTJ(types);
  412. return PartialView("_navLotteryTable", datalist);
  413. }
  414. /// <summary>
  415. /// 历史上的今天
  416. /// </summary>
  417. /// <param name="lotterytype"></param>
  418. /// <param name="type"></param>
  419. /// <returns></returns>
  420. public PartialViewResult _getSjhHistoryToday(string lotterytype, string term)
  421. {
  422. Dictionary<string, object> dict = null;
  423. List<LotteryKaiJiHaoAdShijihaoHModel> list = new List<LotteryKaiJiHaoAdShijihaoHModel>();
  424. if (!string.IsNullOrWhiteSpace(lotterytype) && !string.IsNullOrWhiteSpace(term))
  425. {
  426. dict = new Dictionary<string, object>();
  427. dict["InTerm"] = getTerms(term);
  428. list = KJApiBLL.GetLotteryListShiJiHao(lotterytype, 0, 0, null, dict);
  429. }
  430. return PartialView("_sjhTable", list);
  431. }
  432. private List<string> getTerms(string term)
  433. {
  434. int num = 0; string per = "";
  435. List<string> terms = new List<string>();
  436. if (term.Length >= 7)
  437. {
  438. num = Int32.Parse(term.Substring(0, 4));
  439. per = term.Substring(4, 3);
  440. }
  441. else
  442. {
  443. num = Int32.Parse(term.Substring(0, 2));
  444. per = term.Substring(2, 3);
  445. }
  446. int yearCount = DateTime.Now.Year - 2000;
  447. for (int i = 0; i <= yearCount; i++)
  448. {
  449. terms.Add((num - i).ToString() + per);
  450. }
  451. return terms;
  452. }
  453. }
  454. }