params[ 'page' ] ?? 1; $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS; $name = $this->params[ 'name' ] ?? ''; $start_time = $this->params[ 'fetch_time_start' ] ?? ''; $end_time = $this->params[ 'fetch_time_end' ] ?? ''; $type = $this->params[ 'type' ] ?? ''; $use_type = $this->params[ 'use_type' ] ?? ''; $coupon_model = new CouponModel(); $condition = [ [ 'site_id', "=", $this->site_id ], ]; if (!empty($type)) { $condition[] = [ "type", '=', $type ]; } if (!empty($use_type)) { $condition[] = [ "use_type", '=', $use_type ]; } if ($name !== '') { $condition[] = [ "name", 'like', '%' . $name . '%' ]; } if (!empty($start_time) && empty($end_time)) { $condition[] = [ 'create_time', '>=', date_to_time($start_time) ]; } elseif (empty($start_time) && !empty($end_time)) { $condition[] = [ "create_time", "<=", date_to_time($end_time) ]; } elseif (!empty($start_time) && !empty($end_time)) { $condition[] = [ 'create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ]; } $list = $coupon_model->getCouponPageList($condition, $page, $page_size, 'coupon_id desc'); return $this->response($list); } /** * 优惠券详情 */ public function detail() { $coupon_id = $this->params[ 'coupon_id' ] ?? 0; $coupon_model = new CouponModel(); $condition = array( ['site_id', '=', $this->site_id], ['coupon_id', '=', $coupon_id] ); $info = $coupon_model->getCouponInfo($condition,'*'); return $this->response($info); } /** * 查询优惠券 * @return false|string */ public function couponTypeList() { $page = $this->params[ 'page' ] ?? 1; $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS; $name = $this->params[ 'name' ] ?? ''; $coupon_model = new CouponModel(); $condition = [ [ 'site_id', "=", $this->site_id ], [ 'status', '=', 1] ]; if ($name !== '') { $condition[] = [ "coupon_name", 'like', '%' . $name . '%' ]; } $field = 'coupon_type_id,type,coupon_name,count,lead_count,used_count,goods_type,is_limit,at_least,money,discount,discount_limit,validity_type,end_time,fixed_term'; $list = $coupon_model->getCouponTypePageList($condition, $page, $page_size, 'coupon_type_id desc', $field); return $this->response($list); } }