field('id,turntable_name,start_time,end_time,strategy,explain,status,max_num,day_num,shop_limit,turntable_type,shop_id,vip_limit,vip_level,money_limit,task_type,one_consume,one_month_num') ->find($id); return $one; } /* * 获取商户历史大转盘数据 * param $merchant_id 商户ID * param $title 活动名 * param $type '大转盘类型 1 公众号通知栏 2 小程序商城 3线上支付 线下支付 5任务', * */ public function getMerchantList($merchant_id, $title, $type, $page, $page_size) { $w['merchant_id'] = $merchant_id; if (!empty($title)) { $w['turntable_name'] = '%' . $title . '%'; } if (!empty($type)) { $w['turntable_type'] = $type; } $list = $this ->field('id,turntable_name,start_time,end_time,add_time,prize_total') ->where($w) ->page($page, $page_size) ->order('add_time desc') ->select(); return $list; } /* * 获取商户历史大转盘数据记录总数 * param $where 查询条件 * */ public function getTurntableCount($merchant_id, $title, $type) { $w['merchant_id'] = $merchant_id; if (!empty($title)) { $w['turntable_name'] = '%' . $title . '%'; } if (!empty($type)) { $w['turntable_type'] = $type; } $list = $this ->where($w) ->count(); return $list; } /* * 获取大转盘活动列表 * param $merchant_id 商户ID * param $title 搜索字段 * param $status 活动状态 1,可用,2,关闭, * param $turntable_type 活动类型 1 公众号通知栏 2 小程序商城 3线上支付 线下支付 5任务 * param $start_time 开始时间 * param $end_time 结束时间 * param $page 当前页数 * param $page_size 每页记录数, * */ public function getTurntableList($merchant_id, $title, $status, $turntable_type, $start_time, $end_time, $page, $page_size) { $where['merchant_id'] = $merchant_id; $where['status'] = ['neq', 3]; if (!empty($status)) { //活动状态 1,未开始,2,进行中,3已结束 $time = time(); switch ($status) { case 1: $where['start_time'] = ['gt', $time]; break; case 2: $where['start_time'] = ['elt', $time]; $where['end_time'] = ['egt', $time]; break; case 3: $where['end_time'] = ['lt', $time]; break; } $where['status'] = $status; } if (!empty($turntable_type)) { $where['turntable_type'] = $turntable_type; } if (!empty($start_time) and !empty($end_time)) { $where['add_time'] = array('between', $start_time . ',' . $end_time); } if (!empty($title)) { // $map['a.username'] = array('like', '%'.$title.'%'); // $map['a.phone'] = array('like', '%'.$title.'%'); // $map['_logic'] = 'or'; // $where['_complex'] = $map; $where['turntable_name'] = ['like', '%' . $title . '%']; } $list = $this ->field('id,turntable_name,start_time,end_time,add_time,status,turntable_type,shop_limit,shop_id,prize_total') ->where($where) ->page($page, $page_size) ->order('add_time desc') ->select(); return $list; } /* * 获取大转盘活动列表总记录数 * param $merchant_id 商户ID * param $title 搜索字段 * param $status 活动状态 1,可用,2,关闭, * param $turntable_type 活动类型 1 公众号通知栏 2 小程序商城 3线上支付 线下支付 5任务 * param $start_time 开始时间 * param $end_time 结束时间 * param $page 当前页数 * param $page_size 每页记录数, * */ public function getTurntableListCount($merchant_id, $title, $status, $turntable_type, $start_time, $end_time) { $where['merchant_id'] = $merchant_id; $where['status'] = ['neq', 3]; if (!empty($status)) { $where['status'] = $status; } if (!empty($turntable_type)) { $where['turntable_type'] = $turntable_type; } if (!empty($start_time) and !empty($end_time)) { $where['add_time'] = array('between', $start_time . ',' . $end_time); } if (!empty($title)) { // $map['a.username'] = array('like', '%'.$title.'%'); // $map['a.phone'] = array('like', '%'.$title.'%'); // $map['_logic'] = 'or'; // $where['_complex'] = $map; $where['turntable_name'] = ['like', '%' . $title . '%']; } $list = $this ->field('id,turntable_name,start_time,end_time,add_time,status,turntable_type,shop_limit,shop_id,prize_total') ->where($where) ->count(); return $list; } }