Nobase.php
3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* Created by PhpStorm.
* User: wxd1061
* Date: 2018-07-21
* Time: 17:35
*/
namespace app\mobile\controller;
use app\home\logic\UsersLogic;
use think\Controller;
use think\Cookie;
use Think\Db;
use think\Page;
class Nobase extends Controller
{
/**
* 秒杀活动列表
*/
public function ajax_team_list()
{
$stype = I('type/d', 1);
$now_time = time(); //当前时间
$where = " and f.is_end=0";
/*---当开始时间大于当前时间,就是活动已经开始---*/
if ($stype == 1) {
$where = " and f.start_time<" . $now_time;
$fname = "/team/ajax_team_list_1";
} else {
$where = " and f.start_time>=" . $now_time;
$fname = "/team/ajax_team_list_2";
}
//秒杀商品
$id = getMobileStoId();
if (is_int($now_time / 7200)) { //双整点时间,如:10:00, 12:00
$start_time = $now_time;
} else {
$start_time = floor($now_time / 7200) * 7200; //取得前一个双整点时间
}
$end_time = $start_time + 7200; //结束时间
$tt=time();
/*--and f.goods_num>f.buy_num--*/
$count = M('goods')
->alias('g')
->join('teamlist f', 'g.goods_id = f.goods_id', 'inner')
->where(" g.store_id=" . $id . " and g.is_on_sale=1 and f.show_time<" . $now_time . " and f.end_time>" . $now_time . $where)
->where("g.on_time<".$tt." and (g.down_time>".$tt." or g.down_time=0 ) and g.is_mainshow=1")
->where('f.is_show=1 and f.is_end=0')
->count();
//dump(" g.store_id=".$id." and g.is_on_sale=1 and f.goods_num>f.buy_num and f.show_time<".$now_time." and end_time>".$now_time);exit;
$pagesize = 10;//C('PAGESIZE'); //每页显示数
$Page = new Page($count, $pagesize); // 实例化分页类 传入总记录数和每页显示的记录数
$show = $Page->show(); // 分页显示输出
$this->assign('page', $show); // 赋值分页输出
//mlog($Page->firstRow.','.$Page->listRows,"seckill");
/*and f.goods_num>f.buy_num*/
$list = M('goods')
->alias('g')
->join('teamlist f', 'g.goods_id = f.goods_id', 'inner')
->where(" g.store_id=" . $id . " and g.is_on_sale=1 and f.show_time<" . $now_time . " and f.end_time>" . $now_time . $where)
->where("g.on_time<".$tt." and (g.down_time>".$tt." or g.down_time=0 )")
->where('f.is_show=1 and f.is_end=0')
->order('f.ordid')
->limit($Page->firstRow . ',' . $Page->listRows)
->select();
foreach ($list as $item) {
$item['cur_num'] = $item['goods_num'] - $item['buy_num'];
$list1[] = $item;
}
$this->assign('list', $list1);
$p = I("p/d", 1);
if ($count <= $p * 10) {
$this->assign('mshow', 0);
} else {
$this->assign('mshow', 1);
}
upload_ylp_log('秒杀活动列表');
return $this->fetch($fname, getMobileStoId());
}
}