111
liyaozhi
2025-11-09 c13b8914228e6a404bd60ee36bf2479383da8f23
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
<?php
 
namespace app\api\model\plus\bargain;
 
use app\common\model\plus\bargain\Active as ActiveModel;
 
/**
 * 砍价模型
 */
class Active extends ActiveModel
{
    /**
     *列表
     */
    public function bargainList($param = null)
    {
        return $this->where('is_delete', '=', 0)->select();
    }
 
    /**
     * 获取砍价活动详情
     */
    public function getDetail($activeId)
    {
        $model = static::detail($activeId, 'product.sku');
        if (empty($model) || $model['is_delete'] == true || $model['status'] == false) {
            $this->error = '很抱歉,该砍价商品不存在或已下架';
            return false;
        }
        return $model;
    }
 
    /**
     * 取最近要结束的一条记录
     * 未开始也显示
     */
    public static function getActive()
    {
        return (new static())->where('end_time', '>', time())
            ->where('status', '=', 1)
            ->where('is_delete', '=', 0)
            ->order(['sort' => 'asc', 'create_time' => 'asc'])
            ->find();
    }
 
    /**
     * 获取砍价商品列表
     * 未开始也显示
     */
    public function activityList()
    {
        return  $this->where('end_time', '>=', time())
            ->where('status', '=', 1)
            ->where('is_delete', '=', 0)
            ->order(['sort' => 'asc', 'create_time' => 'asc'])
            ->select();
    }
}