SpikeController.class.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. class SpikeController extends CommonController {
  16. //进行中
  17. public function index(){
  18. $per_page = 10;
  19. $page = I('post.page',1);
  20. $last_btime = I('post.last_btime',0);
  21. $offset = ($page - 1) * $per_page;
  22. $begin_hour_time = strtotime(date('Y-m-d H'.':00:00'));
  23. $begin_hour_time = time();
  24. $sql = 'select s.begin_time as btime,sg.state,sg.begin_time,sg.end_time,g.goods_id,g.name,g.quantity,g.pinprice,g.price,g.image from '.C('DB_PREFIX')."spike_goods as sg ,
  25. ".C('DB_PREFIX')."goods as g ,".C('DB_PREFIX')."spike as s
  26. where sg.state =1 and s.id=sg.spike_id and sg.goods_id = g.goods_id and g.status =1 and g.quantity > 0 and sg.begin_time <= ".$begin_hour_time." and sg.end_time > ".$begin_hour_time." order by sg.end_time asc ,sg.begin_time asc limit {$offset},{$per_page}";
  27. $list = M()->query($sql);
  28. $fc_last_end_time = 0;
  29. foreach ($list as $k => $v) {
  30. $v['image']=resize($v['image'], C('spike_thumb_width'), C('spike_thumb_height'));
  31. $fc_last_end_time = $v['begin_time'];
  32. $list[$k] = $v;
  33. }
  34. $this->last_btime = $last_btime;
  35. $this->cur_btime = $last_btime;
  36. $this->list = $list;
  37. if($page > 1) {
  38. $result = array('code' => 0);
  39. if(!empty($list)) {
  40. $result['code'] = 1;
  41. $result['fc_last_end_time'] = $fc_last_end_time;
  42. $result['html'] = $this->fetch('Widget:spike_ajax_on_fetch');
  43. }
  44. echo json_encode($result);
  45. die();
  46. }
  47. $this->display('index');
  48. }
  49. //未开始
  50. public function wait()
  51. {
  52. $per_page = 10;
  53. $page = I('post.page',1);
  54. $offset = ($page - 1) * $per_page;
  55. $sql = 'select s.begin_time as btime,sg.state,sg.begin_time,sg.end_time,g.goods_id,g.name,g.quantity,g.pinprice,g.price,g.image from '.C('DB_PREFIX')."spike_goods as sg ,
  56. ".C('DB_PREFIX')."goods as g ,".C('DB_PREFIX')."spike as s
  57. where sg.state =1 and s.id=sg.spike_id and sg.goods_id = g.goods_id and g.status =1 and g.quantity >0 and sg.begin_time > ".time()." order by s.begin_time asc ,sg.begin_time asc limit {$offset},{$per_page}";
  58. $list = M()->query($sql);
  59. foreach ($list as $k => $v) {
  60. $list[$k]['image']=resize($v['image'], C('spike_thumb_width'), C('spike_thumb_height'));
  61. }
  62. $this->list = $list;
  63. $result = array('code' => 0);
  64. if(!empty($list)) {
  65. $result['code'] = 1;
  66. $result['html'] = $this->fetch('Widget:spike_ajax_wait_fetch');
  67. }
  68. echo json_encode($result);
  69. die();
  70. }
  71. public function over()
  72. {
  73. $per_page = 10;
  74. $page = I('post.page',1);
  75. $offset = ($page - 1) * $per_page;
  76. $sql = 'select s.begin_time as btime,sg.state,sg.begin_time,sg.end_time,g.goods_id,g.name,g.quantity,g.pinprice,g.price,g.image from '.C('DB_PREFIX')."spike_goods as sg ,
  77. ".C('DB_PREFIX')."goods as g ,".C('DB_PREFIX')."spike as s
  78. where sg.state =1 and s.id=sg.spike_id and sg.goods_id = g.goods_id and g.status =1 and ( g.quantity =0 or sg.end_time < ".time().") order by s.begin_time asc ,sg.begin_time asc limit {$offset},{$per_page}";
  79. $list = M()->query($sql);
  80. foreach ($list as $k => $v) {
  81. $list[$k]['image']=resize($v['image'], C('spike_thumb_width'), C('spike_thumb_height'));
  82. }
  83. $this->list = $list;
  84. $result = array('code' => 0);
  85. if(!empty($list)) {
  86. $result['code'] = 1;
  87. $result['html'] = $this->fetch('Widget:spike_ajax_over_fetch');
  88. }
  89. echo json_encode($result);
  90. die();
  91. }
  92. }