<?php
/**
 * 宝贝标签
 *
 * @author Ftxia
 */
class itemTag {    

    public function orlike($options) {
		$options['cid'] = isset($options['cid']) ? trim($options['cid']) : '';

		$items_mod = D('items');
		if($options['cid']){
			$map = array('cate_id'=>$options['cid'],'pass'=>'1');
			$data = $items_mod->where($map)->limit('0,4')->order('coupon_price asc')->select();
		}else{
			$map = array('pass'=>'1');
			$data = $items_mod->where($map)->limit('0,4')->order('coupon_price asc')->select();
		}
        return $data;
    }


	public function zhi($options) {
		$options['cid'] = isset($options['cid']) ? trim($options['cid']) : '';
		$items_mod = D('items');
		if($options['cid']){
			$map = array('cate_id'=>$options['cid'],'pass'=>'1');
			$data = $items_mod->where($map)->limit('0,6')->order('coupon_rate asc')->select();
		}else{
			$map = array('pass'=>'1');
			$data = $items_mod->where($map)->limit('0,6')->order('coupon_rate asc')->select();
		}
        return $data;
    }

public function lists($options) {
		$items_mod = D('items');
		$map = array('cate_id'=>$options['cid'],'pass'=>'1');
		$options['cid'] = isset($options['cid']) ? trim($options['cid']) : '';
		$options['num'] = isset($options['num']) ? trim($options['num']) : '6';
		$options['status'] = isset($options['status']) ? trim($options['status']) : '1';
		$options['min_price'] = isset($options['min_price']) ? trim($options['min_price']) : '';
		$options['max_price'] = isset($options['max_price']) ? trim($options['max_price']) : '';
		$options['min_volume'] = isset($options['min_volume']) ? trim($options['min_volume']) : '';
		$options['max_volume'] = isset($options['max_volume']) ? trim($options['max_volume']) : '';

		if($options['min_price']>0){$map['coupon_price'] = array('egt',$options['min_price']);}
		if($options['max_price']>0){$map['coupon_price'] = array('elt',$options['max_price']);}
		if($options['min_price']>0 && $options['max_price']>0){$map['coupon_price'] = array(array('egt',$options['min_price']),array('elt',$options['max_price']),'and');}

		if($options['min_volume']>0){$map['volume'] = array('egt',$options['min_volume']);}
		if($options['max_volume']>0){$map['volume'] = array('elt',$options['max_volume']);}
		if($options['max_volume']>0 && $options['min_volume']>0){$map['volume'] = array(array('egt',$options['min_volume']),array('elt',$options['max_volume']),'and');}

		if($options['status'] == 1){
			$map['coupon_end_time'] = array('egt',time());
		}else if($options['status'] == 2){
			$map['coupon_start_time'] = array('egt',time());
		}
		if($options['cid']){
			$id_arr = D('items_cate')->get_child_ids($options['cid'], true);
			
		}

        $data = $items_mod->where($map)->limit('0 ,' . $options['num'])->select();
		return $data;
	}
	
}