LotteryController.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. class LotteryController extends CommonController {
  16. protected function _initialize(){
  17. parent::_initialize();
  18. }
  19. //进行中
  20. public function index(){
  21. $per_page = 10;
  22. $page = I('post.page',1);
  23. $offset = ($page - 1) * $per_page;
  24. $sql = 'select 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')."lottery_goods as sg , ".C('DB_PREFIX')."goods as g
  25. where sg.state =1 and sg.goods_id = g.goods_id and g.status =1 and g.quantity >0 and sg.begin_time < ".time()." and sg.end_time > ".time()." order by sg.begin_time asc limit {$offset},{$per_page}";
  26. $list = M()->query($sql);
  27. foreach ($list as $k => $v) {
  28. $list[$k]['image']=resize($v['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  29. }
  30. $this->list = $list;
  31. if($page > 1) {
  32. $result = array('code' => 0);
  33. if(!empty($list)) {
  34. $result['code'] = 1;
  35. $result['html'] = $this->fetch('Widget:lottery_ajax_on_fetch');
  36. }
  37. echo json_encode($result);
  38. die();
  39. }
  40. $this->display('index');
  41. }
  42. //未开始
  43. public function wait()
  44. {
  45. $per_page = 10;
  46. $page = I('post.page',1);
  47. $offset = ($page - 1) * $per_page;
  48. $sql = 'select 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')."lottery_goods as sg , ".C('DB_PREFIX')."goods as g
  49. where sg.state =1 and sg.goods_id = g.goods_id and g.status =1 and g.quantity >0 and sg.begin_time > ".time()." order by sg.begin_time asc limit {$offset},{$per_page}";
  50. $list = M()->query($sql);
  51. foreach ($list as $k => $v) {
  52. $list[$k]['image']=resize($v['image'], C('spike_thumb_width'), C('spike_thumb_height'));
  53. }
  54. $this->list = $list;
  55. $result = array('code' => 0);
  56. if(!empty($list)) {
  57. $result['code'] = 1;
  58. $result['html'] = $this->fetch('Widget:lottery_ajax_wait_fetch');
  59. }
  60. echo json_encode($result);
  61. die();
  62. }
  63. public function over()
  64. {
  65. $per_page = 10;
  66. $page = I('post.page',1);
  67. $offset = ($page - 1) * $per_page;
  68. $sql = 'select sg.state,sg.begin_time,sg.is_open_lottery,sg.end_time,g.goods_id,g.name,g.quantity,g.pinprice,g.price,g.image from '.C('DB_PREFIX')."lottery_goods as sg , ".C('DB_PREFIX')."goods as g
  69. where sg.state =1 and sg.goods_id = g.goods_id and sg.end_time < ".time()." order by sg.begin_time asc limit {$offset},{$per_page}";
  70. $list = M()->query($sql);
  71. foreach ($list as $k => $v) {
  72. $list[$k]['image']=resize($v['image'], C('spike_thumb_width'), C('spike_thumb_height'));
  73. }
  74. $this->list = $list;
  75. $result = array('code' => 0);
  76. if(!empty($list)) {
  77. $result['code'] = 1;
  78. $result['html'] = $this->fetch('Widget:lottery_ajax_over_fetch');
  79. }
  80. echo json_encode($result);
  81. die();
  82. }
  83. }