SuperSpikeController.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 SuperSpikeController extends CommonController {
  16. //进行中
  17. public function index(){
  18. $per_page = 10;
  19. $page = I('post.page',1);
  20. $offset = ($page - 1) * $per_page;
  21. $super_spike = M('super_spike')->where('begin_time<'.time().' and end_time > '.time())->order('begin_time desc')->find();
  22. if($super_spike){
  23. $sql = 'select sg.state,g.goods_id,g.name,g.quantity,g.pinprice,g.price,g.image,g.store_id,g.seller_count from '.C('DB_PREFIX')."super_spike_goods as sg , ".C('DB_PREFIX')."goods as g
  24. where super_spike_id = ".$super_spike['id']." and sg.state =1 and sg.goods_id = g.goods_id and g.status =1 and g.quantity >0 order by sg.id asc limit {$offset},{$per_page}";
  25. $list = M()->query($sql);
  26. $this->list = $list;
  27. } else {
  28. $this->list = array();
  29. }
  30. if($page > 1) {
  31. $result = array('code' => 0);
  32. if(!empty($list)) {
  33. $result['code'] = 1;
  34. $result['html'] = $this->fetch('SuperSpike:superspike_ajax_fetch');
  35. }
  36. echo json_encode($result);
  37. die();
  38. }
  39. $this->display('SuperSpike:index');
  40. }
  41. //未开始
  42. public function wait()
  43. {
  44. $per_page = 10;
  45. $page = I('post.page',1);
  46. $offset = ($page - 1) * $per_page;
  47. $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')."spike_goods as sg , ".C('DB_PREFIX')."goods as g
  48. 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}";
  49. $list = M()->query($sql);
  50. foreach ($list as $k => $v) {
  51. $list[$k]['image']=resize($v['image'], C('spike_thumb_width'), C('spike_thumb_height'));
  52. }
  53. $this->list = $list;
  54. $result = array('code' => 0);
  55. if(!empty($list)) {
  56. $result['code'] = 1;
  57. $result['html'] = $this->fetch('Widget:spike_ajax_wait_fetch');
  58. }
  59. echo json_encode($result);
  60. die();
  61. }
  62. public function over()
  63. {
  64. $per_page = 10;
  65. $page = I('post.page',1);
  66. $offset = ($page - 1) * $per_page;
  67. $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')."spike_goods as sg , ".C('DB_PREFIX')."goods as g
  68. where sg.state =1 and sg.goods_id = g.goods_id and g.quantity =0 order by sg.begin_time asc limit {$offset},{$per_page}";
  69. $list = M()->query($sql);
  70. foreach ($list as $k => $v) {
  71. $list[$k]['image']=resize($v['image'], C('spike_thumb_width'), C('spike_thumb_height'));
  72. }
  73. $this->list = $list;
  74. $result = array('code' => 0);
  75. if(!empty($list)) {
  76. $result['code'] = 1;
  77. $result['html'] = $this->fetch('Widget:spike_ajax_over_fetch');
  78. }
  79. echo json_encode($result);
  80. die();
  81. }
  82. }