| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace app\api\model\service;
- use think\Model;
- class Coupon extends Model
- {
- // 表名
- protected $name = 'service_coupon';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- public static function getCouponList($params)
- {
- extract($params);
- if(isset($shop_id) && $shop_id)
- {
- $where['shop_id'] = $shop_id;
- }
- if(isset($is_check) && $is_check != '')
- {
- $where['is_check'] = $is_check;
- }
- if(isset($timttype) && $timttype != '')
- {
- switch ($timttype)
- {
- case 0:
- $where['starttime'] = ['>',time()];
- break;
- case 1:
- $where['starttime'] = ['<=',time()];
- $where['endtime'] = ['>=',time()];
- break;
- case 2:
- $where['endtime'] = ['<',time()];
- break;
- }
- }
- $list = self::where($where)->field('id,type,goods_id,shop_id,achieve,reduce,starttime,endtime,effective_day,is_check,note,createtime')->order('id desc')->page($page)->limit(10)->select();
- foreach ($list as $key=>$value)
- {
- $list[$key]['goodsname'] = $value['goods_id']?Goods::getName($value['goods_id']):'';
- }
- return $list;
- }
- }
|